fix: verify SQL migrations before recording and preserve sessions (#3)
This commit is contained in:
1 parent
370407d3ba
commit
a59cc7ccb7
4 files changed
+145
-12
No files matched your search
@@ -439,8 +439,16 @@ MariaDB:
|
||||
`UPTO` as applied **without running them**, for a server whose schema is already current;
|
||||
- migrations use their own connection without read/write timeouts (`openMigrationDB`),
|
||||
not the app's 3s-timeout sync connection — a long backfill must not be cut mid-file;
|
||||
- a file is recorded only after all its statements succeed, so each file must be safe to
|
||||
re-run (`ADD COLUMN IF NOT EXISTS`, idempotent `UPDATE ... WHERE <not yet done>`);
|
||||
- each file, its `-- verify: <description> | <SQL>` queries and history insertion run
|
||||
on one database session, preserving session variables;
|
||||
- a file is recorded only after statements and all verify checks succeed. Verify
|
||||
queries return rows only for broken invariants; a row or SQL error stops the run
|
||||
without marking that file applied. Malformed verify headers fail before execution;
|
||||
- only duplicate column/key names and already-existing objects are tolerated.
|
||||
FK creation errors (including errno 150/121) remain fatal;
|
||||
- each file must be safe to re-run after a partial failure (`ADD COLUMN IF NOT EXISTS`,
|
||||
idempotent `UPDATE ... WHERE <not yet done>`). The current statement splitter assumes
|
||||
semicolons occur only between statements; do not add semicolons inside literals;
|
||||
- there is no GORM `AutoMigrate` against MariaDB: it retypes production columns to match the
|
||||
running binary's models. On 2026-09-24 a stale v1.18 binary run with the old AutoMigrate
|
||||
`-migrate` did exactly that, which is why it was removed.
|
||||
|
||||
Reference in new issue
Block a user