-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Jackson Chadfield
committed
Jul 31, 2019
1 parent
c394fb9
commit 3d7223d
Showing
3 changed files
with
100 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
# -*- coding: utf-8 -*- | ||
import random | ||
|
||
import click | ||
import flask | ||
from flask.cli import with_appcontext | ||
|
||
from OpenLearn.extensions import db | ||
|
||
|
||
@click.command() | ||
@with_appcontext | ||
def rebuild_database() -> None: | ||
"""Builds the database.""" | ||
if flask.current_app.debug is False: | ||
click.secho("You are in production mode", bold=True, fg="white", bg="red") | ||
click.confirm("Are you sure about this?", abort=True, default=False) | ||
code = "".join([str(random.randint(0, 9)) for _ in range(6)]) | ||
click.echo(f"Confirm by using the code: {click.style(code, fg='red', bold=True)}") | ||
u_code = click.prompt("Code", confirmation_prompt=True) | ||
if code != u_code: | ||
raise click.Abort | ||
|
||
db.session.commit() | ||
db.drop_all() | ||
click.secho("Dropped All Tables", fg="red", bold=True) | ||
db.create_all() | ||
click.secho("Created All Tables", fg="green", bold=True) |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters