[openstreetmap/openstreetmap-website] Simplify primary key for relation members tables (PR #4300)

Tom Hughes notifications at github.com
Wed Oct 18 16:00:29 UTC 2023


The two relation members tables have, for some reason that I don't really understand, a primary key that includes all the fields rather than just those needed to identify the member uniquely.

We then have to lie to rails about the primary key makeup in order for things to work properly.

I can't see any purpose to this - there don't seem to be any relationships or queries that would be helped by the extra fields, and having noise between `version` and `sequence_id` means postgres won't be able to assume ordering during an index read of members for a relation and will have to do a sort.
You can view, comment on, or merge this pull request online at:

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

-- Commit Summary --

  * Remove extraneous fields from primary keys for relation members
  * Assign proper sequence numbers to relation members in tests

-- File Changes --

    A db/migrate/20231010194809_correct_relation_members_primary_key.rb (11)
    M db/structure.sql (5)
    M test/controllers/api/changesets_controller_test.rb (16)
    M test/controllers/api/relations_controller_test.rb (12)
    M test/factories/relation_member.rb (1)
    M test/models/old_relation_test.rb (28)
    M test/models/relation_test.rb (20)

-- Patch Links --

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

-- 
Reply to this email directly or view it on GitHub:
https://github.com/openstreetmap/openstreetmap-website/pull/4300
You are receiving this because you are subscribed to this thread.

Message ID: <openstreetmap/openstreetmap-website/pull/4300 at github.com>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.openstreetmap.org/pipermail/rails-dev/attachments/20231018/3c612924/attachment-0001.htm>


More information about the rails-dev mailing list