grafana/pkg/services/sqlstore/migrations/cache_data_mig.go

23 lines
836 B
Go
Raw Normal View History

2019-02-14 16:13:46 -06:00
package migrations
import "github.com/grafana/grafana/pkg/services/sqlstore/migrator"
2019-02-14 16:13:46 -06:00
func addCacheMigration(mg *migrator.Migrator) {
var cacheDataV1 = migrator.Table{
2019-02-14 16:13:46 -06:00
Name: "cache_data",
Columns: []*migrator.Column{
{Name: "cache_key", Type: migrator.DB_NVarchar, IsPrimaryKey: true, Length: 168},
{Name: "data", Type: migrator.DB_Blob},
{Name: "expires", Type: migrator.DB_Integer, Length: 255, Nullable: false},
{Name: "created_at", Type: migrator.DB_Integer, Length: 255, Nullable: false},
},
Indices: []*migrator.Index{
{Cols: []string{"cache_key"}, Type: migrator.UniqueIndex},
2019-02-14 16:13:46 -06:00
},
}
mg.AddMigration("create cache_data table", migrator.NewAddTableMigration(cacheDataV1))
mg.AddMigration("add unique index cache_data.cache_key", migrator.NewAddIndexMigration(cacheDataV1, cacheDataV1.Indices[0]))
2019-02-14 16:13:46 -06:00
}