mirror of
https://github.com/pgadmin-org/pgadmin4.git
synced 2024-11-26 02:30:21 -06:00
6283ef7f5e
based configuration file from one version to another, and also allows us to have a single path of creating the table instead of creating tables using SQLAlchemy or hand rolled SQL This allows us to run the migrations directly in the code, and it will avoid the error prone version numbering. Patched by: Sarah McAlear Revisions: Joao Pedro De Almeida Pereira, George Gelashvili. Reviewed by: Ashesh Vashi, Murtuza Zabuawala
49 lines
1.3 KiB
Python
49 lines
1.3 KiB
Python
#########################################################################
|
|
#
|
|
# pgAdmin 4 - PostgreSQL Tools
|
|
#
|
|
# Copyright (C) 2013 - 2017, The pgAdmin Development Team
|
|
# This software is released under the PostgreSQL Licence
|
|
#
|
|
##########################################################################
|
|
|
|
"""Perform the initial setup of the application, by creating the auth
|
|
and settings database."""
|
|
|
|
import os
|
|
import sys
|
|
|
|
from flask import Flask
|
|
|
|
# We need to include the root directory in sys.path to ensure that we can
|
|
# find everything we need when running in the standalone runtime.
|
|
root = os.path.dirname(os.path.realpath(__file__))
|
|
if sys.path[0] != root:
|
|
sys.path.insert(0, root)
|
|
|
|
if __name__ == '__main__':
|
|
# Configuration settings
|
|
import config
|
|
from pgadmin.model import db, SCHEMA_VERSION
|
|
from pgadmin.setup import db_upgrade, create_app_data_directory
|
|
|
|
config.SETTINGS_SCHEMA_VERSION = SCHEMA_VERSION
|
|
|
|
app = Flask(__name__)
|
|
|
|
app.config.from_object(config)
|
|
|
|
if config.TESTING_MODE:
|
|
config.SQLITE_PATH = config.TEST_SQLITE_PATH
|
|
|
|
create_app_data_directory(config)
|
|
|
|
app.config['SQLALCHEMY_DATABASE_URI'] = \
|
|
'sqlite:///' + config.SQLITE_PATH.replace('\\', '/')
|
|
db.init_app(app)
|
|
|
|
print(u"pgAdmin 4 - Application Initialisation")
|
|
print(u"======================================\n")
|
|
|
|
db_upgrade(app)
|