Skip to content

Instantly share code, notes, and snippets.

@ldmarz
Last active November 13, 2018 12:14
Show Gist options
  • Save ldmarz/5468e89045352ddeb54b8d887f199490 to your computer and use it in GitHub Desktop.
Save ldmarz/5468e89045352ddeb54b8d887f199490 to your computer and use it in GitHub Desktop.
extension User: Migration {
static func prepare(on connection: PostgreSQLConnection) -> Future<void> {
return Database.create(self, on: connection) { builder in
builder.field(for: \.id, type: .int, isIdentifier: true)
builder.field(for: \.email, type: .string, .notNull)
builder.field(for: \.lifeStory, type: .text)
builder.field(for: \.iq, type: .int, .default(.literal("123456")))
builder.field(for: \.companyID, type: .int)
builder.reference(from: \.companyID, to: \Company.id)
builder.unique(on: \.email)
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment