Commit Graph

73 Commits

Author SHA1 Message Date
Akshesh 6a8372e6ec Fixed #26808 -- Added Meta.indexes for class-based indexes.
* Added the index name to its deconstruction.
* Added indexes to sqlite3.schema._remake_table() so that indexes
  aren't dropped when _remake_table() is called.

Thanks timgraham & MarkusH for review and advice.
2016-08-05 18:12:51 -04:00
Loïc Bistuer dab83e5ba1 Fixed #26881 -- Fixed duplicate managers in migrations.
When both parent and child models had managers with the same name and
a migrations opt-in both were added to the migration state.
2016-07-09 17:52:52 +07:00
Akshesh 156e2d59cf Fixed #26709 -- Added class-based indexes.
Added the AddIndex and RemoveIndex operations to use them in migrations.

Thanks markush, mjtamlyn, timgraham, and charettes for review and advice.
2016-06-27 10:41:01 -04:00
Loïc Bistuer 2eb7cb2fff Fixed #26643 -- Prevented unnecessary AlterModelManagers operations caused by the manager inheritance refactor.
This also makes migrations respect the base_manager_name and
default_manager_name model options.

Thanks Anthony King and Matthew Schinckel for the initial patches.
2016-06-20 12:55:57 -04:00
Jon Dufresne 4f336f6652 Fixed #26747 -- Used more specific assertions in the Django test suite. 2016-06-16 14:19:18 -04:00
Alex Hill 2ff7ef15b0 Refs #26421 -- Refactored Apps.lazy_model_operation() for better checks and tests 2016-05-19 21:33:36 -04:00
Loïc Bistuer 3a47d42fa3 Fixed #20932, #25897 -- Streamlined manager inheritance. 2016-05-17 02:29:22 +07:00
Simon Charette c0118ff80b Refs #24201 -- Ignored order_with_respect_to private fields in migrations.
Thanks Tim for the review.
2016-05-13 15:43:23 -04:00
Tim Graham 92053acbb9 Fixed E128 flake8 warnings in tests/. 2016-04-08 10:12:33 -04:00
Simon Charette 63f0e2df2a Refs #18012 -- Accounted for reverse proxy relations in migrations.
Thanks to Markus for the suggestion and Tim for the review.
2015-10-19 20:15:13 -04:00
Dražen Odobašić b1e33ceced Fixed #23395 -- Limited line lengths to 119 characters. 2015-09-12 11:40:50 -04:00
Alex Hill 25c157e4cc Refs #24215 -- Improved error message for unhandled lazy model operations. 2015-09-07 20:31:58 -04:00
Flavio Curella c2e70f0265 Fixed #21127 -- Started deprecation toward requiring on_delete for ForeignKey/OneToOneField 2015-07-27 18:28:13 -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
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 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
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
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
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
Markus Holtermann d538e37e1b Added tests for get_related_models_recursive 2015-02-16 19:31:52 +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
Tim Graham 0ed7d15563 Sorted imports with isort; refs #23860. 2015-02-06 08:16:28 -05:00
Adam Taylor 039465a6a7 Fixed typos in code comments. 2015-01-20 12:18:03 -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
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
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 a159b1facd Replaced migration state render() by apps cached property
Refs #23745.
2015-01-02 15:19:36 +01: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
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
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
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 a8ce5fdc28 Fixed #22470: Full migration support for order_with_respect_to 2014-06-15 14:56:51 -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
Tim Graham 45c2d1f5d9 flake8 fixes. 2014-04-30 18:33:46 -04:00
Andrew Godwin e049c88603 Cleanup failing test w/contenttypes and remove useless graph load 2014-04-30 15:11:52 -07:00
Andrew Godwin 8f6dff372b Fixed #22485: Include all unmigrated apps in project state by default. 2014-04-30 12:25:12 -07:00
Simon Charette 390f888745 Fixed #22447 -- Make sure custom model bases can be migrated.
Thanks to cdestigter for the report.
2014-04-29 09:43:08 -04:00
Tim Graham 471fb04a30 Fixed flake8 errors. 2014-04-20 13:08:04 -04:00
Andrew Gorcester 956bd64424 Fixed #22397 -- Issues removing M2M field with explicit through model
Changed the migration autodetector to remove models last so that FK
and M2M fields will not be left as dangling references. Added a check
in the migration state renderer to error out in the presence of
dangling references instead of leaving them as strings. Fixed a bug
in the sqlite backend to handle the deletion of M2M fields with
"through" models properly (i.e., do nothing successfully).

Thanks to melinath for report, loic for tests and andrewgodwin and
charettes for assistance with architecture.
2014-04-18 16:44:47 -04:00
Simon Charette 0d397e5a5b Revert "Fixed #22397 -- Issues removing M2M field with explicit through model."
This reverts commit 00e3b9a2a9.

It's causing a regression when tested with the proxy_model_inheritance tests.
2014-04-18 01:27:30 -04:00
Andrew Gorcester 00e3b9a2a9 Fixed #22397 -- Issues removing M2M field with explicit through model.
Changed the migration autodetector to remove models last so that FK
and M2M fields will not be left as dangling references. Added a check
in the migration state renderer to error out in the presence of
dangling references instead of leaving them as strings. Fixed a bug
in the sqlite backend to handle the deletion of M2M fields with
"through" models properly (i.e., do nothing successfully).

Thanks to melinath for report, loic for tests and andrewgodwin and
charettes for assistance with architecture.
2014-04-17 12:54:35 -04:00
Tim Graham 42336c84a0 Fixed #22331 -- Made MigrationAutodetector ignore unmanaged models.
This commit reverts 69d4b1c and tackle the issue from a different angle.
Models remain present in the project state, but are now ignored by the
autodetector.
2014-03-25 18:30:58 -04:00
Loic Bistuer 69d4b1c3ea Fixed #22331 -- Fixed migrations ProjectState to ignore unmanaged models. 2014-03-25 10:33:44 -04:00
Loic Bistuer 6436f1fad9 Fixed #21893 -- ModelState didn't account for MTI parents inherited from abstract models. 2014-03-05 03:25:14 +07:00