aboutsummaryrefslogtreecommitdiff
path: root/src/db.js
diff options
context:
space:
mode:
authorAkshay <[email protected]>2024-11-22 19:48:31 +0000
committerAkshay <[email protected]>2024-11-22 19:48:31 +0000
commit622c5fee25e7d86914d343ca3f873dc4bd55ffad (patch)
tree6543c2ef3499eecee3842f433599aaae6c4c2f14 /src/db.js
parent3551ff7a202ad60362888888c42f88b37e32fc59 (diff)
rework invite and admins a bit
Diffstat (limited to 'src/db.js')
-rw-r--r--src/db.js17
1 files changed, 13 insertions, 4 deletions
diff --git a/src/db.js b/src/db.js
index 747168a..c1fecac 100644
--- a/src/db.js
+++ b/src/db.js
@@ -15,16 +15,16 @@ function runMigration(name, migrationFn) {
15} 15}
16 16
17// users table 17// users table
18db.query(` 18db.run(`
19 CREATE TABLE IF NOT EXISTS users ( 19 CREATE TABLE IF NOT EXISTS users (
20 id INTEGER PRIMARY KEY AUTOINCREMENT, 20 id INTEGER PRIMARY KEY AUTOINCREMENT,
21 username TEXT UNIQUE, 21 username TEXT UNIQUE,
22 password_hash TEXT 22 password_hash TEXT
23 ) 23 )
24`).run(); 24`);
25 25
26// subs table 26// subs table
27db.query(` 27db.run(`
28 CREATE TABLE IF NOT EXISTS subscriptions ( 28 CREATE TABLE IF NOT EXISTS subscriptions (
29 id INTEGER PRIMARY KEY AUTOINCREMENT, 29 id INTEGER PRIMARY KEY AUTOINCREMENT,
30 user_id INTEGER, 30 user_id INTEGER,
@@ -32,7 +32,16 @@ db.query(`
32 FOREIGN KEY(user_id) REFERENCES users(id), 32 FOREIGN KEY(user_id) REFERENCES users(id),
33 UNIQUE(user_id, subreddit) 33 UNIQUE(user_id, subreddit)
34 ) 34 )
35`).run(); 35`);
36
37db.run(`
38 CREATE TABLE IF NOT EXISTS invites (
39 id INTEGER PRIMARY KEY AUTOINCREMENT,
40 token TEXT NOT NULL,
41 createdAt TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
42 usedAt TIMESTAMP
43 )
44`);
36 45
37// migrations table 46// migrations table
38db.query(` 47db.query(`