コード例 #1
0
def setup_database(app):
    app_config = app.app_config
    global_config = app.global_config
    run_migrations = app_config['run_migrations']

    # Load all models for media types (plugins, ...)
    load_models(app_config)
    # Set up the database
    db = setup_connection_and_db_from_config(app_config,
                                             run_migrations,
                                             app=app)
    # run_migrations is used for tests
    if run_migrations:
        # Run the migrations to initialize/update the database.
        # We only run the alembic migrations in the case of unit
        # tests, in which case we don't need to run the legacy
        # migrations.
        from mediagoblin.gmg_commands.dbupdate import (run_alembic_migrations,
                                                       run_foundations)
        run_alembic_migrations(db, app_config, global_config)
        run_foundations(db, global_config)
    else:
        check_db_migrations_current(db)

    setup_globals(database=db)

    return db
コード例 #2
0
ファイル: __init__.py プロジェクト: ausbin/mediagoblin
def setup_database(app):
    app_config = app.app_config
    global_config = app.global_config
    run_migrations = app_config['run_migrations']

    # Load all models for media types (plugins, ...)
    load_models(app_config)
    # Set up the database
    db = setup_connection_and_db_from_config(
        app_config, run_migrations, app=app)
    # run_migrations is used for tests
    if run_migrations:
        # Run the migrations to initialize/update the database.
        # We only run the alembic migrations in the case of unit
        # tests, in which case we don't need to run the legacy
        # migrations.
        from mediagoblin.gmg_commands.dbupdate import (
            run_alembic_migrations, run_foundations)
        run_alembic_migrations(db, app_config, global_config)
        run_foundations(db, global_config)
    else:
        check_db_migrations_current(db)

    setup_globals(database=db)

    return db
コード例 #3
0
ファイル: __init__.py プロジェクト: praveen97uma/goblin
def setup_database():
    app_config = mg_globals.app_config

    # Load all models for media types (plugins, ...)
    load_models(app_config)

    # Set up the database
    db = setup_connection_and_db_from_config(app_config)

    check_db_migrations_current(db)

    setup_globals(database=db)

    return db
コード例 #4
0
def setup_database(run_migrations=False):
    app_config = mg_globals.app_config
    global_config = mg_globals.global_config

    # Load all models for media types (plugins, ...)
    load_models(app_config)
    # Set up the database
    db = setup_connection_and_db_from_config(app_config, run_migrations)
    if run_migrations:
        #Run the migrations to initialize/update the database.
        from mediagoblin.gmg_commands.dbupdate import run_all_migrations
        run_all_migrations(db, app_config, global_config)
    else:
        check_db_migrations_current(db)

    setup_globals(database=db)

    return db
コード例 #5
0
ファイル: __init__.py プロジェクト: RichoHan/MediaGoblin
def setup_database(run_migrations=False):
    app_config = mg_globals.app_config
    global_config = mg_globals.global_config

    # Load all models for media types (plugins, ...)
    load_models(app_config)
    # Set up the database
    db = setup_connection_and_db_from_config(app_config, run_migrations)
    if run_migrations:
        #Run the migrations to initialize/update the database.
        from mediagoblin.gmg_commands.dbupdate import run_all_migrations
        run_all_migrations(db, app_config, global_config)
    else:
        check_db_migrations_current(db)

    setup_globals(database=db)

    return db