代码拉取完成,页面将自动刷新
package migrations
import (
"fmt"
. "github.com/grafana/grafana/pkg/services/sqlstore/migrator"
)
func addDropAllIndicesMigrations(mg *Migrator, versionSuffix string, table Table) {
for _, index := range table.Indices {
migrationId := fmt.Sprintf("drop index %s - %s", index.XName(table.Name), versionSuffix)
mg.AddMigration(migrationId, NewDropIndexMigration(table, index))
}
}
func addTableIndicesMigrations(mg *Migrator, versionSuffix string, table Table) {
for _, index := range table.Indices {
migrationId := fmt.Sprintf("create index %s - %s", index.XName(table.Name), versionSuffix)
mg.AddMigration(migrationId, NewAddIndexMigration(table, index))
}
}
func addTableRenameMigration(mg *Migrator, oldName string, newName string, versionSuffix string) {
migrationId := fmt.Sprintf("Rename table %s to %s - %s", oldName, newName, versionSuffix)
mg.AddMigration(migrationId, NewRenameTableMigration(oldName, newName))
}
func addTableReplaceMigrations(mg *Migrator, from Table, to Table, migrationVersion int64, tableDataMigration map[string]string) {
fromV := version(migrationVersion - 1)
toV := version(migrationVersion)
tmpTableName := to.Name + "_tmp_qwerty"
createTable := fmt.Sprintf("create %v %v", to.Name, toV)
copyTableData := fmt.Sprintf("copy %v %v to %v", to.Name, fromV, toV)
dropTable := fmt.Sprintf("drop %v", tmpTableName)
addDropAllIndicesMigrations(mg, fromV, from)
addTableRenameMigration(mg, from.Name, tmpTableName, fromV)
mg.AddMigration(createTable, NewAddTableMigration(to))
addTableIndicesMigrations(mg, toV, to)
mg.AddMigration(copyTableData, NewCopyTableDataMigration(to.Name, tmpTableName, tableDataMigration))
mg.AddMigration(dropTable, NewDropTableMigration(tmpTableName))
}
func version(v int64) string {
return fmt.Sprintf("v%v", v)
}
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。