Skip to content

Commit 9594b84

Browse files
committed
ci(docker): add SEMAPHORE_MIGRATE_FROM_BOLTDB for SQLite to auto migrate
1 parent 11c7194 commit 9594b84

1 file changed

Lines changed: 23 additions & 0 deletions

File tree

deployment/docker/server/server-wrapper

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -287,6 +287,29 @@ if [ -n "${SEMAPHORE_IMPORT_PROJECT_FILE:-}" ]; then
287287
fi
288288

289289

290+
#
291+
# Migrate from BoltDB if SEMAPHORE_MIGRATE_FROM_BOLTDB is set (SQLite only, skipped if DB file already exists)
292+
#
293+
if [ -n "${SEMAPHORE_MIGRATE_FROM_BOLTDB:-}" ]; then
294+
if [ "${SEMAPHORE_DB_DIALECT}" != "sqlite" ]; then
295+
echoerr "SEMAPHORE_MIGRATE_FROM_BOLTDB is only supported with SQLite dialect, ignoring"
296+
elif [ -f "${SEMAPHORE_DB_HOST}" ]; then
297+
echoerr "SQLite database ${SEMAPHORE_DB_HOST} already exists, skipping BoltDB migration"
298+
else
299+
echoerr "Migrating from BoltDB: ${SEMAPHORE_MIGRATE_FROM_BOLTDB}"
300+
MIGRATE_ARGS="--from-boltdb=${SEMAPHORE_MIGRATE_FROM_BOLTDB}"
301+
if [ -n "${SEMAPHORE_MIGRATE_SKIP_TASK_OUTPUT:-}" ]; then
302+
MIGRATE_ARGS="${MIGRATE_ARGS} --skip-task-output"
303+
fi
304+
if test "$#" -ne 1; then
305+
/usr/local/bin/semaphore migrate ${MIGRATE_ARGS} --config "${SEMAPHORE_CONFIG_PATH}/config.json"
306+
else
307+
"$1" migrate ${MIGRATE_ARGS} --config "${SEMAPHORE_CONFIG_PATH}/config.json"
308+
fi
309+
fi
310+
fi
311+
312+
290313
#
291314
# Start Semaphore server
292315
#

0 commit comments

Comments
 (0)