# Migration numbers

**URL:** <https://www.ruby-forum.com/t/migration-numbers/192439>\
**Category:** Rails\
**Created:** [July 30, 2010, 11:36am UTC](https://www.ruby-forum.com/t/migration-numbers/192439 "2010-07-30T11:36:53Z")\
**Posts on this page:** 9\
**Page:** 1

<div class="post-metadata">

**Author:** ![disruptivetechnolog](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/ce7236/32.png) [@disruptivetechnolog](https://www.ruby-forum.com/u/disruptivetechnolog)\
**Post date:** [July 30, 2010, 11:36am UTC](https://www.ruby-forum.com/t/migration-numbers/192439/1 "2010-07-30T11:36:53Z")

</div>

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?

---

<div class="post-metadata">

**Author:** ![disruptivetechnolog](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/ce7236/32.png) [@disruptivetechnolog](https://www.ruby-forum.com/u/disruptivetechnolog)\
**Post date:** [July 30, 2010, 11:46am UTC](https://www.ruby-forum.com/t/migration-numbers/192439/2 "2010-07-30T11:46:28Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![disruptivetechnolog](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/ce7236/32.png) [@disruptivetechnolog](https://www.ruby-forum.com/u/disruptivetechnolog)\
**Post date:** [July 30, 2010, 11:46am UTC](https://www.ruby-forum.com/t/migration-numbers/192439/3 "2010-07-30T11:46:50Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![disruptivetechnolog](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/ce7236/32.png) [@disruptivetechnolog](https://www.ruby-forum.com/u/disruptivetechnolog)\
**Post date:** [July 30, 2010, 11:46am UTC](https://www.ruby-forum.com/t/migration-numbers/192439/4 "2010-07-30T11:46:56Z")

</div>

On Jul 30, 10:36 am, Dis T. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) 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

---

<div class="post-metadata">

**Author:** ![disruptivetechnolog](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/ce7236/32.png) [@disruptivetechnolog](https://www.ruby-forum.com/u/disruptivetechnolog)\
**Post date:** [July 30, 2010, 11:47am UTC](https://www.ruby-forum.com/t/migration-numbers/192439/5 "2010-07-30T11:47:40Z")

</div>

Frederick C. wrote:

> On Jul 30, 10:36ï¿½am, Dis T. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) 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.

---

<div class="post-metadata">

**Author:** ![disruptivetechnolog](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/ce7236/32.png) [@disruptivetechnolog](https://www.ruby-forum.com/u/disruptivetechnolog)\
**Post date:** [July 30, 2010, 1:42pm UTC](https://www.ruby-forum.com/t/migration-numbers/192439/6 "2010-07-30T13:42:19Z")

</div>

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…

---

<div class="post-metadata">

**Author:** ![disruptivetechnolog](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/ce7236/32.png) [@disruptivetechnolog](https://www.ruby-forum.com/u/disruptivetechnolog)\
**Post date:** [July 30, 2010, 11:49am UTC](https://www.ruby-forum.com/t/migration-numbers/192439/7 "2010-07-30T11:49:17Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![disruptivetechnolog](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/ce7236/32.png) [@disruptivetechnolog](https://www.ruby-forum.com/u/disruptivetechnolog)\
**Post date:** [July 30, 2010, 2:53pm UTC](https://www.ruby-forum.com/t/migration-numbers/192439/8 "2010-07-30T14:53:08Z")

</div>

You can revert to the sequential numbering scheme by setting  
config.active\_record.timestamped\_migrations to false in config/  
environment.rb.

–Martin

---

<div class="post-metadata">

**Author:** ![disruptivetechnolog](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/ce7236/32.png) [@disruptivetechnolog](https://www.ruby-forum.com/u/disruptivetechnolog)\
**Post date:** [July 30, 2010, 3:43pm UTC](https://www.ruby-forum.com/t/migration-numbers/192439/9 "2010-07-30T15:43:29Z")

</div>

On Fri, Jul 30, 2010 at 7:42 AM, Ar Chron [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) 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/](http://talklikeaduck.denhaven2.com/)  
Github: [rubyredrick (Rick DeNatale) · GitHub](http://github.com/rubyredrick)  
Twitter: @RickDeNatale  
WWR: [http://www.workingwithrails.com/person/9021-rick-denatale](http://www.workingwithrails.com/person/9021-rick-denatale)  
LinkedIn: [http://www.linkedin.com/in/rickdenatale](http://www.linkedin.com/in/rickdenatale)
