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!")
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!")
def reset_db(): drop_tables() drop_types() create_all()