Ruby on Rails | Screencasts | Download | Documentation | Weblog | Community | Source

Ticket #10377 (closed enhancement: fixed)

Opened 2 years ago

Last modified 2 years ago

[PATCH] db:test:prepare should fail if there are pending migrations

Reported by: joshknowles Assigned to: core
Priority: low Milestone: 2.x
Component: Railties Version: edge
Severity: minor Keywords: verified
Cc:

Description

This patch forces the db:test:prepare rake task to fail if there are pending migrations. This has proved very helpful on a large team to prevent people from running "svn up; rake test" without first running "rake db:migrate"

Attachments

error_if_pending_migrations.patch (1.0 kB) - added by joshknowles on 12/05/07 18:03:17.
error_if_pending_migrations_2.patch (2.0 kB) - added by brynary on 12/05/07 18:35:12.
Updated joshknowles patch to print the specific pending migrations and work when running "rake test".
pending_migrations.patch (0.6 kB) - added by joshknowles on 12/06/07 02:37:08.
update_rake_tasks_to_error_if_pending_migrations.patch (1.8 kB) - added by joshknowles on 12/06/07 02:37:19.

Change History

12/05/07 17:35:58 changed by jbarnette

+1. I've been running into this a lot lately as our team has grown. Obnitpicks: Since db:error_if_pending_migrations is only used in one place, there doesn't seem to be much point to having it be a separate task. Also, it's nice when error messages provide a solution. How about something like this? "You have 2 pending migrations. Run "rake db:migrate" to update your database."

12/05/07 17:51:53 changed by dneighbors

+1. I could really use this patch.

12/05/07 18:03:17 changed by joshknowles

  • attachment error_if_pending_migrations.patch added.

12/05/07 18:03:48 changed by joshknowles

I've updated the patch with the feedback provided by jbarnette.

12/05/07 18:35:12 changed by brynary

  • attachment error_if_pending_migrations_2.patch added.

Updated joshknowles patch to print the specific pending migrations and work when running "rake test".

12/05/07 18:38:07 changed by brynary

  • keywords set to verified.

+1-ing

12/05/07 19:23:22 changed by tolsen

+1. I've tested both patches

12/06/07 00:28:55 changed by matt

+1

12/06/07 01:40:43 changed by trek

+1-ing. this would quite handy.

12/06/07 02:37:08 changed by joshknowles

  • attachment pending_migrations.patch added.

12/06/07 02:37:19 changed by joshknowles

  • attachment update_rake_tasks_to_error_if_pending_migrations.patch added.

12/06/07 02:39:40 changed by joshknowles

Per recommendation by bitsweat I've refactored this patch to be split into two patches, one which updates Migrator for the list of pending_migrations, and another which leverages this for the rake tasks.

12/06/07 06:14:35 changed by chuyeow

+1. Very useful on teams of any size.

There's a typo ('contiuing') in this line:

raise "Stopping. Please run 'rake db:migrate' before contiuing." 

12/06/07 18:23:16 changed by jade

+1 I run into this a lot

12/06/07 18:57:23 changed by bitsweat

  • status changed from new to closed.
  • resolution set to fixed.

(In [8324]) The test task stops with a warning if you have pending migrations. Closes #10377.