Added --check- and --apply-db-migration and add --check-db-migration to troubleshoot
This commit is contained in:
committed by
Elias Hackradt
parent
8907b692c1
commit
7f9344a556
@@ -31,6 +31,8 @@ readonly HELP_MESSAGE="
|
||||
--recreate-containers Deletes all existing containers and recreates them without loss of data
|
||||
--recreate-docker Deletes docker storage (containers and images) and recreates it without loss of data
|
||||
--send-diagnostics Collects server diagnostics and uploads it to ${PASTEBIN}
|
||||
--check-db-migration Checks if the DB migrations are up to date.
|
||||
--apply-db-migration Applys all pending DB migrations.
|
||||
--troubleshoot Dashboard down? Run tests to identify the potential problem
|
||||
--unbound-use-external-dns Forwards all Unbound requests to Google (8.8.8.8) and Cloudflare (1.1.1.1) DNS servers.
|
||||
Unbound is the internal DNS server used for recursive DNS queries. This is only needed
|
||||
@@ -640,6 +642,7 @@ function troubleshoot() {
|
||||
check_dashboard_site_domain # check website via domain name
|
||||
check_expired_domain
|
||||
check_unbound # this is less fatal after 8.0
|
||||
check_db_migration
|
||||
}
|
||||
|
||||
function cleanup_disk_space() {
|
||||
@@ -844,9 +847,25 @@ function apply_patch() {
|
||||
echo "Patch applied"
|
||||
}
|
||||
|
||||
function check_db_migration() {
|
||||
local -r last_migration_from_db="$(mysql -NB -uroot -ppassword -e "SELECT name FROM box.migrations ORDER BY run_on DESC LIMIT 1" 2>/dev/null).js"
|
||||
local -r last_migration_file="/$(ls --ignore schema.sql --ignore initial-schema.sql /home/yellowtent/box/migrations/ | sort | tail -1)"
|
||||
if [[ "${last_migration_from_db}" != "${last_migration_file}" ]]; then
|
||||
fail "Database migrations are pending. Last migration in DB: ${last_migration_from_db}. Last migration file: ${last_migration_file}."
|
||||
info "Please run 'cloudron-support --apply-db-migration' to apply the migrations."
|
||||
else
|
||||
success "No pending database migrations"
|
||||
fi
|
||||
}
|
||||
|
||||
function apply_db_migration() {
|
||||
echo "Applying pending database migrations"
|
||||
bash /home/yellowtent/box/setup/start.sh && success "Database migrations applied successfully" || fail "Database migrations failed"
|
||||
}
|
||||
|
||||
check_disk_space
|
||||
|
||||
args=$(getopt -o "" -l "admin-login,disable-dnssec,enable-remote-support,disable-remote-support,help,owner-login,patch:,recreate-containers,recreate-docker,fix-docker-version,send-diagnostics,unbound-use-external-dns,troubleshoot" -n "$0" -- "$@")
|
||||
args=$(getopt -o "" -l "admin-login,disable-dnssec,enable-remote-support,disable-remote-support,help,owner-login,patch:,recreate-containers,recreate-docker,fix-docker-version,send-diagnostics,unbound-use-external-dns,troubleshoot,check-db-migration,apply-db-migration" -n "$0" -- "$@")
|
||||
eval set -- "${args}"
|
||||
|
||||
while true; do
|
||||
@@ -867,6 +886,8 @@ while true; do
|
||||
--recreate-containers) recreate_containers; exit 0;;
|
||||
--recreate-docker) recreate_docker; exit 0;;
|
||||
--fix-docker-version) fix_docker_version; exit 0;;
|
||||
--check-db-migration) check_db_migration; exit 0;;
|
||||
--apply-db-migration) apply_db_migration; exit 0;;
|
||||
--patch) apply_patch "$2"; exit 0;;
|
||||
--help) break;;
|
||||
--) break;;
|
||||
|
||||
Reference in New Issue
Block a user