Repository navigation
Conversation
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]>
The classpath file used by bin/start-uc-server and bin/uc-migrate listed both
server/target/classes and the server jar, so Flyway found every migration step
twice ("Found more than one migration with version 1") when running from a
source checkout or the Docker image. The jar holds the same classes.
Co-authored-by: Isaac <[email protected]>
Signed-off-by: Shubham Bansal <[email protected]>
etc/db/h2db (the quickstart database) was created before 0.7 and had 10 of the 0.7 schema's 18 tables; older servers added the rest at startup with Hibernate auto-update, which this release turns off, so the server refused it. Upgraded the way a user upgrades: started v0.7.0 on it once (its auto-update added the missing tables), then ran bin/uc-migrate migrate (0.7 baseline, then steps 2 and 3). The sample data is unchanged. Co-authored-by: Isaac <[email protected]> Signed-off-by: Shubham Bansal <[email protected]>
MigrationOutcome, SchemaState and DatabaseKind become nested types of SchemaMigrator, and RunLock a private nested class. No behaviour change. Co-authored-by: Isaac <[email protected]> Signed-off-by: Shubham Bansal <[email protected]>
Every server start now sets up an empty database, adopts a database without schema history and applies the pending steps, under the run lock; it still refuses a newer, foreign or failed schema. Every start path (bin/start-uc-server, the Docker image, a Helm pod) goes through it, so bin/uc-migrate and UcMigrate are removed. The upgrade guide describes the new procedure: stop the servers, back up the database, start the new release. Co-authored-by: Isaac <[email protected]> Signed-off-by: Shubham Bansal <[email protected]>
…ore it SchemaMigrator.BASELINE_RELEASE (0.7.0) is the one place the baseline release is named; messages use it and comments say "the baseline release". Before adopting a database without schema history, the migrator checks that it has every table the baseline step creates, and otherwise refuses it, naming the missing tables: such a database is from an earlier release, which has to be started on 0.7.0 once first. The upgrade guide says so. Co-authored-by: Isaac <[email protected]> Signed-off-by: Shubham Bansal <[email protected]>
… built image UpgradePath.BASE now runs the base commit's shaded server jar as a child process on the test database, so the upgrade tests build no Docker image (dev/build-image.sh is removed). The jar comes from UC_TEST_BASE_JAR, the local cache ~/.cache/uc-upgrade-base/<sha>.jar, or is built once there from git archive. CI saves the jar of every main commit in the Actions cache and the upgrade job restores the one of the merge commit's first parent; the job runs only when schema-related paths change. Published releases keep their Docker Hub images, now pinned by digest; the moving "latest" path becomes a pinned V0_7. Co-authored-by: Isaac <[email protected]> Signed-off-by: Shubham Bansal <[email protected]>
Move the upgrade tests out of unit-tests.yml into upgrade-tests.yml, which runs only when a change touches the schema, its migration code or the upgrade test kit. A base-jar job builds the server jar of the commit the PR starts from and shares it as an artifact. Co-authored-by: Isaac <[email protected]> Signed-off-by: Shubham Bansal <[email protected]>
The upgrade tests now have two paths, and every old server is a server jar run as a child process (no release images, no Docker container mode): - BASE: the jar of the code this change starts from (UC_TEST_BASE_REF). - RELEASE_CHAIN: one jar per release, oldest first, from the release tags: strict vX.Y.Z, from SchemaMigrator.BASELINE_RELEASE up to, not including, this build's version, latest patch per minor. UC_TEST_RELEASE_CHAIN sets the tags (CI computes them once); unset, the kit computes them from git. Each jar is found by its commit: UC_TEST_JAR_DIR/<sha>.jar, else ~/.cache/uc-upgrade-base/<sha>.jar, else built once from that commit and cached. This replaces UC_TEST_BASE_JAR. The first jar writes the data set; every later jar reads it back, then the current server upgrades the database and reads it back; failures name the server that read it. The data set now has one column (and one function parameter) per column type, with every field set, and is compared as whole objects, ignoring only the fields a server fills in itself. The managed table is Delta, whose columns can't have the types Delta lacks (interval, void, user-defined, table), so it has the other 18; the external table is Parquet and has all 22. Dropped: V0_7, V0_6_VIA_0_7 and the pinned release images. Co-authored-by: Isaac <[email protected]> Signed-off-by: Shubham Bansal <[email protected]>
A refs job picks the base commit (the merge commit's first parent) and the release chain from the tags; a build-jars matrix builds each one's server jar and uploads it as jar-<sha>; the upgrade tests download them all and find each by its commit through UC_TEST_JAR_DIR. Co-authored-by: Isaac <[email protected]> Signed-off-by: Shubham Bansal <[email protected]>
…iting its own data The upgrade test now takes one path: every release tag from the baseline release up to this build's version, in version order (not only the latest patch of each minor), then the current server. Each release writes its own copy of the data set, named for the release (catalog, user email, sibling storage directories); the current server checks the schema against a fresh install and reads every copy back. The path from the PR's base commit is gone, with its jar in CI: unreleased code never writes a user's database. Co-authored-by: Isaac <[email protected]> Signed-off-by: Shubham Bansal <[email protected]>
No changes yet. This pull request will hold the lock-wait cap, failed-step recovery and the safe stop on SIGTERM; the real commits replace this one. Co-authored-by: Isaac <[email protected]> Signed-off-by: Shubham Bansal <[email protected]>
No changes yet. This pull request will hold verify-after-apply and the upgrade-only-from-the-previous-release guard; the real commits replace this one. Co-authored-by: Isaac <[email protected]> Signed-off-by: Shubham Bansal <[email protected]>
Every connection of a migration run except the run lock's (Flyway's, through initSql, and those of the probes and checks) waits at most 60 seconds for a lock another session holds: PostgreSQL lock_timeout, MySQL lock_wait_timeout and innodb_lock_wait_timeout, H2 LOCK_TIMEOUT. A step that waits longer fails with a message naming the step, the table when the step's statement names one, and what to do. Closing the migrator soft-evicts the connections of a pool it doesn't own, so the server's own sessions don't keep the cap. Co-authored-by: Isaac <[email protected]> Signed-off-by: Shubham Bansal <[email protected]>
A step that failed in an earlier run (H2 and MySQL DDL can't roll back, and a batched data step commits each batch on every database) no longer refuses every start. Under the run lock, before the checks, the run looks at each failed step: a SQL step whose probe can tell whether its change is there, or a DataStep, which changes only the rows not changed yet. Then Flyway's repair removes the failed rows and the run records or runs the steps like pending ones. Any other failed step (several changes, a statement the probe doesn't recognise, a step not in this build) is refused with a message that says what to do. --check-schema lists a failed step that runs again among the pending steps and runs its check: the current version no longer counts a failed step. Co-authored-by: Isaac <[email protected]> Signed-off-by: Shubham Bansal <[email protected]>
Flyway 13 logs "initSql is deprecated" each time the migrator loads a Flyway configuration, several times on every server start. Flyway now takes its connections through the migrator, which sets the lock wait on each one, as it already does for the probes and checks. Co-authored-by: Isaac <[email protected]> Signed-off-by: Shubham Bansal <[email protected]>
While a server start migrates the schema, a shutdown hook asks the run to stop and waits for it, at most the lock wait (60 seconds). The run stops before its next step, or after the batch a batched data step is in; a statement that is running is not interrupted. The server logs "Stopped the schema migration at <boundary> on SIGTERM; start the server again to finish it.", also on standard error since Log4j's own shutdown hook has usually stopped the logger by then, and the process exits non-zero. The next start runs the step again, and a batched step goes on from the rows it has not changed yet. The test starts a server in a child process on PostgreSQL or MySQL (H2 has no sleep function for the slow step, and closes its database in a shutdown hook of its own), sends SIGTERM during a batch and checks that the batch committed before the process exited, then finishes the step in a second run. Co-authored-by: Isaac <[email protected]> Signed-off-by: Shubham Bansal <[email protected]>
…rver bin/start-uc-server ran java as a child of bash. In the Docker image (CMD ["./bin/start-uc-server"]) and so in the Helm chart, bash is PID 1 and ignores SIGTERM, so the JVM never got the signal and was killed after the grace period; outside a container, SIGTERM killed bash and left java running. The script now execs java, which then receives the signal itself and runs its shutdown hooks, such as the safe stop of the startup migration. The script's exit status is java's, as before. Co-authored-by: Isaac <[email protected]> Signed-off-by: Shubham Bansal <[email protected]>
docs/server/upgrades.md gets three sections: the 60-second lock wait, what the next start does after a failed step, and the safe stop on SIGTERM. The entry for a failed step no longer says to always restore the backup. The refusal for a failed step the server can't check now names the ways out that work: restore the backup, or undo the step's change and remove its failed record as the new section shows. Making such a step's change complete by hand would not help: the server still can't check it. Co-authored-by: Isaac <[email protected]> Signed-off-by: Shubham Bansal <[email protected]>
MySQL's step 3 converts every table to a case-sensitive collation in many statements, each safe to repeat; it failed in practice on latin1 databases. A start no longer refuses it after a failure: the run removes its failed record and runs it again. SchemaMigrator.SAFE_TO_REPEAT declares such steps, and SqlStepsAreSingleDdlTest reads it instead of listing them itself. Co-authored-by: Isaac <[email protected]> Signed-off-by: Shubham Bansal <[email protected]>
…branch Co-authored-by: Isaac <[email protected]> Signed-off-by: Shubham Bansal <[email protected]>
db/migration/releases.properties lists every release since the baseline with the version of its last step (today only 0.7.0=1). The release before this build is the highest one listed below its version. A database at a version below that release's last step would skip the release, so the server refuses to start on it (and --check-schema reports it) and tells the user to upgrade to that release first. An empty database, one without history from the baseline release, and one partway between the previous release and this build go through. ReleasesFileTest checks that releases.properties is in order and names a step of every database. SkippedReleaseTest uses a test-only map and test-only steps 5001 and 5002. Co-authored-by: Isaac <[email protected]> Signed-off-by: Shubham Bansal <[email protected]>
SchemaSnapshot and the recorded schema dumps move to the server (server/src/main/resources/schema/<db>.txt), and SchemaDumpTest keeps checking and regenerating them there. After the pending steps, and on every start, SchemaMigrator compares the tables that this release's SQL steps change (steps above the previous release's last step, parsed from their CREATE/ALTER/DROP TABLE and CREATE/DROP INDEX statements) with the same tables in the dump. A difference means a manual change: the server refuses to start and lists the differing lines (at most 20), and --check-schema reports the same for a database that is up to date. Tables that no step of this release changes are not compared. On MySQL, a text column wider than recorded counts as a match: step 3 converts latin1 and utf8mb3 tables to utf8mb4, and MySQL widens their text columns to keep their length in characters (MigratorTest.convertsALatin1DatabaseWithTheStagingLocationIndex). Co-authored-by: Isaac <[email protected]> Signed-off-by: Shubham Bansal <[email protected]>
…lease docs/server/upgrades.md: upgrade one release at a time and the refusal for a skipped release; what the server compares on every start and the section "The schema differs"; the releases.properties line to add when a release is cut, and a release-notes template for its schema steps and checks; the two new messages. Co-authored-by: Isaac <[email protected]> Signed-off-by: Shubham Bansal <[email protected]>
… release rule A database without schema history is one of the baseline release (0.7.0), at schema version 1. The rule that a release upgrades only from the release before it now applies to it too: it is adopted while this release upgrades from 0.7.0 (the map's previous release ends at step 1, as today) and refused as a skipped release otherwise, before the baseline row is written; --check-schema reports the same. Co-authored-by: Isaac <[email protected]> Signed-off-by: Shubham Bansal <[email protected]>
This was referenced Oct 25, 2026
Closed
… check its whole schema etc/db/h2db was first created by a release before 0.4.1, so its CHECKs on uc_function_params.type_name and uc_functions.data_type still allowed column types 0..20 (VARIANT, 21, came in 0.4.1), and the name columns of uc_catalogs, uc_schemas, uc_tables and uc_volumes were nullable. The schema check on start refused it, so bin/start-uc-server failed on the sample database and with it the Python client tests. The repair widens the two CHECKs to 0..21 under their existing names and makes the four name columns NOT NULL (no row has a NULL name). Data and schema history rows are unchanged. SampleDatabaseIsCurrentTest now also compares the sample database's whole schema with the H2 dump of a fresh install, so drift in it fails a test instead of the server start. 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
Oct 25, 2026
…d sample database Co-authored-by: Isaac <[email protected]> Signed-off-by: Shubham Bansal <[email protected]>
…r's pool
The server's pool doesn't autocommit (Hibernate manages transactions), and
the migration took its connections from it. On PostgreSQL the lock-wait SET
then opened a transaction, so a bad-row check's setReadOnly(true) failed
("Cannot change transaction read-only property in the middle of a
transaction") and every check refused the start. A statement run on such a
connection outside Flyway would also never be committed.
connection() now sets autocommit before the SET, as the backup's connections
do; a check still runs in its own read-only transaction. Flyway gets the same
autocommit connections the tests always gave it. The new test runs the checks
and the upgrade on a pool built like the server's.
Co-authored-by: Isaac <[email protected]>
Signed-off-by: Shubham Bansal <[email protected]>
The type-change probe compared only the type and size, so a step that restates them and changes something else was recorded without running: a MySQL MODIFY c varchar(64) NOT NULL over a nullable varchar(64), or a PostgreSQL ALTER COLUMN c TYPE varchar(64) COLLATE "C". The probe now recognises a type change only when nothing but NULL or NOT NULL follows the type; any other clause (DEFAULT, COLLATE, CHARACTER SET, USING, ...) gets no probe, so the step runs. A NULL or NOT NULL must match the column's nullability. MySQL's MODIFY and H2's ALTER COLUMN c <type> restate the column: they drop its default, and MySQL's makes it nullable unless it says NOT NULL, so for them the column must also have no default, and on MySQL be nullable when the statement says nothing. Co-authored-by: Isaac <[email protected]> Signed-off-by: Shubham Bansal <[email protected]>
…set step
The release before this build's was the highest listed release below it. A
patch release without steps of its own then moved it: with 0.7.0=1, 0.8.0=3
and 0.8.1=3, a 0.8.2 build refused a 0.7.0 database and a 0.8.0 upgrade that
stopped midway ("Upgrade to 0.8.1 first"), and no step was this release's, so
the every-start schema check compared no table.
The release before is now the first listed release of the minor line before
this build's: any release of that line, or a later one such as an earlier
patch of this build's own line, upgrades, and this release's steps are those
above that release's last step. This follows the project's policy of testing
upgrades from the latest patch of each minor line. The refusal names the
line: "... upgrades only from 0.7.0 or a later 0.7 release (version 3 or
later). Upgrade to the latest 0.7 release first, ...". upgrades.md and the
releases.properties header say so.
MySQL's step 3 converts the character set of every table, which made every
table one this release changes, so the every-start check refused, for
example, an index a DBA added to uc_catalogs. A statement that changes only a
table's character set or collation (not compared by the schema check) no
longer counts as changing the table.
Co-authored-by: Isaac <[email protected]>
Signed-off-by: Shubham Bansal <[email protected]>
…e probe The add-column probe also matched ALTER TABLE t ADD UNIQUE (c), ADD PRIMARY KEY, ADD INDEX and the like, taking the keyword for a column name. It then reported the change as absent instead of "can't tell", so a failed step of that form whose change was there was run again: an unnamed unique key was added twice, and a named index failed again on every start. These forms now get no probe: a failed one is refused with the "can't tell" message, a pending one runs. Co-authored-by: Isaac <[email protected]> Signed-off-by: Shubham Bansal <[email protected]>
Conflicts: SchemaMigrator type-change probe keeps the Optional return with the new end-anchored regex and the nullable/restates hasType arguments; StepAlreadyInDatabaseTest keeps both test-step directories. Co-authored-by: Isaac <[email protected]> Signed-off-by: Shubham Bansal <[email protected]>
Conflict: BadRowCheckTest imports. SchemaSnapshot is in the migrate package on this branch, so the kit import goes; the HikariDataSource and HibernateConfigurator imports of the new pool test stay. 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
Oct 25, 2026
Conflict: SchemaMigrator.connection() keeps the autocommit fix and this branch's static lockWaitSql(kind, lockWait). Co-authored-by: Isaac <[email protected]> Signed-off-by: Shubham Bansal <[email protected]>
…tabase Co-authored-by: Isaac <[email protected]> Signed-off-by: Shubham Bansal <[email protected]>
Collaborator
Author
|
Closing this draft. Its code is kept as a reference on |
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
Every start now checks that the tables this release's steps touch match what the steps build, and an upgrade is accepted only from the previous release.
server/src/main/resources/db/migration/releases.propertiesmaps each release to its last step (today0.7.0=1; a line is added when a release is cut). The previous release is the highest one listed below this build's version. A database whose schema version is below the previous release's last step is refused before any change:--check-schemareports the refusal too.SchemaSnapshotand the recorded dumps move into the server (server/src/main/resources/schema/<db>.txt; [Server] Check schema migration steps on every pull request #2046's dump test keeps them current). After the steps run, and on every start when nothing is pending, the server compares the tables this release's SQL steps touch (from theirCREATE/ALTER/DROP TABLEandCREATE/DROP INDEX … ONstatements) with the dump. Any difference stops the start and lists the lines (at most 20), ending with "Undo the manual change, or restore the backup; see docs/server/upgrades.md (section "The schema differs")". Tables no step of this release touches aren't checked. On MySQL, a text column that step 3'sCONVERTwidened on a latin1 database (text → mediumtext) counts as a match.docs/server/upgrades.mdcovers the check, skipping a release, and how to cut a release (add thereleases.propertiesline; the release notes list the steps and checks).Testing
On H2, PostgreSQL 18 and MySQL 8.4 (
migrate.*: H2 63 passed, PostgreSQL 64, MySQL 65; skipped tests are for other databases);testUpgradespasses on H2 (a real 0.7.0 database upgrades and passes the check).SkippedReleaseTest(test-only release map and steps): a database at the previous release's last step upgrades; one part-way through is accepted; an empty database and the baseline release are accepted while the previous release is the baseline; an older database is refused with the message and nothing changes; an unversioned 0.7.0 database is refused after a later release, with no baseline row written;--check-schemareturns 1. Before the change, the refusal tests failed with "Expecting code to raise a throwable".ManualSchemaChangeTest: an extra column on a table this release's step touches → the start is refused with the diff (also after the steps ran on a 0.7.0 database); a dropped index → refused; more than 20 differing lines → capped;--check-schema→ 1; a manual change on an untouched table → still starts. Five of seven failed before the check existed.ReleasesFileTest: releases ascend, last steps never go down, the first is the baseline release, and each listed step exists in every database folder.MigratorTest.convertsALatin1DatabaseWithTheStagingLocationIndex(MySQL) is the regression test for the widened-text rule: without it the check refused that supported upgrade.From the final review (each finding reproduced first): the release an upgrade must start from is now the earliest release of the previous minor line (so 0.7.0 and 0.7.5 databases both upgrade to 0.8.x, and a patch release with no new steps refuses nothing); this release's steps are those above it. Statements that change only a table's character set or collation (MySQL's step 3) no longer make that table checked on every start, so an index a DBA added doesn't stop MySQL servers.
📐 Design notes & details
Why only the tables this release's steps touch. Older tables may carry differences from earlier releases that a later PR repairs (drift); checking them now would refuse databases that run fine today. Steps from tests' own locations are skipped, because no dump records their tables.
Why the release map is a file and not git tags. The server needs it at run time, inside the jar.
Why a database part-way through this release is accepted. A rerun after a stop or a failed step must be able to finish.
This pull request and its description were written by Isaac.