Sybren A. Stüvel a65f234bea Manager: replace GORM database migration with Goose
Replace GORM's auto-migration with Goose. The latter uses hand-written
SQL queries to apply database schema changes, which is safer and easier to
understand than what GORM is doing.
2023-12-14 10:13:40 +01:00

22 lines
655 B
Markdown

# SQL Migrations
The files here are run by [Goose][goose], the database migration tool.
[goose]: https://pkg.go.dev/github.com/pressly/goose/v3
These are embedded into the Flamenco Manager executable, and automatically run
on startup.
## Foreign Key Constraints
Foreign Key constraints (FKCs) are optional in SQLite, and always enabled by
Flamenco Manager. These are temporarily disabled during database migration
itself. This means you can replace a table like this, without `ON DELETE`
effects running.
```sql
INSERT INTO `temp_table` SELECT * FROM `actual_table`;
DROP TABLE `actual_table`;
ALTER TABLE `temp_table` RENAME TO `actual_table`;
```