Skip to content

Commit

Permalink
[Backport 5.5.x] release/bug: generate a new stitched migration graph (
Browse files Browse the repository at this point in the history
…#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 <[email protected]>
  • Loading branch information
sourcegraph-release-bot and DaedalusG committed Jul 10, 2024
1 parent 344169f commit 8ee4149
Show file tree
Hide file tree
Showing 3 changed files with 115 additions and 2 deletions.
2 changes: 1 addition & 1 deletion WORKSPACE
Original file line number Diff line number Diff line change
Expand Up @@ -501,7 +501,7 @@ load("//dev:schema_migrations.bzl", "schema_migrations")

schema_migrations(
name = "schemas_migrations",
updated_at = "2024-07-10 22:05",
updated_at = "2024-07-10 23:24",
)

# wolfi images setup ================================
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import (
// NOTE: This should be kept up-to-date with the upcoming version to be released, and bumped after.
// fallback schemas everything we support migrating to. The release tool automates this upgrade, so don't touch this :)
// This should be the last minor version since patch releases only happen in the release branch.
const maxVersionString = "5.4.0"
const maxVersionString = "5.5.0"

// MaxVersion is the highest known released version at the time the migrator was built.
var MaxVersion = func() oobmigration.Version {
Expand Down
113 changes: 113 additions & 0 deletions internal/database/migration/shared/data/stitched-migration-graph.json
Original file line number Diff line number Diff line change
Expand Up @@ -692,6 +692,19 @@
],
"IsCreateIndexConcurrently": false,
"IndexMetadata": null
},
{
"ID": 1719914228,
"Name": "insight_series_modify_query",
"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.';",
"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$$;",
"Privileged": false,
"NonIdempotent": false,
"Parents": [
1679051112
],
"IsCreateIndexConcurrently": false,
"IndexMetadata": null
}
],
"BoundsByRev": {
Expand Down Expand Up @@ -933,6 +946,13 @@
1679051112
],
"PreCreation": false
},
"v5.5.0": {
"RootID": 1000000027,
"LeafIDs": [
1719914228
],
"PreCreation": false
}
}
},
Expand Down Expand Up @@ -1909,6 +1929,13 @@
1686315964
],
"PreCreation": false
},
"v5.5.0": {
"RootID": 1000000033,
"LeafIDs": [
1686315964
],
"PreCreation": false
}
}
},
Expand Down Expand Up @@ -11221,6 +11248,85 @@
],
"IsCreateIndexConcurrently": false,
"IndexMetadata": null
},
{
"ID": 1717699555,
"Name": "Fix unique index for SCIM external account connection",
"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;",
"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;",
"Privileged": false,
"NonIdempotent": false,
"Parents": [
1713958707
],
"IsCreateIndexConcurrently": false,
"IndexMetadata": null
},
{
"ID": 1719214941,
"Name": "notebooks_add_field_pattern_type",
"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';",
"DownQuery": "ALTER TABLE notebooks DROP COLUMN IF EXISTS pattern_type;\nDROP TYPE IF EXISTS pattern_type;",
"Privileged": false,
"NonIdempotent": false,
"Parents": [
1717699555
],
"IsCreateIndexConcurrently": false,
"IndexMetadata": null
},
{
"ID": 1719498032,
"Name": "add_github_app_batch_changes_site_credential",
"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'));",
"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;",
"Privileged": false,
"NonIdempotent": false,
"Parents": [
1717699555
],
"IsCreateIndexConcurrently": false,
"IndexMetadata": null
},
{
"ID": 1719498091,
"Name": "add_github_app_id_user_credentials",
"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'));",
"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;",
"Privileged": false,
"NonIdempotent": false,
"Parents": [
1719498032
],
"IsCreateIndexConcurrently": false,
"IndexMetadata": null
},
{
"ID": 1719498128,
"Name": "add_kind_column_github_app",
"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;",
"DownQuery": "ALTER TABLE IF EXISTS github_apps DROP COLUMN IF EXISTS kind;\n\nDROP TYPE IF EXISTS github_app_kind;",
"Privileged": false,
"NonIdempotent": false,
"Parents": [
1719498091
],
"IsCreateIndexConcurrently": false,
"IndexMetadata": null
},
{
"ID": 1720165387,
"Name": "notebooks default to keyword search",
"UpQuery": "ALTER TABLE IF EXISTS notebooks ALTER COLUMN pattern_type SET DEFAULT 'keyword';",
"DownQuery": "ALTER TABLE IF EXISTS notebooks ALTER COLUMN pattern_type SET DEFAULT 'standard';",
"Privileged": false,
"NonIdempotent": false,
"Parents": [
1719214941,
1719498128
],
"IsCreateIndexConcurrently": false,
"IndexMetadata": null
}
],
"BoundsByRev": {
Expand Down Expand Up @@ -11484,6 +11590,13 @@
1713958707
],
"PreCreation": false
},
"v5.5.0": {
"RootID": 1648051770,
"LeafIDs": [
1720165387
],
"PreCreation": false
}
}
}
Expand Down

0 comments on commit 8ee4149

Please sign in to comment.