common.go 943 B

1234567891011121314151617181920212223242526
  1. package migrations
  2. import (
  3. "fmt"
  4. . "github.com/grafana/grafana/pkg/services/sqlstore/migrator"
  5. )
  6. func addDropAllIndicesMigrations(mg *Migrator, versionSuffix string, table Table) {
  7. for _, index := range table.Indices {
  8. migrationId := fmt.Sprintf("drop index %s - %s", index.XName(table.Name), versionSuffix)
  9. mg.AddMigration(migrationId, NewDropIndexMigration(table, index))
  10. }
  11. }
  12. func addTableIndicesMigrations(mg *Migrator, versionSuffix string, table Table) {
  13. for _, index := range table.Indices {
  14. migrationId := fmt.Sprintf("create index %s - %s", index.XName(table.Name), versionSuffix)
  15. mg.AddMigration(migrationId, NewAddIndexMigration(table, index))
  16. }
  17. }
  18. func addTableRenameMigration(mg *Migrator, oldName string, newName string, versionSuffix string) {
  19. migrationId := fmt.Sprintf("Rename table %s to %s - %s", oldName, newName, versionSuffix)
  20. mg.AddMigration(migrationId, NewRenameTableMigration(oldName, newName))
  21. }