Exemplo n.º 1
0
    def test_pending_list(self):
        db._run_migrations(u'example_database_migrations', None, False)

        assert db._get_pending_plugins() == {"example_database_migrations": 2}
        db._run_migrations(u'example_database_migrations',
                           version="+1",
                           forward=True)
        assert db._get_pending_plugins() == {"example_database_migrations": 1}
        db._run_migrations(u'example_database_migrations')
        assert db._get_pending_plugins() == {}
Exemplo n.º 2
0
 def runner(plugin, version="head", forward=True):
     assert plugin, "Cannot apply migrations of unknown plugin"
     _run_migrations(plugin, version, forward)
Exemplo n.º 3
0
    def test_upgrade_database(self):
        self.check_upgrade(False, False, "base")

        # core migrations do not change plgugin's state
        db._run_migrations(None, None, True)
        self.check_upgrade(False, False, "base")

        # All migrations applied by default
        db._run_migrations(u'example_database_migrations', None, True)
        self.check_upgrade(True, True, "728663ebe30e (head)")

        # All migrations applied by default
        db._run_migrations(u'example_database_migrations', None, False)
        self.check_upgrade(False, False, "base")

        # Migrations can be applied one after another
        db._run_migrations(u'example_database_migrations',
                           version="+1",
                           forward=True)
        self.check_upgrade(True, False, "4f59069f433e")

        db._run_migrations(u'example_database_migrations',
                           version="+1",
                           forward=True)
        self.check_upgrade(True, True, "728663ebe30e (head)")

        # the same is true for downgrade
        db._run_migrations(u'example_database_migrations',
                           version="-1",
                           forward=False)
        self.check_upgrade(True, False, "4f59069f433e")

        db._run_migrations(u'example_database_migrations',
                           version="-1",
                           forward=False)
        self.check_upgrade(False, False, "base")
Exemplo n.º 4
0
def remove_extra_tables():
    # `clean_db` just removes data leaving tables intact. Thus we have to
    # downgrade database because we don't need those extra tables in the
    # following tests.
    yield
    db._run_migrations(u'example_database_migrations', None, False)