Module: ULID::Rails::Patch::Migrations

Defined in:
lib/ulid/rails/patch.rb

Instance Method Summary collapse

Instance Method Details

#virtual_ulid_timestamp(timestamp_column_name, ulid_column_name) ⇒ Object



5
6
7
8
9
# File 'lib/ulid/rails/patch.rb', line 5

def virtual_ulid_timestamp(timestamp_column_name, ulid_column_name)
  virtual timestamp_column_name,
    type: :datetime,
    as: "FROM_UNIXTIME(CONV(HEX(#{ulid_column_name} >> 80), 16, 10) / 1000.0)"
end