Commit Graph

604 Commits

Author SHA1 Message Date
Flavio Curella c2e70f0265 Fixed #21127 -- Started deprecation toward requiring on_delete for ForeignKey/OneToOneField 2015-07-27 18:28:13 -04:00
Andrei Kulakov db97a88495 Fixed #24375 -- Added Migration.initial attribute
The new attribute is checked when the `migrate --fake-initial` option
is used. initial will be set to True for all initial migrations (this
is particularly useful when initial migrations are split) as well as
for squashed migrations.
2015-07-13 15:57:40 -04:00
Kai Richard Koenig 60f795c060 Fixed #25040 -- Fixed migrations state crash with GenericForeignKey 2015-07-02 12:48:29 -04:00
Andriy Sokolovskiy c0cf73a57d Refs #20203 -- Allowed adding custom default manager to the model state
If the only manager on the model is the default manager defined
by Django (`objects = models.Manager()`), this manager will not
be added to the model state. If it is custom, it needs to be
passed to the model state.
2015-06-29 21:15:37 -04:00
Tim Graham aaacaeb096 Renamed RemovedInDjangoXYWarnings for new roadmap.
Forwardport of ae1d663b79
from stable/1.8.x plus more.
2015-06-24 16:08:20 -04:00
Markus Holtermann 7bb7670ee4 Used mock in MigrationQuestioner tests
Thanks Andriy Sokolovskiy and Simon Charette for the review.
2015-06-23 17:34:22 +02:00
Tim Graham 7f1168e387 Removed support for Python 3.3. 2015-06-18 08:36:50 -04:00
Markus Holtermann e470f311d6 Fixed #24828 -- Allowed migration optimization across AlterFooTogether
The idea behind this change is, that AlterUniqueTogether,
AlterIndexTogether and AlterOrderWithRespectTo can always be moved after
an Add/Alter/Rename/RemoveField operation if they don't refer to the
respective field and are not empty sets / None.

Combined with the optimizations of duplicate AlterUniqueTogether,
AlterIndexTogether, and AlterOrderWithRespectTo operations from
128caa1e16, these operations are optimized
in a later round of the optimizer.

Thanks Tim Graham for the review.
2015-06-16 00:43:22 +02:00
Markus Holtermann 128caa1e16 Optimized duplicate AlterModelTable/AlterFooTogether/AlterOWRT
Thanks Andrew Godwin for the review.
2015-06-14 20:34:48 +02:00
Markus Holtermann 5bc412c35a Took AlterOrderWithRespectTo into account when optimizing migrations
Thanks Andrew Godwin for the review.
2015-06-14 20:34:34 +02:00
Carl Meyer 57dbc87ade Cleaned up docstring style, per Tim Graham review. 2015-06-03 19:20:12 -06:00
Carl Meyer 5c085ea7b3 Refs #24628 -- Added a second test and a docstring comment to avoid regression. 2015-06-03 13:46:01 -06:00
Carl Meyer 492537ac18 Fixed #24628 -- Fixed applied status for squashed migrations. 2015-06-02 16:15:13 -06:00
Carl Meyer 335fc44f68 Improved isolation of applied-migrations table in migration tests. 2015-06-02 16:14:02 -06:00
Carl Meyer 84522c0d16 Fixed #24895 -- Fixed loading a pair of squashed migrations with a dependency. 2015-06-02 12:07:54 -06:00
Yoong Kang Lim 076a63e672 Fixed #24883 -- Added MigrationGraph.__repr__() 2015-06-01 10:45:52 -04:00
Matt Westcott ff8a02ae0b Fixed #24340 -- Added nested deconstruction for list, tuple and dict values
Nested deconstruction should recursively deconstruct items within list,
tuple and dict values.
2015-05-26 17:10:02 +02:00
Marten Kenbeek d73176a842 Fixed #24848 -- Fixed ValueError for faulty migrations module.
Added apps to unmigrated apps if the migrations module is a file
or a folder missing __init__.py.

Thanks to Ernest0x for the bug report.
2015-05-25 13:47:50 -04:00
Simon Charette be67400b47 Refs #24652 -- Used SimpleTestCase where appropriate. 2015-05-20 13:46:13 -04:00
Tim Graham f5da438072 Fixed #24812 -- Fixed app registry RuntimeWarnings in schema and migrations tests. 2015-05-18 09:48:25 -04:00
Markus Holtermann 811d7870a5 Moved migration exception classes to shared module
Thanks Aymeric Augustin for the review.
2015-05-02 12:54:44 +02:00
Markus Holtermann 63f9b633f9 Fixed #24725 -- Allowed renaming of target models in ManyToMany relations
This is a regression caused by introducing rendered migration states in
1aa3e09c20 and the _meta refactoring in fb48eb0581.

Thanks to Danilo Bargen for reporting the issue and Marten Kenbeek and
Tim Graham for triaging the bug and providing the initial test case.
2015-04-30 13:27:29 +02:00
Markus Holtermann faad6070ee Fixed #24701 -- Converted model manager names to unicode in migrations
Thanks to Reto Aebersold for reporting the issue and Tim Graham and
Claude Paroz for the review.
2015-04-25 18:17:06 +02:00
Markus Holtermann b93690c465 Fixed #24573 -- Considered new related models for reloading
Thanks tttomekkk for the report.
2015-04-21 11:35:45 +02:00
Marten Kenbeek 1a1f16d67d Fixed #24591 -- Optimized cloning of ModelState objects.
Changed ModelState.clone() to create a shallow copy of self.fields
and self.managers.
2015-04-20 19:53:21 -04:00
Marten Kenbeek 039d7881b4 Refs #24397 -- Sped up model reloading in ProjectState.
Created bulk_update() context manager on StateApps. Sped up unregistering
models in reload_models() by using this context mananger.
2015-04-20 14:42:23 -04:00
Claude Paroz 02260ea3f6 Fixed #24595 -- Prevented loss of null info in MySQL field alteration
Thanks Simon Percivall for the report, and Simon Charette and Tim
Graham for the reviews.
2015-04-17 10:25:15 +02:00
Christopher Luc a7bc00e17b Fixed #24514 -- Made migration writer omit models import if it's unused. 2015-04-10 07:04:26 -04:00
Curtis Maloney 88d7fcebde Use mock.patch in migrations tests
Currently some of the migrations tests rely on the fact 'input' is aliased
because of six, instead of using mock.patch.  Replace this code with proper
use of mock.patch.

Also, replace one case of excessively specific python version check with
testing six.PY3
2015-04-09 11:16:12 +10:00
Patryk Zawadzki 0385dad073 Fixed #24513 -- Made sure a model is only rendered once during reloads
This also prevents state modifications from corrupting previous states.
Previously, when a model defining a relation was unregistered first,
clearing the cache would cause its related models' _meta to be cleared
and would result in the old models losing track of their relations.
2015-04-07 14:49:47 +02:00
Marten Kenbeek e8e4f978dd Fixed #24278 -- Fixed serialization of migration operations.
Fixed MigrationWriter.serialize() to correctly handle migration
operations by utilizing OperationWriter.

Thanks Piotr Maliński for the report.
2015-04-05 20:26:21 +02:00
Marten Kenbeek d597174bd4 Refs #24278 -- Allowed multi-line serializations in OperationWriter.
Changed OperationWriter to support multi-line serialized values with
correct indentation.
2015-04-05 20:19:24 +02:00
Baptiste Mispelon 30a3c2f74c Fixed #24566 -- Added support for serializing timedelta
Thanks to knbk for the report.
2015-04-02 17:21:20 +02:00
Markus Holtermann c5cc332bf2 Fixed #24550 -- Added migration operation description to sqlmigrate output
Thanks Tim Graham for the review.
2015-03-30 16:31:20 +02:00
Marten Kenbeek 75430be86f Refs #24366 -- Fixed recursion depth error in migration graph
Made MigrationGraph forwards_plan() and backwards_plan() fall back to an
iterative approach in case the recursive approach exceeds the recursion
depth limit.
2015-03-29 16:08:07 +02:00
Marten Kenbeek bc83add04c Refs #24366 -- Renamed arguments in MigrationGraph, renamed tests 2015-03-29 16:07:58 +02:00
Markus Holtermann c7ec3c07e7 Fixed #24537 -- Ignored field order in RenameModel detection
Thanks to David Sanders for the report and test and Simon Charette for
the review.
2015-03-28 20:45:15 +01:00
Anssi Kääriäinen 8f30556329 Renamed Field.rel attribute to remote_field
Field.rel is now deprecated. Rel objects have now also remote_field
attribute. This means that self == self.remote_field.remote_field.

In addition, made the Rel objects a bit more like Field objects. Still,
marked ManyToManyFields as null=True.
2015-03-25 08:16:12 -04:00
David Szotten 80e3444eca Fixed #24483 -- Prevented keepdb from breaking with generator choices.
If Field.choices is provided as an iterator, consume it in __init__ instead
of using itertools.tee (which ends up holding everything in memory
anyway). Fixes a bug where deconstruct() was consuming the iterator but
bypassing the call to `tee`.
2015-03-24 11:42:53 -04:00
Baptiste Mispelon 1aadade373 Fixed #24521 -- Added support for serializing frozensets in migrations. 2015-03-23 15:38:25 +01:00
John Giannelos 8758a63ddb Fixed #24427 -- Stopped writing migration files in dry run mode when merging.
Also added display of migration to stdout when verbosity=3.
2015-03-16 14:04:37 -04:00
Matthew Wilkes ae87ad005f Refs #24354 -- Prevented repointing of relations on superclasses when migrating a subclass's name change
Forwardport of test and release note from stable/1.7.x
2015-03-14 15:37:40 -04:00
Marten Kenbeek e272904ff7 Fixed #23407 -- Extended coverage of makemigrations --noinput option.
Changed --noinput option in makemigrations to suppress all user prompts,
not just when combined with --merge.
2015-03-08 19:44:14 +01:00
Markus Holtermann a9e29fae10 Fixed #24435 -- Prevented m2m field removal and addition in migrations when changing blank
Thanks Mark Tranchant for the report an Tim Graham for the test and
review.
2015-03-04 14:26:49 +01:00
Aymeric Augustin 903d1a57ab Made migrations tests write to a temporary directory.
This is preferrable to writing in the current working directory because
it eliminates the risk to leak unwanted files, which can result in very
weird test failures.

Also this will help if we ever try to run these tests concurrently.
2015-02-23 22:22:58 +01:00
Marten Kenbeek 78d43a5e10 Fixed #24366 -- Optimized traversal of large migration dependency graphs.
Switched from an adjancency list and uncached, iterative depth-first
search to a Node-based design with direct parent/child links and a
cached, recursive depth-first search. With this change, calculating
a migration plan for a large graph takes several seconds instead of
several hours.

Marked test `migrations.test_graph.GraphTests.test_dfs` as an expected
failure due to reaching the maximum recursion depth.
2015-02-23 12:38:53 +01:00
Loic Bistuer bed504d70b Fixed #24351, #24346 -- Changed the signature of allow_migrate().
The new signature enables better support for routing RunPython and
RunSQL operations, especially w.r.t. reusable and third-party apps.

This commit also takes advantage of the deprecation cycle for the old
signature to remove the backward incompatibility introduced in #22583;
RunPython and RunSQL won't call allow_migrate() when when the router
has the old signature.

Thanks Aymeric Augustin and Tim Graham for helping shape up the patch.

Refs 22583.
2015-02-20 21:34:09 +07:00
Shai Berger f7d34fe741 Fixed #24362: Made test run each migration operation in its own schema editor
Thanks Tim Graham for pointing out the fix.
2015-02-18 22:47:15 +02:00
Marten Kenbeek 15dc8d1c9d Fixed #24291 - Fixed migration ModelState generation with unused swappable models
Swapped out models don't have a _default_manager unless they have
explicitly defined managers. ModelState.from_model() now accounts for
this case and uses an empty list for managers if no explicit managers
are defined and a model is swapped out.
2015-02-18 19:05:10 +01:00
Tim Graham 307c0f299a Refs #24324 -- Fixed Python 2 test failures when path to Django source contains non-ASCII characters. 2015-02-17 19:03:03 -05:00
Markus Holtermann d538e37e1b Added tests for get_related_models_recursive 2015-02-16 19:31:52 +01:00
Markus Holtermann 273bc4b667 Refs #24282 -- Added failing test case for assigning models of wrong type to FK
Thanks Jeff Singer for the test case.
2015-02-16 19:31:51 +01:00
Markus Holtermann cc22b009e0 Refs #24264 -- Added failing test case for updating a FK when changing a PK
When the primary key column is altered, foreign keys of referencing
models must be aware of a possible data type change as well and thus
need to be re-rendered.

Thanks Tim Graham for the report.
2015-02-16 19:31:51 +01:00
Claude Paroz 58d0dd9260 Refs #24225 -- Added failing test case for removing a previously added field in migrations
When a related field is deleted, the related model must be updated. As
unchanged models are shared in migration states, the related model must
be re-rendered so that the change applies to a new copy of the related
model.

Thanks Henrik Heimbuerger for the report.
2015-02-16 19:31:51 +01:00
Markus Holtermann f287bec583 Fixed #24184 -- Prevented automatic soft-apply of migrations
Previously Django only checked for the table name in CreateModel
operations in initial migrations and faked the migration automatically.
This led to various errors and unexpected behavior. The newly introduced
--fake-initial flag to the migrate command must be passed to get the
same behavior again. With this change Django will bail out in with a
"duplicate relation / table" error instead.

Thanks Carl Meyer and Tim Graham for the documentation update, report
and review.
2015-02-13 14:29:59 +01:00
Collin Anderson db77915c9f Fixed E265 comment style 2015-02-06 09:30:35 -05:00
Tim Graham 0ed7d15563 Sorted imports with isort; refs #23860. 2015-02-06 08:16:28 -05:00
Tim Graham c0cc8f69e7 Refactored tests that rely on an ImportError for Python 3.5 compatibility
A change in Python test discovery [1] causes the old packages that raised
an error to be discovered; now we use a common directory that's
ignored during discovery. Refs #23763.

[1] http://bugs.python.org/issue7559
2015-02-03 18:30:46 -05:00
Adam Taylor 039465a6a7 Fixed typos in code comments. 2015-01-20 12:18:03 -05:00
Markus Holtermann 7f20041bca Fixed #24155 -- Maintained kwargs and import order in migration writer
Thanks Tomas Dobrovolny for the report and Tim Graham for the review.
2015-01-20 01:24:41 +01:00
Tim Graham 33457cd3b0 Removed IPAddressField per deprecation timeline; refs #20439. 2015-01-19 11:12:57 -05:00
Markus Holtermann 65d55c4093 Cleaned up migration writer tests 2015-01-17 20:29:50 +01:00
Tim Graham 28db4af80a Fixed #24135 -- Made RenameModel rename many-to-many tables.
Thanks Simon and Markus for reviews.
2015-01-15 20:34:33 -05:00
Collin Anderson faf0d66a80 Fixed #23850 -- Fixed a migrations test failure on Mac OS X & Python 3 2015-01-15 19:45:43 -05:00
Markus Holtermann 88786afbff Fixed #24147 -- Prevented managers leaking model during migrations
Thanks Tim Graham for the review.
2015-01-14 16:09:33 +01:00
Markus Holtermann eeb88123e7 Fixed #24129 -- Added indicator that migrations are rendering the initial state
Thanks Tim Graham for the review.
2015-01-12 19:23:46 +01:00
Markus Holtermann bbbed99f62 Fixed #24123 -- Used all available migrations to generate the initial migration state
Thanks Collin Anderson for the input when creating the patch and Tim Graham for the review.
2015-01-12 18:39:18 +01:00
Claude Paroz 68a439a18d Removed supports_binary_field flag as all backends support them
It was mainly for MySQL on Python 3, but now the current
recommended MySQL driver for Python 3 (mysqlclient) does support
binary fields, it is unneeded. Refs #20377.
2015-01-11 23:34:47 +01:00
Markus Holtermann fdc2cc9487 Fixed #24110 -- Rewrote migration unapply to preserve intermediate states 2015-01-10 23:14:15 +01:00
Loic Bistuer 8f4877c89d Fixed #22583 -- Allowed RunPython and RunSQL to provide hints to the db router.
Thanks Markus Holtermann and Tim Graham for the review.
2015-01-10 00:30:48 +07:00
Markus Holtermann c8bac4b556 Fixed #24098 -- Added no-op attributes to RunPython and RunSQL
Thanks Loïc Bistuer and Tim Graham for the discussion and review.
2015-01-09 10:31:32 -05:00
Markus Holtermann 862ea825b5 Fixed #24093 -- Prevented MigrationWriter to write operation kwargs that are not explicitly deconstructed 2015-01-07 17:29:20 -07:00
Markus Holtermann 1f03d2d924 Refs #23822 -- Made MigrationOptimizer aware of model managers 2015-01-07 17:33:04 -05:00
Daniel Pyrathon fb48eb0581 Fixed #12663 -- Formalized the Model._meta API for retrieving fields.
Thanks to Russell Keith-Magee for mentoring this Google Summer of
Code 2014 project and everyone else who helped with the patch!
2015-01-06 19:25:12 -05:00
Markus Holtermann e08318b4ef Refs #23359 -- Removed double newline from output of migrate --list
Thanks Berker Peksag for the review.
2015-01-05 14:52:54 -05:00
Claude Paroz 1aa3e09c20 Fixed #23745 -- Reused states as much as possible in migrations
Thanks Tim Graham and Markus Holtermann for the reviews.
2015-01-02 15:37:10 +01:00
Claude Paroz 2a9c4b4901 Passed around the state between migrations
Refs #23745.
2015-01-02 15:37:10 +01:00
Claude Paroz a159b1facd Replaced migration state render() by apps cached property
Refs #23745.
2015-01-02 15:19:36 +01:00
Markus Holtermann a1487deebf Fixed #23359 -- Added showmigrations command to list migrations and plan.
Thanks to Collin Anderson, Tim Graham, Gabe Jackson, and Marc Tamlyn
for their input, ideas, and review.
2014-12-31 14:14:28 -05:00
Claude Paroz 51890ce889 Applied ignore_warnings to Django tests 2014-12-30 18:16:25 +01:00
Markus Holtermann fca866763a Added test for an intermediate swappable model change in migration state.
refs #22563
2014-12-30 10:01:25 -05:00
Markus Holtermann 623ccdd598 Fixed #23938 -- Added migration support for m2m to concrete fields and vice versa
Thanks to Michael D. Hoyle for the report and Tim Graham for the review.
2014-12-29 13:41:12 -05:00
Tim Graham 061caa5b38 Fixed #24037 -- Prevented data loss possibility when changing Meta.managed.
The migrations autodetector now issues AlterModelOptions operations for
Meta.managed changes instead of DeleteModel + CreateModel.

Thanks iambibhas for the report and Simon and Markus for review.
2014-12-23 14:25:31 -05:00
Oscar Ramirez 54085b0f9b Fixed #23998 -- Added datetime.time support to migrations questioner. 2014-12-22 07:24:54 -05:00
Josh Schneier 9a23470072 Fixed #24017 -- Added python_2_unicode_compatible in db/migrations 2014-12-21 16:10:43 -05:00
Andriy Sokolovskiy 3dbbb8a89c Fixed #23983 -- Fixed a crash in migrations when adding order_with_respect_to to non-empty table. 2014-12-16 10:48:49 -05:00
Diego Guimarães c17d821fa7 Refs #23947 -- Improved migrations tests table cleanup.
Copied technique from schema tests.
2014-12-15 19:05:19 -05:00
Markus Holtermann 3ef50a772b Fixed reverse test execution for migration manager tests
Thanks to Tim Graham for reporting the issue; refs #23822
2014-12-15 17:54:40 -05:00
Andriy Sokolovskiy d8f3b86a76 Fixed #23405 -- Fixed makemigrations prompt when adding Text/CharField.
A default is no longer required.
2014-12-15 14:41:52 -05:00
Markus Holtermann aa5ef0d4fc Fixed #23822 -- Added support for serializing model managers in migration
Thanks to Shai Berger, Loïc Bistuer, Simon Charette, Andrew Godwin,
Tim Graham, Carl Meyer, and others for their review and input.
2014-12-15 08:34:15 -05:00
Markus Holtermann 44927ba817 Fixed #23956 -- Fixed migration creation for multiple table inheritance 2014-12-11 13:28:21 -05:00
Gavin Wahl dee4d23f7e Fixed #23950 -- Prevented calling deconstruct on classes in MigrationWriter. 2014-12-03 08:22:29 -05:00
Claude Paroz e11c6fd218 Fixed #23909 -- Prevented crash when collecting SQL for RunSQL
Thanks James Rivett-Carnac for the report and Markus Holtermann
for the review.
2014-12-01 20:26:40 +01:00
wrwrwr b481c85697 Corrected a docstring in tests/migrations/test_operations.py. 2014-12-01 11:37:51 -05:00
wrwrwr 9136ceb6fb Replaced router.routers usage with override_settings(DATABASE_ROUTERS); refs #23933. 2014-12-01 11:34:15 -05:00
Markus Holtermann d2202ec2d4 Fixed #23880 -- Added missing index_together handling for SQLite 2014-12-01 11:30:33 +07:00
Tim Heap deb607648e Fixed #23728 -- Added the --exit option to makemigrations.
If no changes that need migrations are found, `makemigrations --exit`
exits with error code 1.
2014-11-28 07:48:39 -05:00
Markus Holtermann 912ad03226 Fixed #23894 -- Made deconstruct methods favor kwargs over args 2014-11-28 06:05:56 -05:00
Tim Graham 392e11945f Fixed flake8 warnings. 2014-11-25 11:20:40 -05:00
Luke Plant ff3d746e8d Fixed bug in circular dependency algo for migration dependencies.
Previous algo only worked if the first item was a part of the loop,
and you would get an infinite loop otherwise (see test).

To fix this, it was much easier to do a pre-pass.

A bonus is that you now get an error message that actually helps you debug
the dependency problem.
2014-11-25 15:37:34 +00:00
Andrzej Pragacz 72729f844e Fixed #23794 -- Fixed migrations crash when removing a field that's part of index/unique_together. 2014-11-21 10:55:19 -05:00
Markus Holtermann 4c709cc0ef Fixed duplicate index error on Oracle; refs #23859.
Refers to regression introduced in 7b4a994599
2014-11-20 14:42:39 -05:00
Patryk Zawadzki 21e21c7bc2 Fixed #23844 -- Used topological sort for migration operation dependency resolution.
This removes the concept of equality between operations to guarantee
compatilibity with Python 3.

Python 3 requires equality to result in identical object hashes. It's
impossible to implement a unique hash that preserves equality as
operations such as field creation depend on being able to accept
arbitrary dicts that cannot be hashed reliably.

Thanks Klaas van Schelven for the original patch in
13d613f800.
2014-11-20 12:49:49 -05:00
Carl Meyer 51f2de1530 Added another migration-executor test to avoid regressions. 2014-11-19 19:43:12 -07:00
Carl Meyer ab2819aa7b Fixed #23410 -- Avoided unnecessary rollbacks in related apps when migrating backwards. 2014-11-19 16:11:44 -07:00
Carl Meyer 47b7f601ee Fixed #23872 -- Removed sensitivity of migrations tests to CWD. 2014-11-19 15:03:47 -07:00
Markus Holtermann 2331650835 Cleaned up and reformatted autodetector tests 2014-11-19 11:09:38 -05:00
Markus Holtermann f17acd5930 Formatted model states in autodetector tests 2014-11-19 11:09:38 -05:00
Stratos Moros cf7a2a000e Fixed #22248 -- Made RenameModel reversible 2014-11-19 14:11:35 +02:00
Tillmann Karras d188101319 Fixed #23799 -- Made makemigrations respect --no-optimize.
Thanks to yamila-moreno for the idea of a skip message.
2014-11-18 07:37:06 +01:00
Markus Holtermann 7b4a994599 Fixed #23859 -- Fixed a migration crash when a field is renamed that is part of an index_together 2014-11-17 19:15:07 +01:00
Simon Charette 68ef44c565 Removed references to the deprecated assertRaisesRegexp method. 2014-11-16 02:12:36 +01:00
Andrew Godwin c5def493d0 Fixed #23835: Changed circular dependency in DFS to be less infinite 2014-11-15 17:39:02 +01:00
Tim Graham 83d104d61a Revert "Use topological sort for migration operation dependency resolution"
This commit broke the tests on Python 3.

This reverts commit 13d613f800.
2014-11-15 15:28:04 +01:00
Klaas van Schelven 13d613f800 Use topological sort for migration operation dependency resolution
rather than an ad-hoc algorithm
2014-11-15 14:45:42 +01:00
Markus Holtermann c7c098cf97 Fixed #23770 -- Changed serialization strategy for floats with respect to NaN and Inf
Thanks to w0rp for the report
2014-11-06 15:30:30 +01:00
Berker Peksag f7969b0920 Fixed #23620 -- Used more specific assertions in the Django test suite. 2014-11-03 11:56:37 -05:00
twidi fd061b6591 Fixed #23733 -- Fixed squashing migrations that depend on multiple apps. 2014-10-30 14:39:11 -04:00
Markus Holtermann 85086c8158 Fixed #23556 -- Raised a more meaningful error message when migrations refer to an unavailable node 2014-10-30 00:17:29 +01:00
Markus Holtermann 5c9c1e029d Fixed #23614 -- Changed the way the migration autodetector orders unique/index_together
Thanks to Naddiseo for the report and Tim Graham for the review
2014-10-29 13:05:42 -04:00
Claude Paroz 70428902c0 Added missing available app in migrations test case
In some test combinations, having contrib.auth available but not
contrib.contenttypes can produce failures while creating permissions.
2014-10-23 15:39:26 +02:00
Tim Graham 41b337efa0 Fixed #23630 -- Made AlterModelTable rename auto-created M2M tables.
Thanks Naddiseo for the report, Andrew Godwin for guidance,
and Shai Berger for review.
2014-10-23 08:05:39 -04:00
Loic Bistuer 494ba051bb Made testing of stdout and stderr more consistent.
Refs #23663.
2014-10-22 09:25:50 +07:00
Claude Paroz bbc3505ef8 Removed unneeded override_system_checks
Refs #23685.
2014-10-21 20:54:32 +02:00
Tianyi Wang 5732424bee Fixed #23629 -- Allowed autodetector to detect changes in Meta.db_table.
Thanks Naddiseo for reporting.
2014-10-20 13:14:44 -04:00
Claude Paroz 6d11bb102d Revert "Fixed #23650 -- Prevented migrate from calling checks 3 times"
This reverts commit 8d6e1afe0b.
call_command now always set skip_checks to True (tested in
user_commands).
2014-10-20 17:26:00 +02:00
Claude Paroz 8d6e1afe0b Fixed #23650 -- Prevented migrate from calling checks 3 times
Thanks Ilya Baryshev for the report and Tim Graham for the review.
2014-10-17 20:20:56 +02:00
Collin Anderson 4ef9618e12 Avoided requiring sqlparse for a test.
Refs #23426. Thanks Markus Holtermann for the suggestion.
2014-10-09 14:59:33 -04:00
Collin Anderson d6a87eefd8 Skip another test if sqlparse is not available
Refs #23426
2014-10-09 11:54:42 -04:00
Markus Holtermann f633ba778d Fixed #23609 -- Fixed IntegrityError that prevented altering a NULL column into a NOT NULL one due to existing rows
Thanks to Simon Charette, Loic Bistuer and Tim Graham for the review.
2014-10-09 21:32:06 +07:00
Markus Holtermann 85f6d89313 Fixed #23426 -- Allowed parameters in migrations.RunSQL
Thanks tchaumeny and Loic for reviews.
2014-10-02 11:52:40 -04:00
Rudy Mutter a407b846b4 Fixed #23365 -- Added support for timezone-aware datetimes to migrations. 2014-09-29 20:45:43 -04:00
Thomas Chaumeny b2aad7b836 Replaced set([foo, ...]) by {foo, ...} literals. Refs PR 3282.
Thanks Collin Anderson for the review.
2014-09-29 00:01:38 +07:00
Loic Bistuer b23d47412c Fixed #23560 -- Fixed MigrationWrite to handle builtin types without imports.
Thanks Tim Graham for the review.
2014-09-27 00:36:28 +07:00
Markus Holtermann 215aa4f53b Fixed #23415 -- Added fields for unmanaged and proxy model migrations.
Thanks sky-chen for the report.
2014-09-25 10:25:03 -04:00
Tim Graham d7ab2cefb7 Revert "Fixed #23474 -- Prevented migrating backwards from unapplying the wrong migrations."
This reverts commit abcf28a076.
2014-09-24 15:49:30 -04:00
Markus Holtermann b9a670b227 Fixed #23426 -- Don't require double percent sign in RunSQL without parameters 2014-09-24 07:20:57 -04:00
Claude Paroz 2a1bdf5ced Called table_names instead of get_table_list in migrations 2014-09-23 20:13:31 +02:00
Sergey Fedoseev 463952d940 Fixed #23503 -- Fixed renaming of model with self-referential m2m field. 2014-09-23 10:03:37 -04:00
Tim Graham 9d30412a5a Fixed some flake8 errors.
Originally I added migrations to flake8 exclude because of long lines
in migration files, but there are other directories named migrations we
do want to check. We are not warning on line lengths yet anyway.
2014-09-19 12:31:15 -04:00
valtron abcf28a076 Fixed #23474 -- Prevented migrating backwards from unapplying the wrong migrations. 2014-09-15 14:56:59 -04:00
Szilveszter Farkas 5e32605ce9 Fixed #23483 -- Prevented ImproperlyConfigured with dotted app names
Made sure the app labels stay unique for the AppConfigStubs, so
migrations wouldn't fail if two dotted app names has the same last part
(e.g. django.contrib.auth and vendor.auth)
2014-09-12 14:58:54 -06:00
Markus Bertheau 61f56e239f Corrected grammar in migrations error message. 2014-09-10 10:32:33 -04:00
Markus Holtermann 6d5958c7a3 Fixed #23452 -- Prevented infinite migrations for empty unique/index_together.
Thanks fwkroon for the report.
2014-09-10 07:54:16 -04:00
Markus Holtermann 16548cfc7c Fixed broken test from da160d440f; refs #23418. 2014-09-08 16:49:06 -04:00
Markus Holtermann d28b5f13b3 Fixed #23418 -- Fail when migration deconstruct produces invalid import 2014-09-08 21:27:34 +02:00
Andrew Pinkham 4680d25df2 Fixed #22951 -- Checked for types during deep_deconstruct migration serialization process.
Thanks Sam Hartsfield for the report.
2014-09-08 07:39:09 -04:00
Andrew Godwin 3ab36d0046 Fix Python 3 incompatability 2014-09-05 15:47:20 -07:00
Ben Reilly b878c73fc3 switch out recursive dfs for stack based approach, to avoid possibly hitting the recursion limit 2014-09-05 15:26:05 -07:00
Claude Paroz 885ff6845e Revert "Fixed #23384 -- Allowed overriding part of a dictionary-type setting"
This reverts commit 66757fee7e.
Discussions have led to think that this functionality does not
bring significant benefits to justify the added complexity.
Read also discussions on ticket #22734.
2014-09-05 20:06:02 +02:00
Raffaele Salmaso 1435cfbe8d Fixed #23302 -- Added --name/-n option to makemigrations command 2014-09-02 21:09:18 -04:00
Dave Hall e03b7940e5 Fixed #22918 -- Fixed SeparateDatabaseAndState crash 2014-09-02 08:06:44 -04:00
Claude Paroz 66757fee7e Fixed #23384 -- Allowed overriding part of a dictionary-type setting
This change is needed for upcoming changes where settings might be
grouped in a parent dictionary.
Thanks Tim Graham for the review.
2014-08-30 12:37:10 +02:00
Raffaele Salmaso abd640fbdf Fixed #23341 -- Added migration name to nonexistent migration error in makemigrations. 2014-08-23 19:18:03 -04:00
Raffaele Salmaso be4baaefe2 Fixed #23352 -- Added tests for MigrationGraph.{forwards,backwards}_plan 2014-08-23 21:35:13 +00:00
Markus Holtermann 144cff3f51 Fixed #23322 -- Use resolved swappable model for dependency resolution during makemigrations 2014-08-20 16:04:21 -04:00
Tim Graham d1299fce0e Fixed migrations tests added in refs #23315. 2014-08-20 14:00:59 -04:00
Andrew Godwin 9247da1032 Fixed #23315: Operational dependency fail with mixed create/add 2014-08-19 19:51:12 -07:00
Lee Sanghyuck 11d9cbe2f4 Fixed #23316 -- Added datetime.time serialization in migrations. 2014-08-19 13:31:46 -04:00
Baptiste Mispelon 54164b814c Fixed broken tests on Oracle after 5853c87a45.
Oracle doesn't have a `BEGIN` statement so the test would
fail.

Refs #23303
2014-08-19 17:58:30 +02:00
Baptiste Mispelon 5853c87a45 Fixed #23303 -- Added BEGIN and COMMIT statements to the output of sqlmigrate. 2014-08-18 18:55:12 +02:00
Tim Graham 0ad4672c0f Fixed typo in tests/migrations/test_operations.py 2014-08-15 11:01:49 -04:00
Andrew Godwin 8f9862cd4d Fixed #23275: Unmanaged models kept by autodetector, ignored by ops 2014-08-12 12:49:20 -07:00
Andrew Godwin dfe86449c9 Fixed #23244: Error altering FK to non-FK in migrations 2014-08-07 11:52:31 +10:00
Andrew Godwin c06e124b5e Fixed #23091: CreateModel and AddField were clashing with deferred SQL 2014-08-04 11:59:29 +10:00
Simon Charette 1b00738f73 Fixed a MySQL test failure introduced by cbb29af1aa.
Seems like unlike other backends MySQL get_constraints fails when dealing
with a non-existing table. refs #23160.
2014-08-03 16:32:36 -04:00
Simon Charette cbb29af1aa Fixed #23160 -- Correctly rename models with self referential fields.
Thanks to whitews AT gmail for the report.
2014-08-03 15:27:01 -04:00
Andrew Godwin a338e07735 Fixed #23101: Prefer doing deletes before creates in autodetector.
Makes declined or missed renames still work (but drop data).
2014-07-29 09:38:51 -07:00
Andrew Godwin d6e73a876d Fixed #23121: AlterModelOptions operation not changing state right 2014-07-28 10:47:28 -07:00
Andrew Godwin cb60d22bd9 Fixed #23100: Individual FK creation missing dependencies 2014-07-28 10:32:43 -07:00
Andrew Godwin 805774df1f Fixed #22944: Bad dependency on FK alteration in autodetector 2014-07-26 09:22:19 -07:00
Andrew Godwin a64bc3df77 Fixed #23093: soft application detection for swapped models 2014-07-25 09:35:38 -07:00
Andrew Godwin ed4812692e Merge pull request #2938 from dekkers/ticket_23071
Fixed #23071 -- Use last migration's name in dependency to other app
2014-07-25 08:53:57 -07:00
Tim Graham 64e75c47ef Fixed #23014 -- Infinite migration regression with unique/index_together. 2014-07-24 14:27:10 -04:00
Tim Graham 66211b4b75 Silenced a Python 2 ImportWarning in a migrations test. 2014-07-24 09:24:52 -04:00
Jeroen Dekkers 3582698c13 Fixed #23071 -- Use last migration's name in dependency to other app
Changed the autodetector to lookup the name of the other app's last
migration in the graph and use that as dependency instead of using
__latest__.
2014-07-22 01:03:02 +02:00
Andrew Godwin e24e9e0438 Fixed #23014: Renaming not atomic with unique together 2014-07-21 11:36:34 +01:00
Andrew Godwin dcb4ed5170 Fixed #22975: Don't call rename SQL if not needed 2014-07-21 10:14:00 +01:00
Andrew Godwin 145d231782 Fixed #23041: Bad base dependencies for proxy models 2014-07-16 09:59:08 -07:00
Tim Graham 0154965392 Fixed #23013 -- Fixed removing unique_together/index_together constraints in migrations.
Thanks melinath for the report.
2014-07-15 15:20:59 -04:00
Tim Graham 9a2ab62977 Fixed #23008 -- Fixed typo causing bad migration dependencies.
Thanks semenov for the report and Florian for investigation.
2014-07-15 08:48:29 -04:00
Huu Nguyen f7a78f9bba Fixed #22791 -- Invoke interactive questioner only for conflicts in specified apps.
Thanks bendavis78 for the report and Tim Graham for the review.
2014-07-14 11:00:49 -04:00
Andrew Godwin 9e5a37c82d Fix comment 2014-07-10 10:00:31 -07:00
Andrew Godwin 008bff92b7 Fixed #22970: Incorrect dependencies for existing migrated apps 2014-07-09 23:53:43 -07:00
Loic Bistuer 2572c07cc6 Fixed #22906 -- Added a more helpful repr to migrations' ModelState.
Thanks Collin Anderson for the report and original patch.
2014-07-06 14:56:18 +07:00
Andrew Godwin f751109cb2 Merge pull request #2881 from charettes/ticket-22943-compiled-regex-deconstruction
Fixed #22943 -- Correctly serialize compiled regexes.
2014-07-05 16:37:10 -07:00
Andrew Godwin 80a12f21e3 Fixed #22960: Bad handling of relations as PKs in autodetector 2014-07-05 16:33:03 -07:00
Simon Charette 35c2c37041 Fixed #22943 -- Correctly serialize compiled regexes.
Thanks to antialiasis at gmail dot com for the patch.
2014-07-04 13:34:20 -04:00
Colin Wood 27ee608b55 Fixed #22940 -- Added missing string iterpolation parameters in migrations.writer error.
Forwardport of f5740af868 from stable/1.7.x
2014-07-02 12:45:02 -04:00
Tim Graham 70576740b0 Fixed #22917 -- Fixed typo in AlterIndexTogether.describe(). 2014-06-27 10:34:48 -04:00
Tim Graham e0cd07ec2f Fixed #22903 -- Fixed migration generation if index_together or unique_together is removed from a model. 2014-06-25 10:02:12 -04:00
Andrew Godwin fe262c0b84 Fixed #22708: Typo in autodetector base dependency gen 2014-06-23 20:48:33 -07:00
Tim Graham 908160f692 Fixed test failures introduced by refs #22881. 2014-06-23 09:59:36 -04:00
Chris Beaven 21c496ea52 Fixed #22881 -- Better soft_applied migration detection 2014-06-23 13:36:22 +12:00
Andrew Godwin b30d32ff24 Fixed #22875: Optimizer did not take through= into account. 2014-06-22 11:23:45 -07:00
Tim Graham 9a46836a0c Moved a line outside of try/except to prevent an error in finally.
Thanks Ian Foote.
2014-06-20 09:13:34 -04:00
Huu Nguyen fbb684d95e Fixed #22862 -- Added --noinput option to makemigrations.
Thanks artortenburger for the report.
2014-06-20 08:55:02 -04:00
Alex Gaynor d015c9d11c Fixed several flake8 errors 2014-06-18 07:47:13 -07:00
Andrew Godwin 2cee1d4642 Fixed #22861: Internal migrations done first so __first__ works
Thanks to Chris Beaven.
2014-06-17 23:28:35 -07:00
Andrew Godwin 09b63a7cce Fix __latest__ to actually resolve to the latest migration 2014-06-17 22:12:31 -07:00
Andrew Godwin 405b9dcd8b Fix broken test 2014-06-17 21:32:23 -07:00
Andrew Godwin 8d2ac948a9 Fixed #22853: Swapped models are now ignored for migration operations. 2014-06-17 17:45:38 -07:00
Andrew Godwin 77ff4a9360 Fix previous commit on python 2 2014-06-17 09:56:22 -07:00
Víðir Valberg Guðmundsson 3a6cb9f497 Fixed #22577: Python 3 broke on non-module migrations directory 2014-06-17 18:21:38 +02:00
Tim Graham 317c480c04 Removed some u'' prefixes to fix Python 3.2. 2014-06-16 18:49:37 -04:00
Tim Graham b341f33697 Added database migration for contrib.auth.
refs #22170.
2014-06-16 16:21:37 -04:00
Tim Graham eb8600a656 Added database migration for contrib.contenttypes.
Moved contenttypes tests to allow them to run correctly in the presence of
migrations. refs #22170.
2014-06-16 15:03:00 -04:00
Andrew Godwin 067b9668fb Fixed #22783: Make sure swappable models come first in creation 2014-06-16 10:20:05 -07:00
Matthew Schinckel bb39037fcb Fixed #22788 -- Ensured custom migration operations can be written.
This inspects the migration operation, and if it is not in the
django.db.migrations module, it adds the relevant imports to the
migration writer and uses the correct class name.
2014-06-16 12:28:52 -04:00
Tim Graham 808388c28c Removed usaged of contrib.sessions as a placeholder in migration tests.
Without this, we're unable to add actual migrations for the app.
2014-06-16 10:15:19 -04:00
Andrew Godwin c8c79367a2 Fixed #22844: Duplicate SQL for SQLite FKs 2014-06-16 00:27:32 -07:00
Alex Gaynor d17a4cb037 Fixed several flake8 errors 2014-06-15 20:45:15 -04:00
Andrew Godwin c1276785f9 Fixed #22568: Better proxy model support in migrations 2014-06-15 16:01:49 -07:00
Andrew Godwin a8ce5fdc28 Fixed #22470: Full migration support for order_with_respect_to 2014-06-15 14:56:51 -07:00
Andrew Godwin a58f49d104 Persist non-schema-relevant Meta changes in migrations 2014-06-15 12:34:02 -07:00
Andrew Godwin f717ef083a Fixed #22833: Autodetector not doing through mapping correctly 2014-06-15 12:06:48 -07:00
Andrew Godwin 7b17350a1b Fixed #22823 (and partly #22563) - FKs from unmigrated apps breaking state.
Thanks to bendavis78 for the test and diagnostic work.
2014-06-12 10:22:43 -07:00
Andrew Godwin f146e70cb1 Remove overzealous migration flushes from migration test suite 2014-06-09 09:52:23 -07:00
Andrew Godwin 3f91238adf Fixed #22777: Add dependency on through for autodetected M2M adds 2014-06-08 17:12:59 -07:00
Andrew Godwin 4ce7a6bc84 Fixed #22750, #22248: Model renaming now also alters field FKs 2014-06-07 18:18:02 -07:00
Andrew Godwin 6fd455adfc Fixed #22436: More careful checking on method ref'ce serialization 2014-06-07 17:05:51 -07:00
Andrew Godwin aa12ea05ce Rewrote migration autodetector to involve actual computer science.
Fixes #22605, #22735; also lays the ground for some other fixes.
2014-06-05 23:25:35 -07:00
Andrew Godwin 5826dc5282 Merge pull request #2736 from SmileyChris/migration-run_before
Fixed #22725 - Migration.run_before does nothing
2014-06-05 20:29:26 -07:00
Simon Charette 7a38f88922 Fixed #22659 -- Prevent model states from sharing field instances.
Thanks to Trac alias tbartelmess for the report and the test project.
2014-06-01 15:10:38 -04:00
Moayad Mardini 6f4d7f41b1 Improved the test for refs #22682.
Thanks apollo13 for the review.
2014-05-30 11:00:13 -04:00
Andrew Godwin 9cbf7f25ef Fix additional test failures caused by migration pollution 2014-05-29 16:44:12 -07:00
Moayad Mardini 56cfa508c7 Fixed #22682 -- `makemigrations` will create `MIGRATION_MODULES` package
`makemigrations` will automatically create the package specified
in `MIGRATION_MODULES` if it doesn't already exist.

Thanks ovidiuc4 for the report.
2014-05-30 01:23:09 +03:00
Chris Beaven 45fa520187 Implement Migration.run_before
This attribute (used for reverse dependencies) was previously declared
and mentioned in the code, but never actually used.
2014-05-29 22:42:11 +12:00
Moayad Mardini 2e613ea5c5 Fixed #22675 -- makemigrations --dry-run to output migrations to stdout.
`makemigrations --dry-run` will output the complete migrations file
that would be written if it's used along with `--verbosity 3`.
2014-05-27 00:40:55 +03:00
Moayad Mardini 63fc91b3ca Fixed #22676 -- makemigrations --dry-run should not ask for defaults
Made the fix in InteractiveMigrationQuestioner class code, rather than
MigrationAutodetector, because --dry-run shouldn't affect whether
MigrationAutodetector will detect non-nullable fields, but the
questioner should skip the question and returns a None for default
(since that won't be used anyway) if --dry-run is used.
2014-05-24 09:56:18 -04:00
Baptiste Mispelon f01d2a8f9b Fixed tuple serialization test.
Thanks to rockallite for the report.
2014-05-23 14:50:10 +02:00
Huu Nguyen f851a954ac Fixed #22602 -- Improved code coverage of makemigrations command tests. 2014-05-23 08:05:46 -04:00
Flavio Curella beec05686c Fixed #22667 -- Replaced leader/follower terminology with primary/replica 2014-05-22 11:59:17 -04:00
Moayad Mardini ad994a3c5b Fixed #22679 -- Fixed empty tuple serialization in MigrationWriter.
Thanks rockallite.wulf for the report.
2014-05-22 16:15:09 +02:00
Marc Tamlyn 6ab67919ac Made nested deconstruction support both forms of deconstruct()
Nested deconstruction should (silently) handle Field.deconstruct() as
well as other arbitrary deconstructable objects. This allows having a
field in the deconstruction of another field.
2014-05-22 13:23:51 +01:00
Tim Graham dfeef8e147 Skipped a migrations test that's not supported on MySQL + Python 3. 2014-05-21 06:54:24 -04:00
Alex Gaynor 8a95b4fca7 Merge pull request #2692 from fcurella/patch-5
#22667 replaced occurrences of master/slave terminology with leader/follower
2014-05-20 09:37:04 -07:00
Flavio Curella 73a57b06f9 replaced occurrences of master/slave terminology with leader/follower 2014-05-20 11:35:16 -05:00
Andrew Godwin 03900a02d5 Fixed #22432: SQLite M2M repointing now works. Thanks to xelnor. 2014-05-20 16:25:59 +01:00
Andrew Godwin 4e32e47348 Merge pull request #2634 from loic/ticket22424
Fixed #22424 -- MySQL doesn't accept migrations' one-off default values ...
2014-05-20 14:25:59 +01:00
Huu Nguyen 44304cf04e Fixed #22661 -- Move makemigrations tests to the proper class 2014-05-19 20:16:36 -07:00
Loic Bistuer 5789ff7330 Failing testcases for #22649. 2014-05-18 12:46:12 +07:00
Loic Bistuer 1d3d01b4f7 Fixed #22424 -- Fixed handling of default values for TextField/BinaryField on MySQL.
Thanks syphar for the review and suggestions.
2014-05-18 11:58:16 +07:00
Claude Paroz e520a73eee Harmonized some PEP 0263 coding preambles 2014-05-15 19:58:41 +02:00
Andrew Godwin fdbd29dd27 Tests for #22325 2014-05-08 21:48:10 -07:00
Aymeric Augustin b1432bfc22 Appeased flake8. 2014-05-08 21:49:54 +02:00
Andrew Godwin 5a917cfef3 Fixed #22496: Data migrations get transactions again! 2014-05-07 14:28:34 -07:00
Tim Graham 3818d96426 Fixed #22435 -- Prevented adding a ManyToManyField from prompting for a default.
Thanks andrewsg for the report.
2014-05-02 20:46:47 -04:00
Chris Beaven a0c4b8465d Fix migration autodector to work correctly with custom deconstructed values 2014-05-02 15:08:19 +12:00
Tim Graham 45c2d1f5d9 flake8 fixes. 2014-04-30 18:33:46 -04:00