Skip to content

Commit 5cb16d5

Browse files
committed
fix: add migration annotation
1 parent 4d97736 commit 5cb16d5

File tree

2 files changed

+7
-34
lines changed

2 files changed

+7
-34
lines changed

internal/models/custom_oauth_provider.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -396,6 +396,8 @@ func CreateCustomOAuthProvider(tx *storage.Connection, provider *CustomOAuthProv
396396

397397
// UpdateCustomOAuthProvider updates an existing custom OAuth provider
398398
func UpdateCustomOAuthProvider(tx *storage.Connection, provider *CustomOAuthProvider) error {
399+
// Set updated_at timestamp explicitly in application code
400+
provider.UpdatedAt = time.Now()
399401
if err := tx.Update(provider); err != nil {
400402
return errors.Wrap(err, "error updating custom OAuth provider")
401403
}

migrations/20260128120000_add_custom_oauth_providers.up.sql

Lines changed: 5 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
-- Create unified custom OAuth/OIDC providers table
22
-- This table stores both OAuth2 and OIDC providers with type discrimination
33

4+
/* auth_migration: 20260128120000 */
45
create table if not exists {{ index .Options "Namespace" }}.custom_oauth_providers (
56
id uuid not null default gen_random_uuid(),
67

@@ -96,50 +97,20 @@ create table if not exists {{ index .Options "Namespace" }}.custom_oauth_provide
9697
constraint custom_oauth_providers_client_secret_length check (
9798
char_length(client_secret) >= 1 and char_length(client_secret) <= 1024
9899
),
99-
100-
-- Reserved provider names check
101-
constraint custom_oauth_providers_identifier_not_reserved check (
102-
identifier not in (
103-
'google', 'github', 'apple', 'facebook', 'azure', 'twitter', 'gitlab',
104-
'bitbucket', 'discord', 'twitch', 'slack', 'spotify', 'linkedin',
105-
'notion', 'kakao', 'zoom', 'figma', 'fly', 'snapchat', 'keycloak',
106-
'workos', 'linkedin-oidc', 'slack-oidc', 'vercel-marketplace', 'x'
107-
)
108-
)
109100
);
110101

111-
-- Create indexes for efficient queries
102+
/* auth_migration: 20260128120000 */
112103
create index if not exists custom_oauth_providers_identifier_idx
113104
on {{ index .Options "Namespace" }}.custom_oauth_providers (identifier);
114105

106+
/* auth_migration: 20260128120000 */
115107
create index if not exists custom_oauth_providers_provider_type_idx
116108
on {{ index .Options "Namespace" }}.custom_oauth_providers (provider_type);
117109

118-
-- Create unique partial index for OIDC issuer (acts as unique constraint with WHERE clause)
119-
create unique index if not exists custom_oauth_providers_oidc_issuer_key
120-
on {{ index .Options "Namespace" }}.custom_oauth_providers (issuer)
121-
where provider_type = 'oidc' and issuer is not null;
122-
110+
/* auth_migration: 20260128120000 */
123111
create index if not exists custom_oauth_providers_enabled_idx
124112
on {{ index .Options "Namespace" }}.custom_oauth_providers (enabled);
125113

114+
/* auth_migration: 20260128120000 */
126115
create index if not exists custom_oauth_providers_created_at_idx
127116
on {{ index .Options "Namespace" }}.custom_oauth_providers (created_at);
128-
129-
create index if not exists custom_oauth_providers_discovery_cached_at_idx
130-
on {{ index .Options "Namespace" }}.custom_oauth_providers (discovery_cached_at)
131-
where provider_type = 'oidc';
132-
133-
-- Add trigger to update updated_at timestamp
134-
create or replace function {{ index .Options "Namespace" }}.update_custom_oauth_providers_updated_at()
135-
returns trigger as $$
136-
begin
137-
new.updated_at = now();
138-
return new;
139-
end;
140-
$$ language plpgsql;
141-
142-
create trigger update_custom_oauth_providers_updated_at
143-
before update on {{ index .Options "Namespace" }}.custom_oauth_providers
144-
for each row
145-
execute function {{ index .Options "Namespace" }}.update_custom_oauth_providers_updated_at();

0 commit comments

Comments
 (0)