[openstreetmap/openstreetmap-website] Models in migrations (#2320)

Andy Allan notifications at github.com
Wed Jul 17 10:23:39 UTC 2019


A recent change to the user model triggered breakages in the database migrations. This is because the migrations have, until now, been using the live model in old migrations. When there is a table name change, or certain column changes, in the live model, this can blow up the old migration.

Instead, it's best practise that if a model is needed during the migration, the model is defined within the migration. This ensures that the model picks up the table name, columns etc that match what's in the database at that stage.

You can view, comment on, or merge this pull request online at:

  https://github.com/openstreetmap/openstreetmap-website/pull/2320

-- Commit Summary --

  * Avoid using live models in old migrations
  * Avoid more models in old migrations

-- File Changes --

    M db/migrate/005_tile_tracepoints.rb (4)
    M db/migrate/006_tile_nodes.rb (8)
    M db/migrate/013_add_email_valid.rb (3)
    M db/migrate/039_add_more_controls_to_gpx_files.rb (4)
    M db/migrate/044_create_user_roles.rb (6)
    M db/migrate/046_alter_user_roles_and_blocks.rb (3)
    M db/migrate/051_add_status_to_user.rb (3)
    M db/migrate/20110322001319_add_terms_seen_to_user.rb (3)
    M db/migrate/20120208122334_merge_acl_address_and_mask.rb (3)
    M db/migrate/20120219161649_add_user_image_fingerprint.rb (3)
    M db/migrate/20120808231205_add_counter_caches.rb (7)
    M db/migrate/20121005195010_add_diary_entry_counter_caches.rb (6)
    M db/migrate/20121012044047_add_image_use_gravatar_to_users.rb (3)
    M db/migrate/20150111192335_subscribe_old_changesets.rb (3)
    M db/migrate/20150222101847_rename_openid_url.rb (3)
    M db/migrate/20161011010929_subscribe_authors_to_diary_entries.rb (3)
    M db/migrate/20180204153242_tile_users.rb (3)

-- Patch Links --

https://github.com/openstreetmap/openstreetmap-website/pull/2320.patch
https://github.com/openstreetmap/openstreetmap-website/pull/2320.diff

-- 
You are receiving this because you are subscribed to this thread.
Reply to this email directly or view it on GitHub:
https://github.com/openstreetmap/openstreetmap-website/pull/2320
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.openstreetmap.org/pipermail/rails-dev/attachments/20190717/f816fb1c/attachment.html>


More information about the rails-dev mailing list