summaryrefslogtreecommitdiff
path: root/django/db/migrations/operations/fields.py
AgeCommit message (Collapse)Author
2025-07-25Refs #36438 -- Made FieldOperation.references_field() detect references in ↵Clifford Gama
GeneratedField.expression. Thanks to Simon Charette for the suggestion and review.
2025-02-16Refs #35704 -- Used copy.replace() in Operation.reduce() methods.Adam Johnson
2024-01-17Fixed #31700 -- Made makemigrations command display meaningful symbols for ↵Amir Karimi
each operation.
2023-02-24Fixed #34366 -- Reduced AlterField operations when optimizing migrations.Laurent Tramoy
2022-02-07Refs #33476 -- Reformatted code with Black.django-bot
2021-10-19Fixed #33197 -- Made field rename with prior matching db_column change a noop.Simon Charette
Thanks Jacob Walls for the report.
2021-06-29Refs #29898 -- Moved state_forwards()'s logic from migration operations to ↵manav014
ProjectState. Thanks Simon Charette and Markus Holtermann for reviews.
2021-06-22Refs #29898 -- Moved django.db.migrations.operations.utils to ↵manav014
django.db.migrations.utils.
2021-02-19Fixed #32256 -- Fixed migration optimization crash when swapping field names.Hasan Ramezani
This disables optimization of RenameField operation when an old field name is referenced in subsequent operations. Co-authored-by: InvalidInterrupt <InvalidInterrupt@users.noreply.github.com>
2020-05-28Fixed #31468 -- Allowed specifying migration filename in Operation.Adam Johnson
This adds also suggested filename for many built-in operations.
2020-04-22Fixed #31499 -- Stored ModelState.fields into a dict.Simon Charette
This allows the removal of its O(n) .get_field_by_name method and many other awkward access patterns. While fields were initially stored in a list to preserve the initial model definiton field ordering the auto-detector doesn't take field ordering into account and no operations exists to reorder fields of a model. This makes the preservation of the field ordering completely superflous because field reorganization after the creation of the model state wouldn't be taken into account.
2020-04-10Refs #28305 -- Consolidated field referencing detection in migrations.Simon Charette
This moves all the field referencing resolution methods to shared functions instead of duplicating efforts amongst state_forwards and references methods.
2020-04-09Replaced ModelTuple by a model resolving function and bare tuples.Simon Charette
ModelTuple made handling of app_label=None easier but it isn't necessary anymore.
2020-04-09Replaced Operation._get_model_tuple() by ModelTuple.from_model().Simon Charette
This method predated the introduction of ModelTuple and had a single use.
2020-04-09Made Operation.references_model/references_field require app_label.Simon Charette
This will allow them to drop a ton of logic to deal with null app_label.
2020-04-09Refs #22608 -- Made app_label required when optimizing migrations.Simon Charette
This paved the way for the removal of lot of logic when app_label was not specified.
2020-04-07Refs #29000 -- Restored delayed model rendering of RenameField.Simon Charette
Non-delayed rendering is unnecessary and wasteful now that state models relationship consistency on delayed reload is ensured. This partly reverts commit fcc4e251dbc917118f73d7187ee2f4cbf3883f36.
2020-02-04Simplified imports from django.db and django.contrib.gis.db.Nick Pope
2018-07-11Removed in_between from Operation.reduce()'s signature.Simon Charette
It isn't used since FieldOperation.references_model() takes into account models referenced by the field it's operating on.
2018-07-11Allowed RemoveField operations to be optimized through.Simon Charette
2018-07-11Relaxed FieldOperation.references_field remote field checking.Simon Charette
2018-07-11Introduced ModelTuple to remove migrations boilerplate.Simon Charette
2018-07-11Fixed #26720 -- Prevented invalid CreateModel optimizations of related fields.Simon Charette
2018-07-11Fixed #27768 -- Allowed migration optimization of CreateModel order.Simon Charette
Thanks Ed Morley from Mozilla for the tests.
2018-06-15Fixed #29000 -- Fixed RenameModel's renaming of a M2M column when run after ↵Jeff
RenameField. Regression in 45ded053b1f4320284aa5dac63052f6d1baefea9.
2017-12-30Fixed #25817 -- Made RenameField repoint to_field/to_fields references.Simon Charette
Also updated the autodetector to assume the RenameField operation will perform the required repointing.
2017-12-01Fixed #28305 -- Fixed "Cannot change column 'x': used in a foreign key ↵Tim Graham
constraint" crash on MySQL with a sequence of AlterField or RenameField operations. Regression in 45ded053b1f4320284aa5dac63052f6d1baefea9.
2017-06-30Fixed #28350 -- Fixed UnboundLocalError crash in RenameField with ↵Simon Charette
nonexistent field. Thanks Tim for the review.
2017-02-28Refs #27656 -- Updated django.db docstring verbs according to PEP 257.Anton Samarchyan
2017-01-25Refs #23919 -- Replaced super(ClassName, self) with super().chillaranand
2017-01-18Refs #23919 -- Removed encoding preambles and future importsClaude Paroz
2017-01-17Fixed #27666 -- Delayed rendering of recursivly related models in migration ↵Markus Holtermann
operations.
2016-05-14Removed unused code in AlterField.database_forwards().Tim Graham
This code added in 107c9f545346149b03354678f53a177709edaced isn't used after 4ce7a6bc84c68406e39f48550434faeef3277eba.
2016-03-03Fixed #26316 -- Factored duplicated code in model/field migration operations.Akshesh
2016-01-23Fixed #24109 -- Allowed RunSQL and RunPython operations to be elided.Simon Charette
Thanks to Markus Holtermann and Tim Graham for their review.
2016-01-23Fixed #26064 -- Moved operation reduction logic to their own class.Simon Charette
Thanks to Markus Holtermann and Tim Graham for their review.
2015-03-25Renamed Field.rel attribute to remote_fieldAnssi Kääriäinen
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-02-20Fixed #24351, #24346 -- Changed the signature of allow_migrate().Loic Bistuer
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-06Sorted imports with isort; refs #23860.Tim Graham
2015-01-07Refs #22608 -- Optimized migration optimizer and migrate by caching calls to ↵Ulrich Petri
str.lower()
2015-01-06Fixed #12663 -- Formalized the Model._meta API for retrieving fields.Daniel Pyrathon
Thanks to Russell Keith-Magee for mentoring this Google Summer of Code 2014 project and everyone else who helped with the patch!
2015-01-02Fixed #23745 -- Reused states as much as possible in migrationsClaude Paroz
Thanks Tim Graham and Markus Holtermann for the reviews.
2015-01-02Replaced migration state render() by apps cached propertyClaude Paroz
Refs #23745.
2014-11-28Fixed #23894 -- Made deconstruct methods favor kwargs over argsMarkus Holtermann
2014-11-22Revert "Fixed #23892 -- Made deconstructible classes forwards compatible"Carl Meyer
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-22Fixed #23892 -- Made deconstructible classes forwards compatibleCarl Meyer
2014-11-20Fixed #23844 -- Used topological sort for migration operation dependency ↵Patryk Zawadzki
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-17Fixed #23859 -- Fixed a migration crash when a field is renamed that is part ↵Markus Holtermann
of an index_together
2014-11-17Avoided unneeded calls to state.render() in migrations.twidi
2014-10-29Limited lines to 119 characters in django/{contrib,db}.Berker Peksag
Refs #23395.