Skip to content
This repository was archived by the owner on Sep 30, 2024. It is now read-only.

Commit 8ee4149

Browse files
[Backport 5.5.x] release/bug: generate a new stitched migration graph (#63769)
This will correct6 upgrade path for mvu plan creation ## Test plan CI test ## Changelog <br> Backport cb19d6f from #63764 Co-authored-by: Warren Gifford <warren@sourcegraph.com>
1 parent 344169f commit 8ee4149

File tree

3 files changed

+115
-2
lines changed

3 files changed

+115
-2
lines changed

WORKSPACE

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -501,7 +501,7 @@ load("//dev:schema_migrations.bzl", "schema_migrations")
501501

502502
schema_migrations(
503503
name = "schemas_migrations",
504-
updated_at = "2024-07-10 22:05",
504+
updated_at = "2024-07-10 23:24",
505505
)
506506

507507
# wolfi images setup ================================

internal/database/migration/shared/data/cmd/generator/consts.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ import (
1010
// NOTE: This should be kept up-to-date with the upcoming version to be released, and bumped after.
1111
// fallback schemas everything we support migrating to. The release tool automates this upgrade, so don't touch this :)
1212
// This should be the last minor version since patch releases only happen in the release branch.
13-
const maxVersionString = "5.4.0"
13+
const maxVersionString = "5.5.0"
1414

1515
// MaxVersion is the highest known released version at the time the migrator was built.
1616
var MaxVersion = func() oobmigration.Version {

internal/database/migration/shared/data/stitched-migration-graph.json

Lines changed: 113 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -692,6 +692,19 @@
692692
],
693693
"IsCreateIndexConcurrently": false,
694694
"IndexMetadata": null
695+
},
696+
{
697+
"ID": 1719914228,
698+
"Name": "insight_series_modify_query",
699+
"UpQuery": "ALTER TABLE insight_series ADD COLUMN IF NOT EXISTS query_old TEXT;\nUPDATE insight_series SET query_old = query;\n\n-- prefix query with patternType:standard if there is no patterntype: in the query\nUPDATE insight_series\nSET query = 'patterntype:standard ' || query\nWHERE query NOT ILIKE '%patterntype:%'\n -- exclude empty queries, which are created by language stats insights\n AND query != '';\n\nCOMMENT ON COLUMN insight_series.query_old IS 'Backup for migration. Remove with release 5.6 or later.';",
700+
"DownQuery": "DO\n$$\n BEGIN\n -- Check if column 'query_old' exists\n IF EXISTS (SELECT 1\n FROM information_schema.columns\n WHERE table_name = 'insight_series' AND column_name = 'query_old') THEN\n -- Update the 'query' column with values from 'query_old'\n UPDATE insight_series SET query = query_old;\n ALTER TABLE insight_series DROP COLUMN query_old;\n END IF;\n END\n$$;",
701+
"Privileged": false,
702+
"NonIdempotent": false,
703+
"Parents": [
704+
1679051112
705+
],
706+
"IsCreateIndexConcurrently": false,
707+
"IndexMetadata": null
695708
}
696709
],
697710
"BoundsByRev": {
@@ -933,6 +946,13 @@
933946
1679051112
934947
],
935948
"PreCreation": false
949+
},
950+
"v5.5.0": {
951+
"RootID": 1000000027,
952+
"LeafIDs": [
953+
1719914228
954+
],
955+
"PreCreation": false
936956
}
937957
}
938958
},
@@ -1909,6 +1929,13 @@
19091929
1686315964
19101930
],
19111931
"PreCreation": false
1932+
},
1933+
"v5.5.0": {
1934+
"RootID": 1000000033,
1935+
"LeafIDs": [
1936+
1686315964
1937+
],
1938+
"PreCreation": false
19121939
}
19131940
}
19141941
},
@@ -11221,6 +11248,85 @@
1122111248
],
1122211249
"IsCreateIndexConcurrently": false,
1122311250
"IndexMetadata": null
11251+
},
11252+
{
11253+
"ID": 1717699555,
11254+
"Name": "Fix unique index for SCIM external account connection",
11255+
"UpQuery": "DROP INDEX IF EXISTS user_external_accounts_user_id_scim_service_type;\n\nCREATE UNIQUE INDEX\n user_external_accounts_user_id_scim_service_type\nON\n user_external_accounts (user_id, service_type)\nWHERE\n service_type = 'scim'::text\n AND deleted_at IS NULL;",
11256+
"DownQuery": "DROP INDEX IF EXISTS user_external_accounts_user_id_scim_service_type;\n\nCREATE UNIQUE INDEX\n user_external_accounts_user_id_scim_service_type\nON\n user_external_accounts (user_id, service_type)\nWHERE\n service_type = 'scim'::text;",
11257+
"Privileged": false,
11258+
"NonIdempotent": false,
11259+
"Parents": [
11260+
1713958707
11261+
],
11262+
"IsCreateIndexConcurrently": false,
11263+
"IndexMetadata": null
11264+
},
11265+
{
11266+
"ID": 1719214941,
11267+
"Name": "notebooks_add_field_pattern_type",
11268+
"UpQuery": "DO $$\nBEGIN\n IF NOT EXISTS (SELECT 1 FROM pg_type WHERE typname = 'pattern_type') THEN\n CREATE TYPE pattern_type AS ENUM ('keyword', 'literal', 'regexp', 'standard', 'structural');\n END IF;\nEND\n$$;\n\nALTER TABLE notebooks ADD COLUMN IF NOT EXISTS pattern_type pattern_type NOT NULL DEFAULT 'standard';",
11269+
"DownQuery": "ALTER TABLE notebooks DROP COLUMN IF EXISTS pattern_type;\nDROP TYPE IF EXISTS pattern_type;",
11270+
"Privileged": false,
11271+
"NonIdempotent": false,
11272+
"Parents": [
11273+
1717699555
11274+
],
11275+
"IsCreateIndexConcurrently": false,
11276+
"IndexMetadata": null
11277+
},
11278+
{
11279+
"ID": 1719498032,
11280+
"Name": "add_github_app_batch_changes_site_credential",
11281+
"UpQuery": "ALTER TABLE IF EXISTS batch_changes_site_credentials\n ADD COLUMN IF NOT EXISTS github_app_id INT NULL REFERENCES github_apps(id) ON DELETE CASCADE;\n\nALTER TABLE batch_changes_site_credentials DROP CONSTRAINT IF EXISTS check_github_app_id_and_external_service_type_site_credentials;\n\n-- We want to make sure that we never have a site_credential with a `github_app_id` with an `external_service_type`\n-- that isn't `github`.\nALTER TABLE IF EXISTS batch_changes_site_credentials\n ADD CONSTRAINT check_github_app_id_and_external_service_type_site_credentials\n CHECK ((github_app_id IS NULL) OR (external_service_type = 'github'));",
11282+
"DownQuery": "-- delete the constraints\nALTER TABLE IF EXISTS batch_changes_site_credentials DROP CONSTRAINT IF EXISTS check_github_app_id_and_external_service_type_site_credentials;\n\n-- delete the `github_app_id` column\nALTER TABLE IF EXISTS batch_changes_site_credentials DROP COLUMN IF EXISTS github_app_id;",
11283+
"Privileged": false,
11284+
"NonIdempotent": false,
11285+
"Parents": [
11286+
1717699555
11287+
],
11288+
"IsCreateIndexConcurrently": false,
11289+
"IndexMetadata": null
11290+
},
11291+
{
11292+
"ID": 1719498091,
11293+
"Name": "add_github_app_id_user_credentials",
11294+
"UpQuery": "ALTER TABLE IF EXISTS user_credentials\n ADD COLUMN IF NOT EXISTS github_app_id INT NULL REFERENCES github_apps(id) ON DELETE CASCADE;\n\nALTER TABLE user_credentials DROP CONSTRAINT IF EXISTS check_github_app_id_and_external_service_type_user_credentials;\n\n-- We want to make sure that we never have a user_credential with a `github_app_id` with an `external_service_type`\n-- that isn't `github`.\nALTER TABLE IF EXISTS user_credentials\n ADD CONSTRAINT check_github_app_id_and_external_service_type_user_credentials\n CHECK ((github_app_id IS NULL) OR (external_service_type = 'github'));",
11295+
"DownQuery": "-- delete the constraints\nALTER TABLE IF EXISTS user_credentials DROP CONSTRAINT IF EXISTS check_github_app_id_and_external_service_type_user_credentials;\n\n-- delete the `github_app_id` column\nALTER TABLE IF EXISTS user_credentials DROP COLUMN IF EXISTS github_app_id;",
11296+
"Privileged": false,
11297+
"NonIdempotent": false,
11298+
"Parents": [
11299+
1719498032
11300+
],
11301+
"IsCreateIndexConcurrently": false,
11302+
"IndexMetadata": null
11303+
},
11304+
{
11305+
"ID": 1719498128,
11306+
"Name": "add_kind_column_github_app",
11307+
"UpQuery": "DO $$\nBEGIN\n IF NOT EXISTS (SELECT 1 FROM pg_type WHERE typname = 'github_app_kind') THEN\n CREATE TYPE github_app_kind AS ENUM (\n 'COMMIT_SIGNING',\n 'REPO_SYNC',\n 'USER_CREDENTIAL',\n 'SITE_CREDENTIAL'\n );\n END IF;\nEND\n$$;\n\nALTER TABLE IF EXISTS github_apps\n ADD COLUMN IF NOT EXISTS kind github_app_kind DEFAULT 'REPO_SYNC';\n\nUPDATE github_apps\nSET kind = 'COMMIT_SIGNING'\nWHERE domain = 'batches';\n\n-- This is expected to fail if any row is using an unknown value that is not repos or batches.\n-- We only allow repos or batches at this time.\nALTER TABLE IF EXISTS github_apps\nALTER COLUMN kind SET NOT NULL;",
11308+
"DownQuery": "ALTER TABLE IF EXISTS github_apps DROP COLUMN IF EXISTS kind;\n\nDROP TYPE IF EXISTS github_app_kind;",
11309+
"Privileged": false,
11310+
"NonIdempotent": false,
11311+
"Parents": [
11312+
1719498091
11313+
],
11314+
"IsCreateIndexConcurrently": false,
11315+
"IndexMetadata": null
11316+
},
11317+
{
11318+
"ID": 1720165387,
11319+
"Name": "notebooks default to keyword search",
11320+
"UpQuery": "ALTER TABLE IF EXISTS notebooks ALTER COLUMN pattern_type SET DEFAULT 'keyword';",
11321+
"DownQuery": "ALTER TABLE IF EXISTS notebooks ALTER COLUMN pattern_type SET DEFAULT 'standard';",
11322+
"Privileged": false,
11323+
"NonIdempotent": false,
11324+
"Parents": [
11325+
1719214941,
11326+
1719498128
11327+
],
11328+
"IsCreateIndexConcurrently": false,
11329+
"IndexMetadata": null
1122411330
}
1122511331
],
1122611332
"BoundsByRev": {
@@ -11484,6 +11590,13 @@
1148411590
1713958707
1148511591
],
1148611592
"PreCreation": false
11593+
},
11594+
"v5.5.0": {
11595+
"RootID": 1648051770,
11596+
"LeafIDs": [
11597+
1720165387
11598+
],
11599+
"PreCreation": false
1148711600
}
1148811601
}
1148911602
}

0 commit comments

Comments
 (0)