Skip to content

Commit 5f2b660

Browse files
willnodeChris Stockton
authored andcommitted
fix: prefix schema to enum migration (#2040)
Add support for nonstandard search path migrations
1 parent 11fa653 commit 5f2b660

4 files changed

+10
-10
lines changed

migrations/20221003041349_add_mfa_schema.up.sql

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
-- see: https://stackoverflow.com/questions/7624919/check-if-a-user-defined-type-already-exists-in-postgresql/48382296#48382296
22
do $$ begin
3-
create type factor_type as enum('totp', 'webauthn');
4-
create type factor_status as enum('unverified', 'verified');
5-
create type aal_level as enum('aal1', 'aal2', 'aal3');
3+
create type {{ index .Options "Namespace" }}.factor_type as enum('totp', 'webauthn');
4+
create type {{ index .Options "Namespace" }}.factor_status as enum('unverified', 'verified');
5+
create type {{ index .Options "Namespace" }}.aal_level as enum('aal1', 'aal2', 'aal3');
66
exception
77
when duplicate_object then null;
88
end $$;
@@ -12,8 +12,8 @@ create table if not exists {{ index .Options "Namespace" }}.mfa_factors(
1212
id uuid not null,
1313
user_id uuid not null,
1414
friendly_name text null,
15-
factor_type factor_type not null,
16-
status factor_status not null,
15+
factor_type {{ index .Options "Namespace" }}.factor_type not null,
16+
status {{ index .Options "Namespace" }}.factor_status not null,
1717
created_at timestamptz not null,
1818
updated_at timestamptz not null,
1919
secret text null,
Lines changed: 1 addition & 1 deletion
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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
11
-- see: https://stackoverflow.com/questions/7624919/check-if-a-user-defined-type-already-exists-in-postgresql/48382296#48382296
22
do $$ begin
3-
create type code_challenge_method as enum('s256', 'plain');
3+
create type {{ index .Options "Namespace" }}.code_challenge_method as enum('s256', 'plain');
44
exception
55
when duplicate_object then null;
66
end $$;
77
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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
do $$ begin
2-
create type one_time_token_type as enum (
2+
create type {{ index .Options "Namespace" }}.one_time_token_type as enum (
33
'confirmation_token',
44
'reauthentication_token',
55
'recovery_token',
@@ -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)