temp_user.go 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738
  1. package migrations
  2. import . "github.com/grafana/grafana/pkg/services/sqlstore/migrator"
  3. func addTempUserMigrations(mg *Migrator) {
  4. tempUserV1 := Table{
  5. Name: "temp_user",
  6. Columns: []*Column{
  7. {Name: "id", Type: DB_BigInt, IsPrimaryKey: true, IsAutoIncrement: true},
  8. {Name: "org_id", Type: DB_BigInt, Nullable: false},
  9. {Name: "version", Type: DB_Int, Nullable: false},
  10. {Name: "email", Type: DB_NVarchar, Length: 255},
  11. {Name: "name", Type: DB_NVarchar, Length: 255, Nullable: true},
  12. {Name: "role", Type: DB_NVarchar, Length: 20, Nullable: true},
  13. {Name: "code", Type: DB_NVarchar, Length: 255},
  14. {Name: "status", Type: DB_Varchar, Length: 20},
  15. {Name: "invited_by_user_id", Type: DB_BigInt, Nullable: true},
  16. {Name: "email_sent", Type: DB_Bool},
  17. {Name: "email_sent_on", Type: DB_DateTime, Nullable: true},
  18. {Name: "remote_addr", Type: DB_Varchar, Length: 255, Nullable: true},
  19. {Name: "created", Type: DB_DateTime},
  20. {Name: "updated", Type: DB_DateTime},
  21. },
  22. Indices: []*Index{
  23. {Cols: []string{"email"}, Type: IndexType},
  24. {Cols: []string{"org_id"}, Type: IndexType},
  25. {Cols: []string{"code"}, Type: IndexType},
  26. {Cols: []string{"status"}, Type: IndexType},
  27. },
  28. }
  29. // addDropAllIndicesMigrations(mg, "v7", tempUserV1)
  30. // mg.AddMigration("Drop old table tempUser v7", NewDropTableMigration("temp_user"))
  31. // create table
  32. mg.AddMigration("create temp user table v1-7", NewAddTableMigration(tempUserV1))
  33. addTableIndicesMigrations(mg, "v1-7", tempUserV1)
  34. }