Sha256: 0da415a7affc5b1b6bf3c341ae64720104d44f7daac377f8d7144196e7807a73

Contents?: true

Size: 330 Bytes

Versions: 3

Compression:

Stored size: 330 Bytes

Contents

class AddBlogIdToTags < ActiveRecord::Migration[4.2]
  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

3 entries across 3 versions & 1 rubygems

Version Path
publify_core-9.1.0 db/migrate/20150810094754_add_blog_id_to_tags.rb
publify_core-9.0.1 db/migrate/20150810094754_add_blog_id_to_tags.rb
publify_core-9.0.0 db/migrate/20150810094754_add_blog_id_to_tags.rb