Skip to content

Add migrations to rollback the bad v0082 and v0083 migrations #326

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
May 8, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -450,4 +450,28 @@ var MigrationsToPerform = PolicyServerMigrations{
Id: "85",
Up: migration_v0085,
},
PolicyServerMigration{
Id: "86",
Up: migration_v0086,
},
PolicyServerMigration{
Id: "87",
Up: migration_v0087,
},
PolicyServerMigration{
Id: "88",
Up: migration_v0088,
},
PolicyServerMigration{
Id: "89",
Up: migration_v0089,
},
PolicyServerMigration{
Id: "90",
Up: migration_v0090,
},
PolicyServerMigration{
Id: "91",
Up: migration_v0091,
},
}
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
package migrations

var migration_v0082 = map[string][]string{
"mysql": {
`CREATE INDEX staging_spaces_idx ON security_groups ((CAST(staging_spaces -> '$[*]' AS CHAR(36) ARRAY)))`,
},
"mysql": {},
// This ran into issues with index limits when ASGs are bound to > 148 spaces. Rolling it back.
// `CREATE INDEX staging_spaces_idx ON security_groups ((CAST(staging_spaces -> '$[*]' AS CHAR(36) ARRAY)))`,
"postgres": {},
}
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
package migrations

var migration_v0083 = map[string][]string{
"mysql": {
`CREATE INDEX running_spaces_idx ON security_groups ((CAST(running_spaces -> '$[*]' AS CHAR(36) ARRAY)))`,
},
"mysql": {},
// This ran into issues with index limits when ASGs are bound to > 148 spaces. Rolling it back.
// `CREATE INDEX running_spaces_idx ON security_groups ((CAST(running_spaces -> '$[*]' AS CHAR(36) ARRAY)))`,
"postgres": {},
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
package migrations

var migration_v0086 = map[string][]string{
"mysql": {
`CREATE PROCEDURE drop_running_spaces_index()
BEGIN
SET @exist := (select count(*) from information_schema.statistics where table_name = 'security_groups' and index_name = 'running_spaces_idx' and table_schema = database());
SET @sqlstmt := if( @exist <=> 0, 'select ''INFO: Index does not exist''', 'alter table security_groups drop index running_spaces_idx');
PREPARE stmt FROM @sqlstmt;
EXECUTE stmt;

DEALLOCATE PREPARE stmt;
END;`,
},
"postgres": {},
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
package migrations

var migration_v0087 = map[string][]string{
"mysql": {
`CREATE PROCEDURE drop_staging_spaces_index()
BEGIN
SET @exist := (select count(*) from information_schema.statistics where table_name = 'security_groups' and index_name = 'staging_spaces_idx' and table_schema = database());
SET @sqlstmt := if( @exist <=> 0, 'select ''INFO: Index does not exist''', 'alter table security_groups drop index staging_spaces_idx');
PREPARE stmt FROM @sqlstmt;
EXECUTE stmt;

DEALLOCATE PREPARE stmt;
END;`,
},
"postgres": {},
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
package migrations

var migration_v0088 = map[string][]string{
"mysql": {
`CALL drop_running_spaces_index();`,
},
"postgres": {},
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
package migrations

var migration_v0089 = map[string][]string{
"mysql": {
`CALL drop_staging_spaces_index();`,
},
"postgres": {},
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
package migrations

var migration_v0090 = map[string][]string{
"mysql": {
`DROP PROCEDURE drop_running_spaces_index;`,
},
"postgres": {},
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
package migrations

var migration_v0091 = map[string][]string{
"mysql": {
`DROP PROCEDURE drop_staging_spaces_index;`,
},
"postgres": {},
}