Sha256: 61097ddf962a5bb5208344c59cec005e65401aa1b97e7954f8fca110b9864e7e

Contents?: true

Size: 418 Bytes

Versions: 10

Compression:

Stored size: 418 Bytes

Contents

# frozen_string_literal: true

class AddBlogIdToRedirects < ActiveRecord::Migration[4.2]
  set_role "blog_content"

  class Redirect < ActiveRecord::Base; end

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

  def down
    remove_column :redirects, :blog_id
  end
end

Version data entries

10 entries across 10 versions & 1 rubygems

Version Path
HornsAndHooves-publify_core-10.5.0 db/migrate/20150808191127_add_blog_id_to_redirects.rb
HornsAndHooves-publify_core-10.4.0 db/migrate/20150808191127_add_blog_id_to_redirects.rb
HornsAndHooves-publify_core-10.3.0 db/migrate/20150808191127_add_blog_id_to_redirects.rb
HornsAndHooves-publify_core-10.2.0 db/migrate/20150808191127_add_blog_id_to_redirects.rb
HornsAndHooves-publify_core-10.1.1 db/migrate/20150808191127_add_blog_id_to_redirects.rb
HornsAndHooves-publify_core-10.1.0 db/migrate/20150808191127_add_blog_id_to_redirects.rb
HornsAndHooves-publify_core-10.0.3 db/migrate/20150808191127_add_blog_id_to_redirects.rb
HornsAndHooves-publify_core-10.0.2 db/migrate/20150808191127_add_blog_id_to_redirects.rb
HornsAndHooves-publify_core-10.0.1 db/migrate/20150808191127_add_blog_id_to_redirects.rb
HornsAndHooves-publify_core-10.0.0 db/migrate/20150808191127_add_blog_id_to_redirects.rb