Commit Graph

257 Commits

Author SHA1 Message Date
Tim Graham 54fdf5901b [1.7.x] Fixed #22917 -- Fixed typo in AlterIndexTogether.describe().
Backport of 70576740b0 from master
2014-06-27 10:36:05 -04:00
Tim Graham f1428dc796 [1.7.x] Fixed #22903 -- Fixed migration generation if index_together or unique_together is removed from a model.
Backport of e0cd07ec2f from master
2014-06-25 10:04:46 -04:00
Andrew Godwin 48a2e027bf [1.7.x] Fixed #22708: Typo in autodetector base dependency gen 2014-06-23 20:48:59 -07:00
Tim Graham 21c9591384 [1.7.x] Fixed test failures introduced by refs #22881.
Backport of 908160f692 from master
2014-06-23 10:00:54 -04:00
Chris Beaven 29582ad4a3 [1.7.x] Fixed #22881 -- Better soft_applied migration detection 2014-06-23 13:30:29 +12:00
Andrew Godwin aa0886e7ae [1.7.x] Fixed #22875: Optimizer did not take through= into account. 2014-06-22 11:24:46 -07:00
Huu Nguyen d9a83d597e [1.7.x] Fixed #22862 -- Added --noinput option to makemigrations.
Thanks artortenburger for the report.

Backport of fbb684d95e from master
2014-06-20 09:10:43 -04:00
Alex Gaynor 1d9f308fa1 [1.7.x] Fixed several flake8 errors
Backport of d015c9d11c from master
2014-06-18 12:05:36 -04:00
Andrew Godwin 819d5f0c89 [1.7.x] Fixed #22861: Internal migrations done first so __first__ works
Thanks to Chris Beaven.
2014-06-17 23:27:56 -07:00
Andrew Godwin 1122d2979a [1.7.x] Fix __latest__ to actually resolve to the latest migration 2014-06-17 22:12:53 -07:00
Andrew Godwin cd82069b97 [1.7.x] Fix broken test 2014-06-17 21:32:35 -07:00
Andrew Godwin f355d253f8 [1.7.x] Fixed #22853: Swapped models are now ignored for migration operations. 2014-06-17 17:46:52 -07:00
Andrew Godwin f16554f440 [1.7.x] Fix previous commit on python 2 2014-06-17 09:57:27 -07:00
Víðir Valberg Guðmundsson 7f0c207d1b [1.7.x] Fixed #22577: Python 3 broke on non-module migrations directory 2014-06-17 09:57:15 -07:00
Tim Graham 7f095ea744 [1.7.x] Removed some u'' prefixes to fix Python 3.2.
Backport of 317c480c04 from master
2014-06-16 18:50:07 -04:00
Tim Graham d36b54d753 [1.7.x] Added database migration for contrib.auth.
refs #22170.

Backport of b341f33697 from master
2014-06-16 16:23:28 -04:00
Tim Graham a0bf14a2ac [1.7.x] Added database migration for contrib.contenttypes.
Moved contenttypes tests to allow them to run correctly in the presence of
migrations. refs #22170.

Backport of eb8600a656 from master
2014-06-16 15:03:27 -04:00
Andrew Godwin d9a7663b11 [1.7.x] Fixed #22783: Make sure swappable models come first in creation 2014-06-16 10:20:52 -07:00
Matthew Schinckel 2dba6ab767 [1.7.x] 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.

Backport of bb39037fcb from master
2014-06-16 12:39:05 -04:00
Tim Graham f7709b3ce4 [1.7.x] Removed usaged of contrib.sessions as a placeholder in migration tests.
Without this, we're unable to add actual migrations for the app.

Backport of 808388c28c from master
2014-06-16 11:52:33 -04:00
Andrew Godwin d4305a15c1 [1.7.x] Fixed #22844: Duplicate SQL for SQLite FKs 2014-06-16 00:27:46 -07:00
Alex Gaynor 39e2ad4532 [1.7.x] Fixed several flake8 errors
Backport of d17a4cb037 from master
2014-06-15 21:07:28 -04:00
Andrew Godwin a81282a512 [1.7.x] Fixed #22568: Better proxy model support in migrations 2014-06-15 16:02:24 -07:00
Andrew Godwin e5cde2062c [1.7.x] Fixed #22470: Full migration support for order_with_respect_to 2014-06-15 14:57:00 -07:00
Andrew Godwin 3ef87f664b [1.7.x] Persist non-schema-relevant Meta changes in migrations 2014-06-15 12:34:34 -07:00
Andrew Godwin 13aa079941 [1.7.x] Fixed #22833: Autodetector not doing through mapping correctly 2014-06-15 12:07:27 -07:00
Andrew Godwin 961c9d6c6b [1.7.x] 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:57 -07:00
Andrew Godwin 7406feae33 [1.7.x] Remove overzealous migration flushes from migration test suite 2014-06-09 09:52:35 -07:00
Andrew Godwin 55fa4c2d34 [1.7.x] Fixed #22777: Add dependency on through for autodetected M2M adds 2014-06-08 17:13:11 -07:00
Andrew Godwin b568bdf8da [1.7.x] Fixed #22750, #22248: Model renaming now also alters field FKs 2014-06-07 18:18:18 -07:00
Andrew Godwin 98949e3b10 [1.7.x] Fixed #22436: More careful checking on method ref'ce serialization 2014-06-07 17:06:06 -07:00
Chris Beaven 9f1c4e4d3f [1.7.x] Implement Migration.run_before
This attribute (used for reverse dependencies) was previously declared
and mentioned in the code, but never actually used.
2014-06-05 23:28:17 -07:00
Andrew Godwin 31fc34e447 [1.7.x] Rewrote migration autodetector to involve actual computer science.
Fixes #22605, #22735; also lays the ground for some other fixes.

Conflicts:
	django/db/migrations/autodetector.py
2014-06-05 23:27:21 -07:00
Simon Charette 33511662dd [1.7.x] Fixed #22659 -- Prevent model states from sharing field instances.
Thanks to Trac alias tbartelmess for the report and the test project.

Backport of 7a38f88922 from master
2014-06-01 15:12:23 -04:00
Moayad Mardini 08a2b3b9cf [1.7.x] Improved the test for refs #22682.
Thanks apollo13 for the review.

Backport of 6f4d7f41b1 from master
2014-05-30 11:01:42 -04:00
Andrew Godwin 16d037c4f0 [1.7.x] Fix additional test failures caused by migration pollution 2014-05-29 16:44:29 -07:00
Moayad Mardini e4eae5df0e [1.7.x] 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-29 15:39:02 -07:00
Moayad Mardini c0a56001e0 [1.7.x] 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`.

Backport of 2e613ea5c5 from master
2014-05-26 20:03:41 -04:00
Moayad Mardini a59870e217 [1.7.x] 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.

Backport of ee14961a2a from master
2014-05-24 09:56:43 -04:00
Baptiste Mispelon 8f87b679ed [1.7.x] Fixed tuple serialization test.
Thanks to rockallite for the report.

Backport of f01d2a8f9b from master.
2014-05-23 14:51:22 +02:00
Huu Nguyen 8462883f9b [1.7.x] Fixed #22602 -- Improved code coverage of makemigrations command tests.
Backport of f851a954ac from master
2014-05-23 08:07:58 -04:00
Moayad Mardini 7d4a51e239 [1.7.x] Fixed #22679 -- Fixed empty tuple serialization in MigrationWriter.
Thanks rockallite.wulf for the report.

Backport of ad994a3c5b from master.
2014-05-22 16:20:21 +02:00
Tim Graham f25c5de4ce [1.7.x] Skipped a migrations test that's not supported on MySQL + Python 3.
Backport of dfeef8e147 from master
2014-05-21 07:04:46 -04:00
Andrew Godwin fd62bc165c [1.7.x] Fixed #22432: SQLite M2M repointing now works. Thanks to xelnor.
Backport of 03900a02d5 from master
2014-05-21 07:04:46 -04:00
Loic Bistuer c60240e712 [1.7.x] Failing testcases for #22649.
Backport of 5789ff7330 from master
2014-05-21 07:04:46 -04:00
Loic Bistuer d61b6224b0 [1.7.x] Fixed #22424 -- Fixed handling of default values for TextField/BinaryField on MySQL.
Thanks syphar for the review and suggestions.

Backport of 1d3d01b4f7 from master
2014-05-21 07:04:38 -04:00
Huu Nguyen f7270dcd9d [1.7.x] Fixed #22661 -- Move makemigrations tests to the proper class
Backport of 44304cf04e from master
2014-05-21 06:56:23 -04:00
Claude Paroz e8a7436941 [1.7.x] Harmonized some PEP 0263 coding preambles
Backport of e520a73ee from master.
2014-05-15 20:01:31 +02:00
Andrew Godwin 31eac71a76 [1.7.x] Tests for #22325 2014-05-08 21:49:09 -07:00
Aymeric Augustin e244e456c7 [1.7.x] Appeased flake8.
Backport of b1432bfc from master
2014-05-08 22:45:26 +02:00
Andrew Godwin 7f63ac5a9f [1.7.x] Fixed #22496: Data migrations get transactions again! 2014-05-07 14:29:04 -07:00
Tim Graham f8fa735dc2 [1.7.x] Fixed #22435 -- Prevented adding a ManyToManyField from prompting for a default.
Thanks andrewsg for the report.

Backport of 3818d96426 from master
2014-05-02 20:53:39 -04:00
Chris Beaven 5ab93bbe74 [1.7.x] Fix migration autodector to work correctly with custom deconstructed values 2014-05-02 15:12:42 +12:00
Tim Graham e5941ba5f3 [1.7.x] flake8 fixes.
Backport of 45c2d1f5d9 from master.
2014-04-30 18:35:40 -04:00
Andrew Godwin 6ca5367869 [1.7.x] Cleanup failing test w/contenttypes and remove useless graph load 2014-04-30 15:12:18 -07:00
Andrew Godwin 35c2a14a49 [1.7.x] Fixed #22485: Include all unmigrated apps in project state by default. 2014-04-30 12:26:11 -07:00
Claude Paroz 1084456ac2 [1.7.x] Fixed #22474 -- Made migration recorder aware of multiple databases
Thanks Tim Graham for the review.
Backport of 7c54f8cce from master.
2014-04-30 16:55:12 +02:00
Simon Charette cda5745df0 [1.7.x] Fixed #22447 -- Make sure custom model bases can be migrated.
Thanks to cdestigter for the report.

Backport of 390f888745 from master
2014-04-29 10:55:45 -04:00
Aymeric Augustin 3bb0f118ca [1.7.x] Fixed #3214 -- Stopped parsing SQL with regex.
Avoided introducing a new regex-based SQL splitter in the migrations
framework, before we're bound by backwards compatibility.

Adapted this change to the legacy "initial SQL data" feature, even
though it's already deprecated, in order to facilitate the transition
to migrations.

sqlparse becomes mandatory for RunSQL on some databases (all but
PostgreSQL). There's no API to provide a single statement and tell
Django not to attempt splitting. Since we have a more robust splitting
implementation, that seems like a good tradeoff. It's easier to add a
new keyword argument later if necessary than to remove one.

Many people contributed to both tickets, thank you all, and especially
Claude for the review.

Refs #22401.

Backport of 8b5b199 from master
2014-04-26 17:46:57 +02:00
Claude Paroz 1d0f1ee199 [1.7.x] Fixed table cleanup in GIS migration tests
Backport of ab90c4707b from master.
2014-04-22 19:52:58 +02:00
Aymeric Augustin 62eb79fc4c [1.7.x] Appeased flake8 2.1.0.
Backport of 428c0bbe1b from master
2014-04-21 07:50:50 -04:00
Tim Graham 9e86c3f0a6 [1.7.x] Fixed flake8 errors.
Backport of 471fb04a30 from master
2014-04-20 13:09:12 -04:00
Andrew Gorcester bc5d568e1e [1.7.x] 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.

Backport of 956bd64424 from master
2014-04-18 18:34:00 -04:00
Motiejus Jakštys 71c8ae543f [1.7.x] Fixed #22460 -- Explicity remove constraints when dropping a related field.
Backport of 0e45669fa9 from master
2014-04-16 16:37:08 -04:00
Simon Charette 9fb61cb64a [1.7.x] Fixed #22350 -- Consistently serialize bytes and text in migrations.
Thanks to @treyhunner and Loïc for their suggestions and review.

Backport of 72d3889db4 from master
2014-04-13 19:03:20 -04:00
Simon Charette 7b3a221ad6 [1.7.x] Fixed #22363 -- Correctly serialize `django.utils.datetime_safe` objects.
Thanks to linovia for the report.

Backport of 074d3183d9 from master
2014-04-03 14:56:41 -04:00
Loic Bistuer 8e73d3a2c1 [1.7.x] Fixed #22319 -- Fixed migration external dependencies when there are internal dependencies.
Backport of 0fd51cf0bd from master
2014-03-31 06:57:44 -04:00
Loic Bistuer bdec848063 [1.7.x] Fixed #22359 -- Changing M2M field to blank=True failed on sqlite.
Backport of a449e7feec from master
2014-03-31 06:35:06 -04:00
Loic Bistuer 39fc8d4b8e [1.7.x] 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.

Backport of 42336c84a0 from master
2014-03-25 20:04:49 -04:00
Tim Graham d84beb3d91 Revert "[1.7.x] Fixed #22331 -- Fixed migrations ProjectState to ignore unmanaged models."
This reverts commit bf69375c4d.
2014-03-25 12:07:37 -04:00
Loic Bistuer bf69375c4d [1.7.x] Fixed #22331 -- Fixed migrations ProjectState to ignore unmanaged models.
Backport of 69d4b1c3ea from master
2014-03-25 10:34:28 -04:00
Stephen Burrows b4f165fe94 [1.7.x] Fixed #22300 -- Fixed crash in migrations when changing non-relational field to relational.
Backport of 35ed792cf2 from master
2014-03-25 07:46:48 -04:00
Andrew Godwin 81f5408c7a Fixed #22275: unique_together broken if ForeignKey split into new file.
Thanks to bak1an for the patch.
2014-03-19 21:23:21 -07:00
Andrew Godwin f4d91638fc Remove failing test while we fix the underlying bug 2014-03-11 10:33:57 -07:00
Chris Beaven 107c9f5453 Fix AlterField migrations that are related to a RenameModel migration 2014-03-11 17:13:26 +13:00
Chris Beaven 40f6ca54f8 Fix autodetector creation of RenameModel migration to capitalize model names 2014-03-11 12:23:45 +13:00
Chris Beaven 7feb70eef3 Fixed #22239 -- Add auto detection of renamed models 2014-03-10 13:55:44 +13:00
Andrew Godwin abccbcf52d Fixed #21843: Remove explicit ID column setting in test 2014-03-08 16:04:21 -08:00
Andrew Godwin cdf6eba181 Merge pull request #2315 from bendavis78/issues/22073
Fixed #22073 - Ensure CreateTable operation handles backwards migration correctly when M2M fields are present
2014-03-08 15:44:45 -08:00
Andrew Godwin e46e15e5a1 Fixed #22204: Bad circular-dep-breaking if more than one per run 2014-03-06 13:22:42 -08:00
Alex Gaynor a248c88372 Fixed three small flake8 violations. 2014-03-04 15:13:15 -08: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
Loic Bistuer 99291f5db0 Added tests for MTI in RunPython. 2014-03-05 03:17:52 +07:00
Anubhav Joshi bb2ca9fe6c Fixed #22172 -- Allowed index_together to be a single list (rather than list of lists)..
Thanks EmilStenstrom for the suggestion.
2014-03-01 15:44:42 -05:00
Baptiste Mispelon c679cb7f60 Fixed #22168 -- Fixed migrations failing on sqlite when column names are SQL keywords
Thanks to trac user fallen_flint for the report and initial patch.
2014-03-01 13:45:45 +01:00
Alex Gaynor a8a5c31966 Two whitespace changes to appease flake8 2014-02-23 11:07:52 -06:00
Andrew Gorcester 202bf69c2f Fixed #22095 -- Enabled backward migrations for RunPython operations
Added reversible property to RunPython so that migrations will not
refuse to reverse migrations including RunPython operations, so long as
reverse_code is set in the RunPython constructor. Included tests to
check the reversible property on RunPython and the similar RunSQL.
2014-02-23 09:30:02 +01:00
Ben Davis df2652c448 Fixed #22073 - Ensure CreateTable operation handles backwards migration correctly when M2M fields are present 2014-02-17 16:51:40 -06:00
Andrew Godwin 3c547a423f Merge pull request #2270 from bmispelon/ticket-22030
Fixed #22030 -- Don't assume that all fields have a swappable_setting at...
2014-02-17 01:16:49 +00:00
Anton Baklanov 0bd92d68ad Fixed #22035 -- reordered migration operations
Now AddField actions appear in operations list before AlterUniqueTogether
actions.

Thanks to SmileyChris for the report.
2014-02-14 20:00:39 -05:00
Baptiste Mispelon 6873eeeefb Fixed #22030 -- Don't assume that all fields have a swappable_setting attribute. 2014-02-13 17:43:21 +01:00
Baptiste Mispelon c3434fed5b Removed test for migration check forgotten in 7e941ba67c. 2014-02-13 09:31:39 +01:00
Andrew Godwin bad9456b9c Fix my slightly hasty autodetector changes 2014-02-12 17:22:50 +00:00
Andrew Godwin 97a8fd4682 Fixed #21954: Raise nice error when serializing datetimes with timezones 2014-02-09 11:17:38 +00:00
Tim Graham 4f8e8a6ec2 Removed unused imports + other flake8 fixes. 2014-02-09 06:13:10 -05:00
Andrew Godwin 98dd8dd02e Fixed #21892: RunPython no longer accepts strings 2014-02-09 10:54:02 +00:00
mlavin a3e0d7753d Adding tests for check_migrations. 2014-02-08 09:05:27 -05:00
Michael Manfre ad913f242d Fix regress added to migrations.test_operations.test_alter_field_pk_fk 2014-02-02 15:44:01 -05:00
Michael Manfre 3ffeb93186 Ensure cursors are closed when no longer needed.
This commit touchs various parts of the code base and test framework. Any
found usage of opening a cursor for the sake of initializing a connection
has been replaced with 'ensure_connection()'.
2014-02-02 12:47:21 -05:00
Alex Gaynor 2ba09c000d Added some missing whitespace around arithmetic operators 2014-01-22 09:21:05 -06:00