login_attempt_mig.go 796 B

1234567891011121314151617181920212223
  1. package migrations
  2. import . "github.com/grafana/grafana/pkg/services/sqlstore/migrator"
  3. func addLoginAttemptMigrations(mg *Migrator) {
  4. loginAttemptV1 := Table{
  5. Name: "login_attempt",
  6. Columns: []*Column{
  7. {Name: "id", Type: DB_BigInt, IsPrimaryKey: true, IsAutoIncrement: true},
  8. {Name: "username", Type: DB_NVarchar, Length: 190, Nullable: false},
  9. {Name: "ip_address", Type: DB_NVarchar, Length: 30, Nullable: false},
  10. {Name: "created", Type: DB_DateTime, Nullable: false},
  11. },
  12. Indices: []*Index{
  13. {Cols: []string{"username"}},
  14. },
  15. }
  16. // create table
  17. mg.AddMigration("create login attempt table", NewAddTableMigration(loginAttemptV1))
  18. // add indices
  19. mg.AddMigration("add index login_attempt.username", NewAddIndexMigration(loginAttemptV1, loginAttemptV1.Indices[0]))
  20. }