CICD/manage.py

36 lines
673 B
Python
Raw Normal View History

2019-05-18 19:00:13 +02:00
import os
from flask_script import Manager
from app import create_app, db
from commands.seed_command import SeedCommand
2019-08-03 18:55:38 +02:00
env = os.getenv("FLASK_ENV") or "test"
print(f"Active environment: * {env} *")
2019-05-18 19:00:13 +02:00
app = create_app(env)
manager = Manager(app)
app.app_context().push()
2019-08-03 18:55:38 +02:00
manager.add_command("seed_db", SeedCommand)
2019-05-18 19:00:13 +02:00
@manager.command
def run():
app.run()
@manager.command
def init_db():
2019-08-03 18:55:38 +02:00
print("Creating all resources.")
2019-05-18 19:00:13 +02:00
db.create_all()
@manager.command
def drop_all():
2019-08-03 18:55:38 +02:00
if input("Are you sure you want to drop all tables? (y/N)\n").lower() == "y":
print("Dropping tables...")
2019-05-18 19:00:13 +02:00
db.drop_all()
2019-08-03 18:55:38 +02:00
if __name__ == "__main__":
2019-05-18 19:00:13 +02:00
manager.run()