Skip to content

Commit

Permalink
feat: add flag to activate/deactivate database creation
Browse files Browse the repository at this point in the history
add a config option to skip database (table) creation

this option is necessary for using the app with redshift
  • Loading branch information
Michele-Alberti committed Feb 23, 2024
1 parent 4146131 commit f9e0f67
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 6 deletions.
6 changes: 5 additions & 1 deletion dlunch/conf/db/common.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,11 @@ shared_data_folder: ${oc.env:PANEL_SHARED_DATA_FOLDER, /app/shared_data}
engine:
_target_: sqlalchemy.create_engine
url: ${db.url}
# CREATE DATABASE RETRIES
# CREATE DATABASE
# Set attempt_creation to false to stop panel from creating database tables
# Table shall exist on first run if false
attempt_creation: true
# Retries:
# Stop after delay in seconds or max attempts
# Wait time in seconds before retrying
create_retries:
Expand Down
12 changes: 7 additions & 5 deletions dlunch/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -637,12 +637,14 @@ def create_database_with_retries(config: DictConfig) -> None:
Data.metadata.create_all(engine)

# Create tables
create_database_with_retries(config)
log.debug(f"attempt database creation: {config.db.attempt_creation}")
if config.db.attempt_creation:
create_database_with_retries(config)

# Retries stats
log.debug(
f"create database attempts: {create_database_with_retries.retry.statistics}"
)
# Retries stats
log.debug(
f"create database attempts: {create_database_with_retries.retry.statistics}"
)

# If requested add users for basic auth (admin and guest)
if add_basic_auth_users:
Expand Down

0 comments on commit f9e0f67

Please sign in to comment.