Closed joscdk closed 6 years ago
struct AddUserIndex: PostgreSQLMigration {
static func prepare(on conn: PostgreSQLConnection) -> Future<Void> {
return Database.update(User.self, on: conn) { builder in
builder.unique(on: \.username)
}
}
static func revert(on conn: PostgreSQLConnection) -> Future<Void> {
return Database.update(User.self, on: conn) { builder in
builder.deleteUnique(from: \.username)
}
}
}
Results in
[psql] [2018-07-26 01:11:31 +0000] ALTER TABLE "User #1" ADD CONSTRAINT "uq:User #1.username" UNIQUE ("username") []
[psql] [2018-07-26 01:11:31 +0000] ALTER TABLE "User #1" DROP CONSTRAINT "uq:User #1.username" []
Looks to be fixed. Thanks!
When modifying a table after creation, the migration fails, when adding index and unique to an existing field.
This code fails
With the following error