summaryrefslogtreecommitdiff
path: root/db/updates/update-db-to-v15.sql
diff options
context:
space:
mode:
Diffstat (limited to 'db/updates/update-db-to-v15.sql')
-rw-r--r--db/updates/update-db-to-v15.sql24
1 files changed, 24 insertions, 0 deletions
diff --git a/db/updates/update-db-to-v15.sql b/db/updates/update-db-to-v15.sql
new file mode 100644
index 00000000..ef2bafaf
--- /dev/null
+++ b/db/updates/update-db-to-v15.sql
@@ -0,0 +1,24 @@
+PRAGMA foreign_keys=OFF;
+
+BEGIN EXCLUSIVE TRANSACTION;
+
+PRAGMA user_version = 15;
+
+CREATE TABLE author_new (
+ author_id INTEGER PRIMARY KEY,
+ hash VARCHAR NOT NULL,
+ UNIQUE (hash)
+);
+
+INSERT INTO author_new
+SELECT author_id, hash
+FROM author;
+
+DROP TABLE author;
+ALTER TABLE author_new RENAME TO author;
+
+PRAGMA foreign_key_check;
+
+COMMIT TRANSACTION;
+
+PRAGMA foreign_keys=ON;