Sha256: e80e0ae514a2e031d883406e932015bf34270dd66855ceffdc2a7f9e14700c25
Contents?: true
Size: 492 Bytes
Versions: 20
Compression:
Stored size: 492 Bytes
Contents
class AddArticleUserId < ActiveRecord::Migration class BareArticle < ActiveRecord::Base include BareMigration end class BareUser < ActiveRecord::Base include BareMigration end def self.up STDERR.puts "Linking article authors to users" modify_tables_and_update(:add_column, BareArticle, :user_id, :integer) do |art| art.user_id = (BareUser.find_by_name(art.author).id rescue nil) end end def self.down remove_column :articles, :user_id end end
Version data entries
20 entries across 20 versions & 1 rubygems