Sybren A. Stüvel 71bbaaeae0 Manager; convert fetching of sleep schedules to sqlc
This also corrects the sleep schedule schema to actually store the
`is_active` field as `boolean` (it was `numeric`, which is the same
underlying field type in SQLite, but produces a different struct field
in the sqlc-generated Go code).

Ref: #104305
2024-09-18 21:11:54 +02:00
..
2024-03-04 13:06:09 +01:00

SQL Migrations

The files here are run by Goose, the database migration tool.

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.

INSERT INTO `temp_table` SELECT field1, field2, etc FROM `actual_table`;
DROP TABLE `actual_table`;
ALTER TABLE `temp_table` RENAME TO `actual_table`;

Note that the SELECT clause lists each field specifically. This is to ensure that they are selected in the expected order. Without this, data can get mangled.