This project is archived and is in readonly mode.

#845 ✓resolved
Jeremy Weiskotten

rake db:migrate queries the schema_migrations table many times (unnecessarily?)

Reported by Jeremy Weiskotten | August 25th, 2008 @ 04:59 PM | in 2.x

Here's the log when running "rake db:migrate" when there are 4 migrations in the db/migrate folder (all have already been run).


  SQL (0.008272)   SELECT version FROM schema_migrations
  SQL (0.000360)   SELECT version FROM schema_migrations
  SQL (0.000286)   SELECT version FROM schema_migrations
  SQL (0.000271)   SELECT version FROM schema_migrations
Migrating to CreateSessions (20080812190111)
  SQL (0.000289)   SELECT version FROM schema_migrations
Migrating to CreateUsers (20080812190627)
  SQL (0.000256)   SELECT version FROM schema_migrations
Migrating to AddDefaultUser (20080812205823)
  SQL (0.000256)   SELECT version FROM schema_migrations
Migrating to AddUsersAdmin (20080813112503)
  SQL (0.000266)   SELECT version FROM schema_migrations
  SQL (0.000309)   SELECT version FROM schema_migrations

It appears to be fetching the list of versions once per migration file found in db/migrate, and then some.

This isn't too bad with only a handful of migrations, but older, larger projects with hundreds of migrations can take a while to run, even if you're up to date. The db:migrate task could be smarter and only fetch the versions once at start.

Comments and changes to this ticket

Create your profile

Help contribute to this project by taking a few moments to create your personal profile. Create your profile »

<h2 style="font-size: 14px">Tickets have moved to Github</h2>

The new ticket tracker is available at <a href="https://github.com/rails/rails/issues">https://github.com/rails/rails/issues</a>

Attachments

Referenced by

Pages