Squash Django migrations
Maintaining a Django (and Wagtail) platform over multiple years comes with some challenges. Although Django is build to scale there are some things to consider while keeping your codebase clean. One of them is the amount of migration files checked into Git. Especially Wagtail migrations are growing hard when building a lot of page types and content blocks (due the fact StreamFields internally supports migrations as well).Luckely Django has support to squash migrations. This makes squashing a lot easier (remember connecting to remote databases and manualy apply migrations with Django South) and fully compatible with your common used Continuous Deployment architectures.
Maintaining a Django (and Wagtail) platform over multiple years comes with some challenges. Although Django is build to scale there are some things to consider while keeping your codebase clean. One of them is the amount of migration files checked into Git. Especially Wagtail migrations are growing hard when building a lot of page types and content blocks (due the fact StreamFields internally supports migrations as well).
Luckely Django has support to squash migrations. This makes squashing a lot easier (remember connecting to remote databases and manualy apply migrations with Django South) and fully compatible with your common used Continuous Deployment architectures.
$ ./manage.py squashmigrations myapp 0004 Will squash the following migrations: - 0001_initial - 0002_some_change - 0003_another_change - 0004_undo_something Do you wish to proceed? [yN] y Optimizing... Optimized from 12 operations to 7 operations. Created new squashed migration /home/andrew/Programs/DjangoTest/test/migrations/0001_squashed_0004_undo_something.py You should commit this migration but leave the old ones in place; the new migration will be used for new installs. Once you are sure all instances of the codebase have applied the migrations you squashed, you can delete them.
A more detailed explanation about squashing migrations can be found at the Django documentation.
Over de auteur
Rob Moorman
Iets aan gehad? Deel het artikel.
Andere artikelen
Bekijk alle artikelen-
Werk sneller met herbruikbare content in Vio
Als contentbeheerder wil je snel kunnen werken, zonder concessies te doen aan kwaliteit of consistentie. Lees er meer over in ons blog.
-
Geen plugins, wel alles wat je nodig hebt
Als contentbeheerder wil je snel kunnen werken, zonder concessies te doen aan kwaliteit of consistentie. Lees er meer over in ons blog.
-
Maak sneller betere content met de Vio AI app
Maak, corrigeer of redirigger sneller betere content met de Vio AI app. Lees er meer over in ons blog.
-
Vio vs Wordpress: een eerlijke vergelijking
WordPress is een van de bekendste CMS’en. Vio zich onderscheidt met gebruiksvriendelijkheid, veiligheid en schaalbaarheid. Lees er meer over in ons blog.
-
5 tips om je website optimaal te beveiligen
Datalekken en cyberaanvallen kunnen enorme gevolgen hebben. Vio maakt het eenvoudig om je website optimaal te beveiligen. Lees er meer over in ons blog.
-
7 Signalen dat jouw CMS dringend toe is aan vervanging
Herken je één of meer van deze signalen? Dan is het tijd voor een upgrade. Lees er meer over in ons blog.
-
Waarom updates essentieel zijn voor je website
Het up-to-date houden van een website blijft voor veel bedrijven een uitdaging. Waarom het toch essentieel is? Lees er meer over in ons blog.
-
Vio, een duurzaam en toekomstbestendig CMS
Wat maakt Vio een duurzame en toekomstbestendige keuze voor jouw organisatie? Lees er meer over in ons blog.
-
Gebruiksvriendelijkheid: essentieel voor elke organisatie
In een wereld waar snelheid en eenvoud de norm zijn, is een gebruiksvriendelijk CMS de basis voor succes. Lees er meer over in ons blog.
-
Fix Docker no space left on device
When doing a lot with Docker locally every developer find themselves with the no space left on device error message. Even though the error doesn't occur it's good to often …
Rob Moorman
-
Setup a SSH tunnel
Often you need to migrate production data back to your development environment.In our case we use virtual private networks with strict private- and public subnets in order to secure our …
Rob Moorman
-
Migrating Wagtail ModelAdmin to the new snippet admin views
With the new snippet admin views the usage of modeladmin becomes outdated. The snippets now leverage the preview & history abilities from Wagtail, similar to the workflow of pages:PreviewDraft & …
Rob Moorman
-
Add Plausible to your Terraform CloudFront distribution
At Vicktor we take data very serious, that's why we have fully adopted Plausible as a simple and privacy-friendly Google Analytics alternative."Plausible is lightweight and open source web analytics. No …
Rob Moorman
-
Beautiful asserts with your Django Test Client
When you write tests using the [Django Test Client](https://docs.djangoproject.com/en/4.1/topics/testing/tools/#the-test-client) you often want to check for error messages being displayed correctly, or if a page renders specific HTML elements.
Rob Moorman
-
Structural pattern matching with Python 3.10 (AKA "Switch/Case")
Python has been designed to be a very readable and compact programming language [since the language was born in 1991](https://en.wikipedia.org/wiki/Python_(programming_language)). Indentation is required, semicolons are not needed, readability and elegance …
Rob Moorman
-
A Private PyPI server with AWS CodeArtifact
IntroductionWhen you develop a variety of reusable Python packages or apps you soon will be facing the limits of git dependencies. And you don't want to release company / project …
Rob Moorman