Commit Graph

795 Commits

Author SHA1 Message Date
David Wobrock eacd4977f6 Refs #27064 -- Added RenameIndex migration operation. 2022-05-12 20:44:03 +02:00
Mariusz Felisiak 27b07a3246
Refs #30581 -- Moved CheckConstraint tests for conditional expressions to migrations.test_operations.
This allows avoiding warning in tests about using RawSQL in
CheckConstraints.
2022-05-05 06:44:34 +02:00
David Wobrock aca9bb2a12 Fixed #33413 -- Made migrations propage collations to related fields. 2022-05-02 08:13:38 +02:00
Adam Johnson 6f453cd298 Fixed #33509 -- Added "(no-op)" to sqlmigrate output for operations without SQL statement. 2022-04-21 12:25:16 +02:00
Adam Johnson f15f7d395c Refs #33509 -- Made sqlmigrate tests stricter and improved isolation. 2022-04-21 12:21:46 +02:00
Mariusz Felisiak a65547c04a
Fixed tests on databases that don't support introspecting foreign keys. 2022-04-13 11:52:40 +02:00
Brian Helba 2d5215c675 Fixed #33605 -- Fixed migration crash when altering RegexValidator to pre-compiled regular expression. 2022-04-04 07:38:15 +02:00
Carlton Gibson 59ab3fd0e9 Refs #32365 -- Deprecated django.utils.timezone.utc. 2022-03-29 14:47:44 +02:00
Carlton Gibson bb61f0186d Refs #32365 -- Removed internal uses of utils.timezone.utc alias.
Remaining test case ensures that uses of the alias are mapped
canonically by the migration writer.
2022-03-24 06:29:50 +01:00
Carlton Gibson d46e158ee2 Refs #32365 -- Made migration writer use datetime.timezone.utc. 2022-03-23 12:43:43 +01:00
Adam Johnson 8f7cda0831
Fixed #33572 -- Implemented CreateModel/AlterModelManagers reduction. 2022-03-11 07:03:51 +01:00
Mariusz Felisiak d11944be34
Refs #33476 -- Added warning to optimizemigration/squashmigrations commands when black cannot be applied. 2022-02-23 07:29:15 +01:00
David Wobrock 7c318a8bdd Fixed #27844 -- Added optimizemigration management command. 2022-02-22 10:30:40 +01:00
Mariusz Felisiak 1e2e1be02b
Fixed #33515 -- Prevented recreation of migration for ManyToManyField to lowercased swappable setting.
Thanks Chris Lee for the report.

Regression in 4328970780.

Refs #23916.
2022-02-16 21:09:24 +01:00
Carlton Gibson d113b5a837 Refs #33476 -- Made management commands use black.
Run black on generated files, if it is available on PATH.
2022-02-11 12:23:26 +01:00
Mariusz Felisiak 7119f40c98 Refs #33476 -- Refactored code to strictly match 88 characters line length. 2022-02-07 20:37:05 +01:00
django-bot 9c19aff7c7 Refs #33476 -- Reformatted code with Black. 2022-02-07 20:37:05 +01:00
Mariusz Felisiak c5cd878382
Refs #33476 -- Refactored problematic code before reformatting by Black.
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-02-03 11:20:46 +01:00
Kirill Safronov 97a7274468 Fixed #33480 -- Fixed makemigrations crash when renaming field of renamed model.
Regression in aa4acc164d.
2022-02-01 07:01:41 +01:00
Mariusz Felisiak e972620ada
Fixed #33462 -- Fixed migration crash when altering type of primary key with MTI and foreign key.
This prevents duplicated operations when altering type of primary key
with MTI and foreign key. Previously, a foreign key to the base model
was added twice, once directly and once by the inheritance model.

Thanks bcail for the report.

Regression in 325d7710ce.
2022-01-27 18:51:39 +01:00
Jacob Walls 2d8232fa71 Fixed #26760 -- Added --prune option to migrate command. 2022-01-21 17:10:31 +01:00
Fabian Büchler eeff1787b0 Fixed #33449 -- Fixed makemigrations crash on models without Meta.order_with_respect_to but with _order field.
Regression in aa4acc164d.
2022-01-21 06:44:53 +01:00
Jacob Walls 6f78cb6b13 Fixed #29026 -- Added --scriptable option to makemigrations. 2022-01-10 18:49:57 +01:00
Allen Jonathan David 28c98d4113 Fixed #33216 -- Simpilified deconstructed paths for some expressions. 2022-01-07 11:19:29 +01:00
David Wobrock 482ee63b6f
Fixed #33402 -- Optimized multiple AlterFooTogether operations. 2022-01-04 06:24:03 +01:00
Jacob Walls 0ab58c1209 Refs #29026 -- Allowed customizing InteractiveMigrationQuestioner's prompt destination.
Previously, the questioner did not obey the value of stdout provided
to the command.
2022-01-03 12:30:51 +01:00
Jacob Walls 92412aa94c Fixed #23273 -- Avoided creation of django_migrations table when there are no migrations to apply. 2021-12-30 06:36:55 +01:00
Mariusz Felisiak 2d07e1aaeb
Refs #22983 -- Added tests for squashing migrations with functions from migration files.
Follow up to ebb13bbd88.
2021-12-27 18:49:19 +01:00
Jacob Walls 03cadb912c Removed a Python error message dependency in test_questioner_no_default_bad_user_entry_code(). 2021-12-20 11:11:39 +01:00
Jacob Walls 1833a9eee9 Increased test coverage of django.db.migrations.questioner. 2021-12-20 11:11:39 +01:00
Simon Charette 4328970780 Fixed #33366 -- Fixed case handling with swappable setting detection in migrations autodetector.
The migration framework uniquely identifies models by case insensitive
labels composed of their app label and model names and so does the app
registry in most of its methods (e.g. AppConfig.get_model) but it
wasn't the case for get_swappable_settings_name() until this change.

This likely slipped under the radar for so long and only regressed in
b9df2b74b9 because prior to the changes
related to the usage of model states instead of rendered models in the
auto-detector the exact value settings value was never going through a
case folding hoop.

Thanks Andrew Chen Wang for the report and Keryn Knight for the
investigation.
2021-12-17 07:46:58 +01:00
Baptiste Mispelon a0ed3cfad1 Fixed #33305 -- Fixed autodetector crash for ForeignKey with hardcoded "to" attribute.
Co-authored-by: Simon Charette <charette.s@gmail.com>
2021-11-22 06:46:25 +01:00
Mariusz Felisiak dab48b7482
Fixed #33234 -- Fixed autodetector crash for proxy models inheriting from non-model class.
Regression in aa4acc164d.

Thanks Kevin Marsh for the report.
2021-11-02 15:34:08 +01:00
andrewdotn 9e6d631697
Fixed #33246 -- Made squashmigrations raise CommandError when squashed_name already exists. 2021-11-02 07:13:42 +01:00
Iuri de Silvio afeafd6036 Fixed #33201 -- Made RenameModel operation a noop for models with db_table. 2021-10-27 12:41:29 +02:00
Mariusz Felisiak d446f8ba08
Corrected AutodetectorTests.test_rename_field_and_foo_together()'s docstring. 2021-10-26 08:46:50 +02:00
David Wobrock 0314593fe8 Fixed #31503 -- Made autodetector remove unique/index_together before altering fields. 2021-10-25 10:10:02 +02:00
Simon Charette 5896aa8367 Fixed #33197 -- Made field rename with prior matching db_column change a noop.
Thanks Jacob Walls for the report.
2021-10-19 06:46:35 +02:00
Hannes Ljungberg 86971c4090 Fixed #33194 -- Fixed migrations when altering a field with functional indexes/unique constraints on SQLite.
This adjusts Expressions.rename_table_references() to only update alias
when needed.

Regression in 83fcfc9ec8.

Co-authored-by: Simon Charette <charettes@users.noreply.github.com>
2021-10-18 08:25:23 +02:00
Jacob Walls 15683cdb95 Fixed #23953 -- Made makemigrations continue number sequence for squashed migrations. 2021-10-15 06:59:31 +02:00
Jacob Walls 6e4ac28af0 Refs #23953 -- Added MigrationAutodetector.parse_number() tests. 2021-10-15 06:59:31 +02:00
Jacob Walls 32f1fe5f89 Fixed #29470 -- Logged makemigrations automatic decisions in non-interactive mode. 2021-10-12 15:19:39 +02:00
Jacob Walls 241ba23870 Refs #29470 -- Added makemigrations test for adding fields with no default and auto_now_add=True in non-interactive mode. 2021-10-12 15:19:39 +02:00
Mariusz Felisiak 01bf679e59
Fixed #33022 -- Fixed isolation of migrations.test_executor.ExecutorTests.test_custom_user(). 2021-10-08 15:51:04 +02:00
Jacob Walls 47f791f132 Fixed #23408 -- Added migrations questioner prompt for adding unique fields with a callable default. 2021-10-06 08:05:33 +02:00
AliGhotbizadeh b8f3a3ad54 Refs #33119 -- Added tests for changing model name case referenced by ManyToManyField.
Fixed in aa4acc164d.
2021-09-20 12:00:10 +02:00
Carlton Gibson 306607d5b9 Fixed #32365 -- Made zoneinfo the default timezone implementation.
Thanks to Adam Johnson, Aymeric Augustin, David Smith, Mariusz Felisiak, Nick
Pope, and Paul Ganssle for reviews.
2021-09-16 12:11:05 +02:00
Mariusz Felisiak 1eb3f500a4
Fixed #33057 -- Fixed recreation of foreign key constraints in m2m tables when altering type of referenced primary key on Oracle. 2021-08-31 13:43:10 +02:00
Jacob Walls 3219dd3388 Fixed #24900 -- Allowed migrating backward to squashed migrations. 2021-08-30 12:08:04 +02:00
Jacob Walls 9e17cc062c Refs #24900 -- Added MigrationLoader test for applying squashed migrations. 2021-08-30 11:40:27 +02:00