'Running migrate with some migrations applied before their dependencies
should not be allowed.'

@override_settings(MIGRATION_MODULES={'migrations': 'migrations.test_migrations'})
def test_migrate_inconsistent_history(self):

    recorder = MigrationRecorder(connection)
    recorder.record_applied('migrations', '0002_second')
    msg = 'Migration    migrations.0002_second    is    applied    before    its    dependency    migrations.0001_initial'
    with self.assertRaisesMessage(InconsistentMigrationHistory, msg):
        call_command('migrate')
    applied_migrations = recorder.applied_migrations()
    self.assertNotIn(('migrations', '0001_initial'), applied_migrations)
