diff --git a/nomad/config.py b/nomad/config.py index bb1c7a379982a6fa4994579ed4968ff68a2f32a8..413c9ce10234c287651b813d2e357030f246aec7 100644 --- a/nomad/config.py +++ b/nomad/config.py @@ -110,7 +110,7 @@ services = NomadServicesConfig( api_base_path=os.environ.get('NOMAD_API_BASE_PATH', '/nomad/api'), api_secret=os.environ.get('NOMAD_API_SECRET', 'defaultApiSecret'), admin_password=os.environ.get('NOMAD_API_ADMIN_PASSWORD', 'password'), - disable_reset=os.environ.get('NOMAD_API_DISABLE_RESET', 'true') == 'false' + disable_reset=os.environ.get('NOMAD_API_DISABLE_RESET', 'false') == 'true' ) console_log_level = get_loglevel_from_env('NOMAD_CONSOLE_LOGLEVEL', default_level=logging.INFO) diff --git a/nomad/infrastructure.py b/nomad/infrastructure.py index 02f6499bdae362a59f3adc89b4d0d8466d0f7651..16578843657f6a46744b83f026c967efda85895d 100644 --- a/nomad/infrastructure.py +++ b/nomad/infrastructure.py @@ -128,6 +128,11 @@ def setup_repository_db(): "select exists(select * from information_schema.tables " "where table_name='users')") exists = cur.fetchone()[0] + if not exists: + logger.info('repository db postgres schema does not exists') + reset_repository_db() + else: + logger.info('repository db postgres schema already exists') # set the admin user password with repository_db_connection() as conn: @@ -136,12 +141,6 @@ def setup_repository_db(): "UPDATE public.users SET password='%s' WHERE user_id=1;" % bcrypt.encrypt(config.services.admin_password, ident='2y')) - if not exists: - logger.info('repository db postgres schema does not exists') - reset_repository_db() - else: - logger.info('repository db postgres schema already exists') - global repository_db global repository_db_conn