Skip to content

Instantly share code, notes, and snippets.

@gabidavila
Created August 26, 2017 18:46
Show Gist options
  • Select an option

  • Save gabidavila/b092de0fb2b5c82c8928c470d64154fc to your computer and use it in GitHub Desktop.

Select an option

Save gabidavila/b092de0fb2b5c82c8928c470d64154fc to your computer and use it in GitHub Desktop.
class CreateArtists < ActiveRecord::Migration
def change
create_table :artists do |t|
t.string :name
t.timestamps
end
add_index :artists, :name
end
end
class CreateSongs < ActiveRecord::Migration
def change
create_table :songs do |t|
t.string :title
t.integer :artist_id
t.timestamps
end
add_index :songs, :title
add_foreign_key :songs, :artists
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment