Sha256: 4b2a17fa0f9d5af317d93c784781e89f0bde07b722fc044b0337faa62677a018
Contents?: true
Size: 361 Bytes
Versions: 14
Compression:
Stored size: 361 Bytes
Contents
# frozen_string_literal: true 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
14 entries across 14 versions & 1 rubygems