diff options
author | Joris | 2025-02-07 09:17:26 +0100 |
---|---|---|
committer | Joris | 2025-02-07 09:17:26 +0100 |
commit | 5e2aee9248a00c8b213a8e07e4796d668bff519c (patch) | |
tree | 861fdc7f2b23cc8538cf479f44f62e700a77222f /src/db/migrations | |
parent | 463d58b37909c976d3f30bdb5a652f0e8a018b55 (diff) |
Apply SQL migrations at startup
Diffstat (limited to 'src/db/migrations')
-rw-r--r-- | src/db/migrations/01-init.sql | 7 | ||||
-rw-r--r-- | src/db/migrations/02-strict-tables.sql | 15 |
2 files changed, 22 insertions, 0 deletions
diff --git a/src/db/migrations/01-init.sql b/src/db/migrations/01-init.sql new file mode 100644 index 0000000..75abc54 --- /dev/null +++ b/src/db/migrations/01-init.sql @@ -0,0 +1,7 @@ +CREATE TABLE IF NOT EXISTS "files" ( + id TEXT PRIMARY KEY, + created_at TEXT NOT NULL, + expires_at TEXT NOT NULL, + filename TEXT NOT NULL, + content_length INTEGER NOT NULL +); diff --git a/src/db/migrations/02-strict-tables.sql b/src/db/migrations/02-strict-tables.sql new file mode 100644 index 0000000..433ef39 --- /dev/null +++ b/src/db/migrations/02-strict-tables.sql @@ -0,0 +1,15 @@ +ALTER TABLE "files" RENAME TO "files_non_strict"; + +CREATE TABLE IF NOT EXISTS "files" ( + id TEXT PRIMARY KEY, + created_at TEXT NOT NULL, + expires_at TEXT NOT NULL, + filename TEXT NOT NULL, + content_length INTEGER NOT NULL +) STRICT; + +INSERT INTO files (id, created_at, expires_at, filename, content_length) + SELECT id, created_at, expires_at, filename, content_length + FROM files_non_strict; + +DROP TABLE files_non_strict; |