<p dir="auto">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.</p>
<p dir="auto">We then have to lie to rails about the primary key makeup in order for things to work properly.</p>
<p dir="auto">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 <code class="notranslate">version</code> and <code class="notranslate">sequence_id</code> 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.</p>
<hr>
<h4>You can view, comment on, or merge this pull request online at:</h4>
<p> <a href='https://github.com/openstreetmap/openstreetmap-website/pull/4300'>https://github.com/openstreetmap/openstreetmap-website/pull/4300</a></p>
<h4>Commit Summary</h4>
<ul>
<li><a href="https://github.com/openstreetmap/openstreetmap-website/pull/4300/commits/c2b687d87128d4d64f778158c2ccc60de75e524b" class="commit-link">c2b687d</a> Remove extraneous fields from primary keys for relation members</li>
<li><a href="https://github.com/openstreetmap/openstreetmap-website/pull/4300/commits/428c7c6deffafde2025c0dae156a08e56c1c3f4b" class="commit-link">428c7c6</a> Assign proper sequence numbers to relation members in tests</li>
</ul>
<h4 style="display: inline-block">File Changes </h4> <p style="display: inline-block">(<a href="https://github.com/openstreetmap/openstreetmap-website/pull/4300/files">7 files</a>)</p>
<ul>
<li>
<strong>A</strong>
<a href="https://github.com/openstreetmap/openstreetmap-website/pull/4300/files#diff-3ca4193888f130a34bae719f93719c8348576a099c74ee4317fe50ae84988690">db/migrate/20231010194809_correct_relation_members_primary_key.rb</a>
(11)
</li>
<li>
<strong>M</strong>
<a href="https://github.com/openstreetmap/openstreetmap-website/pull/4300/files#diff-1dd5a8f580b9615769ddc19a64a98f455d9d20eb149c443f41d9d3c797d39b12">db/structure.sql</a>
(5)
</li>
<li>
<strong>M</strong>
<a href="https://github.com/openstreetmap/openstreetmap-website/pull/4300/files#diff-e95198c7f7744be3ce9857db36d2374538ca7d64caaf0f6f85865d6752563ee9">test/controllers/api/changesets_controller_test.rb</a>
(16)
</li>
<li>
<strong>M</strong>
<a href="https://github.com/openstreetmap/openstreetmap-website/pull/4300/files#diff-da8c6d0ce9e50a5d0d4517cb17a60cc0df2f286b573ea8132fd903ad8c227237">test/controllers/api/relations_controller_test.rb</a>
(12)
</li>
<li>
<strong>M</strong>
<a href="https://github.com/openstreetmap/openstreetmap-website/pull/4300/files#diff-41f80dd7fe83fa4c4ff9472b9623d25fb68e0520f2cdb9390c42384475835698">test/factories/relation_member.rb</a>
(1)
</li>
<li>
<strong>M</strong>
<a href="https://github.com/openstreetmap/openstreetmap-website/pull/4300/files#diff-28e1d1cd524f99ebcc4e40698c76858d54b8ca3905f994b16ec524d247faa19d">test/models/old_relation_test.rb</a>
(28)
</li>
<li>
<strong>M</strong>
<a href="https://github.com/openstreetmap/openstreetmap-website/pull/4300/files#diff-f4f4607eb834bc83b509a1de9b73cedd7a01c205ce922f034c37841beab1007b">test/models/relation_test.rb</a>
(20)
</li>
</ul>
<h4>Patch Links:</h4>
<ul>
<li><a href='https://github.com/openstreetmap/openstreetmap-website/pull/4300.patch'>https://github.com/openstreetmap/openstreetmap-website/pull/4300.patch</a></li>
<li><a href='https://github.com/openstreetmap/openstreetmap-website/pull/4300.diff'>https://github.com/openstreetmap/openstreetmap-website/pull/4300.diff</a></li>
</ul>
<p style="font-size:small;-webkit-text-size-adjust:none;color:#666;">—<br />Reply to this email directly, <a href="https://github.com/openstreetmap/openstreetmap-website/pull/4300">view it on GitHub</a>, or <a href="https://github.com/notifications/unsubscribe-auth/AAK2OLL5ND4YIFB46RMD3ALX774J3AVCNFSM6AAAAAA6FYQFWGVHI2DSMVQWIX3LMV43ASLTON2WKOZRHE2TAMBZHAYTAMA">unsubscribe</a>.<br />You are receiving this because you are subscribed to this thread.<img src="https://github.com/notifications/beacon/AAK2OLKLJKVLQTCKJRDQ2STX774J3A5CNFSM6AAAAAA6FYQFWGWGG33NNVSW45C7OR4XAZNFJFZXG5LFVJRW63LNMVXHIX3JMTHHIPBCWQ.gif" height="1" width="1" alt="" /><span style="color: transparent; font-size: 0; display: none; visibility: hidden; overflow: hidden; opacity: 0; width: 0; height: 0; max-width: 0; max-height: 0; mso-hide: all">Message ID: <span><openstreetmap/openstreetmap-website/pull/4300</span><span>@</span><span>github</span><span>.</span><span>com></span></span></p>
<script type="application/ld+json">[
{
"@context": "http://schema.org",
"@type": "EmailMessage",
"potentialAction": {
"@type": "ViewAction",
"target": "https://github.com/openstreetmap/openstreetmap-website/pull/4300",
"url": "https://github.com/openstreetmap/openstreetmap-website/pull/4300",
"name": "View Pull Request"
},
"description": "View this Pull Request on GitHub",
"publisher": {
"@type": "Organization",
"name": "GitHub",
"url": "https://github.com"
}
}
]</script>