Created
November 19, 2018 17:38
-
-
Save ldmarz/9ad97911bd36477200aa4e4a151f2870 to your computer and use it in GitHub Desktop.
executing raw queries vapor3 with fluent
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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