Migration numbers

Why do the migration numbers not appear. I am following the famous depot
example, but I am finding that when I migrate the database using rake
db:migrate I get a createproducts file with a long integer string before
the .rb file, i.e. 20100730085920_create_products.rb. How do I get this
changed. See I want to roll back the database and/or make some
ammendments but I cannot find a way to get this done as in the example
the preceeding integer is supposed to be only 001. Is this a setting
someplace?

Dis T. wrote:

Why do the migration numbers not appear. I am following the famous depot
example, but I am finding that when I migrate the database using rake
db:migrate I get a createproducts file with a long integer string before
the .rb file, i.e. 20100730085920_create_products.rb. How do I get this
changed. See I want to roll back the database and/or make some
ammendments but I cannot find a way to get this done as in the example
the preceeding integer is supposed to be only 001. Is this a setting
someplace?

I believe this is related to the version of Rails.

Anyone is welcome to correct me, but the Depot application tutorial is
dated. At the time of that tutorial, migration date and time prefixes
where not used.

It is far better to have the prefix of date and time than a simple 3
digit integer.

That said, I’m sure there will be a way to alter the prefix. A Google
search should give you the answer if what I’ve said is not satisfactory.

Dis T. wrote:

Why do the migration numbers not appear. I am following the famous depot
example, but I am finding that when I migrate the database using rake
db:migrate I get a createproducts file with a long integer string before
the .rb file, i.e. 20100730085920_create_products.rb. How do I get this
changed. See I want to roll back the database and/or make some
ammendments but I cannot find a way to get this done as in the example
the preceeding integer is supposed to be only 001. Is this a setting
someplace?

BTW I am using MySQL, is this a problem with the DB. I have tried adding
a +1 to version number and migrating.

On Jul 30, 10:36 am, Dis T. [email protected] wrote:

Why do the migration numbers not appear. I am following the famous depot
example, but I am finding that when I migrate the database using rake
db:migrate I get a createproducts file with a long integer string before
the .rb file, i.e. 20100730085920_create_products.rb. How do I get this
changed. See I want to roll back the database and/or make some
ammendments but I cannot find a way to get this done as in the example
the preceeding integer is supposed to be only 001. Is this a setting
someplace?

20100730085920 is the migration number. This changed something like 2
years go, which implies that the tutorial you are following might be a
bit out of date.

Fred

Frederick C. wrote:

On Jul 30, 10:36�am, Dis T. [email protected] wrote:

Why do the migration numbers not appear. I am following the famous depot
example, but I am finding that when I migrate the database using rake
db:migrate I get a createproducts file with a long integer string before
the .rb file, i.e. 20100730085920_create_products.rb. How do I get this
changed. See I want to roll back the database and/or make some
ammendments but I cannot find a way to get this done as in the example
the preceeding integer is supposed to be only 001. Is this a setting
someplace?

20100730085920 is the migration number. This changed something like 2
years go, which implies that the tutorial you are following might be a
bit out of date.

Fred

Thank you for reinforcing my point.

If you really must have your three digit migration numbers, then just
rename the file after it is created…

ruby script/generate migration blah blah blah

rake db:migrate

But please do try to find a newer tutorial… the depot tutorial is
ancient, and many things have changed…

That number (20100730085920) is

Year 2010
Month 07
Day 30
Hour 08
Minute 59
Seconds 20

and tells you much more about the migration than 012 does.

You can revert to the sequential numbering scheme by setting
config.active_record.timestamped_migrations to false in config/
environment.rb.

–Martin

On Fri, Jul 30, 2010 at 7:42 AM, Ar Chron [email protected] wrote:

But please do try to find a newer tutorial… the depot tutorial is
ancient, and many things have changed…

I’m assuming the depot example is the one from Agile Web D.
with Rails.

There have been 3 printed editions of AWDWR, the first came out right
before Rails 1.0, the second covered Rails 1.1 (which had lots of
changes) but was before the change to timestamped migrations*. The
latest, for which Sam Ruby took over the role of primary author from
Dave T., covers Rails 2.x and is the first to show timestamped
migrations. In each of these the depot app has been brought up to
the, then, current version of Rails.

And there’s a fourth edition in preparation which covers Rails 3.
It’s available under the Pragmatic Programmers beta program, in
softcopy (pdf, epub, and mobi formats) updated as they get closer to
press, and optionally as a pre-ordered print edition.

Since I’m a bit of a pack-rat, my bookshelf holds all 3 printed
editions, I bought the beta versions of at least the 3rd and upcoming
4th editions. I always used to pre-order the paper copy, but since I
seem to be able to comfortably read books and the like on my iPad
(something I was never comfortable with on a desktop or laptop). I
decided to just go with the soft copy,

  • It hasn’t been mentioned, but the reason rails went from sequence
    numbered to timestamped migrations is that on projects with more than
    one developer it was not uncommon to have collisions over the
    numbering when different developers were working on different
    branches. Since it’s highly unlikely that two developers will
    generate migrations at the same second, this goes a long way to
    alleviate the problem. As with many things in Rails, it started out
    as a patch/plugin from some Rails user and eventually got assimilated
    into the Borg^h^h^h^h^h^h^h^hRails.


Rick DeNatale

Blog: http://talklikeaduck.denhaven2.com/
Github: http://github.com/rubyredrick
Twitter: @RickDeNatale
WWR: http://www.workingwithrails.com/person/9021-rick-denatale
LinkedIn: http://www.linkedin.com/in/rickdenatale

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs