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