﻿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
31761	Gracefull Migration | relation already exists	Graeme Ford	nobody	"I have noticed that Django's migration system cannot gracefully handle a semi-populated DB.

== Problem
I am stuck in a situation where we maintain development and deployment environments, each with slightly different migrations due to error and bug fixing and the fact that the DB is not backed up to the dev environment. As a result, we do not track/sync migration files between the two as they would not be compatible with the tracked files in each DB. Recently we have just had to wipe and re-start our migrations due to some hardware complications and it has come up that we cannot simply re-generate migration files as Django will attempt to re-create all migration files and all models from scratch. Obviously this is kicking up a `django.db.utils.ProgrammingError: relation ""<Table_Name_Here>"" already exists` which is not very easily fixable.

== Solution/My Request:
I could always play around with the migration files or some such and tweak them until the migrations work but that is not ideal, especially in a production environment. It would be more intuitive to me for Django to check against the database whether or not any of the database tables already exist and optionally (Maybe a command flag?), only migrate '''new''' model tables/fields?
"	Cleanup/optimization	closed	Migrations	3.0	Normal	invalid	migration programming error		Unreviewed	0	0	0	0	0	0
