aboutsummaryrefslogtreecommitdiffstats
path: root/rust/migrations
diff options
context:
space:
mode:
authorBryan Newbold <bnewbold@robocracy.org>2019-01-03 16:53:09 -0800
committerBryan Newbold <bnewbold@robocracy.org>2019-01-03 16:53:09 -0800
commit9bfb8e968fcecbe4dc729b89017d0606d271b287 (patch)
treec6675551a350411904c39be7636718d5c37a6a4d /rust/migrations
parent2ff1adeeb85c23df1dd6de3c2dd9ebede2a04954 (diff)
downloadfatcat-9bfb8e968fcecbe4dc729b89017d0606d271b287.tar.gz
fatcat-9bfb8e968fcecbe4dc729b89017d0606d271b287.zip
OIDC auth table, and is_active editor flag
Diffstat (limited to 'rust/migrations')
-rw-r--r--rust/migrations/2018-05-12-001226_init/down.sql1
-rw-r--r--rust/migrations/2018-05-12-001226_init/up.sql12
2 files changed, 13 insertions, 0 deletions
diff --git a/rust/migrations/2018-05-12-001226_init/down.sql b/rust/migrations/2018-05-12-001226_init/down.sql
index d156370e..b2666083 100644
--- a/rust/migrations/2018-05-12-001226_init/down.sql
+++ b/rust/migrations/2018-05-12-001226_init/down.sql
@@ -42,6 +42,7 @@ DROP TABLE IF EXISTS creator_ident CASCADE;
DROP TABLE IF EXISTS creator_edit CASCADE;
DROP TABLE IF EXISTS abstracts CASCADE;
+DROP TABLE IF EXISTS auth_oidc CASCADE;
DROP TABLE IF EXISTS editor CASCADE;
DROP TABLE IF EXISTS editgroup CASCADE;
DROP TABLE IF EXISTS changelog CASCADE;
diff --git a/rust/migrations/2018-05-12-001226_init/up.sql b/rust/migrations/2018-05-12-001226_init/up.sql
index db2e835f..0d9d81d0 100644
--- a/rust/migrations/2018-05-12-001226_init/up.sql
+++ b/rust/migrations/2018-05-12-001226_init/up.sql
@@ -19,6 +19,7 @@ CREATE TABLE editor (
username TEXT NOT NULL UNIQUE, -- TODO: alphanum and length constraints?
is_admin BOOLEAN NOT NULL DEFAULT false,
is_bot BOOLEAN NOT NULL DEFAULT false,
+ is_active BOOLEAN NOT NULL DEFAULT true,
registered TIMESTAMP WITH TIME ZONE DEFAULT now() NOT NULL,
auth_epoch TIMESTAMP WITH TIME ZONE DEFAULT now() NOT NULL,
wrangler_id UUID REFERENCES editor(id),
@@ -28,6 +29,17 @@ CREATE TABLE editor (
CREATE INDEX active_editgroup_idx ON editor(active_editgroup_id);
CREATE INDEX editor_username_idx ON editor(username);
+CREATE TABLE auth_oidc (
+ id BIGSERIAL PRIMARY KEY,
+ created TIMESTAMP WITH TIME ZONE DEFAULT now() NOT NULL,
+ editor_id UUID REFERENCES editor(id) NOT NULL,
+ provider TEXT NOT NULL,
+ oidc_iss TEXT NOT NULL,
+ oidc_sub TEXT NOT NULL,
+ UNIQUE (editor_id, provider),
+ UNIQUE (oidc_iss, oidc_sub)
+);
+
CREATE TABLE editgroup (
id UUID PRIMARY KEY DEFAULT uuid_generate_v4(),
editor_id UUID REFERENCES editor(id) NOT NULL,