Skip to content

Instantly share code, notes, and snippets.

@intjonathan
Created September 30, 2011 21:12
Show Gist options
  • Save intjonathan/1254984 to your computer and use it in GitHub Desktop.
Save intjonathan/1254984 to your computer and use it in GitHub Desktop.
class CreateStoryTable < ActiveRecord::Migration
def self.up
create_table :stories do |t|
t.string :title
t.integer :journal_id
t.integer :user_id
t.integer :account_id
t.timestamps
end
add_index :stories, [:user_id, :account_id, :journal_id]
add_column :journals, :stories_count, :integer
end
def self.down
remove_index :stories, [:user_id, :account_id, :journal_id]
drop_table :stories
remove_column :journals, :stories_count
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment