~willvaughn/grsroot-auth

ref: 695bfe02e3f9b2c5da83444dfc601d34bbcc3454 grsroot-auth/resources/migrations/20220211035117-grsroot-auth.up.sql -rw-r--r-- 1.0 KiB
695bfe02William Vaughn switch to kebab-case everywhere, auto-convert out of hugsql 4 months ago
                                                                                
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
create table app_user (
  app_user_id uuid primary key default gen_random_uuid(),
  email       character varying(320) unique not null,
  password    text not null,
  created_at  timestamp not null default now()
);
--;;
create table app (
  app_id   uuid primary key default gen_random_uuid(),
  app_slug character varying(60) unique not null
);
--;;
create table app_role (
  app_role_id uuid primary key default gen_random_uuid(),
  app_id      uuid not null references app(app_id),
  role_slug   character varying(60) not null,
  unique(app_id, role_slug)
);
--;;
create table app_user_role (
  app_user_role_id bigserial primary key,
  app_user_id      uuid not null references app_user(app_user_id),
  app_role_id      uuid not null references app_role(app_role_id),
  unique(app_user_id, app_role_id)
);
--;;
create table refresh_token (
  refresh_token_id bigserial primary key,
  app_user_id      uuid not null references app_user(app_user_id),
  issued_at        timestamp not null,
  token            text not null,
  is_valid         boolean not null
);