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

Add documentation for modifying schema #6

Merged
merged 2 commits into from
Feb 8, 2018

Conversation

ashiklom
Copy link
Member

@ashiklom ashiklom commented Feb 7, 2018

Simple overview of how db:migrate works, with a link to a more
comprehensive guide from the Rails documentation.

Simple overview of how `db:migrate` works, with a link to a more
comprehensive guide from the Rails documentation.
In a nutshell, each migration describes a database revision (`up` -- how to make the change) and its inverse (`down` -- how to undo the change).
There are lots of examples of previous migrations in this directory that can be used for reference.
Database operations can be performed by passing SQL queries directly to an `execute %q{<YOUR QUERY HERE>}` statement, or through Ruby helper commands like `change_column`.
Although you can name migrations whatever you want, because they are run in numerical-alphabetical order, the convention is to prefix your script with the current year, month, day, hour, minute, and second (you can generate this string by running `date +%Y%m%d%H%M%S` on the command line).
Copy link
Member

Choose a reason for hiding this comment

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

another option is that you can use bundle exec rails generate migration ChangeParameterListToText. This will generate the migration for you with the current datetime.

Copy link
Member Author

Choose a reason for hiding this comment

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

Didn't know about that, but that's really cool! I'll add it to this.

@dlebauer
Copy link
Member

dlebauer commented Feb 7, 2018

Thanks for adding this - maybe add some examples, and distinguish editing from adding fields, as well as adding new tables.

Also, add `generate migration` command.
@ashiklom
Copy link
Member Author

ashiklom commented Feb 7, 2018

@robkooper Added the generate migration task string -- that's really handy.

@dlebauer Added a few examples based on existing migrations. Not sure what you mean by "distinguish editing from adding fields, as well as adding new tables". Adding tables and adding, removing, or modifying fields all fall under the db:migrate set of tasks, right? Or are some of these done with some other mechanism?

@dlebauer
Copy link
Member

dlebauer commented Feb 8, 2018 via email

@ashiklom
Copy link
Member Author

ashiklom commented Feb 8, 2018

So...is this good to go, or do I need to make further changes?

@dlebauer
Copy link
Member

dlebauer commented Feb 8, 2018 via email

@mdietze mdietze merged commit 45c7ab9 into PecanProject:master Feb 8, 2018
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.

4 participants