﻿id	summary	reporter	owner	description	type	status	component	version	severity	resolution	keywords	cc	stage	has_patch	needs_docs	needs_tests	needs_better_patch	easy	ui_ux
35508	Add an --ignore-deps flag to squashmigrations	Shai Berger	Clinton Christian	"In large, long-going projects -- the ones whose need for migration squashing is the greatest -- apps have a tendency to develop dependencies upon each other. This entails problems with migrations -- dependencies could be circular, or an app could be removed from the project but the migrations that hold dependencies on it still remain, and {{{squashmigrations}}} faces constraints that makes it very hard to do correctly. Current implementation often generates migrations that make no sense, with dependencies on several migrations from the same app.

As a partial solution, let's add a {{{--ignore-deps}}} flag to {{{squashmigrations}}}. When this flag is applied, the generated squashed migration will

- Only depend on the dependencies of the first migration in the range squashed
- Not include the operations that create or modify relation fields, if these fields refer to models from other apps (deletion can be included)

The idea is that such a migration will be correct, but not complete. Assuming the range of migrations includes the last migrations of the app, it will then be possible to add the missing pieces by a regular {{{makemigrations}}}; but the squashing will still include all the non-ellidable {{{RunSQL}}} and {{{RunPython}}} operations -- the {{{squashmigrations --ignore-deps}}} + {{{makemigrations}}} dance is proposed as a safer alternative to ""migration bankruptcy"", the practice of just removing all the migrations and stating afresh

On a side note: It may be safer to add an operation which enforces that it is indeed called with the last migration of the app in range, and maybe even automatically invokes the following {{{makemigrations}}}, but I think we should trust developers with the lower-level building bricks, which may be useful in other situations as well.

This follows from a [https://forum.djangoproject.com/t/idea-make-squash-migrations-no-deps/23986 discussion on the forum]."	New feature	assigned	Migrations	dev	Normal		squash squashmigrations	Mariusz Felisiak David Wobrock David Sanders Andrew Godwin	Accepted	1	1	1	0	0	0
