Skip to content

Commit

Permalink
project-ownership-migration
Browse files Browse the repository at this point in the history
Run the migration generator to see the effect on the app:

    $ hobo generate migration
  • Loading branch information
bryanlarsen authored and iox committed Aug 12, 2013
1 parent 6bc889d commit 561235c
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 1 deletion.
13 changes: 13 additions & 0 deletions db/migrate/20130109025834_project_ownership.rb
@@ -0,0 +1,13 @@
class ProjectOwnership < ActiveRecord::Migration
def self.up
add_column :projects, :owner_id, :integer

add_index :projects, [:owner_id]
end

def self.down
remove_column :projects, :owner_id

remove_index :projects, :name => :index_projects_on_owner_id rescue ActiveRecord::StatementInvalid
end
end
5 changes: 4 additions & 1 deletion db/schema.rb
Expand Up @@ -11,15 +11,18 @@
#
# It's strongly recommended to check this file into your version control system.

ActiveRecord::Schema.define(:version => 20130109024936) do
ActiveRecord::Schema.define(:version => 20130109025834) do

create_table "projects", :force => true do |t|
t.string "name"
t.integer "stories_count", :default => 0, :null => false
t.datetime "created_at"
t.datetime "updated_at"
t.integer "owner_id"
end

add_index "projects", ["owner_id"], :name => "index_projects_on_owner_id"

create_table "stories", :force => true do |t|
t.string "title"
t.text "body"
Expand Down

0 comments on commit 561235c

Please sign in to comment.