From 5e2aee9248a00c8b213a8e07e4796d668bff519c Mon Sep 17 00:00:00 2001
From: Joris
Date: Fri, 7 Feb 2025 09:17:26 +0100
Subject: Apply SQL migrations at startup

---
 src/db/migrations/02-strict-tables.sql | 15 +++++++++++++++
 1 file changed, 15 insertions(+)
 create mode 100644 src/db/migrations/02-strict-tables.sql

(limited to 'src/db/migrations/02-strict-tables.sql')

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;
-- 
cgit v1.2.3

