Skip to content

Database governance built for humans and agents — controlling changes and access across every major database.

chore: add vcs to idp dml (#4728)

boojack7e3a053ee3ed
diff --git a/backend/store/migration/prod/1.12/0007##vcs_to_idp.sql b/backend/store/migration/prod/1.12/0007##vcs_to_idp.sql
new file mode 100644
index 0000000000..2c1f718b68
--- /dev/null
+++ b/backend/store/migration/prod/1.12/0007##vcs_to_idp.sql
@@ -0,0 +1,25 @@
+INSERT INTO idp (resource_id, name, domain, type, config)
+SELECT
+ CONCAT(
+ 'idp-',
+ LEFT(uuid_in(md5(random()::text || random()::text)::cstring)::TEXT, 8)
+ ) AS resource_id,
+ name AS name,
+ TRIM(
+ LEADING 'http://' FROM
+ TRIM(
+ LEADING 'https://' FROM instance_url
+ )
+ ) AS domain,
+ 'OAUTH2' AS type,
+ jsonb_build_object(
+ 'authUrl', instance_url || '/oauth/authorize',
+ 'tokenUrl', instance_url || '/oauth/token',
+ 'userInfoUrl', instance_url || '/api/v4/user',
+ 'clientId', application_id,
+ 'clientSecret', secret,
+ 'scopes', jsonb_build_array('api'),
+ 'fieldMapping', '{"email": "email", "identifier": "email", "displayName": "name"}'::jsonb
+ ) AS config
+FROM vcs
+WHERE type = 'GITLAB_SELF_HOST';
\ No newline at end of file
diff --git a/backend/store/pg_engine_test.go b/backend/store/pg_engine_test.go
index 999dbad264..b4d6891068 100644
--- a/backend/store/pg_engine_test.go
+++ b/backend/store/pg_engine_test.go
@@ -220,5 +220,5 @@ func TestMigrationCompatibility(t *testing.T) {
func TestGetCutoffVersion(t *testing.T) {
releaseVersion, err := getProdCutoffVersion()
require.NoError(t, err)
- require.Equal(t, semver.MustParse("1.12.6"), releaseVersion)
+ require.Equal(t, semver.MustParse("1.12.7"), releaseVersion)
}