Skip to content

Commit

Permalink
Merge pull request #773 from alphagov/add-troubleshooting-note-about-…
Browse files Browse the repository at this point in the history
…mismatching-schemas

Added note about preventing unexpected DB schema diffs
  • Loading branch information
ryanb-gds authored Aug 19, 2024
2 parents ff646d9 + dac8f54 commit f6a6c2d
Showing 1 changed file with 16 additions and 0 deletions.
16 changes: 16 additions & 0 deletions docs/troubleshooting.md
Original file line number Diff line number Diff line change
Expand Up @@ -205,3 +205,19 @@ This may resolve by removing orphan containers which were created in a previous
```
docker-compose down -v --rmi all --remove-orphans
```


## Rails database schema changed unexpectedly when running `rake db:migrate`

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.

Once you have taken a backup, you can remove and re-create your local database using the following commands:

```bash
rake db:drop
rake db:create
rake db:schema:load
rake db:schema:migrate // optional, but if you are adding a new migration this will now update the schema without creating a horrible diff
```

0 comments on commit f6a6c2d

Please sign in to comment.