forked from maangulo12/starter-kit
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmanage.py
More file actions
54 lines (39 loc) · 1.18 KB
/
manage.py
File metadata and controls
54 lines (39 loc) · 1.18 KB
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
43
44
45
46
47
48
49
50
51
52
53
54
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
manage.py
~~~~~~~~~
This module implements the manager commands of this application.
Commands:
- create : Creates all of the tables in the database.
- drop : Drops all of the tables from the database.
- recreate : Drops and recreates the tables in the database.
- db : Performs database migrations.
HOW TO USE:
- Type the following in the command-line
python3 manage.py (insert one of the commands from above here)
"""
from flask_migrate import MigrateCommand
from backend import db, manager
# COMMAND: create
@manager.command
def create():
"""Creates all of the tables in the database."""
db.create_all()
print('Created all of the tables in the database.')
# COMMAND: drop
@manager.command
def drop():
"""Drops all of the tables from the database."""
db.drop_all()
print('Dropped all of the tables from the database.')
# COMMAND: recreate
@manager.command
def recreate():
"""Drops and recreates the tables in the database."""
drop()
create()
# COMMAND: db
manager.add_command('db', MigrateCommand)
if __name__ == "__main__":
manager.run()