Created
February 11, 2015 13:59
-
-
Save wilsonsilva/975017def0ebb33729dc to your computer and use it in GitHub Desktop.
Rails Migration Cheat Sheet
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
| bundle exec rails g migration AddUserRefToProducts user:references | |
| # Generates | |
| class AddUserRefToProducts < ActiveRecord::Migration | |
| def change | |
| add_reference :products, :user, index: true | |
| end | |
| end | |
| # Running it will create a user_id column on products and an index on products table. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment