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

Added note about preventing unexpected DB schema diffs #773

Merged
merged 1 commit into from
Aug 19, 2024

Conversation

ryanb-gds
Copy link
Contributor

This has become a bit of an annoying issue for the Whitehall team over time, and has sometimes led to changes to the schema.rb file not being committed when they should have been.

Trello: https://trello.com/c/Ai59Yd1F

Copy link
Contributor

@ChrisBAshton ChrisBAshton left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, one small suggestion below


It is common to find that running `rake db:migrate` results in unexpected changes to the `schema.rb` file. This is caused by slight differences between databases running in GOV.UK Docker and the production databases on AWS.

Unfortunately, to resolve the issue, the only solution is to drop the database in GOV.UK docker and create a new one. This is annoying if you've built up a useful corpus of development data, so you might want to take a backup containing just the data. For MySQL you can do this using the [--no-create-info](https://dev.mysql.com/doc/refman/8.4/en/mysqldump-definition-data-dumps.html) option with MySQL dump, for Postgres you can use the `--data-only` option for PostgreSQL dump.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you include the exact command you used to create the data backup? As I'd still have to go and Google how to do a data dump and then figure out where to pass this parameter.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I could, but i haven't actually ever done this, so it's entirely theoretical. I suppose I should probably google it on behalf of everyone else instead of being lazy 😅

The other point I hadn't really thought about is that for this to be that useful you would probably need to back up all the databases (publishing app, publishing API, content store, router API, asset manager) so it probably isn't going to be worth it. Though maybe you could just republish all the content from Whitehall 🤔

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In that case I'd probably delete everything after the first sentence - someone else can document it at the point of use if they end up taking a backup 👍

(NB I'd think it's easier to drop the DB and then reimport it from the local tar download in govuk-docker, assuming that's not been deleted by the user since they last downloaded a backup from AWS)

This has become a bit of an annoying issue for the Whitehall team over time, and has sometimes led to changes to the schema.rb file not being committed when they should have been.
@ryanb-gds ryanb-gds force-pushed the add-troubleshooting-note-about-mismatching-schemas branch from 06a8edf to dac8f54 Compare August 19, 2024 09:56
@ryanb-gds ryanb-gds merged commit f6a6c2d into main Aug 19, 2024
2 checks passed
@ryanb-gds ryanb-gds deleted the add-troubleshooting-note-about-mismatching-schemas branch August 19, 2024 10:00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants