Files
Giacomo Vercesi d7d87e237a LocalProvider: add migration logic
Add additional logic to allow the local database to be migrated to newer
versions.
2026-05-22 09:04:35 +02:00

1.0 KiB

How to add a migration to the local storage provider

  1. Look at the current schema
  2. Create a file named vXXXX.sql, the files need to be in order, e.g. v1 v2 ... v9 v10 etc. The migration machinery will check that there are no holes
  3. Add the needed migrations, these will probably be comprised of:
    • Some DELETE FROM statements to clear some tables
    • One or more ALTER TABLE statements

General logic for the migrations

  1. Start with the ALTER TABLE statements you want to make
  2. Do they introduce nullable columns? If so no additional operations are needed
  3. If they need non-nullable columns can the data be derived from the existing data in the database? Note that the pipebox is not available for migrations so these transformations need to be SQL-only. If not then it's ok to drop data from the following tables:
    • objects
    • dependencies
    • custom_dependencies
  4. Usually you want to drop all three tables, they are inter-dependent so the data from one missing usually leads to corrupted data on the other