예제 #1
0
def create_migration_ctx(**kwargs):
    """Create an alembic migration context."""
    env = EnvironmentContext(Config(), None)
    env.configure(connection=db.engine.connect(),
                  sqlalchemy_module_prefix='db.',
                  **kwargs)
    return env.get_context()
예제 #2
0
def create_migration_ctx(**kwargs):
    """Create an alembic migration context."""
    env = EnvironmentContext(Config(), None)
    env.configure(
        connection=db.engine.connect(),
        sqlalchemy_module_prefix='db.',
        **kwargs
    )
    return env.get_context()
예제 #3
0
파일: diff.py 프로젝트: papagr/TheLMA
        op_name = op_[0]
        if op_name.endswith('_table'):
            op_obj = op_[1]
            op_obj_name = op_obj.name
        elif op_name.endswith('_column'):
            op_obj = op_[3]
            op_obj_name = op_[2] + '.' + op_obj.name
        else:
            op_obj = op_[1]
            op_obj_name = op_obj.name
            if op_obj_name is None:
                op_obj_name = op_obj.table.name + '.' \
                                + '_'.join(c.name for c in op_obj.columns)
    else:
        op_name = op_[0][0]
        op_obj_name = op_[0][2] + '.' + op_[0][3]
    return not op_obj_name in IGNORE_OPS.get(op_name, [])


# Set up a migration context.
alembic_cfg.set_main_option('script_location', 'thelma:db/schema/migrations')
script = ScriptDirectory.from_config(alembic_cfg)
env_ctxt = EnvironmentContext(alembic_cfg, script)
engine = create_engine(alembic_cfg)
env_ctxt.configure(engine.connect())  # , include_object=include_object)
mig_ctxt = env_ctxt.get_context()

ops = compare_metadata(mig_ctxt, metadata)
diff = [op for op in ops if include_op(op)]
pprint.pprint(diff, indent=2, width=20)
예제 #4
0
파일: diff.py 프로젝트: helixyte/TheLMA
    if isinstance(op_, tuple):
        op_name = op_[0]
        if op_name.endswith('_table'):
            op_obj = op_[1]
            op_obj_name = op_obj.name
        elif op_name.endswith('_column'):
            op_obj = op_[3]
            op_obj_name = op_[2] + '.' + op_obj.name
        else:
            op_obj = op_[1]
            op_obj_name = op_obj.name
            if op_obj_name is None:
                op_obj_name = op_obj.table.name + '.' \
                                + '_'.join(c.name for c in op_obj.columns)
    else:
        op_name = op_[0][0]
        op_obj_name = op_[0][2] + '.' + op_[0][3]
    return not op_obj_name in IGNORE_OPS.get(op_name, [])

# Set up a migration context.
alembic_cfg.set_main_option('script_location', 'thelma:db/schema/migrations')
script = ScriptDirectory.from_config(alembic_cfg)
env_ctxt = EnvironmentContext(alembic_cfg, script)
engine = create_engine(alembic_cfg)
env_ctxt.configure(engine.connect()) # , include_object=include_object)
mig_ctxt = env_ctxt.get_context()

ops = compare_metadata(mig_ctxt, metadata)
diff = [op for op in ops if include_op(op)]
pprint.pprint(diff, indent=2, width=20)