Sha256: 1328f3c4b2716c3e66e881c7c35a1bb8d7a77e77b0402145ca9f1d8516e95a39

Contents?: true

Size: 976 Bytes

Versions: 3

Compression:

Stored size: 976 Bytes

Contents

class ActsAsAuditedMigration < ActiveRecord::Migration
  def self.up
    create_table :audits, :force => true do |t|
      t.column :created_at, :datetime
      t.column :updated_at, :datetime
      t.column :auditable_id, :integer
      t.column :auditable_type, :string
      t.column :user_id, :integer
      t.column :user_type, :string
      t.column :username, :string
      t.column :action, :string
      t.column :audit_changes, :text
      t.column :version, :integer, :default => 0
      t.column :comment, :string
    end
    if connection.adapter_name =~ /mysql/i
      execute 'ALTER TABLE audits ADD COLUMN full_model longtext collate utf8_unicode_ci' 
    else
      add_column :audits, :full_model, :text
    end
    add_index :audits, [:auditable_id, :auditable_type], :name => 'auditable_index'
    add_index :audits, [:user_id, :user_type], :name => 'user_index'
    add_index :audits, :created_at  
  end

  def self.down
    drop_table :audits
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
acts_as_audited_rails3-1.1.2 lib/generators/audited_migration/templates/migration.rb
acts_as_audited_rails3-1.1.1.5 lib/generators/audited_migration/templates/migration.rb
acts_as_audited_rails3-1.1.1.4 lib/generators/audited_migration/templates/migration.rb