~singpolyma/jmp-schemas

jmp-schemas/deploy/invites.sql -rw-r--r-- 407 bytes
395bb797Stephen Paul Weber Tag for notify on top up an expired account a month ago
                                                                                
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
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;