Last active
August 13, 2020 06:02
-
-
Save joshuawright11/5b777408dfef8397c4a681677e2d1d7e to your computer and use it in GitHub Desktop.
Sample migration
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
struct Sample: Migration { | |
func up(schema: Schema) { | |
schema.rename(table: "todos", to: "user_todos") | |
schema.create(table: "users") { | |
$0.uuid("id").primary() | |
$0.string("name").nullable(false) | |
$0.string("email").nullable(false).unique().index() | |
$0.uuid("mom").references("id", on: "users") | |
} | |
schema.drop(table: "referrals") | |
schema.alter(table: "tokens") { | |
$0.rename(column: "createdAt", to: "created_at") | |
$0.bool("is_expired").default(val: false) | |
$0.drop(column: "expiry_date") | |
} | |
} | |
func down(schema: Schema) { | |
schema.drop(table: "users") | |
} | |
} | |
protocol Migration { | |
func up(schema: Schema) | |
func down(schema: Schema) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment