From eb92f823c31a5e702af7005231f0d6915aad3342 Mon Sep 17 00:00:00 2001
From: benj <benj@rse8.com>
Date: Mon, 24 Apr 2023 13:24:45 -0700
Subject: email templates, sendgrid, creds, and some experimental things

Started playing with namespace configs and integrating with zanzibar impls. Still lot's of experimenting and dead code going on.
---
 .../pg/migrations/20221222002434_bootstrap.sql     | 28 ++++++++++++++++++++--
 1 file changed, 26 insertions(+), 2 deletions(-)

(limited to 'crates/secd/store/pg/migrations/20221222002434_bootstrap.sql')

diff --git a/crates/secd/store/pg/migrations/20221222002434_bootstrap.sql b/crates/secd/store/pg/migrations/20221222002434_bootstrap.sql
index 2b89957..0cf3fa0 100644
--- a/crates/secd/store/pg/migrations/20221222002434_bootstrap.sql
+++ b/crates/secd/store/pg/migrations/20221222002434_bootstrap.sql
@@ -19,7 +19,7 @@ create table if not exists secd.realm_data (
 create table if not exists secd.identity (
        identity_id bigserial primary key
        , identity_public_id uuid not null
-       , data jsonb -- some things are dervied, others are not
+       , data text -- we do not prescribe JSON or any other serialization format.
        , created_at timestamptz not null
        , updated_at timestamptz not null
        , deleted_at timestamptz
@@ -30,14 +30,18 @@ create table if not exists secd.credential (
        credential_id bigserial primary key
        , credential_public_id uuid not null
        , identity_id bigint not null references secd.identity(identity_id)
+       , partial_key text
        , type text not null-- e.g. password, oidc, totop, lookup_secret, webauthn, ...
        , data jsonb not null
-       , version integer not null
        , created_at timestamptz not null
        , revoked_at timestamptz
        , deleted_at timestamptz
 );
 
+create unique index if not exists credential_passphrase_type_key_ix
+on secd.credential (partial_key)
+where type = 'Passphrase';
+
 create table if not exists secd.address (
        address_id bigserial primary key
        , address_public_id uuid not null
@@ -83,3 +87,23 @@ create table if not exists secd.message (
        , created_at timestamptz not null
        , sent_at timestamptz
 );
+
+create table if not exists secd.namespace_config (
+       namespace text not null
+       , serialized_config text not null
+       , created_at xid8 not null
+       , deleted_at xid8
+       -- TODO: indexes and stuff
+);
+
+create table if not exists secd.relation_tuple (
+       namespace text not null
+       , object_id text not null
+       , relation text not null
+       , userset_namespace text not null
+       , userset_object_id text not null
+       , userset_relation text not null
+       , created_at xid8 not null
+       , deleted_at xid8 not null
+       -- TODO: indexes and stuff
+);
-- 
cgit v1.2.3

