Last active
October 2, 2022 13:30
-
-
Save aronbudinszky/2068622cb09cb2fc125029c7bac21488 to your computer and use it in GitHub Desktop.
Run a custom migration via raw query on a Vapor Fluent database.
This file contains hidden or 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
struct CustomRawMigration: AsyncMigration { | |
func prepare(on database: Database) async throws { | |
try await (database as! SQLDatabase) | |
.raw("ALTER TABLE `table_name` MODIFY `field_name` ENUM('case1', 'case2', 'case3') DEFAULT 'case1'") | |
.run() | |
} | |
func revert(on database: Database) async throws { | |
try await (database as! SQLDatabase) | |
.raw("ALTER TABLE `table_name` MODIFY `field_name` ENUM('case1', 'case2') DEFAULT 'case1'") | |
.run() | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment