-
-
Notifications
You must be signed in to change notification settings - Fork 34
Database Migrations
Michael Green edited this page Apr 11, 2026
·
1 revision
Use the MariaDB migration files under gaseous-lib/Support/Database/MySQL to introduce schema changes.
- Name each new migration
gaseous-NNNN.sql. - Pick the next unused numeric version.
- Do not rename, edit, or delete an existing migration after it has been merged.
- Put only the schema change for that version in the SQL file. If an older migration needs correction, add a new migration instead of changing history.
When a migration also needs application-side work:
- Add blocking pre-upgrade logic to
DatabaseMigration.PreUpgradeScript(version, ...). - Add post-upgrade or data-fix logic to
DatabaseMigration.PostUpgradeScript(version, ...). - Add at least one validation entry for the new version in
DatabaseMigrationManifest.BuildManifest().
Safety rules:
-
check-migration-scripts.ymlblocks modifications to historicalgaseous-*.sqlfiles. - The same workflow fails if the newest SQL version has no manifest validation entry.
-
InitDB()takes a backup before pending migrations run and records each step inmigration_journal.
Recommended workflow:
- Add
gaseous-NNNN.sqlunder the MariaDB migration directory atgaseous-lib/Support/Database/MySQL. - Add any required pre/post C# migration logic.
- Add validation entries for version
NNNNinDatabaseMigrationManifest.cs. - Run the CLI migration command against a test database.
- Verify the result with the CLI status and validation commands.
Useful commands:
dotnet run --project ./gaseous-cli/gaseous-cli.csproj -- db migrate
dotnet run --project ./gaseous-cli/gaseous-cli.csproj -- db validate
dotnet run --project ./gaseous-cli/gaseous-cli.csproj -- db status