﻿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
30805	"django 2.x is giving programming error while migrating ""migrations.AlterUniqueTogether"" part of migration"	Anvesh Agarwal		"problem is while migrating my migrations in django 2.x(previously using 1.11 and everything was working fine) , the query generated by the django is not correct for ""migrations.AlterUniqueTogether"" part of migrations.

It is missing 'double quotes' while generating the sql query for particularly ""migrations.AlterUniqueTogether()"" .
A small traceback is here:

{{{
  File ""/lib/python3.7/site-packages/django/db/backends/utils.py"", line 85, in _execute
    return self.cursor.execute(sql, params)
  File ""//lib/python3.7/site-packages/django/db/utils.py"", line 89, in __exit__
    raise dj_exc_value.with_traceback(traceback) from exc_value
  File ""/lib/python3.7/site-packages/django/db/backends/utils.py"", line 85, in _execute
    return self.cursor.execute(sql, params)
django.db.utils.ProgrammingError: syntax error at or near "".""
LINE 1: ...eways.juspay_juspayrefund"" ADD CONSTRAINT gateways.juspay_ju...

}}}


i have hundreds of {{{migrations.AlterUniqueTogether()}}} in migrations but it is showing error for only few. 

so to confirm the sql query generated by the django from the migration files...

i used {{{ python manage.py sqlmigrate <app name> <migration file number> }}} (in django 2.0)

so the result was


{{{
ALTER TABLE ""gateways.juspay_juspayrefund"" ADD CONSTRAINT gateways.juspay_juspayre_refund_type_id_refund_ob_c256672d_uniq UNIQUE (""refund_type_id"", ""refund_object_id"");

ALTER TABLE ""gateways.juspay_juspayorder"" ADD CONSTRAINT ""gateways.juspay_jusp_attempt_id_799d9fbb_fk_gateways_"" FOREIGN KEY (""attempt_id"") REFERENCES ""gateways_attempt"" (""id"") DEFERRABLE INITIALLY DEFERRED;

}}}

here we have double quotes ("" "") missing in ADD CONSTRAINT ...UNIQUE which is not letting me to migrate and hence i cant upgrade to django 2.x

while the result in django 1.11 is 

{{{
ALTER TABLE ""gateways.juspay_juspayrefund"" ADD CONSTRAINT ""gateways.juspay_juspayre_refund_type_id_refund_ob_c256672d_uniq"" UNIQUE (""refund_type_id"", ""refund_object_id"");

ALTER TABLE ""gateways.juspay_juspayorder"" ADD CONSTRAINT ""gateways.juspay_jusp_attempt_id_799d9fbb_fk_gateways_"" FOREIGN KEY (""attempt_id"") REFERENCES ""gateways_attempt"" (""id"") DEFERRABLE INITIALLY DEFERRED;

}}}

it is having proper double quotes ("" "")"	Bug	closed	Error reporting	2.0	Normal	duplicate			Unreviewed	0	0	0	0	0	0
