playlist_mig.go 1.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. package migrations
  2. import . "github.com/grafana/grafana/pkg/services/sqlstore/migrator"
  3. func addPlaylistMigrations(mg *Migrator) {
  4. mg.AddMigration("Drop old table playlist table", NewDropTableMigration("playlist"))
  5. mg.AddMigration("Drop old table playlist_item table", NewDropTableMigration("playlist_item"))
  6. playlistV2 := Table{
  7. Name: "playlist",
  8. Columns: []*Column{
  9. {Name: "id", Type: DB_BigInt, IsPrimaryKey: true, IsAutoIncrement: true},
  10. {Name: "name", Type: DB_NVarchar, Length: 255, Nullable: false},
  11. {Name: "interval", Type: DB_NVarchar, Length: 255, Nullable: false},
  12. {Name: "org_id", Type: DB_BigInt, Nullable: false},
  13. },
  14. }
  15. // create table
  16. mg.AddMigration("create playlist table v2", NewAddTableMigration(playlistV2))
  17. playlistItemV2 := Table{
  18. Name: "playlist_item",
  19. Columns: []*Column{
  20. {Name: "id", Type: DB_BigInt, IsPrimaryKey: true, IsAutoIncrement: true},
  21. {Name: "playlist_id", Type: DB_BigInt, Nullable: false},
  22. {Name: "type", Type: DB_NVarchar, Length: 255, Nullable: false},
  23. {Name: "value", Type: DB_Text, Nullable: false},
  24. {Name: "title", Type: DB_Text, Nullable: false},
  25. {Name: "order", Type: DB_Int, Nullable: false},
  26. },
  27. }
  28. mg.AddMigration("create playlist item table v2", NewAddTableMigration(playlistItemV2))
  29. mg.AddMigration("Update playlist table charset", NewTableCharsetMigration("playlist", []*Column{
  30. {Name: "name", Type: DB_NVarchar, Length: 255, Nullable: false},
  31. {Name: "interval", Type: DB_NVarchar, Length: 255, Nullable: false},
  32. }))
  33. mg.AddMigration("Update playlist_item table charset", NewTableCharsetMigration("playlist_item", []*Column{
  34. {Name: "type", Type: DB_NVarchar, Length: 255, Nullable: false},
  35. {Name: "value", Type: DB_Text, Nullable: false},
  36. {Name: "title", Type: DB_Text, Nullable: false},
  37. }))
  38. }