M .builds/debian-stable.yml => .builds/debian-stable.yml +2 -0
@@ 11,6 11,8 @@ tasks:
sudo -u postgres psql -c "CREATE ROLE $(id -un) LOGIN"
sudo -u postgres psql -c "CREATE DATABASE jmp WITH OWNER $(id -un)"
sudo -u postgres psql -d jmp -c "CREATE EXTENSION btree_gist"
+ sudo -u postgres psql -d jmp -c "CREATE EXTENSION citext"
+ sudo -u postgres psql -d jmp -c "CREATE EXTENSION pgcrypto"
- deploy: |
cd jmp-schemas
sqitch deploy
A deploy/invites.sql => deploy/invites.sql +17 -0
@@ 0,0 1,17 @@
+-- Deploy jmp:invites to pg
+
+BEGIN;
+
+CREATE TABLE invites (
+ creator_id TEXT NOT NULL,
+ used_by_id TEXT,
+ created_at TIMESTAMP NOT NULL DEFAULT(LOCALTIMESTAMP),
+ used_at TIMESTAMP,
+ code CITEXT NOT NULL PRIMARY KEY
+ DEFAULT(UPPER(ENCODE(GEN_RANDOM_BYTES(4), 'hex')))
+);
+
+CREATE INDEX ON invites (creator_id, created_at DESC);
+CREATE INDEX ON invites (used_by_id, used_at DESC);
+
+COMMIT;
A revert/invites.sql => revert/invites.sql +7 -0
@@ 0,0 1,7 @@
+-- Revert jmp:invites from pg
+
+BEGIN;
+
+DROP TABLE invites;
+
+COMMIT;
M sqitch.plan => sqitch.plan +2 -0
@@ 11,3 11,5 @@ cdr 2021-02-24T18:36:49Z Stephen Paul Weber <singpolyma@singpolyma.net> # Create
plan_log_with_range [plan_log customer_plans] 2021-05-03T19:30:36Z Stephen Paul Weber,,, <singpolyma@singpolyma-beefy> # Switch plan_log to use a tsrange
@2021130 2021-05-11T01:37:34Z Stephen Paul Weber,,, <singpolyma@singpolyma-beefy> # Deploy to production
+
+invites 2021-05-17T20:31:00Z Stephen Paul Weber,,, <singpolyma@singpolyma-beefy> # Table to store invite codes and their state
A verify/invites.sql => verify/invites.sql +7 -0
@@ 0,0 1,7 @@
+-- Verify jmp:invites on pg
+
+BEGIN;
+
+SELECT creator_id, used_by_id, created_at, used_at, code FROM invites;
+
+ROLLBACK;