summaryrefslogtreecommitdiff
path: root/tests/migrations/test_writer.py
AgeCommit message (Collapse)Author
2025-11-03Fixed #36695 -- Fixed handling of parameterized generics in migration ↵Augusto Pontes
serialization. Co-authored-by: Jacob Walls <jacobtylerwalls@gmail.com>
2025-10-18Fixed #21961 -- Added support for database-level delete options for ForeignKey.Mariusz Felisiak
Thanks Simon Charette for pair programming. Co-authored-by: Nick Stefan <NickStefan12@gmail.com> Co-authored-by: Akash Kumar Sen <71623442+Akash-Kumar-Sen@users.noreply.github.com> Co-authored-by: Simon Charette <charette.s@gmail.com>
2025-05-13Fixed #36383 -- Improved migration serialization for functools.partial objects.Adam Johnson
2025-05-13Refs #36383 -- Added extra tests for serializing functools.partial in ↵Adam Johnson
tests/migrations/test_writer.py. This includes a test helper to better assert over the expected output. Co-authored-by: Natalia <124304+nessita@users.noreply.github.com>
2025-05-13Refs #36383 -- Extended DeconstructibleSerializer to support non-identifier ↵Adam Johnson
keyword arguments. In Python, keyword arguments must normally be valid identifiers (i.e., variable names that follow Python's naming rules). However, Python dicts can have keys that aren't valid identifiers, like "foo-bar" or "123foo". This commit ensures that keyword arguments that are nt valid identifiers, are properly handled when deconstructing an object.
2025-04-16Fixed #36274 -- Added support for run_before and atomic in MigrationWriter.Mikuláš Poul
2025-03-31Fixed #36265 -- Added support for serialization of ZoneInfo instances in ↵Song Junho
migrations.
2025-02-18Refs #36005 -- Used datetime.UTC alias instead of datetime.timezone.utc.Mariusz Felisiak
datetime.UTC was added in Python 3.11.
2024-11-29Fixed #373 -- Added CompositePrimaryKey.Bendeguz Csirmaz
Thanks Lily Foote and Simon Charette for reviews and mentoring this Google Summer of Code 2024 project. Co-authored-by: Simon Charette <charette.s@gmail.com> Co-authored-by: Lily Foote <code@lilyf.org>
2024-09-03Fixed #35724 -- Tested migration commands handling of distributed namespace ↵Jacob Walls
packages. Also increased coverage of module_loading.py.
2024-02-09Fixed #35175 -- Made migraton writer preserve keyword-only arguments.David Sanders
Thanks Gerald Goh for the report.
2023-09-14Fixed #24561 -- Added support for callables on model fields' choices.Natalia
2023-09-13Fixed #34822 -- Added support for serializing functions decorated with ↵Nick Pope
functools.lru_cache in migrations. `@functools.cache` and `@functools.lru_cache` return an object of type `functools._lru_cache_wrapper` which prevented the migrations serializer from working. Simply using the existing `FunctionTypeSerializer` for this additional type works as expected.
2023-09-13Refs #34822 -- Added tests for serializing decorated functions in migrations.Nick Pope
Functions decorated with a decorator that is properly wrapped, e.g. by using `@functools.wraps`, are already supported.
2023-08-30 Fixed #31262 -- Added support for mappings on model fields and ↵Nick Pope
ChoiceField's choices.
2023-07-18Fixed #34716 -- Fixed serialization of nested class methods in migrations.Nicolò Intrieri
Co-authored-by: Nicolò <nicolo.intrieri@spinforward.it>
2023-07-12Fixed #34697 -- Fixed non-deterministic order of dependencies and ↵Yury V. Zaytsev
sets/frozensets in migrations. Co-authored-by: Dakota Hawkins <dakotahawkins@gmail.com>
2023-03-21Fixed #34388 -- Allowed using choice enumeration types directly on model and ↵T. Franzel
form fields.
2023-03-20Fixed #34420 -- Corrected the order of imports in generated migration files.Andy Chosak
2023-01-18Refs #34233 -- Used types.NoneType.Nick Pope
Available since Python 3.10 where it was reintroduced.
2023-01-18Fixed #34233 -- Dropped support for Python 3.8 and 3.9.Mariusz Felisiak
2023-01-17Refs #32365 -- Removed django.utils.timezone.utc per deprecation timeline.Mariusz Felisiak
2023-01-17Refs #32365 -- Removed support for pytz timezones per deprecation timeline.Mariusz Felisiak
2022-08-25Fixed #33916 -- Added support for serialization of enum.Flag in migrations.Willem Van Onsem
2022-08-16Refs #33916 -- Added tests for serialization of enum.Flag in migrations.Willem Van Onsem
2022-03-29Refs #32365 -- Deprecated django.utils.timezone.utc.Carlton Gibson
2022-03-24Refs #32365 -- Removed internal uses of utils.timezone.utc alias.Carlton Gibson
Remaining test case ensures that uses of the alias are mapped canonically by the migration writer.
2022-03-23Refs #32365 -- Made migration writer use datetime.timezone.utc.Carlton Gibson
2022-02-07Refs #33476 -- Refactored code to strictly match 88 characters line length.Mariusz Felisiak
2022-02-07Refs #33476 -- Reformatted code with Black.django-bot
2022-02-03Refs #33476 -- Refactored problematic code before reformatting by Black.Mariusz Felisiak
In these cases Black produces unexpected results, e.g. def make_random_password( self, length=10, allowed_chars='abcdefghjkmnpqrstuvwxyz' 'ABCDEFGHJKLMNPQRSTUVWXYZ' '23456789', ): or cursor.execute(""" SELECT ... """, [table name], )
2022-01-07Fixed #33216 -- Simpilified deconstructed paths for some expressions.Allen Jonathan David
2021-09-16Fixed #32365 -- Made zoneinfo the default timezone implementation.Carlton Gibson
Thanks to Adam Johnson, Aymeric Augustin, David Smith, Mariusz Felisiak, Nick Pope, and Paul Ganssle for reviews.
2021-07-01Fixed #32893 -- Fixed serialization of models.Model class in migrations.abhiabhi94
Migrations assumed that an import of the models.Model class must already be included when it's serialized, but for models with only custom fields this was not necessarily the case. Thanks Jaap Joris Vens for the report.
2021-06-07Fixed #32821 -- Updated os.scandir() uses to use a context manager.Chris Jerdonek
2021-05-12Fixed #32366 -- Updated datetime module usage to recommended approach.Nick Pope
- Replaced datetime.utcnow() with datetime.now(). - Replaced datetime.utcfromtimestamp() with datetime.fromtimestamp(). - Replaced datetime.utctimetuple() with datetime.timetuple(). - Replaced calendar.timegm() and datetime.utctimetuple() with datetime.timestamp().
2021-05-12Added extra assertion to ↵Nick Pope
migrations.test_writer.WriterTests.test_serialize_datetime. This checks that datetime.timezone.utc serializes correctly.
2020-06-24Fixed #31529 -- Added support for serialization of pathlib.Path/PurePath and ↵Nick Pope
os.PathLike in migrations.
2019-11-25Fixed #27914 -- Fixed serialization of nested classes in migrations.John Bowen
2019-11-25Refs #23950 --- Moved test DeconstructibleInstances class to a module level.John Bowen
DeconstructibleInstances was not importable from the asserted path.
2019-10-03Refs #27914 -- Fixed serialization of nested enum.Enum classes in migrations.Hasan Ramezani
2019-10-03Refs #27914 -- Moved test enum.Enum subclasses outside of ↵Hasan Ramezani
WriterTests.test_serialize_enums().
2019-09-30Fixed #30774 -- Made serialization in migrations use members names for Enums.Hasan Ramezani
2019-09-04Fixed #27910 -- Added enumeration helpers for use in Field.choices.Shai Berger
These classes can serve as a base class for user enums, supporting translatable human-readable names, or names automatically inferred from the enum member name. Additional properties make it easy to access the list of names, values and display labels. Thanks to the following for ideas and reviews: Carlton Gibson, Fran Hrženjak, Ian Foote, Mariusz Felisiak, Shai Berger. Co-authored-by: Shai Berger <shai@platonix.com> Co-authored-by: Nick Pope <nick.pope@flightdataservices.com> Co-authored-by: Mariusz Felisiak <felisiak.mariusz@gmail.com>
2019-04-14Fixed #30350 -- Prevented recreation of migration for operations with a ↵Florian Apolloner
range object. Thanks to Mariusz Felisiak for helping with the patch.
2019-01-30Fixed #30116 -- Dropped support for Python 3.5.Tim Graham
2019-01-11Refs #29738 -- Allowed registering serializers with MigrationWriter.can
2019-01-11Moved django.db.migrations.writer.SettingsReference to django.conf.Tim Graham
Reduces the possibility of circular imports.
2018-12-19Fixed #30031 -- Added --no-header option to makemigrations/squashmigrations.Dakota Hawkins
2018-10-11Fixed #29814 -- Added support for NoneType serialization in migrations.Patrik Sletmo