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')
|
2016-04-29 21:36:37 +00:00
|
|
|
fullscreen_layout_setting = Setting('fullscreen_layout', 'True')
|
2016-06-07 04:19:12 +00:00
|
|
|
record_helper_setting = Setting('record_helper', 'True')
|
2016-06-12 17:13:29 +00:00
|
|
|
default_table_size_setting = Setting('default_record_table_size', '15')
|
2016-04-11 09:40:44 +00:00
|
|
|
db.session.add(admin_role)
|
|
|
|
db.session.add(user_role)
|
|
|
|
db.session.add(maintenance_setting)
|
2016-04-29 21:36:37 +00:00
|
|
|
db.session.add(fullscreen_layout_setting)
|
2016-05-15 18:47:02 +00:00
|
|
|
db.session.add(record_helper_setting)
|
2016-06-09 01:23:08 +00:00
|
|
|
db.session.add(default_table_size_setting)
|
2016-04-11 09:40:44 +00:00
|
|
|
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:
|
2016-06-12 17:13:29 +00:00
|
|
|
api.version_control(SQLALCHEMY_DATABASE_URI, SQLALCHEMY_MIGRATE_REPO, api.version(SQLALCHEMY_MIGRATE_REPO))
|