-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathmanage.py
More file actions
33 lines (24 loc) · 689 Bytes
/
manage.py
File metadata and controls
33 lines (24 loc) · 689 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
from flask_script import Manager
from flask_migrate import Migrate, MigrateCommand
from app.server import create_app, db
from app.server.model import User
app = create_app()
migrate = Migrate(app, db)
manager = Manager(app)
# migrations
manager.add_command('db', MigrateCommand)
@manager.command
def create_db():
"""Creates the db tables."""
db.create_all()
@manager.command
def drop_db():
"""Drops the db tables."""
db.drop_all()
@manager.command
def create_admin():
"""Creates the admin user."""
db.session.add(User(username='admin', email='ad@min.com', password='admin', admin=True))
db.session.commit()
if __name__ == '__main__':
manager.run()