Esempio n. 1
0
def runMigrationsOnline():
  """Run migrations in 'online' mode.

  See Alembic documentation for more details on these functions.

  In this scenario we need to create an Engine
  and associate a connection with the context.
  """
  CONFIG.set_main_option("sqlalchemy.url", repository.getDbDSN())

  engine = engine_from_config(
      CONFIG.get_section(CONFIG.config_ini_section),
      prefix="sqlalchemy.",
      poolclass=pool.NullPool)

  connection = engine.connect()
  context.configure(
    connection=connection,
    target_metadata=TARGET_METADATA
  )

  try:
    with context.begin_transaction():
      context.run_migrations()
  finally:
    connection.close()
Esempio n. 2
0
def runMigrationsOffline():
  """Run migrations in 'offline' mode.

  See Alembic documentation for more details on these functions.

  This configures the context with just a URL
  and not an Engine, though an Engine is acceptable
  here as well.  By skipping the Engine creation
  we don't even need a DBAPI to be available.

  Calls to context.execute() here emit the given string to the
  script output.
  """
  context.configure(url=repository.getDbDSN(), target_metadata=TARGET_METADATA)

  with context.begin_transaction():
    context.run_migrations()