Skip to content

Commit

Permalink
Merge pull request #59878 from ClickHouse/cherrypick/23.8/1285bdbef13…
Browse files Browse the repository at this point in the history
…057de50c66b0af0232922300ec6ef

Cherry pick #59808 to 23.8: Option to run init db scripts every time
  • Loading branch information
robot-clickhouse-ci-1 committed Feb 12, 2024
2 parents 9d0e57a + 1285bdb commit 8195e83
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions docker/server/entrypoint.sh
Expand Up @@ -104,13 +104,19 @@ if [ -n "$CLICKHOUSE_USER" ] && [ "$CLICKHOUSE_USER" != "default" ] || [ -n "$CL
EOT
fi

CLICKHOUSE_ALWAYS_RUN_INITDB_SCRIPTS="${CLICKHOUSE_ALWAYS_RUN_INITDB_SCRIPTS:-}"

# checking $DATA_DIR for initialization
if [ -d "${DATA_DIR%/}/data" ]; then
DATABASE_ALREADY_EXISTS='true'
fi

# only run initialization on an empty data directory
if [ -z "${DATABASE_ALREADY_EXISTS}" ]; then
# run initialization if flag CLICKHOUSE_ALWAYS_RUN_INITDB_SCRIPTS is not empty or data directory is empty
if [[ -n "${CLICKHOUSE_ALWAYS_RUN_INITDB_SCRIPTS}" || -z "${DATABASE_ALREADY_EXISTS}" ]]; then
RUN_INITDB_SCRIPTS='true'
fi

if [ -z "${RUN_INITDB_SCRIPTS}" ]; then
if [ -n "$(ls /docker-entrypoint-initdb.d/)" ] || [ -n "$CLICKHOUSE_DB" ]; then
# port is needed to check if clickhouse-server is ready for connections
HTTP_PORT="$(clickhouse extract-from-config --config-file "$CLICKHOUSE_CONFIG" --key=http_port --try)"
Expand Down

0 comments on commit 8195e83

Please sign in to comment.