aboutsummaryrefslogtreecommitdiff
path: root/crates/secd/store/sqlite/migrations/20221125051738_bootstrap.sql
blob: aa95afce6f7b23982ce436c8367e0e4cfb077962 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
create table if not exists identity (
       identity_id integer primary key autoincrement
       , identity_public_id uuid
       , data text
       , created_at timestamp not null
       , unique(identity_public_id)
);

create table if not exists email (
       email_id integer primary key autoincrement
       , address text not null
       , unique(address)
);

create table if not exists identity_email (
       identity_email_id integer primary key autoincrement
       , identity_id integer not null references identity(identity_id)
       , email_id integer not null references email(email_id)
       , created_at timestamp not null
       , deleted_at timestamp
);

create table if not exists email_validation (
       email_validation_id integer primary key autoincrement
       , email_validation_public_id text not null -- uuid
       , identity_email_id integer not null references identity_email(identity_email_id)
       , attempts integer not null
       , code text
       , is_validated boolean not null
       , created_at timestamp not null
       , expires_at timestamp
       , revoked_at timestamp
       , unique(email_validation_public_id)
);

create table if not exists session (
       session_id integer primary key autoincrement
       , identity_id not null references identity(identity_id)
       , secret_hash blob not null
       , created_at timestamp not null
       , touched_at timestamp not null
       , expires_at timestamp
       , revoked_at timestamp
       , unique(secret_hash)
);