mirror of
https://github.com/pixelfed/pixelfed.git
synced 2024-11-25 15:55:22 +00:00
quick take on applying migrations automatically
This commit is contained in:
parent
a8c5585e19
commit
6edf266a14
3 changed files with 30 additions and 2 deletions
|
@ -19,6 +19,9 @@ DOCKER_TAG="branch-jippi-fork-apache-8.1"
|
||||||
# See: https://www.php.net/manual/en/timezones.php
|
# See: https://www.php.net/manual/en/timezones.php
|
||||||
TZ="UTC"
|
TZ="UTC"
|
||||||
|
|
||||||
|
# Automatically run [artisan migrate --force] if new migrations are detected
|
||||||
|
DOCKER_APPLY_NEW_MIGRATIONS_AUTOMATICALLY="0"
|
||||||
|
|
||||||
###############################################################
|
###############################################################
|
||||||
# Pixelfed application configuration
|
# Pixelfed application configuration
|
||||||
###############################################################
|
###############################################################
|
||||||
|
|
|
@ -3,7 +3,29 @@ source /docker/helpers.sh
|
||||||
|
|
||||||
entrypoint-set-script-name "$0"
|
entrypoint-set-script-name "$0"
|
||||||
|
|
||||||
|
# Allow automatic applying of outstanding/new migrations on startup
|
||||||
|
: ${DOCKER_APPLY_NEW_MIGRATIONS_AUTOMATICALLY:=0}
|
||||||
|
|
||||||
|
if [[ $DOCKER_APPLY_NEW_MIGRATIONS_AUTOMATICALLY -eq 0 ]]; then
|
||||||
|
log-info "Automatic applying of new database migrations is disabled"
|
||||||
|
log-info "Please set [DOCKER_APPLY_NEW_MIGRATIONS_AUTOMATICALLY=1] in your [.env] file to enable this."
|
||||||
|
|
||||||
|
exit 0
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Wait for the database to be ready
|
||||||
await-database-ready
|
await-database-ready
|
||||||
|
|
||||||
declare new_migrations=0
|
# Detect if we have new migrations
|
||||||
run-as-runtime-user php artisan migrate:status | grep No && migrations=yes || migrations=no
|
declare -i new_migrations=0
|
||||||
|
run-as-runtime-user php artisan migrate:status | grep No && new_migrations=1
|
||||||
|
|
||||||
|
if [[ $new_migrations -eq 0 ]]; then
|
||||||
|
log-info "No outstanding migrations detected"
|
||||||
|
|
||||||
|
exit 0
|
||||||
|
fi
|
||||||
|
|
||||||
|
log-warning "New migrations available, will automatically apply them now"
|
||||||
|
|
||||||
|
run-as-runtime-user php artisan migrate --force
|
||||||
|
|
|
@ -29,6 +29,9 @@ declare -g docker_once_path="${docker_state_path}/once"
|
||||||
|
|
||||||
declare -g runtime_username=$(id -un ${RUNTIME_UID})
|
declare -g runtime_username=$(id -un ${RUNTIME_UID})
|
||||||
|
|
||||||
|
# We should already be in /var/www, but just to be explicit
|
||||||
|
cd /var/www || log-error-and-exit "could not change to /var/www"
|
||||||
|
|
||||||
# @description Restore the log prefix to the previous value that was captured in [entrypoint-set-script-name ]
|
# @description Restore the log prefix to the previous value that was captured in [entrypoint-set-script-name ]
|
||||||
# @arg $1 string The name (or path) of the entrypoint script being run
|
# @arg $1 string The name (or path) of the entrypoint script being run
|
||||||
function entrypoint-set-script-name() {
|
function entrypoint-set-script-name() {
|
||||||
|
|
Loading…
Reference in a new issue