Skip to content

Commit cc80ca3

Browse files
committed
Add latest migration changes
Signed-off-by: Edward Fitz Abucay <[email protected]>
1 parent b9c57b8 commit cc80ca3

4 files changed

+11
-8
lines changed

migrations/20221003041349_add_mfa_schema.up.sql

+8-5
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,22 @@
11
-- see: https://stackoverflow.com/questions/7624919/check-if-a-user-defined-type-already-exists-in-postgresql/48382296#48382296
2-
do $$ begin
2+
do $$
3+
begin
34
create type {{ index .Options "Namespace" }}.factor_type as enum('totp', 'webauthn');
45
create type {{ index .Options "Namespace" }}.factor_status as enum('unverified', 'verified');
56
create type {{ index .Options "Namespace" }}.aal_level as enum('aal1', 'aal2', 'aal3');
67
exception
7-
when duplicate_object then null;
8-
end $$;
8+
when duplicate_object then raise notice '%, skipping', sqlerrm using errcode = sqlstate;
9+
when others then null;
10+
end
11+
$$;
912

1013
-- auth.mfa_factors definition
1114
create table if not exists {{ index .Options "Namespace" }}.mfa_factors(
1215
id uuid not null,
1316
user_id uuid not null,
1417
friendly_name text null,
15-
factor_type factor_type not null,
16-
status factor_status not null,
18+
factor_type {{ index .Options "Namespace" }}.factor_type not null,
19+
status {{ index .Options "Namespace" }}.factor_status not null,
1720
created_at timestamptz not null,
1821
updated_at timestamptz not null,
1922
secret text null,
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
-- add factor_id to sessions
22
alter table {{ index .Options "Namespace" }}.sessions add column if not exists factor_id uuid null;
3-
alter table {{ index .Options "Namespace" }}.sessions add column if not exists aal aal_level null;
3+
alter table {{ index .Options "Namespace" }}.sessions add column if not exists aal {{ index .Options "Namespace" }}.aal_level null;

migrations/20230322519590_add_flow_state_table.up.sql

+1-1
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ create table if not exists {{ index .Options "Namespace" }}.flow_state(
88
id uuid primary key,
99
user_id uuid null,
1010
auth_code text not null,
11-
code_challenge_method code_challenge_method not null,
11+
code_challenge_method {{ index .Options "Namespace" }}.code_challenge_method not null,
1212
code_challenge text not null,
1313
provider_type text not null,
1414
provider_access_token text null,

migrations/20240427152123_add_one_time_tokens_table.up.sql

+1-1
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ do $$ begin
1616
create table if not exists {{ index .Options "Namespace" }}.one_time_tokens (
1717
id uuid primary key,
1818
user_id uuid not null references {{ index .Options "Namespace" }}.users on delete cascade,
19-
token_type one_time_token_type not null,
19+
token_type {{ index .Options "Namespace" }}.one_time_token_type not null,
2020
token_hash text not null,
2121
relates_to text not null,
2222
created_at timestamp without time zone not null default now(),

0 commit comments

Comments
 (0)