Sha256: bcd417016222c200696092d9838933264c6ae05577e6f5aba89a281e903692e5

Contents?: true

Size: 1.26 KB

Versions: 201

Compression:

Stored size: 1.26 KB

Contents

class MoveAdminNotesToComments < ActiveRecord::Migration
  def self.up
    remove_index  :admin_notes, [:admin_user_type, :admin_user_id]
    rename_table  :admin_notes, :active_admin_comments
    rename_column :active_admin_comments, :admin_user_type, :author_type
    rename_column :active_admin_comments, :admin_user_id, :author_id
    add_column    :active_admin_comments, :namespace, :string
    add_index     :active_admin_comments, [:namespace]
    add_index     :active_admin_comments, [:author_type, :author_id]

    # Update all the existing comments to the default namespace
    say "Updating any existing comments to the #{ActiveAdmin.application.default_namespace} namespace."
    execute "UPDATE active_admin_comments SET namespace='#{ActiveAdmin.application.default_namespace}'"
  end

  def self.down
    remove_index  :active_admin_comments, :column => [:author_type, :author_id]
    remove_index  :active_admin_comments, :column => [:namespace]
    remove_column :active_admin_comments, :namespace
    rename_column :active_admin_comments, :author_id, :admin_user_id
    rename_column :active_admin_comments, :author_type, :admin_user_type
    rename_table  :active_admin_comments, :admin_notes
    add_index     :admin_notes, [:admin_user_type, :admin_user_id]
  end
end

Version data entries

201 entries across 201 versions & 19 rubygems

Version Path
st-rich-1.5.1 test/dummy/db/migrate/20111014143349_move_admin_notes_to_comments.rb
lentil-1.0.5 db/migrate/20121120191531_move_admin_notes_to_comments.rb
rules-1.1.1 spec/dummy/db/migrate/20120901044907_move_admin_notes_to_comments.rb
lentil-1.0.4 db/migrate/20121120191531_move_admin_notes_to_comments.rb
lentil-1.0.3 db/migrate/20121120191531_move_admin_notes_to_comments.rb
lentil-1.0.2 db/migrate/20121120191531_move_admin_notes_to_comments.rb
lentil-1.0.1 db/migrate/20121120191531_move_admin_notes_to_comments.rb
lentil-1.0.0 db/migrate/20121120191531_move_admin_notes_to_comments.rb
rules-1.1.0 spec/dummy/db/migrate/20120901044907_move_admin_notes_to_comments.rb
lentil-0.9.1 db/migrate/20121120191531_move_admin_notes_to_comments.rb
rules-1.0.0 spec/dummy/db/migrate/20120901044907_move_admin_notes_to_comments.rb
lentil-0.9.0 db/migrate/20121120191531_move_admin_notes_to_comments.rb
lentil-0.8.0 db/migrate/20121120191531_move_admin_notes_to_comments.rb
lentil-0.7.1 db/migrate/20121120191531_move_admin_notes_to_comments.rb
lentil-0.6.0 db/migrate/20121120191531_move_admin_notes_to_comments.rb
lentil-0.5.2 db/migrate/20121120191531_move_admin_notes_to_comments.rb
lentil-0.5.1 db/migrate/20121120191531_move_admin_notes_to_comments.rb
lentil-0.5.0 db/migrate/20121120191531_move_admin_notes_to_comments.rb
lentil-0.4.2 db/migrate/20121120191531_move_admin_notes_to_comments.rb
lentil-0.4.0 db/migrate/20121120191531_move_admin_notes_to_comments.rb