def db_sync(version='heads', engine=None): """Migrate the database to `version` or the most recent version.""" if engine is None: engine = db_api.get_engine() alembic_config = alembic_migrations.get_alembic_config(engine=engine) alembic_command.upgrade(alembic_config, version)
def db_sync(version='heads', engine=None): """Migrate the database to `version` or the most recent version.""" if engine is None: engine = db_api.get_engine() alembic_config = alembic_migrations.get_alembic_config(engine=engine) alembic_command.upgrade(alembic_config, version)
def test_walk_versions(self): alembic_config = alembic_migrations.get_alembic_config(self.engine) for revision in self._get_revisions(alembic_config): self._migrate_up(alembic_config, self.engine, revision, with_data=True)
def version_control(self, version=db_migration.ALEMBIC_INIT_VERSION): """Place a database under migration control""" if version is None: version = db_migration.ALEMBIC_INIT_VERSION a_config = alembic_migrations.get_alembic_config() alembic_command.stamp(a_config, version) print(_("Placed database under migration control at " "revision:"), version)
def test_db_complex_password(self): engine = mock.Mock() # See comments in get_alembic_config; make an engine url with # password characters that will be escaped, to ensure the # resulting value makes it into alembic unaltered. engine.url = sqlalchemy_make_url( 'mysql+pymysql://username:pw@%/!#$()@host:1234/dbname') alembic_config = alembic_migrations.get_alembic_config(engine) self.assertEqual(str(engine.url), alembic_config.get_main_option('sqlalchemy.url'))
def test_db_complex_password(self): engine = mock.Mock() # See comments in get_alembic_config; make an engine url with # password characters that will be escaped, to ensure the # resulting value makes it into alembic unaltered. engine.url = sqlalchemy_make_url( 'mysql+pymysql://username:pw@%/!#$()@host:1234/dbname') alembic_config = alembic_migrations.get_alembic_config(engine) self.assertEqual(str(engine.url), alembic_config.get_main_option('sqlalchemy.url'))
def _sync(self, version): """ Place an existing database under migration control and upgrade it. """ alembic_migrations.place_database_under_alembic_control() a_config = alembic_migrations.get_alembic_config() alembic_command.upgrade(a_config, version) heads = alembic_migrations.get_current_alembic_heads() if heads is None: raise exception.GlanceException("Database sync failed") revs = ", ".join(heads) if version == 'heads': print(_("Upgraded database, current revision(s):"), revs) else: print( _('Upgraded database to: %(v)s, current revision(s): %(r)s') % { 'v': version, 'r': revs })
def test_walk_versions(self): alembic_config = alembic_migrations.get_alembic_config(self.engine) for revision in self._get_revisions(alembic_config): self._migrate_up(alembic_config, self.engine, revision, with_data=True)