Django: Getting Started Transcripts
Chapter: DB Migrations
Lecture: Squashing migrations together

Login or purchase this course to watch this video and the rest of the course contents.
0:00 Say you've been tinkering around for a while and you've added a lot of migration scripts.
0:05 There might be a big difference between your current state and production and all those
0:10 scripts you've got in development and that will mean a lot would have to be run at your next deployment.
0:17 You can optimize this a bit by squishing migrations together. You do that with the squash migrations command.
0:30 The argument here specifies the ending point for the squash and all the scripts up to it, get included in the squash.
0:40 Let me go back to the migrations directory. The new file here is named after the start an end state of the squash. Let's open it up.
0:56 The replaces attribute tells Django what was squashed. Thus enabling the migrations command to know to run this script instead of the others.
1:05 This means you don't have to get rid of the old files, which gives you a nice clean way to back out of this squishing if you need to.
1:11 The result of squishing a create and a field add is just a single create. but this create has both the title and artist name fields inside of it.

Talk Python's Mastodon Michael Kennedy's Mastodon