about summary refs log tree commit diff
path: root/src/init.sql
diff options
context:
space:
mode:
authorWilliam Carroll <wpcarro@gmail.com>2020-08-02T15·07+0100
committerWilliam Carroll <wpcarro@gmail.com>2020-08-02T15·07+0100
commit25334080b9bcdf238f75069feb92fba65896da5e (patch)
treef3410227de97c10936a260e9e7a6bbe6ac43231d /src/init.sql
parentfe609bbe5804be229a7e5c0d276654fb3e45179b (diff)
Support POST /invite
Allow Admin accounts to invite users to the application.
Diffstat (limited to 'src/init.sql')
-rw-r--r--src/init.sql8
1 files changed, 8 insertions, 0 deletions
diff --git a/src/init.sql b/src/init.sql
index b616fdece52d..b42753ae5d01 100644
--- a/src/init.sql
+++ b/src/init.sql
@@ -11,6 +11,7 @@ DROP TABLE IF EXISTS Trips;
 DROP TABLE IF EXISTS Sessions;
 DROP TABLE IF EXISTS LoginAttempts;
 DROP TABLE IF EXISTS PendingAccounts;
+DROP TABLE IF EXISTS Invitations;
 
 CREATE TABLE Accounts (
   username TEXT CHECK(LENGTH(username) > 0) NOT NULL,
@@ -56,4 +57,11 @@ CREATE TABLE PendingAccounts (
   PRIMARY KEY (username)
 );
 
+CREATE TABLE Invitations (
+  email TEXT CHECK(LENGTH(email) > 0) NOT NULL UNIQUE,
+  role TEXT CHECK(role IN ('user', 'manager', 'admin')) NOT NULL,
+  secret TEXT CHECK(LENGTH(secret) == 36) NOT NULL,
+  PRIMARY KEY (email)
+);
+
 COMMIT;