aboutsummaryrefslogtreecommitdiff
path: root/src/db/migrations/04-strict-tables.sql
diff options
context:
space:
mode:
authorJoris2025-02-07 11:45:22 +0100
committerJoris2025-02-07 11:45:22 +0100
commitb324803fe11b52b28ac2dc459504f904a48a79d4 (patch)
tree1d916303b3b262dc09c38a3c6f9abbb4a9a4e4be /src/db/migrations/04-strict-tables.sql
parentf7afa9cf50a9459f41146ca5cb009eab69b76c5f (diff)
Use strict tables
Diffstat (limited to 'src/db/migrations/04-strict-tables.sql')
-rw-r--r--src/db/migrations/04-strict-tables.sql18
1 files changed, 18 insertions, 0 deletions
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;