user_auth_mig.go 1.0 KB

1234567891011121314151617181920212223242526272829
  1. package migrations
  2. import . "github.com/grafana/grafana/pkg/services/sqlstore/migrator"
  3. func addUserAuthMigrations(mg *Migrator) {
  4. userAuthV1 := Table{
  5. Name: "user_auth",
  6. Columns: []*Column{
  7. {Name: "id", Type: DB_BigInt, IsPrimaryKey: true, IsAutoIncrement: true},
  8. {Name: "user_id", Type: DB_BigInt, Nullable: false},
  9. {Name: "auth_module", Type: DB_NVarchar, Length: 190, Nullable: false},
  10. {Name: "auth_id", Type: DB_NVarchar, Length: 100, Nullable: false},
  11. {Name: "created", Type: DB_DateTime, Nullable: false},
  12. },
  13. Indices: []*Index{
  14. {Cols: []string{"auth_module", "auth_id"}},
  15. },
  16. }
  17. // create table
  18. mg.AddMigration("create user auth table", NewAddTableMigration(userAuthV1))
  19. // add indices
  20. addTableIndicesMigrations(mg, "v1", userAuthV1)
  21. mg.AddMigration("alter user_auth.auth_id to length 255", new(RawSqlMigration).
  22. Sqlite("SELECT 0 WHERE 0;").
  23. Postgres("ALTER TABLE user_auth ALTER COLUMN auth_id TYPE VARCHAR(255);").
  24. Mysql("ALTER TABLE user_auth MODIFY auth_id VARCHAR(255);"))
  25. }