Commit Graph

851 Commits

Author SHA1 Message Date
Nick Pope 500e01073a
Fixed #31262 -- Added support for mappings on model fields and ChoiceField's choices. 2023-08-30 22:57:40 -03:00
David Sanders 76c3e310dd Fixed #34744 -- Prevented recreation of migration for constraints with a dict_keys.
Co-authored-by: Mariusz Felisiak <felisiak.mariusz@gmail.com>
2023-08-23 11:42:18 +02:00
Mariusz Felisiak 2b582387d5
Fixed #34760 -- Dropped support for SQLite < 3.27. 2023-08-04 06:35:13 +02:00
devilsautumn f05cc5e3d2 Refs #24686 -- Made AlterField operation a noop when renaming related model with db_table. 2023-07-22 20:13:42 +02:00
Mariusz Felisiak 3109038992
Refs #33201 -- Avoided unnecessary queries when renaming models with db_table on SpatiaLite. 2023-07-18 14:08:47 +02:00
Nicolò Intrieri e8252fc445
Fixed #34716 -- Fixed serialization of nested class methods in migrations.
Co-authored-by: Nicolò <nicolo.intrieri@spinforward.it>
2023-07-18 05:27:40 +02:00
Yury V. Zaytsev 02966a30dd Fixed #34697 -- Fixed non-deterministic order of dependencies and sets/frozensets in migrations.
Co-authored-by: Dakota Hawkins <dakotahawkins@gmail.com>
2023-07-12 12:33:23 +02:00
Mariusz Felisiak 21e6864715
Fixed RecorderTests.test_has_table_cached() on databases that perform multiple queries when introspecting tables.
Thanks Tim Graham for the report and implementation idea.

Follow up to ea8cbca579.
2023-06-28 12:11:25 +02:00
Tom Forbes ea8cbca579 Made MigrationRecorder cache has_table() result if django_migrations table exists. 2023-05-25 13:18:02 +02:00
Mariusz Felisiak c52f4295f2
Fixed #34568 -- Made makemigrations --update respect --name option.
Thanks David Sanders for the report.
2023-05-17 13:14:43 +02:00
Ian Foote 7414704e88 Fixed #470 -- Added support for database defaults on fields.
Special thanks to Hannes Ljungberg for finding multiple implementation
gaps.

Thanks also to Simon Charette, Adam Johnson, and Mariusz Felisiak for
reviews.
2023-05-12 19:11:40 +02:00
Simon Charette ffff17d4b0 Fixed #34553 -- Fixed improper % escaping of literal in constraints.
Proper escaping of % in string literals used when defining constaints
was attempted (a8b3f96f6) by overriding quote_value of Postgres and
Oracle schema editor. The same approach was used when adding support for
constraints to the MySQL/MariaDB backend (1fc2c70).

Later on it was discovered that this approach was not appropriate and
that a preferable one was to pass params=None when executing the
constraint creation DDL to avoid any form of interpolation in the first
place (42e8cf47).

When the second patch was applied the corrective of the first were not
removed which caused % literals to be unnecessary doubled. This flew
under the radar because the existings test were crafted in a way that
consecutive %% didn't catch regressions.

This commit introduces an extra test for __exact lookups which
highlights more adequately % doubling problems but also adjust a
previous __endswith test to cover % doubling problems (%\% -> %%\%%).

Thanks Thomas Kolar for the report.

Refs #32369, #30408, #30593.
2023-05-10 17:25:57 +02:00
Simon Charette e0f8104a96 Refs #34553 -- Split constraint escaping test in subtests.
This ensures that constraint violations are tested in isolation from
each other as an IntegrityError only ensures a least one constraint is
violated.

For example, the assertion added in 42e8cf4 break both the
name_constraint_rhs and the rebate_constraint constraints and thus
doesn't constitute a proper regression test. Refs #32369.
2023-05-10 17:25:57 +02:00
Akash Kumar Sen 92f0017133 Refs #34534 -- Reduced Add/RemoveConstraint and Add/RenameIndex operations when optimizing migrations. 2023-05-09 12:45:09 +02:00
Mariusz Felisiak 8e2460d599
Fixed #34529, Refs #34525 -- Reduced index operations with Meta.indexes/index_together when optimizing migrations.
This makes squashing migrations an available path for changing
Meta.index_together, which is deprecated, to Meta.indexes.

Follow up to f810325721.
2023-05-03 13:06:19 +02:00
Mariusz Felisiak 191f6a9a45
Fixed #34528 -- Reduced Add/RemoveIndex operations when optimizing migrations. 2023-05-01 18:57:24 +02:00
T. Franzel a2eaea8f22 Fixed #34388 -- Allowed using choice enumeration types directly on model and form fields. 2023-03-21 19:44:41 +01:00
Andy Chosak b295b31171 Fixed #34420 -- Corrected the order of imports in generated migration files. 2023-03-20 06:23:08 +01:00
Durval Carvalho 4b1bfea284 Fixed #34333 -- Fixed migration operations ordering when adding index/constraint on new foreign key.
Thanks Simon Charette and David Wobrock for reviews.
2023-03-10 07:05:11 +01:00
Mariusz Felisiak 61f599aeb9
Refs #34381 -- Fixed isolation of MigrateTests.test_migrate_fake_initial(). 2023-03-04 13:09:38 +01:00
Laurent Tramoy 2276ec8c21 Fixed #34366 -- Reduced AlterField operations when optimizing migrations. 2023-02-24 13:59:42 +01:00
Mariusz Felisiak 16c966ff7f
Refs #30060, Refs #34217 -- Made SchemaEditor not generate SQL for CheckConstraint if not supported.
The new logic mirrors the logic in SchemaEditor._delete_check_sql()
added in 68ef274bc5.

Thanks Tim Graham for the report.
2023-02-23 21:12:17 +01:00
Marcelo Galigniana f608e6a157 Completed test coverage for django.db.migrations.graph. 2023-02-15 07:40:19 +01:00
DevilsAutumn ff3a283422 Fixed #34250 -- Fixed renaming model with m2m relation to a model with the same name. 2023-02-14 14:08:06 +01:00
David Smith 097e3a70c1 Refs #33476 -- Applied Black's 2023 stable style.
Black 23.1.0 is released which, as the first release of the year,
introduces the 2023 stable style. This incorporates most of last year's
preview style.

https://github.com/psf/black/releases/tag/23.1.0
2023-02-01 11:04:38 +01:00
Nick Pope 1282b5e420 Fixed #32528 -- Replaced django.utils.topological_sort with graphlib.TopologicalSort().
graphlib.TopologicalSort() is available since Python 3.9.
2023-01-19 06:31:40 +01:00
Nick Pope fd21f82aa8
Refs #34233 -- Used types.NoneType.
Available since Python 3.10 where it was reintroduced.
2023-01-18 17:27:23 +01:00
Mariusz Felisiak 3bbe22dafc
Fixed #34233 -- Dropped support for Python 3.8 and 3.9. 2023-01-18 09:46:01 +01:00
Mariusz Felisiak d6816bff73 Refs #32365 -- Removed django.utils.timezone.utc per deprecation timeline. 2023-01-17 11:49:15 +01:00
Mariusz Felisiak e6f82438d4 Refs #32365 -- Removed support for pytz timezones per deprecation timeline. 2023-01-17 11:49:15 +01:00
kimsoungryoul 78f163a4fb Fixed #18468 -- Added support for comments on columns and tables.
Thanks Jared Chung, Tom Carrick, David Smith, Nick Pope, and Mariusz
Felisiak for reviews.

Co-authored-by: Mariusz Felisiak <felisiak.mariusz@gmail.com>
Co-authored-by: Nick Pope <nick@nickpope.me.uk>
2022-12-28 06:28:07 +01:00
DevilsAutumn 68ef274bc5 Fixed #34217 -- Fixed migration crash when removing check constraints on MySQL < 8.0.16. 2022-12-27 07:11:13 +01:00
DevilsAutumn 81b1c167bf Fixed #28987 -- Fixed altering ManyToManyField when changing to self-referential. 2022-11-17 12:36:52 +01:00
Nick Pope d3cb91db87 Used more augmented assignment statements.
Identified using the following command:

$ git grep -I '\(\<[_a-zA-Z0-9]\+\>\) *= *\1 *[-+/*^%&|<>@]'
2022-10-31 12:30:13 +01:00
Jacob Walls 80d38de52b Fixed #34051 -- Made makemigrations --check exit before making migrations. 2022-09-28 09:48:07 +02:00
JunKi Yoon 1a7b6909ac Fixed #34052 -- Made migrate --check don't emit signals and output when up to date. 2022-09-27 21:10:30 +02:00
Adam Johnson cd03e8e2d6 Fixed #34050 -- Replaced invalid chars in migration names with '_'.
Thanks to Bishal Gautam for the report and initial implementation.

Regression in fa58450a9a.

Co-Authored-By: Bishal Gautam <bisalgt@gmail.com>
2022-09-27 08:02:51 +02:00
David Sanders 9f8c994851 Fixed #34027 -- Fixed migrations crash when altering type of char/text fields referenced by foreign key on PostgreSQL. 2022-09-25 20:23:01 +02:00
Mariusz Felisiak a9e7beb959
Refs #33953 -- Fixed test_rename_model_with_db_table_rename_m2m() crash on SQLite < 3.20. 2022-08-29 10:07:53 +02:00
Iuri de Silvio 166a3b3263 Fixed #33953 -- Reverted "Fixed #33201 -- Made RenameModel operation a noop for models with db_table."
Regression in afeafd6036.
This reverts afeafd6036.

Thanks Timothy Thomas for the report.
2022-08-26 06:14:44 +02:00
Simon Charette 71902e0d9f Fixed #33938 -- Fixed migration crash for m2m with a through model in another app.
Regression in aa4acc164d.

Thanks bryangeplant for the report.
2022-08-25 10:03:57 +02:00
Willem Van Onsem 16fffc829c Fixed #33916 -- Added support for serialization of enum.Flag in migrations. 2022-08-25 06:43:48 +02:00
Willem Van Onsem 08688bd7dd Refs #33916 -- Added tests for serialization of enum.Flag in migrations. 2022-08-16 07:52:27 +02:00
Alberto Planas 4e13b40a76
Fixed #33887 -- Fixed test_fails_squash_migration_manual_porting() on final tags.
Regression in 7c318a8bdd.
2022-08-03 16:36:04 +02:00
Mariusz Felisiak c773d5794e Refs #27236 -- Reverted AlterIndexTogether deprecation.
This partly reverts a6385b382e.
2022-07-26 11:41:19 +02:00
Mariusz Felisiak f810325721
Refs #27236 -- Made cosmetic edits to Meta.index_together deprecation.
This should make it more straightforward to move forward when
deprecation ends.
2022-07-21 07:05:50 +02:00
David Wobrock a6385b382e
Fixed #27236 -- Deprecated Meta.index_together in favor of Meta.indexes.
This also deprecates AlterIndexTogether migration operation.
2022-07-12 09:04:31 +02:00
David Wobrock 4f284115a9 Refs #27236 -- Split RenameField() tests with unique/index_together. 2022-07-12 06:38:03 +02:00
David Wobrock e286ce17ff Fixed #24870 -- Added --update option to makemigrations command. 2022-06-17 07:50:39 +02:00
David Wobrock db588d4f0e Refs #27236 -- Split index_together and unique_together autodetector tests. 2022-06-13 09:03:36 +02:00