Sha256: 186f46a811837f88ffa21541d17995cb98ac99d790d9c3959f037f2d3be23874

Contents?: true

Size: 1.35 KB

Versions: 309

Compression:

Stored size: 1.35 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."
    comments_table_name = ActiveRecord::Migrator.proper_table_name("active_admin_comments")
    execute "UPDATE #{comments_table_name} 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

309 entries across 207 versions & 8 rubygems

Version Path
active_admin-state_machine-1.0.0.pre1 spec/dummy/db/migrate/20130817004307_move_admin_notes_to_comments.rb
activeadmin-mongoid-1.0.0 test_app/db/migrate/20130514223108_move_admin_notes_to_comments.rb
active_admin-workflow-0.1.0 spec/dummy/db/migrate/20130817004307_move_admin_notes_to_comments.rb
activeadmin-mongoid-0.9.0 test_app/db/migrate/20130514223108_move_admin_notes_to_comments.rb
activeadmin-mongoid-0.7.0 test_app/db/migrate/20130514223108_move_admin_notes_to_comments.rb
activeadmin-mongoid-0.5.0 test_app/db/migrate/20130514223108_move_admin_notes_to_comments.rb
activeadmin-mongoid-0.4.0 test_app/db/migrate/20130514223108_move_admin_notes_to_comments.rb
lalala-4.1.0.dev.425 db/migrate/20130321140352_move_admin_notes_to_comments.rb
lalala-4.1.0.dev.420 db/migrate/20130321140352_move_admin_notes_to_comments.rb
lalala-4.1.0.dev.419 db/migrate/20130321140352_move_admin_notes_to_comments.rb
lalala-4.1.0.dev.418 db/migrate/20130321140352_move_admin_notes_to_comments.rb
lalala-4.1.0.dev.417 db/migrate/20130321140352_move_admin_notes_to_comments.rb
lalala-4.0.0.dev.416 db/migrate/20130321140352_move_admin_notes_to_comments.rb
lalala-4.1.0.dev.415 db/migrate/20130321140352_move_admin_notes_to_comments.rb
lalala-4.1.0.dev.414 db/migrate/20130321140352_move_admin_notes_to_comments.rb
lalala-4.1.0.dev.413 db/migrate/20130321140352_move_admin_notes_to_comments.rb
lalala-4.1.0.dev.412 db/migrate/20130321140352_move_admin_notes_to_comments.rb
lalala-4.1.0.dev.411 db/migrate/20130321140352_move_admin_notes_to_comments.rb
lalala-4.1.0.dev.410 db/migrate/20130321140352_move_admin_notes_to_comments.rb
lalala-4.1.0.dev.409 db/migrate/20130321140352_move_admin_notes_to_comments.rb