Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Create migrations section #107

Merged
merged 2 commits into from
Jan 10, 2017
Merged

Conversation

jdmcd
Copy link
Member

@jdmcd jdmcd commented Jan 10, 2017

A little addition the documentation section on Preparations that addresses how to use a Preparation to change an existing db schema.

@jdmcd jdmcd mentioned this pull request Jan 10, 2017
Copy link
Member

@loganwright loganwright left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Tiny and nitpicky change and let's merge it!

@@ -123,6 +123,27 @@ final class User {

Here we are deleting the table named `users`.

### Preparations as Migrations

If you want to add a field to your table after you've already created the initial schema, you can create a struct or class that inherits from `Preparation` like so:
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

conforms to not inherits from

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah, yes, thank you

@loganwright loganwright merged commit e0b5077 into vapor:master Jan 10, 2017

struct AddFooToBar: Preparation {
static func prepare(_ database: Database) throws {
try database.modify("bars", closure: { bar in
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Trailing Swift closure syntax I think would be a little more Swifty here

@kdawgwilk
Copy link
Contributor

Sorry saw a notification for this and made a comment without realizing it had already merged

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants