Skip to content

Instantly share code, notes, and snippets.

@ldmarz
Created November 19, 2018 17:38
Show Gist options
  • Save ldmarz/9ad97911bd36477200aa4e4a151f2870 to your computer and use it in GitHub Desktop.
Save ldmarz/9ad97911bd36477200aa4e4a151f2870 to your computer and use it in GitHub Desktop.
executing raw queries vapor3 with fluent
import Foundation
import FluentPostgreSQL
import Vapor
struct RemoveHashColumn: Migration {
typealias Database = PostgreSQLDatabase
static func prepare( on connection: PostgreSQLConnection ) -> Future<Void> {
return Database.update(Files.self, on: connection) { builder in
connection.raw("ALTER TABLE oldName RENAME TO newName;")
}
}
static func revert(on connection: PostgreSQLConnection) -> EventLoopFuture<Void> {
return Database.update(Files.self, on: connection) { builder in
connection.raw("ALTER TABLE newName RENAME TO oldNew;")
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment