コード例 #1
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!")
コード例 #2
0
ファイル: manage.py プロジェクト: metabrainz/critiquebrainz
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!")
コード例 #3
0
ファイル: testing.py プロジェクト: shagun6/critiquebrainz
 def reset_db():
     drop_tables()
     drop_types()
     create_all()
コード例 #4
0
ファイル: testing.py プロジェクト: metabrainz/critiquebrainz
 def reset_db():
     drop_tables()
     drop_types()
     create_all()