-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmanage.py
More file actions
42 lines (32 loc) · 851 Bytes
/
manage.py
File metadata and controls
42 lines (32 loc) · 851 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
"""
Manager script for testing and database utilities
Implemenation adapted from https://github.com/realpython/flask-jwt-auth
"""
from flask_script import Manager
from api import create_app, db
from api.src.utils.utilities import create_roles, create_admin
manager = Manager(create_app)
@manager.command
def create_db():
"""Creates the db tables"""
print("Creating database tables...")
db.create_all()
create_roles()
create_admin()
@manager.command
def drop_db():
"""Drops the db tables."""
db.drop_all()
@manager.command
def refresh_db():
"""Drops & Recreates db tables"""
print("Recreating Database...")
drop_db()
print("Tables dropped...")
create_db()
@manager.command
def populate_db():
import api.src.utils.populate_db as pop_db
pop_db
if __name__ == '__main__':
manager.run()