-
Notifications
You must be signed in to change notification settings - Fork 27
WIP Rebuild migrations #1679
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
base: master
Are you sure you want to change the base?
WIP Rebuild migrations #1679
Conversation
bb3b872 to
3caf5b4
Compare
|
Having opened this, I think it is actually better to do this in two steps that then dont rely on committing any changes on the server, as per last comment. So now the process to run this (and test locally) would be to:
Another thought I had was that we may want to do this when we dont think anyone will be using the site, or even disable access temporarily by stopping gunicorn? In case there is an issue with a DB record being updated at the same time as we are running these commands. Although as the schema will not actually alter perhaps its not an issue, I'm not sure. |
|
Couple of quick fire questions:
|
ff5ca91 to
8eb4c7b
Compare
- Adds dependency to the Person model in people add to resolve a dependency error when attempting to reset the duplicates table to zero - Reverts changes made in previous commit which caused an error when trying to reset the moderation_queue table back to zero 2bcdef4#diff-08fed5bc216bd87881c23595b3f49c415b29b39ff68680f4ec405858683791ca
8eb4c7b to
d25cd3f
Compare
I've updated the commit message to explain why I made those changes in the migration file. Also this blog has more detail about the approach in general |
64904b0 to
44bf9f8
Compare
UPDATE - see latest comment below about how to run this locally. Leaving the old commits and description for now though as an example of the alternative
This adds a bash script to reset migrations and recreate them. As this will need to be run on the server manually it would be good to have this tested by others first. Before running, I recommend taking a backup of your database in case anything goes wrong.
The script will do the following:
makemigrations. This creates a set of new initial files which match our current schemaThis will result in uncommitted changes, because we need to keep the old migration files in place to un-apply them before we can generate the new ones. This means there is a slightly awkward scenario of needing to run this on the server and then commit the changes there, where they will need to be pushed back to the repo - but I'm not sure if this is possible?
To avoid this, I could remove the find and delete command from the script, and run this locally and commit it separately. Then on the server we could checkout the previous commit to run the script to reset the migrations, and then checkout the later commit to apply the new files.