Module db_migration

Module db_migration 

Source
Expand description

Schema migration support

Our basic approach:

The 12-step process from s7 in https://sqlite.org/lang_altertable.html “Making Other Kinds Of Table Schema Changes” (retrieved 2025-10-12).

But we do it to the whole db at once, and we store the temporary copy in a whole temporary database which we ATTACH. So we don’t rename the tables.

So the procedure is (roughly):

  • Attach temporary database
  • Create tables in temporary database by running (new) schema on it
  • Copy data from real to temporary database, with data alteration/supplementation as needed (including sqlite_sequence table but not other sqlite_* tables).
  • Drop every table in the real database.
  • Create tables in real database by running schema on it.
  • Copy data from temporary database back to main database.

Structs§

Migration
MigrationData
Schema

Enums§

Exception
OnComplete
Outcome

Functions§

migration_core
prepare_idempotent
Ensure that the database has a suitable schema