Skip to content

Commit a7174e1

Browse files
geofffranksebroberson
authored andcommitted
Add migrations to rollback the bad v0082 and v0083 migrations
Signed-off-by: Maria Shaldybin <maria.shaldybin@broadcom.com>
1 parent 9a1f13b commit a7174e1

File tree

9 files changed

+94
-6
lines changed

9 files changed

+94
-6
lines changed

src/code.cloudfoundry.org/policy-server/store/migrations/migrations.go

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -450,4 +450,28 @@ var MigrationsToPerform = PolicyServerMigrations{
450450
Id: "85",
451451
Up: migration_v0085,
452452
},
453+
PolicyServerMigration{
454+
Id: "86",
455+
Up: migration_v0086,
456+
},
457+
PolicyServerMigration{
458+
Id: "87",
459+
Up: migration_v0087,
460+
},
461+
PolicyServerMigration{
462+
Id: "88",
463+
Up: migration_v0088,
464+
},
465+
PolicyServerMigration{
466+
Id: "89",
467+
Up: migration_v0089,
468+
},
469+
PolicyServerMigration{
470+
Id: "90",
471+
Up: migration_v0090,
472+
},
473+
PolicyServerMigration{
474+
Id: "91",
475+
Up: migration_v0091,
476+
},
453477
}
Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
package migrations
22

33
var migration_v0082 = map[string][]string{
4-
"mysql": {
5-
`CREATE INDEX staging_spaces_idx ON security_groups ((CAST(staging_spaces -> '$[*]' AS CHAR(36) ARRAY)))`,
6-
},
4+
"mysql": {},
5+
// This ran into issues with index limits when ASGs are bound to > 148 spaces. Rolling it back.
6+
// `CREATE INDEX staging_spaces_idx ON security_groups ((CAST(staging_spaces -> '$[*]' AS CHAR(36) ARRAY)))`,
77
"postgres": {},
88
}
Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
package migrations
22

33
var migration_v0083 = map[string][]string{
4-
"mysql": {
5-
`CREATE INDEX running_spaces_idx ON security_groups ((CAST(running_spaces -> '$[*]' AS CHAR(36) ARRAY)))`,
6-
},
4+
"mysql": {},
5+
// This ran into issues with index limits when ASGs are bound to > 148 spaces. Rolling it back.
6+
// `CREATE INDEX running_spaces_idx ON security_groups ((CAST(running_spaces -> '$[*]' AS CHAR(36) ARRAY)))`,
77
"postgres": {},
88
}
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
package migrations
2+
3+
var migration_v0086 = map[string][]string{
4+
"mysql": {
5+
`CREATE PROCEDURE drop_running_spaces_index()
6+
BEGIN
7+
SET @exist := (select count(*) from information_schema.statistics where table_name = 'security_groups' and index_name = 'running_spaces_idx' and table_schema = database());
8+
SET @sqlstmt := if( @exist <=> 0, 'select ''INFO: Index does not exist''', 'alter table security_groups drop index running_spaces_idx');
9+
PREPARE stmt FROM @sqlstmt;
10+
EXECUTE stmt;
11+
12+
DEALLOCATE PREPARE stmt;
13+
END;`,
14+
},
15+
"postgres": {},
16+
}
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
package migrations
2+
3+
var migration_v0087 = map[string][]string{
4+
"mysql": {
5+
`CREATE PROCEDURE drop_staging_spaces_index()
6+
BEGIN
7+
SET @exist := (select count(*) from information_schema.statistics where table_name = 'security_groups' and index_name = 'staging_spaces_idx' and table_schema = database());
8+
SET @sqlstmt := if( @exist <=> 0, 'select ''INFO: Index does not exist''', 'alter table security_groups drop index staging_spaces_idx');
9+
PREPARE stmt FROM @sqlstmt;
10+
EXECUTE stmt;
11+
12+
DEALLOCATE PREPARE stmt;
13+
END;`,
14+
},
15+
"postgres": {},
16+
}
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
package migrations
2+
3+
var migration_v0088 = map[string][]string{
4+
"mysql": {
5+
`CALL drop_running_spaces_index();`,
6+
},
7+
"postgres": {},
8+
}
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
package migrations
2+
3+
var migration_v0089 = map[string][]string{
4+
"mysql": {
5+
`CALL drop_staging_spaces_index();`,
6+
},
7+
"postgres": {},
8+
}
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
package migrations
2+
3+
var migration_v0090 = map[string][]string{
4+
"mysql": {
5+
`DROP PROCEDURE drop_running_spaces_index;`,
6+
},
7+
"postgres": {},
8+
}
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
package migrations
2+
3+
var migration_v0091 = map[string][]string{
4+
"mysql": {
5+
`DROP PROCEDURE drop_staging_spaces_index;`,
6+
},
7+
"postgres": {},
8+
}

0 commit comments

Comments
 (0)