Module: Mycroseconds::Migration::AbstractAdapter

Defined in:
lib/mycroseconds/migration.rb

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.included(base) ⇒ Object



6
7
8
9
10
11
# File 'lib/mycroseconds/migration.rb', line 6

def self.included(base)
  base.class_eval do
    alias_method_chain :add_timestamps, :precision
    alias_method_chain :remove_timestamps, :precision
  end
end

Instance Method Details

#add_timestamps_with_precision(*args) ⇒ Object



13
14
15
16
17
18
19
# File 'lib/mycroseconds/migration.rb', line 13

def add_timestamps_with_precision(*args)
  add_timestamps_without_precision(*args)

  if ADAPTER_NAMES.include?(@base.adapter_name.downcase)
    add_column(table_name, :updated_at_precision, :integer, :default => 0, :null => false)
  end
end

#remove_timestamps_with_precision(*args) ⇒ Object



21
22
23
24
25
26
27
# File 'lib/mycroseconds/migration.rb', line 21

def remove_timestamps_with_precision(*args)
  remove_timestamps_without_precision(*args)

  if ADAPTER_NAMES.include?(@base.adapter_name.downcase)
    remove_column(table_name, :updated_at_precision)
  end
end