def setup_db(connection_string, create_tables=False): models.register_models(get_engine(), connection_string) if create_tables: models.create_tables(get_engine())
def setup_db(connection_string): models.register_models(get_engine(), connection_string)
config = context.config # Interpret the config file for Python logging. # This line sets up loggers basically. fileConfig(config.config_file_name) # Portions modified for Deckhand Specifics: # Set up and retrieve the config file for Deckhand. Sets up the oslo_config logger = logging.getLogger('alembic.env') CONF = cfg.CONF dirname = os.environ.get('DECKHAND_CONFIG_DIR', '/etc/deckhand').strip() config_files = [os.path.join(dirname, 'deckhand.conf')] CONF([], project='deckhand', default_config_files=config_files) logger.info("Database Connection: %s", CONF.database.connection) config.set_main_option('sqlalchemy.url', CONF.database.connection) models.register_models(db_api.get_engine(), CONF.database.connection) target_metadata = models.BASE.metadata # End Deckhand Specifics def run_migrations_offline(): """Run migrations in 'offline' mode. 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.
def setup_db(): # Ensure the DB doesn't exist before creation. drop_db() models.register_models(get_engine())