Lighthouse has a new layout. Prefer the old one? Return to the old layout, and switch back any time from the link at the top of each page.

This project is archived and is in readonly mode.

[PATCH] Timestamped migrations should detect collisions

#4412

The timestamp in timestamped migrations does not account for other migrations sharing the same timestamp. The corner case was previously pathological.

One reasonable use case is @James Adam 's suggestion for engine migrations in #2058 Rake tasks for run engine migrations. Briefly, engine migrations are copied into the host app. They are re-indexed at the same time, preserving their relative order while letting the host application keep a single, linear schema history.

This copy & re-index can add many migrations to an application at once, which ActiveRecord::Generators::Base.next_migration_number will naively timestamp to the same second.

One solution is to have next_migration_number push the returned timestamp 1 second into the future until there's no collision. I'll see if I can brew up a patch.

Reported by phs · April 16th, 2010 @ 03:54 AM

State: resolved
Milestone: none
Assigned to: nobody
Importance: none

Activity

  1. phs
    phs

    The patch. Timestamp migration numbers are [current timestamp, current_migration_number + 1].max

    April 16th, 2010 @ 06:38 AM

  2. phs
    phs
    • Title changed from Timestamped migrations should detect collisions to [PATCH] Timestamped migrations should detect collisions

    April 16th, 2010 @ 06:39 AM

  3. Repository
    Repository
    • State changed from new to resolved

    (from [64373937a393518a6e6a63255176ca297d3c009e]) Make the migration generator handle pre-existing migrations with the same timestamp.

    In the event a migration already exists with that number, the new migration's timestamp will be incremented by 1.

    [#4412 [PATCH] Timestamped migrations should detect collisions state:resolved]

    Signed-off-by: Michael Koziarski michael@koziarski.com
    http://github.com/rails/rails/commit/64373937a393518a6e6a63255176ca...

    April 19th, 2010 @ 03:52 AM