Nona Nona - 6 months ago 14
Ruby Question

How to read the version timestamp of ActiveRecord::Schema.define?

When I see the version value in in schema.rb of a Rails 4.2 application as below, it looks like 2015 is the year, 04 is the month (April), and 27 is the day. But what is 115639 then?

ActiveRecord::Schema.define(version: 20150427115639) do


I'm trying to understand how the ActiveRecord::Schema version value is formatted.

It's not a Unix timestamp is it? If I convert a particular day month time as follows using an online calculator I get:

1429927200

Is equivalent to:

04/25/2015 @ 2:00am (UTC)


which doesn't seem to match the value defined by version.

Mostly I'm trying to understand how to quickly decide if a merge contains a more updated schema version.

Answer

The schema version comes from the timestamp of the most recent migration. That in turn is the concatenated digits of the date and time when the migration was generated. 20150427115639 comes from "2015-04-27 11:56:39".