Class: ActiveRecord::Migration

Inherits:
Object
  • Object
show all
Defined in:
lib/hopsoft/acts_as_lookup.rb

Class Method Summary collapse

Class Method Details

.create_lookup_table(name) ⇒ Object

Migration helper for creating a standardized lookup table.



228
229
230
231
232
233
234
235
236
237
# File 'lib/hopsoft/acts_as_lookup.rb', line 228

def self.create_lookup_table(name)
  create_table name do |t|
    # lookup columns
    t.column :name, :string, :limit => 50, :null => false
    t.column :description, :text
    t.column :enabled, :boolean, :default => true, :null => false
    t.column :sort_order, :integer, :default => 0, :null => false
  end rescue
  add_index(name, :name, :unique => true)
end