Sha256: 92f4f6deeff52c4573cc095b7c809c3993ed115b9147a85a389e065bf9528d6c

Contents?: true

Size: 325 Bytes

Versions: 6

Compression:

Stored size: 325 Bytes

Contents

class AddBlogIdToTags < ActiveRecord::Migration
  class Tag < ActiveRecord::Base; end

  def up
    add_column :tags, :blog_id, :integer
    if Tag.any?
      default_blog_id = Blog.order(:id).first.id
      Tag.update_all("blog_id = #{default_blog_id}")
    end
  end

  def down
    remove_column :tags, :blog_id
  end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
publify_core-9.0.0.pre6 db/migrate/20150810094754_add_blog_id_to_tags.rb
publify_core-9.0.0.pre5 db/migrate/20150810094754_add_blog_id_to_tags.rb
publify_core-9.0.0.pre4 db/migrate/20150810094754_add_blog_id_to_tags.rb
publify_core-9.0.0.pre3 db/migrate/20150810094754_add_blog_id_to_tags.rb
publify_core-9.0.0.pre2 db/migrate/20150810094754_add_blog_id_to_tags.rb
publify_core-9.0.0.pre1 db/migrate/20150810094754_add_blog_id_to_tags.rb