<blockquote>
<p>The <code>structure.sql</code> file is basically just rough documentation (personally I would get rid of it but people insist on having it) and should not be treated as gospel truth as it often picks up random bits of breakage from people's development databases which have complex histories.</p>
</blockquote>
<p>I disagree. The structure.sql should exactly mirror the database structure, and eventually we should the oldest migrations (e.g. when they are more than 3-4 years old). There's a good explanation of why in the <a href="https://edgeguides.rubyonrails.org/active_record_migrations.html#schema-dumping-and-you" rel="nofollow">rails documentation</a> and elsewhere in blog posts. There are migrations written more than a decade ago, for different versions of postgres and different assumptions in active_record and trying to revisit them over and over every few years is unnecessary when we have a structure file that explicitly states the end result.</p>
<p>But of course, it doesn't matter if <a class="user-mention" data-hovercard-type="user" data-hovercard-url="/hovercards?user_id=147741" data-octo-click="hovercard-link-click" data-octo-dimensions="link_type:self" href="https://github.com/tomhughes">@tomhughes</a> and I disagree on this topic, so long as we have both the migrations, and the schema, and that they both match the real database! Any discrepancies between the production database and the schema.sql are bugs and definitely need to be fixed. Old migrations can also be changed (e.g. for bigint/integer changes as rails has evolved) but this is a bit more hard work.</p>
<p style="font-size:small;-webkit-text-size-adjust:none;color:#666;">—<br />You are receiving this because you are subscribed to this thread.<br />Reply to this email directly, <a href="https://github.com/openstreetmap/openstreetmap-website/issues/2211#issuecomment-484169428">view it on GitHub</a>, or <a href="https://github.com/notifications/unsubscribe-auth/ABWnLdCgXOUN0tiYgBmtio5BP5eziN8Dks5vh08tgaJpZM4cxnxU">mute the thread</a>.<img src="https://github.com/notifications/beacon/ABWnLc-8bRfk_FeOxBx8_1V-iqvXjTatks5vh08tgaJpZM4cxnxU.gif" height="1" width="1" alt="" /></p>
<script type="application/json" data-scope="inboxmarkup">{"api_version":"1.0","publisher":{"api_key":"05dde50f1d1a384dd78767c55493e4bb","name":"GitHub"},"entity":{"external_key":"github/openstreetmap/openstreetmap-website","title":"openstreetmap/openstreetmap-website","subtitle":"GitHub repository","main_image_url":"https://github.githubassets.com/images/email/message_cards/header.png","avatar_image_url":"https://github.githubassets.com/images/email/message_cards/avatar.png","action":{"name":"Open in GitHub","url":"https://github.com/openstreetmap/openstreetmap-website"}},"updates":{"snippets":[{"icon":"PERSON","message":"@gravitystorm in #2211: \u003e The `structure.sql` file is basically just rough documentation (personally I would get rid of it but people insist on having it) and should not be treated as gospel truth as it often picks up random bits of breakage from people's development databases which have complex histories.\r\n\r\nI disagree. The structure.sql should exactly mirror the database structure, and eventually we should the oldest migrations (e.g. when they are more than 3-4 years old). There's a good explanation of why in the [rails documentation](https://edgeguides.rubyonrails.org/active_record_migrations.html#schema-dumping-and-you) and elsewhere in blog posts. There are migrations written more than a decade ago, for different versions of postgres and different assumptions in active_record and trying to revisit them over and over every few years is unnecessary when we have a structure file that explicitly states the end result.\r\n\r\nBut of course, it doesn't matter if @tomhughes and I disagree on this topic, so long as we have both the migrations, and the schema, and that they both match the real database! Any discrepancies between the production database and the schema.sql are bugs and definitely need to be fixed. Old migrations can also be changed (e.g. for bigint/integer changes as rails has evolved) but this is a bit more hard work."}],"action":{"name":"View Issue","url":"https://github.com/openstreetmap/openstreetmap-website/issues/2211#issuecomment-484169428"}}}</script>
<script type="application/ld+json">[
{
"@context": "http://schema.org",
"@type": "EmailMessage",
"potentialAction": {
"@type": "ViewAction",
"target": "https://github.com/openstreetmap/openstreetmap-website/issues/2211#issuecomment-484169428",
"url": "https://github.com/openstreetmap/openstreetmap-website/issues/2211#issuecomment-484169428",
"name": "View Issue"
},
"description": "View this Issue on GitHub",
"publisher": {
"@type": "Organization",
"name": "GitHub",
"url": "https://github.com"
}
}
]</script>