diff options
| author | Kyren223 <Kyren223@proton.me> | 2025-01-09 17:28:46 +0200 |
|---|---|---|
| committer | Kyren223 <Kyren223@proton.me> | 2025-01-09 17:28:46 +0200 |
| commit | 936d3cf690ace9adfdfe0fb44193c11a0cb26d95 (patch) | |
| tree | 3d0699aa5c50efb7ecac3dddd25fe959366b7562 /internal/server/api/migrations/20250109135557_frequencies.sql | |
| parent | d0cb135161b18f37c25501cb863fa783cd723758 (diff) | |
Added goose for migrations, refactored SQL schema, server and client
are broken
Diffstat (limited to 'internal/server/api/migrations/20250109135557_frequencies.sql')
| -rw-r--r-- | internal/server/api/migrations/20250109135557_frequencies.sql | 24 |
1 files changed, 24 insertions, 0 deletions
diff --git a/internal/server/api/migrations/20250109135557_frequencies.sql b/internal/server/api/migrations/20250109135557_frequencies.sql new file mode 100644 index 0000000..a444af1 --- /dev/null +++ b/internal/server/api/migrations/20250109135557_frequencies.sql @@ -0,0 +1,24 @@ +-- +goose Up +CREATE TABLE IF NOT EXISTS frequencies ( + id INTEGER PRIMARY KEY, + network_id INT NOT NULL REFERENCES networks (id) ON DELETE CASCADE, + name TEXT NOT NULL, + hex_color TEXT NOT NULL, + perms INT NOT NULL CHECK (perms IN (0, 1, 2)), + -- 0 no access | 1 read | 2 read & write + position INT NOT NULL +); + +-- +goose StatementBegin +CREATE TRIGGER IF NOT EXISTS on_frequency_delete +AFTER DELETE ON frequencies +BEGIN + UPDATE frequencies SET + position = position - 1 + WHERE network_id = OLD.network_id AND position > OLD.position; +END +-- +goose StatementEnd + +-- +goose Down +DROP TABLE IF EXISTS frequencies; +DROP TRIGGER IF EXISTS on_frequency_delete; |
