mirror of
https://github.com/cwinfo/powerdns-admin.git
synced 2024-11-08 22:50:26 +00:00
25 lines
1.0 KiB
Python
Executable File
25 lines
1.0 KiB
Python
Executable File
#!flask/bin/python
|
|
from migrate.versioning import api
|
|
from config import SQLALCHEMY_DATABASE_URI
|
|
from config import SQLALCHEMY_MIGRATE_REPO
|
|
from app import db
|
|
from app.models import Role, Setting
|
|
import os.path
|
|
db.create_all()
|
|
# create initial user roles and turn off maintenance mode
|
|
admin_role = Role('Administrator', 'Administrator')
|
|
user_role = Role('User', 'User')
|
|
maintenance_setting = Setting('maintenance', 'False')
|
|
fullscreen_layout_setting = Setting('fullscreen_layout', 'True')
|
|
record_helper_setting = Setting('record_helper', 'True')
|
|
db.session.add(admin_role)
|
|
db.session.add(user_role)
|
|
db.session.add(maintenance_setting)
|
|
db.session.add(fullscreen_layout_setting)
|
|
db.session.add(record_helper_setting)
|
|
db.session.commit()
|
|
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)) |