Change the logic to call setup_db if the database doesn't exist.

This commit is contained in:
Akshay Joshi 2022-07-01 18:12:00 +05:30
parent 9c45a62b53
commit 3a69d50458
2 changed files with 8 additions and 7 deletions

View File

@ -82,6 +82,10 @@ class ReverseProxied(object):
##########################################################################
config.SETTINGS_SCHEMA_VERSION = SCHEMA_VERSION
# Check if the database exists. If it does not, create it.
setup_db_required = False
if not os.path.isfile(config.SQLITE_PATH):
setup_db_required = True
##########################################################################
# Create the app and configure it. It is created outside main so that
@ -91,8 +95,7 @@ app = create_app()
app.debug = False
app.config['sessions'] = dict()
# Check if the database exists. If it does not, create it.
if not os.path.isfile(config.SQLITE_PATH):
if setup_db_required:
setup.setup_db(app)
if config.SERVER_MODE:

View File

@ -14,6 +14,7 @@ import argparse
import os
import sys
import builtins
import config
# Grab the SERVER_MODE if it's been set by the runtime
if 'SERVER_MODE' in globals():
@ -31,6 +32,7 @@ from pgadmin.model import db, Version, SCHEMA_VERSION as CURRENT_SCHEMA_VERSION
from pgadmin import create_app
from pgadmin.utils import clear_database_servers, dump_database_servers,\
load_database_servers
from pgadmin.setup import db_upgrade, create_app_data_directory
def dump_servers(args):
@ -139,10 +141,6 @@ def clear_servers():
if __name__ == '__main__':
# Configuration settings
import config
from pgadmin.model import SCHEMA_VERSION
from pgadmin.setup import db_upgrade, create_app_data_directory
parser = argparse.ArgumentParser(description='Setup the pgAdmin config DB')
exp_group = parser.add_argument_group('Dump server config')
@ -172,7 +170,7 @@ if __name__ == '__main__':
args, extra = parser.parse_known_args()
config.SETTINGS_SCHEMA_VERSION = SCHEMA_VERSION
config.SETTINGS_SCHEMA_VERSION = CURRENT_SCHEMA_VERSION
if "PGADMIN_TESTING_MODE" in os.environ and \
os.environ["PGADMIN_TESTING_MODE"] == "1":
config.SQLITE_PATH = config.TEST_SQLITE_PATH