Sha256: c7a1707c1264d1cb39d2df4ec2cb0e5bae127c598be9ebd2fb60d8f0db0cae1d

Contents?: true

Size: 685 Bytes

Versions: 10

Compression:

Stored size: 685 Bytes

Contents

class RemoveBlogIds < ActiveRecord::Migration
  def self.up
    remove_index :contents, :blog_id rescue nil
    remove_column :contents, :blog_id 
    remove_column :sidebars, :blog_id 
    remove_column :feedback, :blog_id 
  end

  def self.down
    add_column :contents, :blog_id, :integer
    add_column :sidebars, :blog_id, :integer
    add_column :feedback, :blog_id, :integer

    default_blog_id = Blog.find(:first, :order => 'id').id

    Content.update_all("blog_id = #{default_blog_id}")
    Feedback.update_all("blog_id = #{default_blog_id}")
    Sidebar.update_all("blog_id = #{default_blog_id}")

    change_column :sidebars, :blog_id, :integer, :null => false
  end
end

Version data entries

10 entries across 10 versions & 1 rubygems

Version Path
typo-5.0.3.98.1 db/migrate/067_remove_blog_ids.rb
typo-5.0.3.98 db/migrate/067_remove_blog_ids.rb
typo-5.1.2 db/migrate/067_remove_blog_ids.rb
typo-5.1.1 db/migrate/067_remove_blog_ids.rb
typo-5.1.3 db/migrate/067_remove_blog_ids.rb
typo-5.1 db/migrate/067_remove_blog_ids.rb
typo-5.1.98 db/migrate/067_remove_blog_ids.rb
typo-5.2.98 db/migrate/067_remove_blog_ids.rb
typo-5.2 db/migrate/067_remove_blog_ids.rb
typo-5.3 db/migrate/067_remove_blog_ids.rb