# Path: drift/flaskfactory.py
# def drift_app(app=None):
#     try:
#         return _drift_app(app=app)
#     except Exception:
#         log.exception("Flask app creation failed.")
# 
# Path: drift/core/resources/postgres.py
# def format_connection_string(postgres_parameters):
#     postgres_parameters = process_connection_values(postgres_parameters)
#     connection_string = '{driver}://{username}:{password}@{server}:{port}/{database}'.format(**postgres_parameters)
#     return connection_string
# 
# def connect(params, connect_timeout=None):
# 
#     engine = create_engine(
#         format_connection_string(params),
#         echo=ECHO_SQL,
#         isolation_level='AUTOCOMMIT',
#         connect_args={
#             'connect_timeout': connect_timeout or 10,
#             'application_name': params.get('application_name', 'drift.core.resources.postgres'),
#         }
#     )
#     return engine
# 
# Path: drift/utils.py
# def get_tier_name(fail_hard=True):
#     """
#     Get tier name from environment
#     """
#     if 'DRIFT_TIER' in os.environ:
#         return os.environ['DRIFT_TIER']
# 
#     if fail_hard:
#         raise RuntimeError(
#             "No tier specified. Specify one in "
#             "'DRIFT_TIER' environment variable, or use the --tier command "
#             "line argument."
#         )
# 
# def get_config(ts=None, tier_name=None, tenant_name=None):
#     """Wraps get_drift_config() by providing default values for tier, tenant and drift_app."""
#     # Hack: Must delay import this
#     # TODO: Stop using this function. Who is doing it anyways?
#     from drift.flaskfactory import load_flask_config
#     if current_app:
#         app_ts = current_app.extensions['driftconfig'].table_store
#         if ts is not app_ts:
#             log.warning("Mismatching table_store objects in get_config(): ts=%s, app ts=%s", ts, app_ts)
#         ts = app_ts
# 
#     conf = get_drift_config(
#         ts=ts,
#         tier_name=tier_name or get_tier_name(),
#         tenant_name=tenant_name or tenant_from_hostname,
#         drift_app=load_flask_config(),
#     )
#     return conf
# 
# Path: drift/orm.py
# class ModelBase(Base):
#     def create_date(cls):
#     def modify_date(cls):
#     def as_dict(self):


from click import echo, secho
from alembic import context
from sqlalchemy import pool, create_engine
from drift.flaskfactory import drift_app
from drift.core.resources.postgres import format_connection_string, connect
from drift.utils import get_tier_name, get_config
from drift.orm import Base



MASTER_USERNAME = 'postgres'
MASTER_PASSWORD = 'postgres'


def run_migrations():


# Path: drift/flaskfactory.py
# def drift_app(app=None):
#     try:
#         return _drift_app(app=app)
#     except Exception:
#         log.exception("Flask app creation failed.")
# 
# Path: drift/core/resources/postgres.py
# def format_connection_string(postgres_parameters):
#     postgres_parameters = process_connection_values(postgres_parameters)
#     connection_string = '{driver}://{username}:{password}@{server}:{port}/{database}'.format(**postgres_parameters)
#     return connection_string
# 
# def connect(params, connect_timeout=None):
# 
#     engine = create_engine(
#         format_connection_string(params),
#         echo=ECHO_SQL,
#         isolation_level='AUTOCOMMIT',
#         connect_args={
#             'connect_timeout': connect_timeout or 10,
#             'application_name': params.get('application_name', 'drift.core.resources.postgres'),
#         }
#     )
#     return engine
# 
# Path: drift/utils.py
# def get_tier_name(fail_hard=True):
#     """
#     Get tier name from environment
#     """
#     if 'DRIFT_TIER' in os.environ:
#         return os.environ['DRIFT_TIER']
# 
#     if fail_hard:
#         raise RuntimeError(
#             "No tier specified. Specify one in "
#             "'DRIFT_TIER' environment variable, or use the --tier command "
#             "line argument."
#         )
# 
# def get_config(ts=None, tier_name=None, tenant_name=None):
#     """Wraps get_drift_config() by providing default values for tier, tenant and drift_app."""
#     # Hack: Must delay import this
#     # TODO: Stop using this function. Who is doing it anyways?
#     from drift.flaskfactory import load_flask_config
#     if current_app:
#         app_ts = current_app.extensions['driftconfig'].table_store
#         if ts is not app_ts:
#             log.warning("Mismatching table_store objects in get_config(): ts=%s, app ts=%s", ts, app_ts)
#         ts = app_ts
# 
#     conf = get_drift_config(
#         ts=ts,
#         tier_name=tier_name or get_tier_name(),
#         tenant_name=tenant_name or tenant_from_hostname,
#         drift_app=load_flask_config(),
#     )
#     return conf
# 
# Path: drift/orm.py
# class ModelBase(Base):
#     def create_date(cls):
#     def modify_date(cls):
#     def as_dict(self):


# Path: drift/contrib/alembic.py
from click import echo, secho
from alembic import context
from sqlalchemy import pool, create_engine
from drift.flaskfactory import drift_app
from drift.core.resources.postgres import format_connection_string, connect
from drift.utils import get_tier_name, get_config
from drift.orm import Base




MASTER_USERNAME = 'postgres'
MASTER_PASSWORD = 'postgres'


def run_migrations():


    conf = get_config()