diff --git a/rhodecode/lib/db_manage.py b/rhodecode/lib/db_manage.py --- a/rhodecode/lib/db_manage.py +++ b/rhodecode/lib/db_manage.py @@ -41,23 +41,25 @@ import logging log = logging.getLogger(__name__) class DbManage(object): - def __init__(self, log_sql, dbname, root, tests=False): - self.dbname = dbname + def __init__(self, log_sql, dbconf, root, tests=False): + self.dbname = dbconf.split('/')[-1] self.tests = tests self.root = root - dburi = 'sqlite:////%s' % jn(self.root, self.dbname) - engine = create_engine(dburi, echo=log_sql) + self.dburi = dbconf + engine = create_engine(self.dburi, echo=log_sql) init_model(engine) self.sa = meta.Session() self.db_exists = False def check_for_db(self, override): db_path = jn(self.root, self.dbname) - log.info('checking for existing db in %s', db_path) - if os.path.isfile(db_path): - self.db_exists = True - if not override: - raise Exception('database already exists') + if self.dburi.startswith('sqlite'): + log.info('checking for existing db in %s', db_path) + if os.path.isfile(db_path): + + self.db_exists = True + if not override: + raise Exception('database already exists') def create_tables(self, override=False): """ diff --git a/rhodecode/websetup.py b/rhodecode/websetup.py --- a/rhodecode/websetup.py +++ b/rhodecode/websetup.py @@ -8,16 +8,15 @@ log = logging.getLogger(__name__) def setup_app(command, conf, vars): """Place any commands to setup rhodecode here""" - dbname = os.path.split(conf['sqlalchemy.db1.url'])[-1] - dbmanage = DbManage(log_sql=True, dbname=dbname, root=conf['here'], - tests=False) + dbconf = conf['sqlalchemy.db1.url'] + dbmanage = DbManage(log_sql=True, dbconf=dbconf, root=conf['here'], tests=False) dbmanage.create_tables(override=True) dbmanage.config_prompt(None) dbmanage.create_default_user() dbmanage.admin_prompt() dbmanage.create_permissions() dbmanage.populate_default_permissions() - + load_environment(conf.global_conf, conf.local_conf, initial=True)