Sha256: 523a8da79d7c97680dcb76b5d8052327449386288b3e51fb105e6d399db5306e
Contents?: true
Size: 388 Bytes
Versions: 10
Compression:
Stored size: 388 Bytes
Contents
# frozen_string_literal: true class AddBlogIdToTags < ActiveRecord::Migration[4.2] set_role "blog_content" 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
10 entries across 10 versions & 1 rubygems