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

Ticket #11458 (closed enhancement: fixed)

Opened 1 month ago

Last modified 1 month ago

Timestamped Migrations

Reported by: jbarnette Assigned to: core
Priority: normal Milestone: 2.x
Component: ActiveRecord Version: edge
Severity: normal Keywords:
Cc:

Description

This patch changes migration generation to use a UTC timestamp (YYYYMMDDHHMMSS) instead of a simple sequence. This should help minimize the number of migration collisions as more people do branch-heavy development.

This behavior can be disabled:

# Use a simple numeric sequence instead of UTC timestamps when generating migrations.
config.active_record.timestamped_migrations = false

This patch also adds Rake tasks to run the "up" and "down" actions of a specific migration without changing the persisted schema version.

rake db:migrate:up      # Runs the "up" for a given migration VERSION.
rake db:migrate:down    # Runs the "down" for a given migration VERSION.

Attachments

timestamped-migrations.diff (16.4 kB) - added by jbarnette on 03/28/08 18:51:36.
Git diff: apply with patch -p1
timestamped-migrations-2.diff (15.1 kB) - added by jbarnette on 03/28/08 21:15:12.
No more waffling (patch -p1)
timestamped-migrations-3.diff (15.4 kB) - added by jbarnette on 03/28/08 21:58:16.
10% less suckage (patch -p1)
arrgh.diff (1.7 kB) - added by jbarnette on 03/28/08 22:10:57.
seriously, my codes are perfect (patch -p0)

Change History

03/28/08 18:51:36 changed by jbarnette

  • attachment timestamped-migrations.diff added.

Git diff: apply with patch -p1

03/28/08 21:15:12 changed by jbarnette

  • attachment timestamped-migrations-2.diff added.

No more waffling (patch -p1)

03/28/08 21:21:05 changed by david

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

(In [9122]) Switched to UTC-timebased version numbers for migrations and the schema. This will as good as eliminate the problem of multiple migrations getting the same version assigned in different branches. Also added rake db:migrate:up/down to apply individual migrations that may need to be run when you merge branches (closes #11458) [jbarnette]

03/28/08 21:58:16 changed by jbarnette

  • attachment timestamped-migrations-3.diff added.

10% less suckage (patch -p1)

03/28/08 22:10:57 changed by jbarnette

  • attachment arrgh.diff added.

seriously, my codes are perfect (patch -p0)