Changes between Version 1 and Version 2 of Ticket #28250, comment 9


Ignore:
Timestamp:
May 30, 2017, 3:20:12 PM (7 years ago)
Author:
Marten Kenbeek

Legend:

Unmodified
Added
Removed
Modified
  • Ticket #28250, comment 9

    v1 v2  
    11Ideally, an exception will still be raised if the initial migration that may be faked is in the same app as an applied migration that depends on it. So if `app1.0001` is not applied, but is an initial migration that may be faked, and `app1.0002` is recorder as applied, it will still be an error. The executor should never apply `app1.0002` without faking `app1.0001`, so that state should be unreachable under normal circumstances.
    22
    3 I believe you can check this with `if migration[0] != parent[0]`.
     3You can check this with `if migration[0] != parent[0]`.
    44
    55I've written the following test for your branch, which should go into `migrations.test_loader.LoaderTests`:
     
    1212    @modify_settings(INSTALLED_APPS={'append': 'migrations2'})
    1313    @mock.patch.object(MigrationLoader, 'detect_soft_applied', return_value=(True, None))
    14     def test_check_consistent_history_fake_initial(self):
     14    def test_check_consistent_history_fake_initial(self, mock_detect_soft_applied):
    1515        loader = MigrationLoader(connection)
    1616        recorder = MigrationRecorder(connection)
     
    2727}}}
    2828
    29 This also tests for the same-app scenario. I haven't checked if the test is actually correct, and my mocking skills aren't too sharp, but this should get you a long way.
     29This also tests for the same-app scenario. ~~I haven't checked if the test is actually correct, and my mocking skills aren't too sharp, but this should get you a long way.~~ I've had a chance to run the test, and it seems to be correct.
    3030
    3131Note that `detect_soft_applied` returns a 2-tuple of `(<is_applied>, <state_after_migration>)`, which is non-empty and thus truthy, so you need to check for the first item in the return value.
Back to Top