Exemple #1
0
 def _cache_schema(self):
     global DB_SCHEMA
     if not DB_SCHEMA:
         engine = self.get_engine()
         conn = engine.connect()
         alemb_conf = db_sync.get_alembic_config()
         db_sync.do_alembic_command(alemb_conf, 'upgrade', revision='head')
         DB_SCHEMA = "".join(line for line in conn.connection.iterdump())
Exemple #2
0
    def test_walk_versions(self):
        # Determine latest version script from the repo, then
        # upgrade from 1 through to the latest, with no data
        # in the databases. This just checks that the schema itself
        # upgrades successfully.

        alembic_cfg = sync.get_alembic_config()

        # Place the database under version control
        with patch_with_engine(self.engine):

            script_directory = script.ScriptDirectory.from_config(alembic_cfg)

            self.assertIsNone(sync._version(alembic_cfg))

            versions = [ver for ver in script_directory.walk_revisions()]

            for version in reversed(versions):
                self._migrate_up(self.engine, alembic_cfg, version.revision)
Exemple #3
0
 def db_sync(self, engine):
     with patch_with_engine(engine):
         alemb_conf = sync.get_alembic_config()
         sync.do_alembic_command(alemb_conf, 'upgrade', revision='head')