diff --git a/DEVELOPING.md b/DEVELOPING.md index b7ab548a9..2af559591 100644 --- a/DEVELOPING.md +++ b/DEVELOPING.md @@ -42,13 +42,33 @@ First of all the `makemigrations` command must be run only if you modified the ` ### 1. You modify `models.py` -Since this models does not have a production environment that runs 24/7, so you don't need to update the production environment with multiple migration files event though Django docs promote making as many migrations as you need to ([see Django migration guidelines](https://docs.djangoproject.com/en/3.0/topics/migrations/#squashing-migrations)). For such reasons please consider doing the following steps: -1. Make your changes to `models.py` -2. Remove the only migration file `0001_initial.py` -3. Run `./manage.py makemigrations` -4. Commit the 'new' migraton file `0001_initial.py` as well as `models.py` within a single commit, and add an appropriate message (e.g. add field X to model Y) +In this case there are 2 situations that arise: -__NOTE__: do not touch the `0002_q3c.py` file as relates to migration operations for using Q3C plugin and related functions! +1. You currently don't have a production environment and/or you are comfortable in dropping all the data in the database. In this case, you don't need to update the production environment with multiple migration files even though Django docs promote making as many migrations as you need to ([see Django migration guidelines](https://docs.djangoproject.com/en/3.0/topics/migrations/#squashing-migrations)). For such reasons please consider doing the following steps: + + 1.1. Make your changes to `models.py`. + + 1.2. Remove all the migration files including `0002_q3c.py`. + + 1.3. Run `./manage.py makemigrations`. This will generate a __NEW__ `0001_initial.py` file. + + 1.4. Commit the new migraton file `0001_initial.py` as well as `models.py` within a single commit, and add an appropriate message (e.g. add field X to model Y). __DO NOT__ commit the removal of `0002_q3c.py`. + + 1.5. Get back the Q3C migration file `git checkout pipeline/migrations/0002_q3c.py`. + +2. You currently have a production environment and/or you do not want to lose all the data in the database. In this situation, you need to be careful not to mess up with the producation database, so please consider doing the following steps: + + 2.1. Make a copy ("dump") of the production database as it is, e.g. (by logging remotely to the server) `pg_dump -h DBHOST_PROD -p DBPORT_PROD -U DBUSER_PROD -Fc -o DBNAME_PROD > prod-backup-$(date +"%F_%H%M").sql`. + + 2.2. Upload the copy to your local development database, e.g. `pg_restore -h DBHOST_DEV -p DBPORT_DEV --verbose --clean --no-acl --no-owner -U DBUSER_DEV -d DBNAME_DEV prod-backup.sql`. + + 2.3. Make your changes to `models.py`. + + 2.4. Run `./manage.py makemigrations` with optional but strongly recommended `-n 'my_migration_name'`. This will generate a new migration file `000X_my_migration_name.py` where X is incremented by 1 with respect the last migration file. + + 2.5. Commit the new migraton file `000X_my_migration_name.py` as well as `models.py` within a single commit, and add an appropriate message (e.g. add field X to model Y) + +__NOTE__: do not modify the `0002_q3c.py` file as it relates to migration operations for using Q3C plugin and related functions! ### 2. Someone else modified `models.py` and you pull the changes