DoDiODev commented on PR #9015:
URL: https://github.com/apache/devlake/pull/9015#issuecomment-5163755052

   Thanks — I checked this against both engines rather than reasoning about it, 
and the specific example turns out to be already covered, for a slightly 
different reason than expected.
   
   On **MySQL 8.4.10**, replacing the explicit DDL with plain `AutoMigrate` 
emits `ALTER TABLE ... ADD id bigint unsigned AUTO_INCREMENT` and fails with 
`Error 1075 (42000): Incorrect table definition; there can be only one auto 
column and it must be defined as a key` **regardless of row count** — it is a 
DDL-level rejection, so the guard fails on the empty table too (verified with 0 
and with 2 pre-existing rows).
   
   On **PostgreSQL 17.2** the same `AutoMigrate` succeeds in both cases (`ALTER 
TABLE ... ADD "id" bigserial`), just without the PRIMARY KEY constraint — so a 
seeded row would not surface it there either. What is invisible on Postgres is 
the missing primary key, and a column-presence guard cannot see that with or 
without data.
   
   Your general point stands, though: data-dependent failures are not exercised 
— `NOT NULL` without a default, a `uniqueIndex` over pre-existing duplicates, 
type narrowing. A fully generic "seed every table before the tail migrations 
run" would need a two-phase migrator run with an arbitrary version cutoff plus 
valid rows for every tool table (JSON columns, NOT NULL fields), which ages 
badly.
   
   What I am adding instead is a targeted upgrade-path guard for the tables 
this PR repairs: build the pre-repair table shape, insert rows, run only the 
new script's `Up()`, then assert the added columns exist, the rows survived, 
and the ids were backfilled — plus a primary-key assertion, so the 
`AutoMigrate`-instead-of-DDL case is caught on Postgres as well. That codifies 
exactly what is currently only documented as manual verification.
   
   Thanks for the careful read — the `Dialect()` / `BIGSERIAL` confirmation is 
appreciated.
   
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to