49 Commits

Author SHA1 Message Date
Simon Charette
ad82900ad9 Fixed #26720 -- Prevented invalid CreateModel optimizations of related fields. 2018-07-11 10:49:50 -04:00
Simon Charette
a97845a823 Fixed #27768 -- Allowed migration optimization of CreateModel order.
Thanks Ed Morley from Mozilla for the tests.
2018-07-11 10:49:50 -04:00
Jeff
fcc4e251db Fixed #29000 -- Fixed RenameModel's renaming of a M2M column when run after RenameField.
Regression in 45ded053b1f4320284aa5dac63052f6d1baefea9.
2018-06-15 11:51:09 -04:00
Simon Charette
dcdd219ee1 Fixed #25817 -- Made RenameField repoint to_field/to_fields references.
Also updated the autodetector to assume the RenameField operation will
perform the required repointing.
2017-12-30 14:59:22 -05:00
Tim Graham
c3e0adcad8 Fixed #28305 -- Fixed "Cannot change column 'x': used in a foreign key constraint" crash on MySQL with a sequence of AlterField or RenameField operations.
Regression in 45ded053b1f4320284aa5dac63052f6d1baefea9.
2017-12-01 19:07:46 -05:00
Simon Charette
5cbcb36839 Fixed #28350 -- Fixed UnboundLocalError crash in RenameField with nonexistent field.
Thanks Tim for the review.
2017-06-30 12:50:37 -04:00
Anton Samarchyan
60e52a047e Refs #27656 -- Updated django.db docstring verbs according to PEP 257. 2017-02-28 09:17:27 -05:00
chillaranand
d6eaf7c018 Refs #23919 -- Replaced super(ClassName, self) with super(). 2017-01-25 12:23:46 -05:00
Claude Paroz
d7b9aaa366 Refs #23919 -- Removed encoding preambles and future imports 2017-01-18 09:55:19 +01:00
Markus Holtermann
45ded053b1 Fixed #27666 -- Delayed rendering of recursivly related models in migration operations. 2017-01-17 08:12:52 -05:00
Tim Graham
cb4be0262a Removed unused code in AlterField.database_forwards().
This code added in 107c9f545346149b03354678f53a177709edaced isn't
used after 4ce7a6bc84c68406e39f48550434faeef3277eba.
2016-05-14 06:43:40 -04:00
Akshesh
b886f166b3 Fixed #26316 -- Factored duplicated code in model/field migration operations. 2016-03-03 18:24:36 -05:00
Simon Charette
729e0b086d Fixed #24109 -- Allowed RunSQL and RunPython operations to be elided.
Thanks to Markus Holtermann and Tim Graham for their review.
2016-01-23 14:19:03 -05:00
Simon Charette
49f4c9f4c6 Fixed #26064 -- Moved operation reduction logic to their own class.
Thanks to Markus Holtermann and Tim Graham for their review.
2016-01-23 14:19:02 -05:00
Anssi Kääriäinen
8f30556329 Renamed Field.rel attribute to remote_field
Field.rel is now deprecated. Rel objects have now also remote_field
attribute. This means that self == self.remote_field.remote_field.

In addition, made the Rel objects a bit more like Field objects. Still,
marked ManyToManyFields as null=True.
2015-03-25 08:16:12 -04:00
Loic Bistuer
bed504d70b Fixed #24351, #24346 -- Changed the signature of allow_migrate().
The new signature enables better support for routing RunPython and
RunSQL operations, especially w.r.t. reusable and third-party apps.

This commit also takes advantage of the deprecation cycle for the old
signature to remove the backward incompatibility introduced in #22583;
RunPython and RunSQL won't call allow_migrate() when when the router
has the old signature.

Thanks Aymeric Augustin and Tim Graham for helping shape up the patch.

Refs 22583.
2015-02-20 21:34:09 +07:00
Tim Graham
0ed7d15563 Sorted imports with isort; refs #23860. 2015-02-06 08:16:28 -05:00
Ulrich Petri
391bb09bb0 Refs #22608 -- Optimized migration optimizer and migrate by caching calls to str.lower() 2015-01-07 08:54:46 -05:00
Daniel Pyrathon
fb48eb0581 Fixed #12663 -- Formalized the Model._meta API for retrieving fields.
Thanks to Russell Keith-Magee for mentoring this Google Summer of
Code 2014 project and everyone else who helped with the patch!
2015-01-06 19:25:12 -05:00
Claude Paroz
1aa3e09c20 Fixed #23745 -- Reused states as much as possible in migrations
Thanks Tim Graham and Markus Holtermann for the reviews.
2015-01-02 15:37:10 +01:00
Claude Paroz
a159b1facd Replaced migration state render() by apps cached property
Refs #23745.
2015-01-02 15:19:36 +01:00
Markus Holtermann
912ad03226 Fixed #23894 -- Made deconstruct methods favor kwargs over args 2014-11-28 06:05:56 -05:00
Carl Meyer
bcb693ebd4 Revert "Fixed #23892 -- Made deconstructible classes forwards compatible"
This reverts commit f36151ed169813f2873e13ca9de616cfa4095321.

Adding kwargs to deconstructed objects does not achieve useful
forward-compatibility in general, since additional arguments are silently
dropped rather than having their intended effect. In fact, it can make the
failure more difficult to diagnose. Thanks Shai Berger for discussion.
2014-11-22 22:29:23 -07:00
Carl Meyer
f36151ed16 Fixed #23892 -- Made deconstructible classes forwards compatible 2014-11-22 14:30:14 -07:00
Patryk Zawadzki
21e21c7bc2 Fixed #23844 -- Used topological sort for migration operation dependency resolution.
This removes the concept of equality between operations to guarantee
compatilibity with Python 3.

Python 3 requires equality to result in identical object hashes. It's
impossible to implement a unique hash that preserves equality as
operations such as field creation depend on being able to accept
arbitrary dicts that cannot be hashed reliably.

Thanks Klaas van Schelven for the original patch in
13d613f80011852404198dfafd1f09c0c0ea42e6.
2014-11-20 12:49:49 -05:00
Markus Holtermann
7b4a994599 Fixed #23859 -- Fixed a migration crash when a field is renamed that is part of an index_together 2014-11-17 19:15:07 +01:00
twidi
19ae13d9ed Avoided unneeded calls to state.render() in migrations. 2014-11-17 18:44:09 +01:00
Berker Peksag
c9178ef17a Limited lines to 119 characters in django/{contrib,db}.
Refs #23395.
2014-10-29 07:59:35 -04:00
Markus Holtermann
f633ba778d Fixed #23609 -- Fixed IntegrityError that prevented altering a NULL column into a NOT NULL one due to existing rows
Thanks to Simon Charette, Loic Bistuer and Tim Graham for the review.
2014-10-09 21:32:06 +07:00
Andrew Godwin
dfe86449c9 Fixed #23244: Error altering FK to non-FK in migrations 2014-08-07 11:52:31 +10:00
Andrew Godwin
e24e9e0438 Fixed #23014: Renaming not atomic with unique together 2014-07-21 11:36:34 +01:00
Andrew Godwin
8d2ac948a9 Fixed #22853: Swapped models are now ignored for migration operations. 2014-06-17 17:45:38 -07:00
Claude Paroz
12474dacef Added a bunch of missing unicode_literals
Refs #22564.
2014-05-06 09:13:07 +02:00
Chris Beaven
107c9f5453 Fix AlterField migrations that are related to a RenameModel migration 2014-03-11 17:13:26 +13:00
Andrew Godwin
af4a8478e4 Fixed #21783: (again) Found second source of bug, also squashed it. 2014-01-19 17:43:31 +00:00
Andrew Godwin
5db028affb Fix altering of SERIAL columns and InnoDB being picky about FK changes 2013-12-11 14:19:05 +00:00
Andrew Godwin
248fdb1110 Change FKs when what they point to changes 2013-12-11 13:16:29 +00:00
Andrew Godwin
ce05b8a69e Don't make a second migration if there was a force-null-default addcol. 2013-12-04 13:56:22 +00:00
Alex Gaynor
e5b7045422 flake8 fixes 2013-11-06 20:00:48 -08:00
Andrew Godwin
106b019dc9 Massive migration optimiser improvements + RenameModel opn 2013-11-06 13:47:58 +00:00
Andrew Godwin
a80d9ab0fe Initial version of MigrationOptimizer and tests 2013-10-02 17:34:22 +01:00
Andrew Godwin
fddc5957c5 Implement allow_migrate for migration operations 2013-07-30 12:34:31 +01:00
Andrew Godwin
67dcea711e Add unique_together altering operation 2013-07-02 11:19:02 +01:00
Andrew Godwin
80bdf68d6b Add AlterField and RenameField operations 2013-06-20 15:12:59 +01:00
Andrew Godwin
41214eaf18 Autodetect fields, have migrate actually work 2013-06-19 16:41:04 +01:00
Andrew Godwin
f25a385a5e Makemigration command now works 2013-06-19 16:23:52 +01:00
Andrew Godwin
8d81c6bc82 Use correct model versions for field operations 2013-05-30 18:24:20 +01:00
Andrew Godwin
e6f7f4533c Add an Executor for end-to-end running 2013-05-30 18:08:58 +01:00
Andrew Godwin
d0ecefc2c9 Start adding operations that work and tests for them 2013-05-29 17:47:10 +01:00