Migrations

Legacy systems

To align existing systems run the commands:

find . -path "*/migrations/*.py" -not -name "__init__.py" -delete
find . -path "*/migrations/*.pyc"  -delete

git reset --hard
git pull origin master (o checkout)

which deletes the py and pyc files inside the folder migrations.

Pull and align the database by hand for the last time.

launch the command from active virtualenv:

python manage.py migrate --fake

Current systems

For subsequent releases, run the command ./relase.sh which cleans it from the master and launches the migrations, collectstatic and restart

Use migrations normally.

If a script has changed, update the file in / scripts / migrations_scripts and run:

python manage.py makemigrations kpis --empty

and edit the migrations file with:

    migrations_array = []
f = 'scripts\migrations_scripts\sp_set_imported_values_for_export.sql'
with open(os.path.join(settings.AGREGG_DIR, f), 'r') as myfile:
    data = myfile.read()
    migrations_array.append(migrations.RunSQL(data))

operations = migrations_array