-
-
Save rickywid/85c64f6e2b1f65af6c74 to your computer and use it in GitHub Desktop.
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
rails generate model Micropost content:text user:references | |
class CreateMicroposts < ActiveRecord::Migration | |
def change | |
create_table :microposts do |t| | |
t.text :content | |
t.references :user, index: true, foreign_key: true | |
t.timestamps null: false | |
end | |
end | |
end | |
============================================================== | |
rails generate model Micropost content:text user:references | |
class CreateMicroposts < ActiveRecord::Migration | |
def change | |
create_table :microposts do |t| | |
t.text :content | |
t.references :user, index: true | |
t.timestamps null: false | |
end | |
add_foreign_key :microposts, :users | |
add_index :microposts, [:user, :created_at] | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment