Skip to content

Instantly share code, notes, and snippets.

@ldmarz
Created November 13, 2018 12:09
Show Gist options
  • Save ldmarz/595a19b3b69bd465fe1b2ebb1209588e to your computer and use it in GitHub Desktop.
Save ldmarz/595a19b3b69bd465fe1b2ebb1209588e to your computer and use it in GitHub Desktop.
Adding new field on vapor 3
import Foundation
import Vapor
import FluentPostgreSQL
struct AddUserPassword: Migration {
typealias Database = PostgreSQLDatabase
static func prepare( on connection: PostgreSQLConnection ) -> Future<Void> {
return Database.update(User.self, on: connection) { builder in
builder.field(for: \.password)
}
}
static func revert(on connection: PostgreSQLConnection) -> EventLoopFuture<Void> {
return Database.update(User.self, on: connection) { builder in
builder.deleteField(for: \.password)
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment