Files
grafana/pkg/services/sqlstore/migrations/migrations.go
T

71 lines
2.1 KiB
Go
Raw Normal View History

package migrations
import . "github.com/grafana/grafana/pkg/services/sqlstore/migrator"
// --- Migration Guide line ---
// 1. Never change a migration that is committed and pushed to master
// 2. Always add new migrations (to change or undo previous migrations)
2017-02-03 12:10:22 +01:00
// 3. Some migrations are not yet written (rename column, table, drop table, index etc)
func AddMigrations(mg *Migrator) {
addMigrationLogMigrations(mg)
addUserMigrations(mg)
addTempUserMigrations(mg)
addStarMigrations(mg)
addOrgMigrations(mg)
addDashboardMigration(mg)
addDataSourceMigration(mg)
addApiKeyMigrations(mg)
2015-03-21 08:53:16 -04:00
addDashboardSnapshotMigrations(mg)
addQuotaMigration(mg)
addAppSettingsMigration(mg)
addSessionMigration(mg)
2015-12-24 02:25:49 -08:00
addPlaylistMigrations(mg)
2016-03-04 01:29:46 -08:00
addPreferencesMigrations(mg)
addAlertMigrations(mg)
addAnnotationMig(mg)
2017-03-30 18:03:50 +02:00
addTestDataMigrations(mg)
addDashboardVersionMigration(mg)
2017-12-08 18:25:45 +03:00
addTeamMigrations(mg)
addDashboardAclMigrations(mg)
2017-10-07 10:31:39 +02:00
addTagMigration(mg)
addLoginAttemptMigrations(mg)
addUserAuthMigrations(mg)
2018-12-13 09:52:13 +01:00
addServerlockMigrations(mg)
2019-01-15 15:15:17 +01:00
addUserAuthTokenMigrations(mg)
2019-02-14 23:13:46 +01:00
addCacheMigration(mg)
}
func addMigrationLogMigrations(mg *Migrator) {
migrationLogV1 := Table{
Name: "migration_log",
Columns: []*Column{
2015-03-07 16:23:22 +01:00
{Name: "id", Type: DB_BigInt, IsPrimaryKey: true, IsAutoIncrement: true},
{Name: "migration_id", Type: DB_NVarchar, Length: 255},
{Name: "sql", Type: DB_Text},
{Name: "success", Type: DB_Bool},
{Name: "error", Type: DB_Text},
{Name: "timestamp", Type: DB_DateTime},
},
}
mg.AddMigration("create migration_log table", NewAddTableMigration(migrationLogV1))
}
func addStarMigrations(mg *Migrator) {
starV1 := Table{
Name: "star",
Columns: []*Column{
2015-03-07 16:23:22 +01:00
{Name: "id", Type: DB_BigInt, IsPrimaryKey: true, IsAutoIncrement: true},
{Name: "user_id", Type: DB_BigInt, Nullable: false},
{Name: "dashboard_id", Type: DB_BigInt, Nullable: false},
},
Indices: []*Index{
2015-03-07 16:23:22 +01:00
{Cols: []string{"user_id", "dashboard_id"}, Type: UniqueIndex},
},
}
mg.AddMigration("create star table", NewAddTableMigration(starV1))
mg.AddMigration("add unique index star.user_id_dashboard_id", NewAddIndexMigration(starV1, starV1.Indices[0]))
}