Skip to content

Commit 4e5c390

Browse files
authored
refactor: use template schema in SAML migration (#772)
Uses the `{{ index .Options "Namespace" }}` template string instead of `auth` as a schema in the SAML migration.
1 parent 0fffe5e commit 4e5c390

File tree

1 file changed

+24
-24
lines changed

1 file changed

+24
-24
lines changed
Lines changed: 24 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
-- Multi-instance mode (see auth.instances) table intentionally not supported and ignored.
22

3-
create table if not exists auth.sso_providers (
3+
create table if not exists {{ index .Options "Namespace" }}.sso_providers (
44
id uuid not null,
55
resource_id text null,
66
created_at timestamptz null,
@@ -9,28 +9,28 @@ create table if not exists auth.sso_providers (
99
constraint "resource_id not empty" check (resource_id = null or char_length(resource_id) > 0)
1010
);
1111

12-
comment on table auth.sso_providers is 'Auth: Manages SSO identity provider information; see saml_providers for SAML.';
13-
comment on column auth.sso_providers.resource_id is 'Auth: Uniquely identifies a SSO provider according to a user-chosen resource ID (case insensitive), useful in infrastructure as code.';
12+
comment on table {{ index .Options "Namespace" }}.sso_providers is 'Auth: Manages SSO identity provider information; see saml_providers for SAML.';
13+
comment on column {{ index .Options "Namespace" }}.sso_providers.resource_id is 'Auth: Uniquely identifies a SSO provider according to a user-chosen resource ID (case insensitive), useful in infrastructure as code.';
1414

15-
create unique index if not exists sso_providers_resource_id_idx on auth.sso_providers (lower(resource_id));
15+
create unique index if not exists sso_providers_resource_id_idx on {{ index .Options "Namespace" }}.sso_providers (lower(resource_id));
1616

17-
create table if not exists auth.sso_domains (
17+
create table if not exists {{ index .Options "Namespace" }}.sso_domains (
1818
id uuid not null,
1919
sso_provider_id uuid not null,
2020
domain text not null,
2121
created_at timestamptz null,
2222
updated_at timestamptz null,
2323
primary key (id),
24-
foreign key (sso_provider_id) references auth.sso_providers (id) on delete cascade,
24+
foreign key (sso_provider_id) references {{ index .Options "Namespace" }}.sso_providers (id) on delete cascade,
2525
constraint "domain not empty" check (char_length(domain) > 0)
2626
);
2727

28-
create index if not exists sso_domains_sso_provider_id_idx on auth.sso_domains (sso_provider_id);
29-
create unique index if not exists sso_domains_domain_idx on auth.sso_domains (lower(domain));
28+
create index if not exists sso_domains_sso_provider_id_idx on {{ index .Options "Namespace" }}.sso_domains (sso_provider_id);
29+
create unique index if not exists sso_domains_domain_idx on {{ index .Options "Namespace" }}.sso_domains (lower(domain));
3030

31-
comment on table auth.sso_domains is 'Auth: Manages SSO email address domain mapping to an SSO Identity Provider.';
31+
comment on table {{ index .Options "Namespace" }}.sso_domains is 'Auth: Manages SSO email address domain mapping to an SSO Identity Provider.';
3232

33-
create table if not exists auth.saml_providers (
33+
create table if not exists {{ index .Options "Namespace" }}.saml_providers (
3434
id uuid not null,
3535
sso_provider_id uuid not null,
3636
entity_id text not null unique,
@@ -40,17 +40,17 @@ create table if not exists auth.saml_providers (
4040
created_at timestamptz null,
4141
updated_at timestamptz null,
4242
primary key (id),
43-
foreign key (sso_provider_id) references auth.sso_providers (id) on delete cascade,
43+
foreign key (sso_provider_id) references {{ index .Options "Namespace" }}.sso_providers (id) on delete cascade,
4444
constraint "metadata_xml not empty" check (char_length(metadata_xml) > 0),
4545
constraint "metadata_url not empty" check (metadata_url = null or char_length(metadata_url) > 0),
4646
constraint "entity_id not empty" check (char_length(entity_id) > 0)
4747
);
4848

49-
create index if not exists saml_providers_sso_provider_id_idx on auth.saml_providers (sso_provider_id);
49+
create index if not exists saml_providers_sso_provider_id_idx on {{ index .Options "Namespace" }}.saml_providers (sso_provider_id);
5050

51-
comment on table auth.saml_providers is 'Auth: Manages SAML Identity Provider connections.';
51+
comment on table {{ index .Options "Namespace" }}.saml_providers is 'Auth: Manages SAML Identity Provider connections.';
5252

53-
create table if not exists auth.saml_relay_states (
53+
create table if not exists {{ index .Options "Namespace" }}.saml_relay_states (
5454
id uuid not null,
5555
sso_provider_id uuid not null,
5656
request_id text not null,
@@ -60,16 +60,16 @@ create table if not exists auth.saml_relay_states (
6060
created_at timestamptz null,
6161
updated_at timestamptz null,
6262
primary key (id),
63-
foreign key (sso_provider_id) references auth.sso_providers (id) on delete cascade,
63+
foreign key (sso_provider_id) references {{ index .Options "Namespace" }}.sso_providers (id) on delete cascade,
6464
constraint "request_id not empty" check(char_length(request_id) > 0)
6565
);
6666

67-
create index if not exists saml_relay_states_sso_provider_id_idx on auth.saml_relay_states (sso_provider_id);
68-
create index if not exists saml_relay_states_for_email_idx on auth.saml_relay_states (for_email);
67+
create index if not exists saml_relay_states_sso_provider_id_idx on {{ index .Options "Namespace" }}.saml_relay_states (sso_provider_id);
68+
create index if not exists saml_relay_states_for_email_idx on {{ index .Options "Namespace" }}.saml_relay_states (for_email);
6969

70-
comment on table auth.saml_relay_states is 'Auth: Contains SAML Relay State information for each Service Provider initiated login.';
70+
comment on table {{ index .Options "Namespace" }}.saml_relay_states is 'Auth: Contains SAML Relay State information for each Service Provider initiated login.';
7171

72-
create table if not exists auth.sso_sessions (
72+
create table if not exists {{ index .Options "Namespace" }}.sso_sessions (
7373
id uuid not null,
7474
session_id uuid not null,
7575
sso_provider_id uuid null,
@@ -79,12 +79,12 @@ create table if not exists auth.sso_sessions (
7979
created_at timestamptz null,
8080
updated_at timestamptz null,
8181
primary key (id),
82-
foreign key (session_id) references auth.sessions (id) on delete cascade,
83-
foreign key (sso_provider_id) references auth.sso_providers (id) on delete cascade
82+
foreign key (session_id) references {{ index .Options "Namespace" }}.sessions (id) on delete cascade,
83+
foreign key (sso_provider_id) references {{ index .Options "Namespace" }}.sso_providers (id) on delete cascade
8484
);
8585

86-
create index if not exists sso_sessions_session_id_idx on auth.sso_sessions (session_id);
87-
create index if not exists sso_sessions_sso_provider_id_idx on auth.sso_sessions (sso_provider_id);
86+
create index if not exists sso_sessions_session_id_idx on {{ index .Options "Namespace" }}.sso_sessions (session_id);
87+
create index if not exists sso_sessions_sso_provider_id_idx on {{ index .Options "Namespace" }}.sso_sessions (sso_provider_id);
8888

89-
comment on table auth.sso_sessions is 'Auth: A session initiated by an SSO Identity Provider';
89+
comment on table {{ index .Options "Namespace" }}.sso_sessions is 'Auth: A session initiated by an SSO Identity Provider';
9090

0 commit comments

Comments
 (0)