示例#1
0
def init_db(skip_create_db=False):
    """Initialize the database.

    * Creates the database.
    * Creates all tables.
    * Adds fixtures required to run the app.
    """
    click.echo("Initializing the database...")

    db_uri = frontend.create_app().config['SQLALCHEMY_DATABASE_URI']
    if not skip_create_db:
        init_postgres(db_uri)
        create_extension(db_uri)

    click.echo("Creating tables... ", nl=False)
    data_utils.create_all()
    click.echo("Done!")

    click.echo("Adding fixtures... ")
    app = frontend.create_app()
    with app.app_context():
        _fixtures.install(*_fixtures.all_data)
    click.echo("Done!")

    click.echo("Initialization has been completed!")
示例#2
0
def init_db(test_db=False, force=False):
    """Initialize the database.

    * Creates the database.
    * Creates all tables.
    * Adds fixtures required to run the app.
    """
    click.echo("Initializing the database...")

    if force:
        click.echo("Dropping existing tables and types...")
        data_utils.drop_tables()
        data_utils.drop_types()
        click.echo("Done!")

    if test_db:
        frontend.create_app(config_path=os.path.join(
            os.path.dirname(os.path.realpath(__file__)),
            'critiquebrainz', 'test_config.py'
        ))
    else:
        frontend.create_app()

    click.echo("Creating tables... ", nl=False)
    data_utils.create_all()
    click.echo("Done!")

    click.echo("Adding fixtures... ")
    app = frontend.create_app()
    with app.app_context():
        _fixtures.install(*_fixtures.all_data)
    click.echo("Done!")

    click.echo("Initialization has been completed!")
示例#3
0
def init_db(skip_create_db=False, test_db=False):
    """Initialize the database.

    * Creates the database.
    * Creates all tables.
    * Adds fixtures required to run the app.
    """
    click.echo("Initializing the database...")

    if test_db:
        db_uri = frontend.create_app(config_path=os.path.join(
            os.path.dirname(os.path.realpath(__file__)), 'critiquebrainz',
            'test_config.py')).config['SQLALCHEMY_DATABASE_URI']
    else:
        db_uri = frontend.create_app().config['SQLALCHEMY_DATABASE_URI']

    if not skip_create_db:
        init_postgres(db_uri)
        create_extension(db_uri)

    click.echo("Creating tables... ", nl=False)
    data_utils.create_all()
    click.echo("Done!")

    click.echo("Adding fixtures... ")
    app = frontend.create_app()
    with app.app_context():
        _fixtures.install(*_fixtures.all_data)
    click.echo("Done!")

    click.echo("Initialization has been completed!")
示例#4
0
def init_db():
    """Initialize the database.

    * Creates the database.
    * Creates all tables.
    * Adds fixtures required to run the app.
    """
    click.echo("Initializing the database...")

    init_postgres(frontend.create_app().config["SQLALCHEMY_DATABASE_URI"])

    click.echo("Creating tables... ", nl=False)
    data_utils.create_tables(frontend.create_app())
    click.echo("Done!")

    click.echo("Adding fixtures... ")
    app = frontend.create_app()
    with app.app_context():
        _fixtures.install(app, *_fixtures.all_data)
    click.echo("Done!")

    click.echo("Initialization has been completed!")
示例#5
0
def init_db(skip_create_db=False, test_db=False, force=False):
    """Initialize the database.

    * Creates the database.
    * Creates all tables.
    * Adds fixtures required to run the app.
    """
    click.echo("Initializing the database...")

    if force:
        click.echo("Dropping existing tables and types...")
        data_utils.drop_tables()
        data_utils.drop_types()
        click.echo("Done!")

    if test_db:
        db_uri = frontend.create_app(config_path=os.path.join(
            os.path.dirname(os.path.realpath(__file__)),
            'critiquebrainz', 'test_config.py'
        )).config['SQLALCHEMY_DATABASE_URI']
    else:
        db_uri = frontend.create_app().config['SQLALCHEMY_DATABASE_URI']

    if not skip_create_db:
        init_postgres(db_uri)
        create_extension(db_uri)

    click.echo("Creating tables... ", nl=False)
    data_utils.create_all()
    click.echo("Done!")

    click.echo("Adding fixtures... ")
    app = frontend.create_app()
    with app.app_context():
        _fixtures.install(*_fixtures.all_data)
    click.echo("Done!")

    click.echo("Initialization has been completed!")
示例#6
0
def fixtures():
    """Update the newly created database with default schema and testing data."""
    _fixtures.install(current_app, *_fixtures.all_data)