Simon Charette
06889d6206
Fixed #31499 -- Stored ModelState.fields into a dict.
...
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-22 07:10:00 +02:00
Simon Charette
696024fb73
Refs #31499 -- Ignored field ordering to determine ModelState equality.
2020-04-22 06:20:54 +02:00
Simon Charette
5220ca8d8a
Refs #30591 -- Adjusted table rebuild for non-pk relationship on SQLite.
...
The existing code was only accounting for primary key changes and not
all unique key fields that can be referenced.
2020-04-21 08:37:47 +02:00
Simon Charette
a548280857
Fixed #31064 -- Recreated auto-created many-to-many tables on primary key data type change on SQLite.
...
Both local and remote auto-created many-to-many relationships were
affected.
2020-04-21 08:37:40 +02:00
Simon Charette
2ba55b2905
Removed redundant import in tests/migrations/test_operations.py.
2020-04-21 08:37:37 +02:00
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
Tim Graham
8f4eee1777
Moved django.db.migrations.writer.SettingsReference to django.conf.
...
Reduces the possibility of circular imports.
2019-01-11 15:28:22 -05:00
Simon Charette
8c775391b7
Refs #28478 -- Deprecated TestCase's allow_database_queries and multi_db in favor of databases.
2019-01-10 19:11:21 -05:00
Dakota Hawkins
8d3147e130
Fixed #30031 -- Added --no-header option to makemigrations/squashmigrations.
2018-12-19 12:41:31 +01:00
Tim Fiedler
b07273a0f7
Fixed #29987 -- Detected unmanaged model deletions.
2018-11-30 09:57:43 -05:00
Tim Graham
193c109327
Switched TestCase to SimpleTestCase where possible in Django's tests.
2018-11-27 08:58:44 -05:00
Sarah Guermond
cd40306854
Fixed #25884 -- Fixed migrate --run-syncdb when specifying an app label.
2018-11-14 18:22:59 -05:00
Tim Graham
f82be9ebc7
Fixed #29934 -- Added sqlparse as a require dependency.
2018-11-09 19:09:36 -05:00
Junyoung
df448bfd02
Fixed #29783 -- Added app label validation to showmigrations command.
2018-10-30 19:29:00 -04:00
Simon Charette
630f3d8b46
Refs #29868 -- Prevented name collisions between test constraints on Oracle.
2018-10-30 09:26:03 -04:00
Simon Charette
d8e03fdeb9
Fixed #29897 -- Fixed autodetector's swappable MTI dependency resolution.
...
Thanks Steven Ganz for the detailed report.
2018-10-29 11:24:30 -04:00
Simon Charette
95bda03f2d
Fixed #29868 -- Retained database constraints on SQLite table rebuilds.
...
Refs #11964 .
Thanks Scott Stevens for testing this upcoming feature and the report.
2018-10-29 10:33:41 +01:00
Sanyam Khurana
c86a3d80a2
Fixed #29721 -- Ensured migrations are applied and recorded atomically.
2018-10-24 19:29:11 -04:00
Simon Charette
32da3cfdf9
Refs #11964 -- Removed raw SQL from and cleaned up constraint operation tests.
2018-10-24 19:18:41 -04:00
Prabakaran Kumaresshan
10d82c85aa
Fixed #29831 -- Added validation for makemigrations --name.
2018-10-23 10:05:24 -04:00
Patrik Sletmo
adfdb9f169
Fixed #29814 -- Added support for NoneType serialization in migrations.
2018-10-11 09:02:14 -04:00
Simon Charette
9142bebff2
Refs #11964 -- Changed CheckConstraint() signature to use keyword-only arguments.
...
Also renamed the `constraint` argument to `check` to better represent which
part of the constraint the provided `Q` object represents.
2018-10-02 10:53:04 -04:00
Tim Graham
4fc8fb7dda
Tested showmigrations with apps without migrations.
2018-09-28 09:56:40 -04:00
Tim Graham
495abe0095
Refs #29198 -- Fixed migrate --plan crash if RunSQL uses a list or tuple.
...
Also fixed test failures if sqlparse isn't installed.
2018-09-19 17:13:39 -04:00
Simon Charette
a4495f4b98
Fixed #29755 -- Made migrations detect changes to Meta.default_related_name.
2018-09-14 09:09:17 -04:00
Tim Graham
32fbccab40
Fixed #29749 -- Made the migrations loader ignore files starting with a tilde or underscore.
...
Regression in 29150d5da8
.
2018-09-11 12:51:11 -04:00
Krzysztof Gogolewski
db926a0048
Fixed #29243 -- Improved efficiency of migration graph algorithm.
2018-09-10 09:57:31 -04:00
Claude Paroz
50b8493581
Refs #29654 -- Replaced three dots with ellipsis character in output strings.
2018-08-22 09:13:58 -04:00
Claude Paroz
201017df30
Fixed #29654 -- Made text truncation an ellipsis character instead of three dots.
...
Thanks Sudhanshu Mishra for the initial patch and Tim Graham for the review.
2018-08-21 17:46:45 +02:00
Calvin DeBoer
058d33f3ed
Fixed #29198 -- Added migrate --plan option.
2018-08-03 15:22:42 -04:00
Tim Graham
c72dde41e6
Fixed #29595 -- Allowed using timedelta in migrations questioner.
...
Refs #29600 -- Removed usage of django.utils.datetime_safe in migrations.
2018-07-27 11:53:49 -04:00
Simon Charette
dc1dcad0f5
Refs #24424 -- Added regression tests for MTI-inheritance model removal.
...
The issue was fixed as a side effect of implementing RemoveField's reduction
of DeleteModel to a DeleteModel in ad82900ad9
.
2018-07-25 12:07:41 -04:00
Mariusz Felisiak
5a017eef4c
Fixed test_migrate_syncdb_deferred_sql_executed_with_schemaeditor() on Oracle.
2018-07-22 08:47:55 +02:00
Tim Graham
8d4ab0c41f
Added tests for migrate logging and error messages.
2018-07-20 20:37:52 -04:00
Simon Charette
8e3f22f251
Fixed #27731 -- Implemented CreateModel/AlterFooOperation reduction.
...
This should alleviate the side effects of disabling the AlterFooOperation
reduction with RemoveField to fix refs #28862 during migration squashing
because CreateModel can perform a reduction with RemoveField.
Thanks Nick Pope for the review.
2018-07-19 17:06:01 -04:00
Simon Charette
ed7898e1b5
Fixed #28862 -- Disabled optimization of AlterFooTogether and RemoveField.
...
AlterFooTogether operations cannot be swapped with RemoveField operations on
the same model as they could be removing the the same field as well.
Since AlterFooTogether operations don't track what their previous value was,
it's impossible to determine whether or not the optimization is safe so the
only way to proceed is to disable the optimization.
Thanks Ramiro Morales for the in-depth analysis of the issue.
Refs #24828
2018-07-19 17:06:01 -04:00
Simon Charette
37cafbfb79
Fixed #27845 -- Allowed both right and left optimizations of operations.
...
Thanks Raphael Gaschignard for the suggestion.
2018-07-11 10:49:50 -04:00
Simon Charette
0025dd5eb4
Allowed RemoveField operations to be optimized through.
2018-07-11 10:49:50 -04:00
Simon Charette
50b8c98a0f
Relaxed FieldOperation.references_field remote field checking.
2018-07-11 10:49:50 -04:00
Simon Charette
ad82900ad9
Fixed #26720 -- Prevented invalid CreateModel optimizations of related fields.
2018-07-11 10:49:50 -04:00
Simon Charette
a97845a823
Fixed #27768 -- Allowed migration optimization of CreateModel order.
...
Thanks Ed Morley from Mozilla for the tests.
2018-07-11 10:49:50 -04:00
Simon Charette
d3a935f01f
Refs #27768 -- Reversed order of optimized and in-between operations.
...
Operations can only be optimized through if they don't reference any of the
state the operation they are compared against defines or alters, so it's
safe to reverse the order.
2018-07-11 10:49:50 -04:00
Simon Charette
e4c0878b30
Refs #22875 -- Fixed an optimizer test to use a valid scenario.
...
An explicit intermediary many-to-many relationship must declare forward and
reverse foreign keys. The original issue was in the autodetector as these
operations shouldn't have been generated in this order in the first place
which is tested by AutodetectorTests.test_create_with_through_model.
2018-07-10 16:47:57 -04:00
Ian Foote
952f05a6db
Fixed #11964 -- Added support for database check constraints.
2018-07-10 15:32:33 -04:00
Sergey Fedoseev
338f741c5e
Fixed #29546 -- Deprecated django.utils.timezone.FixedOffset.
2018-07-09 16:33:36 -04:00
oliver
6b3e17bab6
Fixed #29518 -- Added validation for sqlmigrate's app_label argument.
2018-06-25 10:43:12 -04:00
Claude Paroz
fc26615164
Refs #29506 -- Added validation for squashmigrations' app_label option.
2018-06-20 15:46:43 -04:00
Claude Paroz
c723a1ff8e
Fixed #29506 -- Added validation for migrate's app_label option.
...
Thanks MyungSeKyo for the report and the initial patch.
2018-06-20 15:42:40 -04:00
Claude Paroz
c3c7d15c34
Refs #29469 -- Reused get_app_config() error message in makemigrations error.
2018-06-20 15:41:51 -04:00
Claude Paroz
abbc9cd71c
Moved makemigrations app_label validation tests.
2018-06-20 15:33:23 -04:00
oliver
78972af367
Fixed #29469 -- Added a helpful makemigrations error if app_label contains dots.
2018-06-16 15:18:57 -04:00