Class: DynamicModel::Migration

Inherits:
ActiveRecord::Migration
  • Object
show all
Defined in:
lib/database_introspection/dynamic_model/migration.rb

Class Method Summary collapse

Class Method Details

.create_for(name, &block) ⇒ Object



3
4
5
6
7
8
9
10
11
12
# File 'lib/database_introspection/dynamic_model/migration.rb', line 3

def self.create_for(name, &block)
  create_table name.to_sym do |t|
    block.call(t) if block_given?
    begin
      t.timestamps
    rescue
      puts "Cannot create timestamps... Probably already created."
    end
  end
end

.update_for(name, &block) ⇒ Object



14
15
16
17
18
# File 'lib/database_introspection/dynamic_model/migration.rb', line 14

def self.update_for(name, &block)
  change_table name.to_sym do |t|
    block.call(t) if block_given?
  end
end