Skip to content

Commit

Permalink
Add users to posts that were made prior to user migration
Browse files Browse the repository at this point in the history
  • Loading branch information
baileylo committed Feb 22, 2011
1 parent 29091cf commit ec3ced2
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 1 deletion.
13 changes: 13 additions & 0 deletions db/migrate/20110222070136_insert_user_in_all_posts.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
class InsertUserInAllPosts < ActiveRecord::Migration
def self.up
user = User.find(:first)
Post.where(:user_id => nil).each do |post|
post.user = user;
post.save
end

end

def self.down
end
end
2 changes: 1 addition & 1 deletion db/schema.rb
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
#
# It's strongly recommended to check this file into your version control system.

ActiveRecord::Schema.define(:version => 20110221020819) do
ActiveRecord::Schema.define(:version => 20110222070136) do

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

0 comments on commit ec3ced2

Please sign in to comment.