-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathmanage.py
36 lines (29 loc) · 1000 Bytes
/
manage.py
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
import sys
import unittest
from flask.ext.script import Manager
from flask.ext.migrate import Migrate, MigrateCommand
from alembic.runtime.environment import EnvironmentContext
from app import app, db
# import os
# app.config.from_object(os.environ['APP_SETTINGS'])
env = EnvironmentContext.configure
# This will allow migrations to listen to column type changes.
env.compare_type = True
migrate = Migrate(app, db)
manager = Manager(app)
manager.add_command('db', MigrateCommand)
@manager.command
def test():
"""Runs the unit tests without coverage."""
tests = unittest.TestLoader().discover('tests')
result = unittest.TextTestRunner(verbosity=2).run(tests)
if result.wasSuccessful():
return 0
else:
return 1
if __name__ == '__main__':
if sys.argv[1] == 'db':
print("")
print("# # # Ran DB Manager, using Alembic and Flask-Migrate. # # #")
print("# # # DB: '", app.config['SQLALCHEMY_DATABASE_URI'], "' # # #")
manager.run()