Class: ActsAsImportantMigrationGenerator

Inherits:
Rails::Generators::Base
  • Object
show all
Defined in:
lib/generators/migration_generator.rb

Instance Method Summary collapse

Instance Method Details

#create_migration_fileObject



2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
# File 'lib/generators/migration_generator.rb', line 2

def create_migration_file
  create_file "db/migrations/initializer.rb", <<-EOV
    class ActsAsImportantTables < ActiveRecord::Migration
      def change
        create_table :importance_indicators do |t|
          t.belongs_to :user
          t.belongs_to :record, :polymorphic => true
          t.text       :note
        end

        add_index :importance_indicators, [:record_id, :record_type], :name => 'index_importance_indicators', :unique => true
      end
    end
  EOV
end