Repository navigation
[Build] Leave the schema-change rule to CODE_REVIEW.md in the domain reviewer - #2221
Merged
yili-db merged 2 commits intoNov 13, 2026
Merged
Conversation
…teps Since unitycatalog#2045, a schema change is a new Flyway step per database. The uc-domain-reviewer still checked for additive changes under Hibernate's hbm2ddl.auto=update. Split out of unitycatalog#2113. Co-authored-by: Isaac <[email protected]> Signed-off-by: Shubham Bansal <[email protected]>
2 of 4 tasks
Collaborator
|
/review |
yili-db
reviewed
Nov 13, 2026
…reviewer Yi's review: the agent already points at CODE_REVIEW.md T11, so it names the rule there instead of restating it. Co-authored-by: Isaac <[email protected]> Signed-off-by: Shubham Bansal <[email protected]>
Collaborator
|
/review |
yili-db
pushed a commit
that referenced
this pull request
Nov 13, 2026
## 🥞 Stacked PR Use this [link](https://github.com/unitycatalog/unitycatalog/pull/2113/files) to review incremental changes. - [stack/uc-flyway-schema](#2045) (merged) - [stack/uc-upgrade-adopt](#2112) (merged) - [**stack/uc-upgrade-merge-checks**](#2113) [[Files changed](https://github.com/unitycatalog/unitycatalog/pull/2113/files)] ← _this PR_ - [stack/uc-upgrade-retry](#2114) [[Files changed](https://github.com/unitycatalog/unitycatalog/pull/2114/files/a395b2cd9afd6a655c47bbc0d6aa201c9cebcf84..253a7b0792d4e4739cc430282a2f67982aeb67a2)] - [stack/uc-upgrade-check-schema](#2115) [[Files changed](https://github.com/unitycatalog/unitycatalog/pull/2115/files/253a7b0792d4e4739cc430282a2f67982aeb67a2..a9c120f91359e8674c3797f5e1b8256348c67053)] - [stack/uc-sample-database-built](#2116) [[Files changed](https://github.com/unitycatalog/unitycatalog/pull/2116/files/a9c120f91359e8674c3797f5e1b8256348c67053..69874b352e28548397f03df542394b2a734f1968)] - [stack/uc-flyway-owns-schema](#2117) [[Files changed](https://github.com/unitycatalog/unitycatalog/pull/2117/files/69874b352e28548397f03df542394b2a734f1968..65384ccc509936cdbe4cd33cf77bad5008e07a53)] - [stack/uc-hibernate-fallback](#2118) [[Files changed](https://github.com/unitycatalog/unitycatalog/pull/2118/files/65384ccc509936cdbe4cd33cf77bad5008e07a53..655da6a52af5ec0510b736c2a80d2ff288d81201)] --------- This PR adds the checks that every new schema step must pass before it merges, so that `--upgrade-schema` can tell from the schema whether a step ran, and a step avoids the changes that rows already in a database can make fail: a unique index, an index whose PostgreSQL entry (key and `INCLUDE` columns) can be over 2,704 bytes, a partial index (its predicate runs on every row), NOT NULL without a default, a narrowing type change (including an unconstrained PostgreSQL `numeric` to one with a precision), dropping an enum or set member, and a MySQL `MODIFY` that drops a column's default or collation. ### What a contributor sees - A step after the first holds one SQL statement as Flyway sends it to each database, or none when the step changes nothing on that database. The statement creates a table, creates an index that is not unique, adds a column (NOT NULL only with a default, and without a key or CHECK rule), changes a column's type, or drops a NOT NULL. A type change must widen the column, and no change may make a column NOT NULL. - Every step exists for H2, PostgreSQL and MySQL as a versioned `V<n>__<description>.sql` file, and has an effect file for each database. - A new CI job fails a pull request that edits, deletes or renames a merged step or effect file, adds a step whose number is not above every merged one, or adds any step on a release branch (`branch-*`). - The "All tests" rows of Unit Tests (H2, PostgreSQL 18, MySQL 8) run the step checks on every pull request, and fail if either check class ran no tests or skipped them. - `--upgrade-schema` refuses a build that holds a repeatable (`R__`) step, before it changes the database. - `AGENTS.md` and `CODE_REVIEW.md` now say that a schema change ships as a new Flyway step with its effect files, instead of relying on Hibernate's `update`. The same line for the AI reviewer's rules is in #2221. For example, a step `V3__add_index.sql` with `CREATE UNIQUE INDEX ...` fails the checks: a unique index can fail on rows that are already in the database. ### What doesn't change yet - Server start still runs Hibernate's `update`, and `--upgrade-schema` is still optional and run by hand. #2117 switches that. ### Tests Ran locally with `UC_TEST_MIGRATION_CHECKS=true`, every test in `io.unitycatalog.server.migrate` (`MigrationStepRulesTest`, `BaselineMatchesEntitiesTest`, `SchemaMigratorTest` and the rest): on H2, PostgreSQL 18 and MySQL 8 at 431a23e (the later commit only moves the AI reviewer's line to #2221). CI runs the full suite with the step checks on all three. <details><summary><b>📐 Design notes & details</b></summary> ### Design - `MigrationStepRulesTest` reads what Flyway sends to each database with JSqlParser (a test-only dependency, Apache-2.0 or LGPL-2.1), not the raw file, so the check sees the same statements as the database. SQL that JSqlParser can't read fails the check, because what it can't read, it can't check. - Step 1, the 0.7.0 baseline, may create any table and index, but not from a query or `CONCURRENTLY`. - Why these limits: with one statement per step, the schema shows whether the step ran, which #2114 needs to retry a run that stopped. A unique index, a NOT NULL without a default, or a narrowing type change can fail on rows already in a database, so they're out. - The step checks and `BaselineMatchesEntitiesTest` now run only with `UC_TEST_MIGRATION_CHECKS=true`, which the "All tests" rows set; a plain `build/sbt test` skips them. - `dev/check-migration-steps.sh` (job "Merged migration steps unchanged" in `unit-tests.yml`) compares the pull request with its base: merged steps and effect files stay as they are, because databases already ran those steps and the effect files tell `--upgrade-schema` what they did. A new step must be numbered above every merged step for that database, because Flyway refuses a step below the recorded version. Release branches take no new steps, because the number could clash with a different step on `main`. - The step order is checked against the pull request's base, so two open pull requests can each pass with the same step number. `AGENTS.md` asks the author to merge `main` into a pull request that adds a step just before it merges (or to rely on a merge queue or "require branches to be up to date"). ### Test coverage - `MigrationStepRulesTest`: `eachStepIsOneAllowedStatement`, `everyStepExistsForEveryDatabase`, `typeChangesWiden`, and `eachStepHasItsEffectFile` (from #2112), all on each database in CI. - `dev/check-migration-steps.sh` runs in CI on this pull request. ### Stack Part 3 of 8 of the schema-upgrade stack: 1. #2045 [Server] Add the schema steps and a manual --upgrade-schema command 2. #2112 [Server] Adopt existing databases in --upgrade-schema 3. #2113 [Build] Check the schema steps on every pull request (this PR) 4. #2114 [Server] Retry a schema upgrade that stopped part way 5. #2115 [Server] Add a read-only --check-schema command 6. #2116 [Build] Build the sample database instead of checking it in 7. #2117 [Server] Let only the schema steps change the schema 8. #2118 [Server] Add a temporary fallback to Hibernate schema updates </details> **PR Checklist** - [x] A description of the changes is added to the description of this PR. - [ ] If there is a related issue, make sure it is linked to this PR. - [x] If you've fixed a bug or added code that should be tested, add tests! - [ ] If you've added or modified a feature, documentation in `docs` is updated This pull request and its description were written by Isaac. --------- Signed-off-by: Shubham Bansal <[email protected]> Co-authored-by: Isaac <[email protected]>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
Since #2045, a schema change ships as a new Flyway step for each database. The
uc-domain-revieweragent still tells reviewers to check that schema changes are additive under Hibernate'shbm2ddl.auto=update. This removes that clause, so the agent only points atCODE_REVIEW.mdT11, the one place that states the schema-change rule.This was part of #2113, which updates T11 in
CODE_REVIEW.mdto describe the Flyway steps. It is split out so the AI reviewer's own rules change in a PR of their own.📐 Design notes & details
.github/omnigent/reviewer/agents/uc-domain-reviewer/REVIEW.md, item 3 ("Persistence and schema portability"): the "additive-only (Hibernatehbm2ddl.auto=update)" clause is removed; the rest of the item stays.CODE_REVIEW.mdbefore and after [Build] Check the schema steps on every pull request #2113 merges.This pull request and its description were written by Isaac.