Skip to content

Commit

Permalink
Merge pull request #201 from dpmittal/reset_db
Browse files Browse the repository at this point in the history
CB-284: Add an option to reset tables and types to manage.py init_db
  • Loading branch information
paramsingh committed May 6, 2018
2 parents 2b39e2d + 266c358 commit 7e2c5c7
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion manage.py
Original file line number Diff line number Diff line change
Expand Up @@ -88,8 +88,10 @@ def clear_memcached():
help="Skip database creation step.")
@click.option("--test-db", "-t", is_flag=True,
help="Initialize the test database.")
@click.option("--force", "-f", is_flag=True,
help="Drop existing tables and types.")
@cli.command()
def init_db(skip_create_db=False, test_db=False):
def init_db(skip_create_db=False, test_db=False, force=False):
"""Initialize the database.
* Creates the database.
Expand All @@ -98,6 +100,12 @@ def init_db(skip_create_db=False, test_db=False):
"""
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__)),
Expand Down

0 comments on commit 7e2c5c7

Please sign in to comment.