Commit Graph

657 Commits

Author SHA1 Message Date
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
Tim Graham 63f90f55f3 Fixed #29498 -- Fixed a missing pyc test file in source distribution. 2018-06-15 14:18:08 -04:00
Jeff fcc4e251db Fixed #29000 -- Fixed RenameModel's renaming of a M2M column when run after RenameField.
Regression in 45ded053b1.
2018-06-15 11:51:09 -04:00
Morgan Aubert 704443acac Fixed #29363 -- Added SimpleTestCase.assertWarnsMessage(). 2018-05-09 11:40:28 -04:00
Sanket Saurav 079f324357 Fixed #28913 -- Fixed error handling when MIGRATIONS_MODULES specifies a nonexistent top-level package. 2018-05-05 18:26:33 -04:00
Jon Dufresne f3b1c3bd06 Refs #23406 -- Fixed "invalid escape sequence" warning in migrations test. 2018-04-02 22:54:05 -04:00
Simon Charette 2156565b5b Fixed #29245 -- Made autodetector treat field renames + db_column addition as RenameField. 2018-03-28 12:43:43 -04:00
Dan Watson 29150d5da8 Fixed #23406 -- Allowed migrations to be loaded from .pyc files. 2018-03-23 13:20:38 -04:00
Mariusz Felisiak 362813d628
Fixed hanging indentation in various code. 2018-03-16 10:54:34 +01:00
Carlton Gibson 5b083a824e Fixed #29180 -- Fixed a regression where migrations already in the plan were readded.
Regression in a38ae914d8.
2018-03-09 08:59:57 +01:00
Tim Graham 0a37ea56d0 Fixed #29091 -- Fixed makemigrations crash if migrations directory doesn't have __init__.py.
Regression in aadd3aeb2b.
2018-01-31 09:36:36 -05:00
Simon Charette dcdd219ee1 Fixed #25817 -- Made RenameField repoint to_field/to_fields references.
Also updated the autodetector to assume the RenameField operation will
perform the required repointing.
2017-12-30 14:59:22 -05:00
Mariusz Felisiak 83a36ac49a
Removed unnecessary trailing commas and spaces in various code. 2017-12-28 21:07:29 +01:00
Simon Charette 9f7772e098 Fixed #28884 -- Fixed crash on SQLite when renaming a field in a model referenced by a ManyToManyField.
Introspected database constraints instead of relying on _meta.related_objects
to determine whether or not a table or a column is referenced on rename
operations.

This has the side effect of ignoring both db_constraint=False and virtual
fields such as GenericRelation which aren't backend by database level
constraints and thus shouldn't prevent the rename operations from being
performed in a transaction.

Regression in 095c1aaa89.

Thanks Tim for the additional tests and edits, and Mariusz for the review.
2017-12-22 15:19:05 -05:00
Sergey Fedoseev 183fb7b2b9 Fixed #28870 -- Added support for functools.partialmethod serialization in migrations. 2017-12-06 14:49:37 -05:00
Дилян Палаузов d2afa5eb23 Fixed #28860 -- Removed unnecessary len() calls. 2017-12-04 10:35:23 -05:00
Simon Charette 095c1aaa89 Fixed #28849 -- Fixed referenced table and column rename on SQLite.
Thanks Ramiro for the input and Tim for the review.
2017-12-01 22:12:24 -05:00
Tim Graham c3e0adcad8 Fixed #28305 -- Fixed "Cannot change column 'x': used in a foreign key constraint" crash on MySQL with a sequence of AlterField or RenameField operations.
Regression in 45ded053b1.
2017-12-01 19:07:46 -05:00
Дилян Палаузов 6c0042430e Fixed #28776 -- Fixed a/an/and typos in docs and comments. 2017-11-06 22:41:03 -05:00
Tim Graham 941b0a5b33 Fixed #28708 -- Added constants to detect the Python version. 2017-10-13 10:11:15 -04:00
Jeremy Satterfield 0891503fad Fixed #28493 -- Made migrations autodetector find dependencies for model renaming. 2017-09-04 15:15:39 -04:00
Evan Grim 7937cc16f5 Fixed #28386 -- Made operations within non-atomic migrations honor the operation's atomic flag when migrating backwards. 2017-08-10 19:21:14 -04:00
Evan Grim 5893eaddf4 Added missing test for RunPython behavior when unapplying. 2017-08-10 19:19:48 -04:00
Mads Jensen a51c4de194 Used assertRaisesMessage() to test Django's error messages. 2017-07-29 19:07:23 -04:00
Melvyn Sopacua 5bb9b9a388 Fixed #28363 -- Allowed naming the migration generated by squashmigrations. 2017-07-26 13:47:35 -04:00
Simon Charette 5cbcb36839 Fixed #28350 -- Fixed UnboundLocalError crash in RenameField with nonexistent field.
Thanks Tim for the review.
2017-06-30 12:50:37 -04:00
Mariusz Felisiak 081e787160 Refs #23919 -- Stopped inheriting from object to define new style classes.
Tests and docs complement to cecc079168.
2017-06-26 10:30:31 -04:00
Marti Raudsepp fda55c71a8 Fixed #27858 -- Prevented read-only management commands from creating the django_migrations table.
MigrationRecorder now assumes that if the django_migrations table
doesn't exist, then no migrations are applied.

Reverted documentation change from refs #23808.
2017-06-19 13:04:57 -04:00
Jon Dufresne 2c69824e5a Refs #23968 -- Removed unnecessary lists, generators, and tuple calls. 2017-06-01 19:08:59 -04:00
Jon Dufresne 21046e7773 Fixed #28249 -- Removed unnecessary dict.keys() calls.
iter(dict) is equivalent to iter(dict.keys()).
2017-05-27 19:08:46 -04:00
Jon Dufresne f599747fc8 Fixed #28152 -- Made migrations serialize sets as set literals rather than set(). 2017-05-18 09:33:40 -04:00
Markus Holtermann 8e352876c3
Refs #22397 -- Removed model in test cleanup
The test was failing when using --keepdb due to a pre-existing
PonyStables model.

Thanks Florian Apolloner for the report
2017-05-09 11:15:41 +02:00
Ian Foote 63afe3a2bf Fixed #28043 -- Prevented AddIndex and RemoveIndex from mutating model state. 2017-05-01 09:32:44 -04:00
Michiel Beijen 5e8625ba64 Renamed "Mac OS X" to "macOS" in docs. 2017-04-24 20:16:09 -04:00
Tim Graham eb9a3bd63a Refs #26605 -- Isolated a migrations state test. 2017-04-10 08:13:45 -04:00
Ingo Klöcker 67b2b1f116 Refs #26605 -- Added migrations state test for a swappable model inheriting an abstract model inheriting concrete model.
Thanks Sébastien Diemer for the report and test.
2017-04-07 13:41:07 -04:00
Markus Holtermann d3cf75ec6f Fixed #28051 -- Made migrations respect Index's name argument.
Thanks Marc Tamlyn for the report and Tim Graham for the review.
2017-04-07 11:47:53 -04:00
Tim Graham 3d19d1428a Fixed #27915 -- Allowed Meta.indexes to be defined in abstract models.
Thanks Markus Holtermann for review.
2017-03-21 10:53:21 -04:00
Claude Paroz 8346680e1c Refs #27795 -- Removed unneeded force_text calls
Thanks Tim Graham for the review.
2017-03-04 18:18:21 +01:00
Tim Graham ab83d4d8fe Added multi_db=True to test cases that access the 'other' db connection.
Fixed a failure in the context processors tests when running in
reverse on MySQL due to an extra query after refs #27683.
2017-02-10 08:19:32 -05:00
Claude Paroz c651331b34 Converted usage of ugettext* functions to their gettext* aliases
Thanks Tim Graham for the review.
2017-02-07 09:04:04 +01:00
Mads Jensen ce69a421f6 Added tests for various __repr__() methods. 2017-02-04 11:29:39 -05:00
Tim Graham 29f607927f Fixed spelling of "nonexistent". 2017-02-03 08:01:45 -05:00
Chillar Anand 6478e07a62 Refs #23919 -- Replaced tempfile.mkdtemp() with TemporaryDirectory() context manager. 2017-01-26 13:54:16 -05:00
Tim Graham 1c466994d9 Refs #23919 -- Removed misc Python 2/3 references. 2017-01-25 13:59:25 -05:00
Ed Morley bfd42392ab Simplified tests with assertDoesNotOptimize(). 2017-01-25 13:52:44 -05:00
chillaranand d6eaf7c018 Refs #23919 -- Replaced super(ClassName, self) with super(). 2017-01-25 12:23:46 -05:00
Mads Jensen ebf34c3cdc Removed unused variables that are overwritten. 2017-01-25 09:14:05 -05:00
Claude Paroz 2366100872 Removed unneeded force_text calls in the test suite 2017-01-24 18:45:54 +01:00
Mariusz Felisiak c22212220a Refs #23919 -- Removed re.U and re.UNICODE (default on Python 3). 2017-01-21 14:28:16 -05:00
Tim Graham 7aba69145d Refs #23919 -- Removed django.test.mock Python 2 compatibility shim. 2017-01-20 08:17:20 -05:00
Claude Paroz 042b7350a0 Refs #23919 -- Removed unneeded str() calls 2017-01-20 14:13:55 +01:00
Tim Graham 4e729feaa6 Refs #23919 -- Removed django.utils._os.upath()/npath()/abspathu() usage.
These functions do nothing on Python 3.
2017-01-20 08:01:02 -05:00
Tim Graham 109b33f64c Refs #23919 -- Simplified assertRaisesRegex()'s that accounted for Python 2. 2017-01-20 08:49:47 +01:00
Claude Paroz dc8834cad4 Refs #23919 -- Removed unneeded force_str calls 2017-01-20 08:44:31 +01:00
Tim Graham 9ee47ce7b4 Refs #23919 -- Removed enum ImportError handling for Python 2. 2017-01-19 13:55:20 -05:00
Simon Charette 9695b14982 Refs #23919 -- Removed str() conversion of type and method __name__. 2017-01-19 11:31:07 -05:00
Simon Charette cecc079168 Refs #23919 -- Stopped inheriting from object to define new style classes. 2017-01-19 08:39:46 +01:00
Aymeric Augustin a556396339 Refs #23919 -- Replaced io.open() with open().
io.open() is an alias for open() on Python 3.
2017-01-18 21:45:12 -05:00
Claude Paroz 2b281cc35e Refs #23919 -- Removed most of remaining six usage
Thanks Tim Graham for the review.
2017-01-18 21:33:28 +01:00
Claude Paroz 7b2f2e74ad Refs #23919 -- Removed six.<various>_types usage
Thanks Tim Graham and Simon Charette for the reviews.
2017-01-18 20:18:46 +01:00
Claude Paroz c716fe8782 Refs #23919 -- Removed six.PY2/PY3 usage
Thanks Tim Graham for the review.
2017-01-18 16:21:28 +01:00
Claude Paroz f3c43ad1fd Refs #23919 -- Removed python_2_unicode_compatible decorator usage 2017-01-18 13:44:34 +01:00
Claude Paroz d7b9aaa366 Refs #23919 -- Removed encoding preambles and future imports 2017-01-18 09:55:19 +01:00
Tim Graham e0910dcc92 Refs #25604 -- Removed makemigrations --exit option per deprecation timeline. 2017-01-17 20:52:01 -05:00
Simon Charette dc1193085d Made contenttypes and auth apps unavailable when not necessary in tests. 2017-01-13 08:50:03 -05:00
Ed Morley 7156a6c9c4 Fixed #27717 -- Allowed migration optimization across AlterModelOptions. 2017-01-10 18:38:48 -05:00
Tim Graham 9932e1bf52 Fixed test isolation in a couple migrations tests.
Without this, tests from refs #27432 fail when running with --reverse.
2017-01-09 08:02:09 -05:00