Commit Graph

669 Commits

Author SHA1 Message Date
Simon Charette 8069526ce3 Made Operation.references_model/references_field require app_label.
This will allow them to drop a ton of logic to deal with null
app_label.
2020-04-09 10:08:06 +02:00
Simon Charette 25bf15c0da Refs #22608 -- Made app_label required when optimizing migrations.
This paved the way for the removal of lot of logic when app_label was
not specified.
2020-04-09 10:08:02 +02:00
Mariusz Felisiak db6933a032
Refs #30966 -- Added test for reloading related model state on non-relational changes.
Thanks Markus Holtermann for initial test.

Fixed in 1d16c5d562.
2020-04-08 10:43:38 +02:00
Simon Charette 1d16c5d562 Refs #27666 -- Ensured relationship consistency on delayed reloads.
Delayed reloads of state models broke identity based relationships
between direct and non-direct ancestors.

Basing models.Options related objects map of model labels instead of
their identity ensured relationship consistency is maintained.

Refs #30966.

Co-authored-by: Hasan Ramezani <hasan.r67@gmail.com>
2020-04-07 09:20:46 +02:00
Gordon Pendleton d0da2820ca Fixed #31402 -- Added migrate --check option.
Command exits with non-zero status if unapplied migrations exist.
2020-03-26 20:12:39 +01:00
Adam Johnson 9e1b6b8a66 Fixed #23916 -- Allowed makemigrations to handle related model name case changes.
Made autodetector ignore related model name case changes so unnecessary
migrations are not created.
2020-03-25 10:39:34 +01:00
David Wobrock d88365708c Fixed #31318 -- Allowed sqlmigrate to inspect squashed migrations. 2020-03-09 08:42:30 +01:00
David Wobrock b88ad1d356 Refs #31318 -- Added tests for inspecting squashed migrations and ambiguous names in sqlmigrate. 2020-03-09 08:21:34 +01:00
Nick Pope 335c9c94ac Simplified imports from django.db and django.contrib.gis.db. 2020-02-04 13:20:06 +01:00
Mariusz Felisiak b423873cb7
Refs #31197 -- Added tests for combined expressions in CheckConstraint.check.
Thanks Adam Johnson for the report.

Fixed in 306b687520.
2020-01-23 10:28:36 +01:00
Matthijs Kooijman 2a2ea4ee18 Refs #31117 -- Made various tests properly handle unexpected databases aliases.
- Used selected "databases" instead of django.db.connections.
- Made routers in tests.migrations skip migrations on unexpected
  databases.
- Added DiscoverRunnerGetDatabasesTests.assertSkippedDatabases() hook
  which properly asserts messages about skipped databases.
2020-01-20 14:39:02 +01:00
Mariusz Felisiak bf77669453
Fixed #29998 -- Allowed multiple OneToOneFields to the parent model.
We assumed that any OneToOneField's in a child model must be the
parent link and raised an error when parent_link=True was not
specified. This patch allows to specify multiple OneToOneField's to
the parent model.

OneToOneField's without a custom related_name will raise fields.E304
and fields.E305 so this should warn users when they try to override
the auto-created OneToOneField.
2020-01-16 08:06:16 +01:00
John Bowen 29d8198841 Fixed #27914 -- Fixed serialization of nested classes in migrations. 2019-11-25 11:12:44 +01:00
John Bowen 8008795a38 Refs #23950 --- Moved test DeconstructibleInstances class to a module level.
DeconstructibleInstances was not importable from the asserted path.
2019-11-25 11:05:09 +01:00
Jon Dufresne e649d691f8 Removed unnecessary parentheses in various code. 2019-11-18 15:25:59 +01:00
Mariusz Felisiak 4527d5db0f
Refs #29808 -- Fixed MigrateTests.test_migrate_fake_initial_case_insensitive() crash on Oracle. 2019-11-15 21:05:42 +01:00
Hasan Ramezani 530dd193f2 Fixed #29808 -- Fixed initial migration detection when identifiers are case-insensitive.
Thanks Simon Charette for the review.
2019-11-15 09:01:30 +01:00
Nick Pope 7552de7866 Used more specific unittest assertions in tests.
* assertIsNone()/assertIsNotNone() instead of comparing to None.
* assertLess() for < comparisons.
* assertIs() for 'is' expressions.
* assertIsInstance() for isinstance() expressions.
* rounding of assertAlmostEqual() for round() expressions.
* assertIs(..., True/False) instead of comparing to True/False.
* assertIs()/assertIsNot() for ==/!= comparisons.
* assertNotEqual() for == comparisons.
* assertTrue()/assertFalse() instead of comparing to True/False.
2019-10-29 12:37:30 +01:00
Mariusz Felisiak 06d34aab7c Fixed #30870 -- Fixed showing that RunPython operations are irreversible by migrate --plan.
Thanks Hasan Ramezani for the initial patch and Kyle Dickerson for the
report.
2019-10-14 11:13:27 +02:00
Mariusz Felisiak 05186c03a3 Isolated migrations.test_commands.MigrateTests.test_migrate_plan. 2019-10-14 08:42:38 +02:00
Simon Charette 2839659b42 Fixed #30868 -- Prevented unnecessary AlterField when renaming a referenced pk.
Regression introduced by dcdd219ee1, refs #25817.

Thanks Carlos E. C. Leite for the report and Mariusz for the bisect.
2019-10-14 08:02:26 +02:00
Benjy Weinberger 3cd3bebe89 Fixed #30300 -- Allowed migrations to be loaded from directories without __init__.py file. 2019-10-10 08:31:41 +02:00
Hasan Ramezani 6452112640 Refs #27914 -- Fixed serialization of nested enum.Enum classes in migrations. 2019-10-03 08:39:30 +02:00
Hasan Ramezani d3030deaaa Refs #27914 -- Moved test enum.Enum subclasses outside of WriterTests.test_serialize_enums(). 2019-10-03 08:39:30 +02:00
Hasan Ramezani f0adf3b9b7 Fixed #30774 -- Made serialization in migrations use members names for Enums. 2019-09-30 10:28:05 +02:00
Mariusz Felisiak 937ddaff55
Refs #30591 -- Fixed too long identifier crash in migrations.test_operations on MySQL 8.0.16+. 2019-09-11 12:20:16 +02:00
Adnan Umer 241deed259 Fixed #30591 -- Fixed recreation of foreign key constraints on MySQL when altering type of referenced unique field.
Thanks Mariusz Felisiak for tests and Matthijs Kooijman for
investigation and initial patch.
2019-09-11 11:21:08 +02:00
Shai Berger 72ebe85a26 Fixed #27910 -- Added enumeration helpers for use in Field.choices.
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-09-04 14:42:49 +02:00
Viktor Lomakin 5931d2e96a Fixed #30691 -- Made migrations autodetector find dependencies for foreign keys altering. 2019-09-03 14:45:49 +02:00
Mads Jensen 85ac838d9e Fixed #21039 -- Added AddIndexConcurrently/RemoveIndexConcurrently operations for PostgreSQL.
Thanks to Simon Charettes for review.

Co-Authored-By: Daniel Tao <daniel.tao@gmail.com>
2019-08-21 13:10:06 +02:00
Mads Jensen b10d322c41 Moved migrations.test_operations.OperationTestBase to migrations.test_base.
Co-Authored-By: Daniel Tao <daniel.tao@gmail.com>
2019-08-19 16:06:14 +02:00
Min ho Kim 65e86948b8 Corrected several typos in string literals and test names. 2019-08-07 11:23:14 +02:00
Nick Pope 194d1dfc18 Fixed #30661 -- Added models.SmallAutoField. 2019-08-02 11:39:01 +02:00
Mariusz Felisiak 8233144ca0 Changed django.db.models.indexes.Index imports to django.db.models.Index. 2019-07-08 14:19:46 +02:00
Hasan Ramezani 5d03f2bc01 Fixed #30595 -- Added error message when no objects found to sql* management commands. 2019-07-01 13:47:54 +02:00
Jon Dufresne 42b9a23267 Fixed #30400 -- Improved typography of user facing strings.
Thanks Claude Paroz for assistance with translations.
2019-06-28 16:46:18 +02:00
can 719b746620 Fixed #30412 -- Fixed crash when adding check constraints with OR'ed condition on Oracle and SQLite. 2019-04-30 12:32:27 +02:00
Simon Charette a8b3f96f6a Fixed #30408 -- Fixed crash when adding check constraints with LIKE operator on Oracle and PostgreSQL.
The LIKE operator wildcard generated for contains, startswith, endswith and
their case-insensitive variant lookups was conflicting with parameter
interpolation on CREATE constraint statement execution.

Ideally we'd delegate parameters interpolation in DDL statements on backends
that support it but that would require backward incompatible changes to the
Index and Constraint SQL generating methods.

Thanks David Sanders for the report.
2019-04-30 07:38:22 +02:00
Florian Apolloner 2e38f2015a
Fixed #30350 -- Prevented recreation of migration for operations with a range object.
Thanks to Mariusz Felisiak for helping with the patch.
2019-04-14 12:04:48 +02:00
tschilling 7c68cea7ee Fixed #30186 -- Made showmigrations --list display the applied datetimes at verbosity 2+. 2019-03-08 08:25:38 -05:00
Tim Schilling 371ddade1e Refs #30186 -- Changed MigrationRecorder.applied_migrations() to return a dict. 2019-03-07 19:36:55 -05:00
Parth Patil acc041984f Fixed #30189 -- Removed transaction from sqlmigrate output if database doesn't use one. 2019-03-07 18:28:22 -05:00
Dan Davis 2bd8df243a Fixed #30184 -- Removed ellipsis characters from shell output strings.
Partially reverted 50b8493581 (refs #29654)
to avoid a crash when the user shell doesn't support non-ASCII characters.
2019-02-13 13:59:44 -05:00
Semen Zhydenko 255d6a26a8 Fixed spelling mistakes in comments and tests. 2019-02-11 08:55:57 -05:00
Tim Graham 7e6b214ed3 Fixed #30116 -- Dropped support for Python 3.5. 2019-01-30 10:19:48 -05:00
Paveł Tyślacki 62b8596616 Made test table cleanup in OperationTestBase more robust.
Some non-unique constraint names were added in
b69f8eb04c which resulted in failures
depending on the order in which tests were run.
2019-01-28 11:51:23 -05:00
Jon Dufresne 7e3bf2662b Removed default mode='r' argument from calls to open(). 2019-01-27 17:41:43 -05:00
Vytis Banaitis d02b2aa11e Made assertOptimizesTo() more strict in migrations tests.
A recursive deconstruction is needed because comparing deconstructed
operations doesn't check field attributes. Fixed typo in failing test.
2019-01-21 17:29:46 -05:00
Paveł Tyślacki b69f8eb04c Fixed #30062 -- Added support for unique conditional constraints. 2019-01-12 09:50:20 -05:00
can 7d3b3897c1 Refs #29738 -- Allowed registering serializers with MigrationWriter. 2019-01-11 18:13:16 -05:00