preferences_mig.go 1.1 KB

1234567891011121314151617181920212223242526272829303132
  1. package migrations
  2. import . "github.com/grafana/grafana/pkg/services/sqlstore/migrator"
  3. func addPreferencesMigrations(mg *Migrator) {
  4. mg.AddMigration("drop preferences table v2", NewDropTableMigration("preferences"))
  5. preferencesV2 := Table{
  6. Name: "preferences",
  7. Columns: []*Column{
  8. {Name: "id", Type: DB_BigInt, IsPrimaryKey: true, IsAutoIncrement: true},
  9. {Name: "org_id", Type: DB_BigInt, Nullable: false},
  10. {Name: "user_id", Type: DB_BigInt, Nullable: false},
  11. {Name: "version", Type: DB_Int, Nullable: false},
  12. {Name: "home_dashboard_id", Type: DB_BigInt, Nullable: false},
  13. {Name: "timezone", Type: DB_NVarchar, Length: 50, Nullable: false},
  14. {Name: "theme", Type: DB_NVarchar, Length: 20, Nullable: false},
  15. {Name: "created", Type: DB_DateTime, Nullable: false},
  16. {Name: "updated", Type: DB_DateTime, Nullable: false},
  17. },
  18. Indices: []*Index{
  19. {Cols: []string{"org_id"}},
  20. {Cols: []string{"user_id"}},
  21. },
  22. }
  23. mg.AddMigration("drop preferences table v3", NewDropTableMigration("preferences"))
  24. // create table
  25. mg.AddMigration("create preferences table v3", NewAddTableMigration(preferencesV2))
  26. }