Repository navigation
Record each table upgrade and refuse a database a newer schema format upgraded [all-db] - #517
Merged
Merged
Conversation
… upgraded [all-db] Every upgrade TableUpgradeOrchestrator.Execute runs now writes a row per table to st_table_upgrade in the database it changes, before any statement runs, then records the outcome: the applied schema and its SHA-256 on success, the error on failure. The highest format version recorded in the database is checked first; a database a tool of a higher SchemaFormat upgraded is refused with nothing changed, so an older tool cannot change the newer shape back. DatabaseInitializer reports such a database once and skips its tables. PublicAPI: additions only (SchemaFormat, TableUpgradeRecordStore, TableUpgradeRecord, TableUpgradeStatus, UpgradePlan.DefineTable as an init property), so existing callers stay binary compatible. Part of #512
|
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.



Part of #512. This is the first step: per-table upgrade records, and the guard that stops an older tool from undoing a newer tool's upgrade.
What changes
st_table_upgrade, one per database, one row per upgraded table:SchemaFormatand framework version of the tool that ran the upgrade;Upgrading/Succeeded/Failed) and the error;TableSchemaas XML, and its SHA-256.The table is created on first use, from a schema built in code, through each dialect's create builder. It is not declared in any definition.
TableUpgradeOrchestrator.Executedoes three things, in order:SchemaFormat.Current.Upgradingbefore any statement runs, so an older tool is refused even after a failed or half-finished upgrade.What creates no record:
TableSchemaBuilder.GetCommandText;DatabaseInitializer.UpgradeTableschecks each database once. A database a newer format upgraded becomes a single problem in the report, and none of its tables is touched (dry run included).SchemaFormat.Currentstarts at 1.Compatibility
Public API changes are additions only:
SchemaFormatTableUpgradeRecordStoreTableUpgradeRecordTableUpgradeStatusUpgradePlan.DefineTable, as aninitpropertyExisting callers stay binary compatible. A plan built by hand without
DefineTableruns without a record, but the format guard still applies.Known limits (left to later phases of #512)
Failedcan overwrite the winner'sSucceeded. The data is unaffected.Verification
dotnet build Polhem.slnx -c Release: 0 warnings../test.shlocally with all five databases, everything passing exceptGenerate_iOS_Builds, which fails because the local Xcode does not match the iOS workload. That test is unrelated to this change.TableUpgradeRecordDbTestscovers success, failure and the newer-format refusal on each database, plus an empty plan and a plan without its definition.DatabaseInitializerSqliteTestscover records after a build, and one report per newer-format database.table_namecolumn is widened to 128;