summaryrefslogtreecommitdiff
path: root/tests/migrations
AgeCommit message (Collapse)Author
2013-12-22Expurged INSTALLED_APPS from code and tests.Aymeric Augustin
Except the app cache code and a few specific tests, of course.
2013-12-22Deprecated load_app().Aymeric Augustin
Adjusted several tests that used it to add apps to the app cache and then attempted to remove them by manipulating attributes directly. Also renamed invalid_models to invalid_models_tests to avoid clashing application labels between the outer and the inner invalid_models applications.
2013-12-22Refactored registration of models.Aymeric Augustin
Got rid of AppConfig._stub. As a side effect, app_cache.app_configs now only contains entries for applications that are in INSTALLED_APPS, which is a good thing and will allow dramatic simplifications (which I will perform in the next commit). That required adjusting all methods that iterate on app_configs without checking the "installed" flag, hence the large changes in get_model[s]. Introduced AppCache.all_models to store models: - while the app cache is being populated and a suitable app config object to register models isn't available yet; - for applications that aren't in INSTALLED_APPS since they don't have an app config any longer. Replaced get_model(seed_cache=False) by registered_model() which can be kept simple and safe to call at any time, and removed the seed_cache argument to get_model[s]. There's no replacement for that private API. Allowed non-master app caches to go through populate() as it is now safe to do so. They were introduced in 1.7 so backwards compatibility isn't a concern as long as the migrations framework keeps working.
2013-12-17Deborgified the app cache.Aymeric Augustin
Improved Andrew's hack to create temporary app caches to handle migrations. Now the main app cache has a "master" flag set to True (which is a non-default keyword argument, thus unlikely to be used by mistake). Other app cache instances have "master" set to False. The only sanctioned way to access the app cache is by importing django.core.apps.app_cache. If you were instanciating an app cache and relying on the Borg pattern, you'll have to refactor your code.
2013-12-17Removed superfluous models.py files.Aymeric Augustin
Added comments in the three empty models.py files that are still needed. Adjusted the test runner to add applications corresponding to test labels to INSTALLED_APPS even when they don't have a models module.
2013-12-17Moved the new app cache inside core.Aymeric Augustin
2013-12-17Simplified register_models.Aymeric Augustin
Since it's never called with more than one model at a time the current signature is needlessly complicated.
2013-12-17Moved list of models inside AppConfig instances.Aymeric Augustin
This commit is a refactoring with no change of functionality, according to the following invariants: - An app_label that was in app_configs and app_models stays in app_config and has its 'installed' attribute set to True. - An app_label that was in app_models but not in app_configs is added to app_configs and has its 'installed' attribute set to True. As a consequence, all the code that iterated on app_configs is modified to check for the 'installed' attribute. Code that iterated on app_models is rewritten in terms of app_configs. Many tests that stored and restored the state of the app cache were updated. In the long term, we should reconsider the usefulness of allowing importing models from non-installed applications. This doesn't sound particularly useful, can be a trap in some circumstances, and causes significant complexity in sensitive areas of Django.
2013-12-17Removed module-level functions for the app cache.Aymeric Augustin
Since the original ones in django.db.models.loading were kept only for backwards compatibility, there's no need to recreate them. However, many internals of Django still relied on them. They were also imported in django.db.models. They never appear in the documentation, except a quick mention of get_models and get_app in the 1.2 release notes to document an edge case in GIS. I don't think that makes them a public API. This commit doesn't change the overall amount of global state but clarifies that it's tied to the app_cache object instead of hiding it behind half a dozen functions.
2013-12-17Removed BaseAppCache.app_store.Aymeric Augustin
It was only storing redundant information. This is part of the effort to allow applications without a models module.
2013-12-17Moved django.db.models.loading to django.apps.cache.Aymeric Augustin
This commit doesn't contain any code changes; it's purely a refactoring.
2013-12-11Fix altering of SERIAL columns and InnoDB being picky about FK changesAndrew Godwin
2013-12-06Fixed ModelState breaking when unique_together has unhashable elements.Baptiste Mispelon
2013-12-06Fixed TypeError when rendering ModelState with multiple bases.Baptiste Mispelon
2013-12-05Fixed a flake8 errorAlex Gaynor
2013-12-04Migration VCS conflict detection and --merge for makemigrationsAndrew Godwin
2013-12-04Don't make a second migration if there was a force-null-default addcol.Andrew Godwin
2013-11-27Fixed #21438: makemigrations now detects ManyToManyFieldsAndrew Godwin
2013-11-06flake8 fixesAlex Gaynor
2013-11-06Massive migration optimiser improvements + RenameModel opnAndrew Godwin
2013-11-03Fixed all E251 violationsAlex Gaynor
2013-11-02Fixed #21302 -- Fixed unused imports and import *.Tim Graham
2013-10-30Fixed some flake8 issuesAlex Gaynor
2013-10-30Auto-apply initial migrations if their tables exist already.Andrew Godwin
2013-10-27Fixed test that reads a migration file from disk.Ramiro Morales
We need to make sure content read from the file is decoded from UTF-8 right from the start so Python doesn't try to use another encoding (read: ASCII/CP1252 under Windows.)
2013-10-23Fix migration planner to fully understand squashed migrations. And test.Andrew Godwin
2013-10-23Fixed #21298 -- Fixed E301 pep8 warningsAlasdair Nicol
2013-10-21Fixed #21275 -- Fixed a serializer error when generating migrations for ↵Loic Bistuer
contrib.auth. The migration serializer now looks for a deconstruct method on any object.
2013-10-19Added support for serializing class methods. - Refs #21290.Loic Bistuer
The new handling allows us to do away with the whitelisting that was required to support date and datetime objects.
2013-10-19Fixed #21283 -- Added support for migrations if models is a package.Loic Bistuer
Thanks Markus Holtermann for the report.
2013-10-17Added test for a921f06 - refs #21280.Loic Bistuer
This commit also lays the groundwork for future tests for the makemigrations command.
2013-10-16Improve migration optimizer to be able to optimize through other opsAndrew Godwin
2013-10-10Whitespace cleanup.Tim Graham
* Removed trailing whitespace. * Added newline to EOF if missing. * Removed blank lines at EOF. * Removed some stray tabs.
2013-10-07Fixed #21236 -- Allowed migrations to work with unique_together tuples.Javed Khan
Thanks hjwp for the report.
2013-10-02Initial version of MigrationOptimizer and testsAndrew Godwin
2013-09-25Remove most errors when running migration tests twiceAndrew Godwin
2013-09-25Allow callables as the argument to RunPythonAndrew Godwin
2013-09-25Add RunPython migration operation and testsAndrew Godwin
2013-09-25Add equality support for Project/ModelStateAndrew Godwin
2013-09-17Fixed #21115 -- Fixed NameError in migrate --list commandMarkus Holtermann
2013-09-17Fixed #21114 -- Migrations must not have a dependency to themselves.Markus Holtermann
2013-09-10Made MigrationWriter look for a "deconstruct" attribute on functions.Loic Bistuer
Refs #20978.
2013-09-07RunSQL migration operation and alpha SeparateDatabaseAndState op'n.Andrew Godwin
2013-09-06Fixed #21037 -- Made MigrationWriter raise a ValueError when serializing ↵Loic Bistuer
lambda functions.
2013-09-06Adding 'sqlmigrate' command and quote_parameter to support it.Andrew Godwin
2013-09-06Migration autodetector now corerctly deals with proxy modelsAndrew Godwin
2013-09-06Also test failure case of ProjectState dependency resolutionAndrew Godwin
2013-09-06Project/ModelState now correctly serialize multi-model inheritanceAndrew Godwin
2013-09-06Fixed #20977 -- Fixed writing migrations to disk on Python 3Markus Holtermann
2013-09-06Fixed #21015 -- Fixed MigrationLoader when importlib.import_module returns a ↵Loic Bistuer
file module or an empty directory.