Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

AO3-6639 Output current DB schema #4669

Merged
merged 6 commits into from
Dec 1, 2023

Conversation

brianjaustin
Copy link
Member

Pull Request Checklist

Issue

https://otwarchive.atlassian.net/browse/AO3-6639

Purpose

  • Output the latest DB schema (based on a Docker setup)
    • This should make new environment bootstrapping a bit quicker
    • Since Rails upgrades change schema formats, we will have a record of things now before Rails 7
  • Change the schema output process to update schema.rb when a new migration runs; this will make it so PRs with migrations update by default, saving us work later (we update the structure SQL separately, and that will stay manual as MySQL formats may change to not match real prod)

Credit

Brian Austin (they/he)

@brianjaustin brianjaustin added the Scope: Tests Only Only changes automated tests or test configuration label Nov 21, 2023
@brianjaustin
Copy link
Member Author

(This isn't quite tests, but that's the closest label.)

config/application.rb Outdated Show resolved Hide resolved
@Bilka2
Copy link
Contributor

Bilka2 commented Nov 22, 2023

Things I noticed:
Some tables lost the ENGINE=InnoDB option and new tables don't have it. MariaDB defaults to innodb so that seems fine.
The limit option on text columns was converted to size. size is specific to the mysql adapter/schema (and doesnt show up in the docs). Since that's the adapter that's getting used, that also seems fine.

Based on https://github.com/otwcode/otwarchive/wiki/Migrations#why-not-dumping-from-development-environments it may be better to run this in production, not in a local docker setup.

@github-actions github-actions bot removed the Scope: Tests Only Only changes automated tests or test configuration label Nov 22, 2023
@brianjaustin
Copy link
Member Author

Based on https://github.com/otwcode/otwarchive/wiki/Migrations#why-not-dumping-from-development-environments it may be better to run this in production, not in a local docker setup.

I pulled the schema from a prod DB and it's almost the same as the one from Docker (compare the last 2 commits to see the few differences).

In terms of updating the schema on migrate with Docker, I think it's a tradeoff between 100% exact match against prod and staying more up-to-date. Since we never recreated the prod database from schema.rb, but often do so for Docker, I'm more inclined towards auto-updating the schema and accepting a few slight differences from prod (we can and have dumped the exact structure as SQL elsewhere)

@Bilka2
Copy link
Contributor

Bilka2 commented Nov 22, 2023

Agreed to the reasoning for keeping the Docker schema, good to see that there are no major differences.

Regarding the config, the docs suggest setting dump_schema_after_migration to false in production (and likely also staging).

@brianjaustin
Copy link
Member Author

(I've added the SQL dump too per conversation with @Bilka2 elsewhere; I'd recommend skimming it at most since the diff is a bit larger.)

@Bilka2
Copy link
Contributor

Bilka2 commented Nov 24, 2023

I looked over the SQL dump and it looks consistent with the rb dump and good in general 👍

@sarken sarken merged commit 820914f into otwcode:master Dec 1, 2023
25 checks passed
@brianjaustin brianjaustin deleted the AO3-6639-schema-dump branch January 27, 2024 18:59
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants