2015-12-13 09:34:12 +00:00
|
|
|
#!flask/bin/python
|
|
|
|
from migrate.versioning import api
|
|
|
|
from config import SQLALCHEMY_DATABASE_URI
|
|
|
|
from config import SQLALCHEMY_MIGRATE_REPO
|
|
|
|
from app import db
|
2016-04-11 09:40:44 +00:00
|
|
|
from app.models import Role, Setting
|
2015-12-13 09:34:12 +00:00
|
|
|
import os.path
|
|
|
|
db.create_all()
|
2016-04-11 09:40:44 +00:00
|
|
|
# create initial user roles and turn off maintenance mode
|
|
|
|
admin_role = Role('Administrator', 'Administrator')
|
|
|
|
user_role = Role('User', 'User')
|
|
|
|
maintenance_setting = Setting('maintenance', 'False')
|
|
|
|
db.session.add(admin_role)
|
|
|
|
db.session.add(user_role)
|
|
|
|
db.session.add(maintenance_setting)
|
|
|
|
db.session.commit()
|
2015-12-13 09:34:12 +00:00
|
|
|
if not os.path.exists(SQLALCHEMY_MIGRATE_REPO):
|
|
|
|
api.create(SQLALCHEMY_MIGRATE_REPO, 'database repository')
|
|
|
|
api.version_control(SQLALCHEMY_DATABASE_URI, SQLALCHEMY_MIGRATE_REPO)
|
|
|
|
else:
|
|
|
|
api.version_control(SQLALCHEMY_DATABASE_URI, SQLALCHEMY_MIGRATE_REPO, api.version(SQLALCHEMY_MIGRATE_REPO))
|