stats_mig.go 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  1. package migrations
  2. import . "github.com/grafana/grafana/pkg/services/sqlstore/migrator"
  3. // commented out because of the deadcode CI check
  4. //func addStatsMigrations(mg *Migrator) {
  5. // statTable := Table{
  6. // Name: "stat",
  7. // Columns: []*Column{
  8. // {Name: "id", Type: DB_Int, IsPrimaryKey: true, IsAutoIncrement: true},
  9. // {Name: "metric", Type: DB_Varchar, Length: 20, Nullable: false},
  10. // {Name: "type", Type: DB_Int, Nullable: false},
  11. // },
  12. // Indices: []*Index{
  13. // {Cols: []string{"metric"}, Type: UniqueIndex},
  14. // },
  15. // }
  16. //
  17. // // create table
  18. // mg.AddMigration("create stat table", NewAddTableMigration(statTable))
  19. //
  20. // // create indices
  21. // mg.AddMigration("add index stat.metric", NewAddIndexMigration(statTable, statTable.Indices[0]))
  22. //
  23. // statValue := Table{
  24. // Name: "stat_value",
  25. // Columns: []*Column{
  26. // {Name: "id", Type: DB_Int, IsPrimaryKey: true, IsAutoIncrement: true},
  27. // {Name: "value", Type: DB_Double, Nullable: false},
  28. // {Name: "time", Type: DB_DateTime, Nullable: false},
  29. // },
  30. // }
  31. //
  32. // // create table
  33. // mg.AddMigration("create stat_value table", NewAddTableMigration(statValue))
  34. //}
  35. func addTestDataMigrations(mg *Migrator) {
  36. testData := Table{
  37. Name: "test_data",
  38. Columns: []*Column{
  39. {Name: "id", Type: DB_Int, IsPrimaryKey: true, IsAutoIncrement: true},
  40. {Name: "metric1", Type: DB_Varchar, Length: 20, Nullable: true},
  41. {Name: "metric2", Type: DB_NVarchar, Length: 150, Nullable: true},
  42. {Name: "value_big_int", Type: DB_BigInt, Nullable: true},
  43. {Name: "value_double", Type: DB_Double, Nullable: true},
  44. {Name: "value_float", Type: DB_Float, Nullable: true},
  45. {Name: "value_int", Type: DB_Int, Nullable: true},
  46. {Name: "time_epoch", Type: DB_BigInt, Nullable: false},
  47. {Name: "time_date_time", Type: DB_DateTime, Nullable: false},
  48. {Name: "time_time_stamp", Type: DB_TimeStamp, Nullable: false},
  49. },
  50. }
  51. // create table
  52. mg.AddMigration("create test_data table", NewAddTableMigration(testData))
  53. }