aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorJulien Dessaux2021-11-01 00:41:36 +0100
committerJulien Dessaux2021-11-01 00:41:36 +0100
commitc1b4cee29ba45ee8319e9c9dcd34b753aed05de8 (patch)
treeb34eb0cb62a6301edfd47002e13d5464f87077d3 /src
parentAdded README (diff)
downloadshort-c1b4cee29ba45ee8319e9c9dcd34b753aed05de8.tar.gz
short-c1b4cee29ba45ee8319e9c9dcd34b753aed05de8.tar.bz2
short-c1b4cee29ba45ee8319e9c9dcd34b753aed05de8.zip
Enforce a more strict database schema
Diffstat (limited to '')
-rw-r--r--src/database.nim15
1 files changed, 15 insertions, 0 deletions
diff --git a/src/database.nim b/src/database.nim
index 004d7c4..3cf1e40 100644
--- a/src/database.nim
+++ b/src/database.nim
@@ -18,6 +18,21 @@ const migrations = [
expires DATE
);
CREATE UNIQUE INDEX idx_url_token ON url(token);
+ """,
+ """
+ CREATE TABLE url2 (
+ id INTEGER PRIMARY KEY,
+ token TEXT NOT NULL UNIQUE,
+ title TEXT NOT NULL,
+ url TEXT NOT NULL,
+ created DATE NOT NULL,
+ expires DATE NOT NULL
+ );
+ INSERT INTO url2(id, token, title, url, created, expires)
+ SELECT id, token, title, url, created, expires FROM url;
+ DROP TABLE url;
+ ALTER TABLE url2 RENAME TO url;
+ CREATE UNIQUE INDEX idx_url_token ON url(token);
"""
]
const latestVersion = migrations.len