mirror of https://github.com/JohnHammond/CTFd.git
Adding sqlalchemy-utils as a dependency in order to create databases automatically
parent
9ebf4c51e8
commit
9ef27ae54b
|
@ -2,6 +2,7 @@ from flask import Flask, render_template, request, redirect, abort, session, jso
|
|||
from flask.ext.sqlalchemy import SQLAlchemy
|
||||
from logging.handlers import RotatingFileHandler
|
||||
from flask.ext.session import Session
|
||||
from sqlalchemy_utils import database_exists, create_database
|
||||
import os
|
||||
import sqlalchemy
|
||||
|
||||
|
@ -13,6 +14,10 @@ def create_app(config='CTFd.config'):
|
|||
|
||||
from CTFd.models import db, Teams, Solves, Challenges, WrongKeys, Keys, Tags, Files, Tracking
|
||||
|
||||
## sqlite database creation is relative to the script which causes issues with serve.py
|
||||
if not database_exists(app.config['SQLALCHEMY_DATABASE_URI']) and not app.config['SQLALCHEMY_DATABASE_URI'].startswith('sqlite'):
|
||||
create_database(app.config['SQLALCHEMY_DATABASE_URI'])
|
||||
|
||||
db.init_app(app)
|
||||
db.create_all()
|
||||
|
||||
|
|
|
@ -2,6 +2,7 @@ Flask
|
|||
Flask-SQLAlchemy
|
||||
Flask-Session
|
||||
SQLAlchemy
|
||||
sqlalchemy-utils
|
||||
passlib
|
||||
bcrypt
|
||||
six
|
||||
|
|
Loading…
Reference in New Issue