Forked from d3r1v3d/add_double_to_active_record.rb
Last active
December 21, 2015 21:58
-
-
Save esromneb/6371964 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
module CustomColumnTypes | |
def double(*args) | |
if !args.last.is_a? Hash | |
args.push({}) | |
end | |
args.last[:limit] = 53 | |
float *args | |
end | |
end | |
module ActiveRecord | |
module ConnectionAdapters | |
class Table | |
include CustomColumnTypes | |
end | |
class TableDefinition | |
include CustomColumnTypes | |
end | |
end | |
end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class CreateVeryPreciseTimes < ActiveRecord::Migration | |
def up | |
create_table :very_precise_times do |t| | |
t.datetime :measured_at | |
t.double :measured_at_frac | |
end | |
end | |
def down | |
drop_table :very_precise_times | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment