Module: Mycroseconds::Migration::AbstractAdapter

Defined in:
lib/mycroseconds/migration.rb

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.included(base) ⇒ Object



4
5
6
7
8
9
# File 'lib/mycroseconds/migration.rb', line 4

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



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

def add_timestamps_with_precision(*args)
  add_timestamps_without_precision(*args)

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

#remove_timestamps_with_precision(*args) ⇒ Object



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

def remove_timestamps_with_precision(*args)
  remove_timestamps_without_precision(*args)

  if @base.adapter_name.downcase == 'mysql'
    remove_column(table_name, :updated_at_precision)
  end
end