From b324803fe11b52b28ac2dc459504f904a48a79d4 Mon Sep 17 00:00:00 2001
From: Joris
Date: Fri, 7 Feb 2025 11:45:22 +0100
Subject: Use strict tables

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

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

diff --git a/src/db/migrations/04-strict-tables.sql b/src/db/migrations/04-strict-tables.sql
new file mode 100644
index 0000000..9ce4ce9
--- /dev/null
+++ b/src/db/migrations/04-strict-tables.sql
@@ -0,0 +1,18 @@
+ALTER TABLE "cards" RENAME TO "cards_non_strict";
+
+CREATE TABLE IF NOT EXISTS "cards" (
+  question TEXT NOT NULL,
+  responses TEXT NOT NULL,
+  state TEXT NOT NULL,
+  created INTEGER NOT NULL, /* TIMESTAMP */
+  updated INTEGER NULL, /* TIMESTAMP */
+  deleted INTEGER NULL, /* TIMESTAMP */
+  ready INTEGER NOT NULL, /* TIMESTAMP */
+  PRIMARY KEY (question, responses)
+) STRICT;
+
+INSERT INTO cards (question, responses, state, created, updated, deleted, ready)
+  SELECT question, responses, state, created, updated, deleted, ready
+  FROM cards_non_strict;
+
+DROP TABLE cards_non_strict;
-- 
cgit v1.2.3

