Sha256: bd40ad87c943dcd494e2243f95170461b38b159371b7234705f4158c496bde35

Contents?: true

Size: 355 Bytes

Versions: 6

Compression:

Stored size: 355 Bytes

Contents

class AddBlogIdToRedirects < ActiveRecord::Migration
  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

6 entries across 6 versions & 1 rubygems

Version Path
publify_core-9.0.0.pre6 db/migrate/20150808191127_add_blog_id_to_redirects.rb
publify_core-9.0.0.pre5 db/migrate/20150808191127_add_blog_id_to_redirects.rb
publify_core-9.0.0.pre4 db/migrate/20150808191127_add_blog_id_to_redirects.rb
publify_core-9.0.0.pre3 db/migrate/20150808191127_add_blog_id_to_redirects.rb
publify_core-9.0.0.pre2 db/migrate/20150808191127_add_blog_id_to_redirects.rb
publify_core-9.0.0.pre1 db/migrate/20150808191127_add_blog_id_to_redirects.rb