From f15aa2d30dabbe28a23993b9b050e80575e9d80d Mon Sep 17 00:00:00 2001 From: Leonard Gram Date: Tue, 12 Mar 2024 15:44:10 +0100 Subject: [PATCH] CloudMigrations: draft of cloud migration tables (#83990) * CloudMigrations: draft of cloud migration tables * naming migration rules * removes feature flag for migration * tweaked db types * removed comment --- .../sqlstore/migrations/cloud_migrations.go | 32 +++++++++++++++++++ .../sqlstore/migrations/migrations.go | 2 ++ 2 files changed, 34 insertions(+) create mode 100644 pkg/services/sqlstore/migrations/cloud_migrations.go diff --git a/pkg/services/sqlstore/migrations/cloud_migrations.go b/pkg/services/sqlstore/migrations/cloud_migrations.go new file mode 100644 index 00000000000..bcdb8f36dc3 --- /dev/null +++ b/pkg/services/sqlstore/migrations/cloud_migrations.go @@ -0,0 +1,32 @@ +package migrations + +import ( + . "github.com/grafana/grafana/pkg/services/sqlstore/migrator" +) + +func addCloudMigrationsMigrations(mg *Migrator) { + migrationTable := Table{ + Name: "cloud_migration", + Columns: []*Column{ + {Name: "id", Type: DB_BigInt, IsPrimaryKey: true, IsAutoIncrement: true}, + {Name: "auth_token", Type: DB_Text, Nullable: true}, // encrypted + {Name: "stack", Type: DB_Text}, + {Name: "created", Type: DB_DateTime, Nullable: false}, + {Name: "updated", Type: DB_DateTime, Nullable: false}, + }, + } + migrationRunTable := Table{ + Name: "cloud_migration_run", + Columns: []*Column{ + {Name: "id", Type: DB_BigInt, IsPrimaryKey: true, IsAutoIncrement: true}, + {Name: "cloud_migration_uid", Type: DB_NVarchar, Length: 40, Nullable: true}, // get from the cloud service + {Name: "result", Type: DB_Text, Nullable: false}, + {Name: "created", Type: DB_DateTime, Nullable: false}, + {Name: "updated", Type: DB_DateTime, Nullable: false}, + {Name: "finished", Type: DB_DateTime, Nullable: true}, + }, + } + + mg.AddMigration("create cloud_migration table v1", NewAddTableMigration(migrationTable)) + mg.AddMigration("create cloud_migration_run table v1", NewAddTableMigration(migrationRunTable)) +} diff --git a/pkg/services/sqlstore/migrations/migrations.go b/pkg/services/sqlstore/migrations/migrations.go index 6cbb2f1b694..a9e1de52193 100644 --- a/pkg/services/sqlstore/migrations/migrations.go +++ b/pkg/services/sqlstore/migrations/migrations.go @@ -112,6 +112,8 @@ func (oss *OSSMigrations) AddMigration(mg *Migrator) { accesscontrol.AddManagedDashboardAnnotationActionsMigration(mg) } + addCloudMigrationsMigrations(mg) + addKVStoreMySQLValueTypeLongTextMigration(mg) ualert.AddRuleNotificationSettingsColumns(mg)