Ejemplo n.º 1
0
def setup_package():
    # set up database
    engine = get_engine()
    DBSession.configure(bind=engine)
    Base.metadata.drop_all(engine)
    initializedb.setup_db(engine, DBSession)
    DBSession.remove()
Ejemplo n.º 2
0
def main(argv=sys.argv):
    settings_file = os.path.join(
        os.path.dirname(os.path.abspath(__file__)), 'migration.ini')
    settings = get_appsettings(settings_file)

    engine_target = engine_from_config(settings, 'sqlalchemy_target.')
    engine_source = engine_from_config(settings, 'sqlalchemy_source.')

    logging.basicConfig()
    logging.getLogger('sqlalchemy.engine').setLevel(logging.WARN)

    # create a fresh schema on the target database
    Session = sessionmaker(extension=ZopeTransactionExtension())  # noqa
    session = Session(bind=engine_target)
    Base.metadata.drop_all(engine_target, checkfirst=True)
    setup_db(engine_target, session)

    connection_source = engine_source.connect()

    batch_size = 1000
    MigrateUsers(connection_source, session, batch_size).migrate()
    MigrateSummits(connection_source, session, batch_size).migrate()
    MigrateParkings(connection_source, session, batch_size).migrate()
    MigrateSites(connection_source, session, batch_size).migrate()
    MigrateProducts(connection_source, session, batch_size).migrate()
    MigrateHuts(connection_source, session, batch_size).migrate()
    MigrateRoutes(connection_source, session, batch_size).migrate()
    MigrateVersions(connection_source, session, batch_size).migrate()
    UpdateSequences(connection_source, session, batch_size).migrate()
Ejemplo n.º 3
0
def setup_package():
    # set up database
    engine = get_engine()
    DBSession.configure(bind=engine)
    Base.metadata.drop_all(engine)
    initializedb.setup_db(engine, DBSession)
    DBSession.remove()
Ejemplo n.º 4
0
def main(argv=sys.argv):
    alembic_configfile = os.path.realpath(
        os.path.join(os.path.dirname(os.path.abspath(__file__)),
                     '../../../alembic.ini'))
    alembic_config = Config(alembic_configfile)

    settings_file = os.path.join(os.path.dirname(os.path.abspath(__file__)),
                                 'migration.ini')
    settings = get_appsettings(settings_file)

    engine_target = engine_from_config(settings, 'sqlalchemy_target.')
    engine_source = engine_from_config(settings, 'sqlalchemy_source.')

    logging.basicConfig()
    logging.getLogger('sqlalchemy.engine').setLevel(logging.WARN)

    Session = sessionmaker()  # noqa
    register(Session)
    session = Session(bind=engine_target)

    # set up the target database
    setup_db(alembic_config, session)

    connection_source = engine_source.connect()

    batch_size = 1000
    MigrateAreas(connection_source, session, batch_size).migrate()
    MigrateUserProfiles(connection_source, session, batch_size).migrate()
    MigrateUsers(connection_source, session, batch_size).migrate()
    MigrateSummits(connection_source, session, batch_size).migrate()
    MigrateParkings(connection_source, session, batch_size).migrate()
    MigrateSites(connection_source, session, batch_size).migrate()
    MigrateProducts(connection_source, session, batch_size).migrate()
    MigrateHuts(connection_source, session, batch_size).migrate()
    MigrateRoutes(connection_source, session, batch_size).migrate()
    MigrateMaps(connection_source, session, batch_size).migrate()
    MigrateOutings(connection_source, session, batch_size).migrate()
    MigrateImages(connection_source, session, batch_size).migrate()
    MigrateXreports(connection_source, session, batch_size).migrate()
    MigrateArticles(connection_source, session, batch_size).migrate()
    MigrateBooks(connection_source, session, batch_size).migrate()
    MigrateVersions(connection_source, session, batch_size).migrate()
    MigrateAssociations(connection_source, session, batch_size).migrate()
    CreateClimbingSiteRoutes(connection_source, session, batch_size).migrate()
    SetRouteTitlePrefix(connection_source, session, batch_size).migrate()
    SetDefaultGeometries(connection_source, session, batch_size).migrate()
    MigrateAreaAssociations(connection_source, session, batch_size).migrate()
    MigrateMapAssociations(connection_source, session, batch_size).migrate()
    MigrateMailinglists(connection_source, session, batch_size).migrate()
    UpdateSequences(connection_source, session, batch_size).migrate()
    InitFeed(connection_source, session, batch_size).migrate()
    AnalyzeAllTables(connection_source, session, batch_size).migrate()
Ejemplo n.º 5
0
def main(argv=sys.argv):
    alembic_configfile = os.path.realpath(os.path.join(
        os.path.dirname(os.path.abspath(__file__)),
        '../../../alembic.ini'))
    alembic_config = Config(alembic_configfile)

    settings_file = os.path.join(
        os.path.dirname(os.path.abspath(__file__)), 'migration.ini')
    settings = get_appsettings(settings_file)

    engine_target = engine_from_config(settings, 'sqlalchemy_target.')
    engine_source = engine_from_config(settings, 'sqlalchemy_source.')

    logging.basicConfig()
    logging.getLogger('sqlalchemy.engine').setLevel(logging.WARN)

    Session = sessionmaker(extension=ZopeTransactionExtension())  # noqa
    session = Session(bind=engine_target)

    # set up the target database
    setup_db(alembic_config, session)

    connection_source = engine_source.connect()

    batch_size = 1000
    MigrateAreas(connection_source, session, batch_size).migrate()
    MigrateUserProfiles(connection_source, session, batch_size).migrate()
    MigrateUsers(connection_source, session, batch_size).migrate()
    MigrateSummits(connection_source, session, batch_size).migrate()
    MigrateParkings(connection_source, session, batch_size).migrate()
    MigrateSites(connection_source, session, batch_size).migrate()
    MigrateProducts(connection_source, session, batch_size).migrate()
    MigrateHuts(connection_source, session, batch_size).migrate()
    MigrateRoutes(connection_source, session, batch_size).migrate()
    MigrateMaps(connection_source, session, batch_size).migrate()
    MigrateOutings(connection_source, session, batch_size).migrate()
    MigrateImages(connection_source, session, batch_size).migrate()
    MigrateXreports(connection_source, session, batch_size).migrate()
    MigrateArticles(connection_source, session, batch_size).migrate()
    MigrateBooks(connection_source, session, batch_size).migrate()
    MigrateVersions(connection_source, session, batch_size).migrate()
    MigrateAssociations(connection_source, session, batch_size).migrate()
    CreateClimbingSiteRoutes(connection_source, session, batch_size).migrate()
    SetRouteTitlePrefix(connection_source, session, batch_size).migrate()
    SetDefaultGeometries(connection_source, session, batch_size).migrate()
    MigrateAreaAssociations(connection_source, session, batch_size).migrate()
    MigrateMapAssociations(connection_source, session, batch_size).migrate()
    MigrateMailinglists(connection_source, session, batch_size).migrate()
    UpdateSequences(connection_source, session, batch_size).migrate()
    InitFeed(connection_source, session, batch_size).migrate()
    AnalyzeAllTables(connection_source, session, batch_size).migrate()
Ejemplo n.º 6
0
def setup_package():
    # set up database
    engine = get_engine()
    DBSession.configure(bind=engine)
    Base.metadata.drop_all(engine)
    initializedb.setup_db(engine, DBSession)
    # Add test data needed for all tests
    with transaction.manager:
        _add_global_test_data(DBSession)
    DBSession.remove()
    # set up ElasticSearch
    configure_es_from_config(settings)
    initializees.drop_index()
    initializees.setup_es()
Ejemplo n.º 7
0
def setup_package():
    # set up database
    engine = get_engine()
    DBSession.configure(bind=engine)
    Base.metadata.drop_all(engine)
    initializedb.setup_db(engine, DBSession)

    # set up ElasticSearch
    configure_es_from_config(settings)
    initializees.drop_index()
    initializees.setup_es()

    # Add test data needed for all tests
    with transaction.manager:
        _add_global_test_data(DBSession)
        fill_index(DBSession)
    DBSession.remove()
Ejemplo n.º 8
0
def setup_package():
    # set up database
    engine = get_engine()
    DBSession.configure(bind=engine)

    alembic_config = _get_alembic_config()
    downgrade(alembic_config, 'base')
    initializedb.setup_db(alembic_config, DBSession)

    # set up ElasticSearch
    configure_es_from_config(settings)
    initializees.drop_index()
    initializees.setup_es()

    # Add test data needed for all tests
    with transaction.manager:
        _add_global_test_data(DBSession)
        fill_index(DBSession)
    DBSession.remove()
Ejemplo n.º 9
0
def main(argv=sys.argv):
    settings_file = os.path.join(os.path.dirname(os.path.abspath(__file__)),
                                 'migration.ini')
    settings = get_appsettings(settings_file)

    engine_target = engine_from_config(settings, 'sqlalchemy_target.')
    engine_source = engine_from_config(settings, 'sqlalchemy_source.')

    logging.basicConfig()
    logging.getLogger('sqlalchemy.engine').setLevel(logging.WARN)

    # create a fresh schema on the target database
    Session = sessionmaker(extension=ZopeTransactionExtension())  # noqa
    session = Session(bind=engine_target)
    Base.metadata.drop_all(engine_target, checkfirst=True)
    setup_db(engine_target, session)

    connection_source = engine_source.connect()

    batch_size = 1000
    MigrateUserProfiles(connection_source, session, batch_size).migrate()
    MigrateUsers(connection_source, session, batch_size).migrate()
    MigrateSummits(connection_source, session, batch_size).migrate()
    MigrateParkings(connection_source, session, batch_size).migrate()
    MigrateSites(connection_source, session, batch_size).migrate()
    MigrateProducts(connection_source, session, batch_size).migrate()
    MigrateHuts(connection_source, session, batch_size).migrate()
    MigrateRoutes(connection_source, session, batch_size).migrate()
    MigrateMaps(connection_source, session, batch_size).migrate()
    MigrateAreas(connection_source, session, batch_size).migrate()
    MigrateOutings(connection_source, session, batch_size).migrate()
    MigrateImages(connection_source, session, batch_size).migrate()
    MigrateVersions(connection_source, session, batch_size).migrate()
    MigrateAssociations(connection_source, session, batch_size).migrate()
    SetDefaultGeometries(connection_source, session, batch_size).migrate()
    MigrateAreaAssociations(connection_source, session, batch_size).migrate()
    UpdateSequences(connection_source, session, batch_size).migrate()