Repository navigation
Conversation
This was referenced Oct 24, 2026
shba24
force-pushed
the
stack/uc-flyway-merge-checks
branch
5 times, most recently
from
October 24, 2026 23:42
dd7a8ed to
e45f944
Compare
Signed-off-by: Shubham Bansal <[email protected]>
Co-authored-by: Isaac <[email protected]> Signed-off-by: Shubham Bansal <[email protected]>
Adds MySQL 8.4 to the test database harness (testMySQL8) and a CI job. Test databases use the case-sensitive utf8mb4_0900_bin collation. The isolation test now reads the database's default level instead of assuming READ_COMMITTED. Co-authored-by: Isaac <[email protected]> Signed-off-by: Shubham Bansal <[email protected]>
Without an ORDER BY, MySQL returned columns (and function parameters) in its own order. Co-authored-by: Isaac <[email protected]> Signed-off-by: Shubham Bansal <[email protected]>
Storage paths and names are case-sensitive, but MySQL's default collation is not. Log a warning at startup and document the utf8mb4_0900_bin collation. Co-authored-by: Isaac <[email protected]> Signed-off-by: Shubham Bansal <[email protected]>
MySQL and PostgreSQL now share one harness: Hibernate builds the schema once per JVM into a template and each test clones it. Both containers keep their data in memory with durability off. Co-authored-by: Isaac <[email protected]> Signed-off-by: Shubham Bansal <[email protected]>
Fix harness comments and docs, assign the cached database only after it started, drop duplicate test dependencies, request a different isolation level in the restore test, check the MySQL template has every mapped table, and cover parameter order in the function CRUD test. Co-authored-by: Isaac <[email protected]> Signed-off-by: Shubham Bansal <[email protected]>
The MYSQL_8 CI row runs SdkDeltaCommitsCRUDTest on MySQL, so the class that started its own MySQL container is no longer needed. Its lock-reading test moves into SdkDeltaCommitsCRUDTest and runs on every database. Co-authored-by: Isaac <[email protected]> Signed-off-by: Shubham Bansal <[email protected]>
A @TempDatabase field gets a fresh TestDatabase, per test for an instance field and per class for a static one. The extension stores it in the JUnit store, which closes it after every @AfterEach, so a test's server always closes before its database is dropped, and a failing setUp still drops it. TestDatabase no longer takes a ServerProperties (it overwrote everything the properties set) and offers hibernateProperties(), hibernateConfigurator() and sessionFactory(). All tests that made their own database now use the annotation. Co-authored-by: Isaac <[email protected]> Signed-off-by: Shubham Bansal <[email protected]>
Co-authored-by: Isaac <[email protected]> Signed-off-by: Shubham Bansal <[email protected]>
…eSQL containers Co-authored-by: Isaac <[email protected]> Signed-off-by: Shubham Bansal <[email protected]>
…lt_on_error The isolation test asks for a level other than the default, because asking for the default would pass even if nothing were restored. The MySQL template keeps halt_on_error off only for the one index InnoDB rejects; a TODO removes it once the schema migration steps build the template. Co-authored-by: Isaac <[email protected]> Signed-off-by: Shubham Bansal <[email protected]>
Adds Flyway 13.10.3, the V1 baseline of the 0.7 schema and V2 (type_json widening) for H2, PostgreSQL and MySQL; empty test databases, @TempDatabase and TestDatabase.dataSource()/kind() in the harness; and a schema snapshot check that the steps build the schema the entities expect. Co-authored-by: Isaac <[email protected]> Signed-off-by: Shubham Bansal <[email protected]>
Adds Migrator, which classifies a database (empty, current, pending, newer than this release, an unversioned 0.7 database, not a Unity Catalog database, failed step) and, under a run lock, sets up an empty database, adopts a 0.7 one (version 1 recorded as the baseline) and applies the pending steps. The run lock is pg_advisory_lock on PostgreSQL, GET_LOCK on MySQL and an in-process lock per database file on H2. bin/uc-migrate runs `migrate` and `info` against the database in etc/conf/hibernate.properties. Co-authored-by: Isaac <[email protected]> Signed-off-by: Shubham Bansal <[email protected]>
…ases with Flyway The server sets up an empty database itself (a second server starting at the same time waits on the run lock) and refuses any other schema version with a message that names the fix. Hibernate never alters the schema: hbm2ddl.auto is forced to none, even if an old hibernate.properties says update. Co-authored-by: Isaac <[email protected]> Signed-off-by: Shubham Bansal <[email protected]>
…ases Adds V3. On MySQL it converts the database and every Unity Catalog table (and casbin_rule, when it exists) to utf8mb4_0900_bin, so a database created with MySQL's case-insensitive default compares names and storage paths like PostgreSQL and H2. Converting is safe to repeat, so the step holds several statements. On PostgreSQL and H2, V3 does nothing. The startup collation warning skips Flyway's history table, which keeps the database's original collation. Test-only steps move to version 1000 and tests read the latest version instead of hard-coding it. Co-authored-by: Isaac <[email protected]> Signed-off-by: Shubham Bansal <[email protected]>
Every test database now gets its schema from Migrator, never from Hibernate DDL: the PostgreSQL and MySQL templates are migrated once, and each H2 test database is migrated when it is created. Hibernate runs with hbm2ddl.auto=none in every test. MySQL clones now also copy the template's rows (Flyway's history), as PostgreSQL's TEMPLATE does, so a clone is at the current version. The MySQL template no longer needs halt_on_error=false or the check that every mapped table exists: Flyway stops on any failed statement. PopulateTestDatabase migrates its database before opening it. Co-authored-by: Isaac <[email protected]> Signed-off-by: Shubham Bansal <[email protected]>
Describe how Flyway manages the schema, how to upgrade without Helm with bin/uc-migrate, the first start on an empty database, the MySQL case-sensitivity change, going back to 0.7, and each error message with what to do. Replace the outdated Hibernate auto-update paragraph in the deployment guide with a link to the guide. Co-authored-by: Isaac <[email protected]> Signed-off-by: Shubham Bansal <[email protected]>
- The server and bin/uc-migrate print the same refusal for a foreign, newer or failed schema (Migrator.refusal); "Stop the servers and run bin/uc-migrate migrate" is kept for a 0.7 or pending database. - bin/uc-migrate runs from the repository or tarball root, so it reads etc/conf/hibernate.properties from any directory; it exits 1 when it finds neither, and builds a missing classpath file. - The MySQL run lock is per database, not per MySQL server. - Flyway fails on missing step locations; a jar without steps says so. - uc-migrate reuses the server's Hikari settings. - The shaded server jar keeps META-INF/services (merged), so Flyway finds its database support in connector tests. - The Helm chart no longer sets hibernate.hbm2ddl.auto=update. - Tests: release-to-release upgrade, casbin_rule conversion on MySQL, server properties always turn Hibernate schema updates off. - Docs: messages say who prints them; going back to 0.7 needs no restore; waiting applies to PostgreSQL and MySQL. Co-authored-by: Isaac <[email protected]> Signed-off-by: Shubham Bansal <[email protected]>
…6 via 0.7 RealUpgradeTest runs real server images on each UpgradePath and test database: the first image writes a data set through the API with authorization on, later images just start, then the current server refuses the database until Migrator.migrate() upgrades it to the fresh install schema, and the data reads back. The test kit gains AcrossUpgradePaths, UpgradePath (BASE built from UC_TEST_BASE_REF by dev/build-image.sh, LATEST, V0_6_VIA_0_7), OldImage, OldServer and DataSet. The tests are tagged "upgrades": the default test and coverage runs leave them out, and testUpgrades, testUpgradesPostgres18 and testUpgradesMySQL8 run them, also in a new CI job. Real 0.7 databases showed that Hibernate's auto-update names the unique constraints of uc_columns, uc_delta_commits and uc_properties, so the H2 and PostgreSQL baselines now name them the same way, and the baseline check builds its reference schema with "update", as 0.7 installs did. Co-authored-by: Isaac <[email protected]> Signed-off-by: Shubham Bansal <[email protected]>
…ySQL Hibernate already defaults halt_on_error to false, so the old MySQL-only setting did nothing. Set it always: true on H2 and PostgreSQL, false on MySQL, where one entity index is too long. Co-authored-by: Isaac <[email protected]> Signed-off-by: Shubham Bansal <[email protected]>
Co-authored-by: Isaac <[email protected]> Signed-off-by: Shubham Bansal <[email protected]>
Co-authored-by: Isaac <[email protected]> Signed-off-by: Shubham Bansal <[email protected]>
Co-authored-by: Isaac <[email protected]> Signed-off-by: Shubham Bansal <[email protected]>
The H2 run lock holds only within one JVM, so with AUTO_SERVER=TRUE or a jdbc:h2:tcp:/jdbc:h2:ssl: URL two servers could run steps at once. The migrator now refuses those URLs before opening its pool. It reads the configured URL, since H2's connection URL leaves AUTO_SERVER out. Co-authored-by: Isaac <[email protected]> Signed-off-by: Shubham Bansal <[email protected]>
…atabase - The H2 server-mode refusal read only hibernate.connection.url and only AUTO_SERVER=TRUE. It now also reads the data-source URL of a pool set up by data source class and an AUTO_SERVER driver property, accepts every value H2 reads as true (1, t, y, yes, true), and finds :h2:tcp:/:h2:ssl: behind a wrapping driver's prefix. - The test rows open their databases under a temp directory. - Remove uc.mv.db, which an earlier run of that test wrote into the checkout. - upgrades.md: name only Group Replication for the unshared named lock. Co-authored-by: Isaac <[email protected]> Signed-off-by: Shubham Bansal <[email protected]>
Signed-off-by: Shubham Bansal <[email protected]> # Conflicts: # server/src/test/java/io/unitycatalog/server/migrate/SchemaSnapshot.java
Collaborator
Author
|
/review |
3 of 4 tasks
Co-authored-by: Isaac <[email protected]> Signed-off-by: Shubham Bansal <[email protected]>
KeyMapperTest (added on main in unitycatalog#1939) opened its own in-memory H2 database and relied on Hibernate creating the tables. The server no longer lets Hibernate change the schema, so the test found no tables. It now uses the shared test database, which the schema steps build, like the other tests that write entities directly. Co-authored-by: Isaac <[email protected]> Signed-off-by: Shubham Bansal <[email protected]>
…apperTest fix into stack/uc-flyway-merge-checks Co-authored-by: Isaac <[email protected]> Signed-off-by: Shubham Bansal <[email protected]>
shba24
added a commit
to shba24/unitycatalog
that referenced
this pull request
Nov 4, 2026
…d KeyMapperTest fix into stack/uc-hibernate-mode Co-authored-by: Isaac <[email protected]> Signed-off-by: Shubham Bansal <[email protected]>
Collaborator
Author
|
/review |
…e database DatabaseMetaData.getTables and getColumns take the schema (and getColumns the table) as a search pattern, where _ and % match any character. With PostgreSQL currentSchema=uc_a, the tables of a schema named ucxa were listed too, so an empty uc_a looked like another application's database and the server refused to start. The migrator and the tests' schema snapshot now escape the names. Co-authored-by: Isaac <[email protected]> Signed-off-by: Shubham Bansal <[email protected]>
The server ignores the setting now that the schema steps own the schema, and warned about it on every start of a Helm install. Also treat NONE like none, as the other schema-action checks do, so it logs no warning. Co-authored-by: Isaac <[email protected]> Signed-off-by: Shubham Bansal <[email protected]>
…and the Helm setting into stack/uc-flyway-merge-checks Co-authored-by: Isaac <[email protected]> Signed-off-by: Shubham Bansal <[email protected]>
shba24
added a commit
to shba24/unitycatalog
that referenced
this pull request
Nov 4, 2026
…names and the Helm setting into stack/uc-hibernate-mode Co-authored-by: Isaac <[email protected]> Signed-off-by: Shubham Bansal <[email protected]>
Collaborator
Author
|
/review |
1 similar comment
Collaborator
Author
|
/review |
This was referenced Nov 4, 2026
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.
🥞 Stacked PR
Use this link to review incremental changes.
PR Checklist
docsis updatedDescription of changes
Pull requests that change the schema the wrong way now fail CI with a message saying what to do.
#2045 makes Flyway steps the only way the schema changes. This PR adds the checks that keep those steps trustworthy:
migration-steps, runsdev/check-migration-steps.shagainst the pull request's base and fails on an edited, deleted or renamed step underserver/src/main/resources/db/migration/.branch-*) that adds a step. Together withBaselineMatchesEntitiesTest(an entity change without a step fails), a patch release keeps exactly the schema of its.0release. This applies frombranch-0.8on;branch-0.7has no steps.MigrationStepRulesTestfails on a step with two statements, or whose statement isn't on an allow-list: create a table, create an index that is not unique, add a column (NOT NULL only with a DEFAULT, without a key or CHECK), widen a column's type, or drop its NOT NULL. Everything else is refused until a release needs it: data changes, unique indexes and rules that existing rows can break, and drops and renames that servers of the previous release still use. The test reads the statement, not the column, so review checks that a type change widens the column. Outside'...'strings and--comments a step may use only letters, digits,_, spaces and( ) , . = < > -; a backslash in a string,--without a space after it, a carriage return without a line feed, andCREATE INDEX CONCURRENTLYare refused too. Other quoting and comments (", backticks, MySQL#, H2//, block comments,$$strings) could hide a second statement from the test. One statement keeps a step all-or-nothing on MySQL. OnlyV1__baseline_0_7.sql, the 0.7.0 schema, is exempt.BaselineMatchesEntitiesTestcompares the schema the steps build with the one Hibernate builds from the entities; it now also compares CHECK constraints. Adding an enum value (say a 23rd column type) changes the entities'check (type_name between 0 and 22); without this, every database would keep0 and 21and writing the new value would fail at runtime.SampleDatabaseIsCurrentTestchecks thatetc/db/h2db.mv.dbis on the build's latest schema version. When it is behind, the test migrates the file in place and fails asking you to commit it, so there's nothing to do by hand. It also compares the file's whole schema with what the steps build on an empty H2 database. That found two old differences in the shipped file, now fixed: its function type rules allowed only codes 0 to 20, so a function returning a table (code 21) couldn't be stored, andnamewas nullable on catalogs, schemas, tables and volumes. The file's data and schema history are unchanged.AGENTS.mdlists how to add a schema step.Testing
h2/V3__scratch.sql has 2 statements;DEFAULT 'it\'s'on MySQL, a"it's"column on PostgreSQL, each followed byDROP TABLE uc_tables; -- '): passed before, now refused; the same for a MySQL#comment, an H2//comment, a nested block comment, a$$string, a lone carriage return, MySQL--1andCREATE INDEX CONCURRENTLY ON t (a);V1edited from0 and 21to0 and 20:BaselineMatchesEntitiesTestfails, listingcheck uc_function_params "TYPE_NAME" BETWEEN 0 AND 20against the entities'21;etc/db/h2db.mv.db is PENDING at version 2, this build at 3; the test migrated it, commit etc/db/h2db.mv.db. The next run passes and leaves the file unchanged.dev/check-migration-steps.shon throwaway commits:migrate.*tests pass on H2, PostgreSQL 18 and MySQL 8.4. Locally,build/sbt testpasses on H2 exceptSdkModelCRUDTest.testModelCRUD, an existing flaky test (two updates in the same millisecond) that passes on its own;server/testpasses on PostgreSQL 18 (903 tests) and MySQL 8.4 (902 tests); Javadoc builds.📐 Design notes & details
Why "merged" and not "released". A step that reached
mainmay already have run on a database built frommain. Freezing steps at merge is stricter than freezing them at release, and needs no release bookkeeping. Flyway itself only notices an edited step when a database that ran it starts, which is after the release.Why our own statement splitter. The steps are written in three dialects (H2, PostgreSQL, MySQL). The check only needs to count statements and match each one against the allow-list: it strips comments and splits on
;outside'...'strings, and refuses every character it doesn't need, so other quoting and comments can't hide a;. A file with only comments passes. Flyway's own parser would do it, but it is internal API.Later baselines. If the list of steps gets long, a later release can add a Flyway baseline migration (
B<version>__…sql, the whole schema at that version) next to theVsteps; Flyway runs it only on a new database. The test reads onlyVfiles, so it needs no change for that.How CHECK constraints are compared. By clause, without their generated names (a schema the steps built and one Hibernate built name them differently), and keeping their case, because the enum literals in them are case-sensitive.
Moved out of this PR. The recorded schema dumps (
schema/<db>.txt,SchemaDumpTest) move to #2050, the PR whose server code reads them. A check that new steps are numbered above the base's was dropped: Flyway already refuses two steps with the same version.This pull request and its description were written by Isaac.