summaryrefslogtreecommitdiffhomepage
path: root/apioforum/db.py
diff options
context:
space:
mode:
authorubq323 <ubq323>2021-06-20 23:12:44 +0000
committerubq323 <ubq323>2021-06-20 23:12:44 +0000
commit5f24e7ca10bffc20aa486e50e9dee222bda28dc6 (patch)
treeb6b349bbca974cece24052509123997d34a87b74 /apioforum/db.py
parentfdbbda97f604e9fca9cd490e0227313130b75f28 (diff)
much better schema, and some (but only some) multiforumification
Diffstat (limited to 'apioforum/db.py')
-rw-r--r--apioforum/db.py17
1 files changed, 16 insertions, 1 deletions
diff --git a/apioforum/db.py b/apioforum/db.py
index ad6cd39..136b7c6 100644
--- a/apioforum/db.py
+++ b/apioforum/db.py
@@ -92,7 +92,22 @@ CREATE TABLE forums (
description TEXT
);
INSERT INTO forums (name,parent,description) values ('root',null,'the default root forum');
-ALTER TABLE threads ADD COLUMN forum NOT NULL DEFAULT 1 REFERENCES forums(id);
+
+PRAGMA foreign_keys = off;
+BEGIN TRANSACTION;
+CREATE TABLE threads_new (
+ id INTEGER PRIMARY KEY,
+ title TEXT NOT NULL,
+ creator TEXT NOT NULL,
+ created TIMESTAMP NOT NULL,
+ updated TIMESTAMP NOT NULL,
+ forum NOT NULL REFERENCES forums(id)
+);
+INSERT INTO threads_new (id,title,creator,created,updated,forum)
+ SELECT id,title,creator,created,updated,1 FROM threads;
+DROP TABLE threads;
+ALTER TABLE threads_new RENAME TO threads;
+COMMIT;
""",
]