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

Squash migrations #31

Closed
dennissiemensma opened this issue Feb 3, 2016 · 6 comments
Closed

Squash migrations #31

dennissiemensma opened this issue Feb 3, 2016 · 6 comments
Assignees
Milestone

Comments

@dennissiemensma
Copy link
Member

Originally reported by: Dennis Siemensma (Bitbucket: dennissiemensma, GitHub: dennissiemensma)


https://docs.djangoproject.com/es/1.9/topics/migrations/#squashing-migrations

Can only be executed (remove old migrations) when every user has deployed all migrations squeezed.

  • ./manage.py squashmigrations dsmr_stats 0012_meta
  • ./manage.py squashmigrations dsmr_weather 0002_meta

@dennissiemensma
Copy link
Member Author

I will only squash dsmr_stats, reducing 16 migrations (files) to just a single one.

It also renders all runPython migrations obsolete, as Django will run the old migrations for checkouts halfway migrated and the squashed ones for new checkouts.

@dennissiemensma dennissiemensma removed their assignment Feb 8, 2016
@dennissiemensma dennissiemensma modified the milestones: 1.0.0, 0.9 (β), 1.1.0 Feb 8, 2016
@dennissiemensma dennissiemensma modified the milestones: 1.0.0, 0.11 (β) Feb 16, 2016
@dennissiemensma dennissiemensma modified the milestones: 0.13 (β), 1.0.0 Mar 5, 2016
@dennissiemensma dennissiemensma self-assigned this Mar 5, 2016
@dennissiemensma
Copy link
Member Author

I will also drop any prints in legacy migration, as they are deployed everywhere by now. RunPython-migrations will be dropped completely in the squashed version, because they only fix existing data.

@dennissiemensma
Copy link
Member Author

  • ./manage.py squashmigrations dsmr_consumption 0004_recalculate_gas_consumption
  • ./manage.py squashmigrations dsmr_datalogger 0005_optional_gas_readings
  • ./manage.py squashmigrations dsmr_stats 0016_drop_stats_settings

Added a runpython for database init of MeterStatistics.objects.create().

@dennissiemensma
Copy link
Member Author

I think I'm running into a migration bug in Django, but I'm not sure. It seems index operations for MySQL and PostgreSQL do not respect the operation order. When a squashed migration ends up having this:

  • Create model
  • Add field with index
  • Drop model

Then the creation of the index is delayed after dropping the model, which is denied by the database. Only SQLite seems unaffected.

@dennissiemensma
Copy link
Member Author

Seems related to:

I think the reason behind is that squashmigrations doesn't remove the model from the migrations. It shouldn't exist at all.

Fow now I will fix it manually by dropping db_index=True attribute of the model created and dropped later.

dennissiemensma added a commit that referenced this issue Mar 5, 2016
dennissiemensma added a commit that referenced this issue Mar 5, 2016
dennissiemensma added a commit that referenced this issue Mar 5, 2016
@dennissiemensma
Copy link
Member Author

Merged & deployed.

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

No branches or pull requests

1 participant