mirror of
https://github.com/bigbeartechworld/big-bear-scripts.git
synced 2026-08-03 02:38:43 -04:00
🚀 feat: Add database migrations to startup (#75)
* 🚀 feat: Add database migrations to startup Add database migrations execution to the panel startup process. This ensures the database schema is properly initialized before the application starts. The migration runs with the --force flag to allow non-interactive execution in containerized environments. * 🔧 fix: Add error handling for database migrations Add error handling to the database migration step to detect and abort if migrations fail. This prevents the panel from starting in an inconsistent state when database changes encounter errors. * fix: 🐛 Remove interactive terminal flag from docker exec Remove the `-t` flag from docker exec commands in the startup script. The `-t` flag allocates a pseudo-terminal which is unnecessary for non-interactive command execution and can cause issues in automated environments. Keep the `-i` flag for stdin input handling. * 🛡️ fix: add error handling to startup scripts Add error checking to key generation and cache optimization commands. Exit with status code 1 if either command fails, preventing silent failures during panel startup.
This commit is contained in:
@@ -11,13 +11,28 @@ log() {
|
||||
|
||||
generate_key() {
|
||||
log "Generating key..."
|
||||
docker exec -it $CONTAINER_ID php artisan key:generate --force
|
||||
if ! docker exec -i $CONTAINER_ID php artisan key:generate --force; then
|
||||
log "ERROR: Key generation failed. Aborting."
|
||||
exit 1
|
||||
fi
|
||||
log "Key generated successfully."
|
||||
}
|
||||
|
||||
run_migrations() {
|
||||
log "Running database migrations..."
|
||||
if ! docker exec -i $CONTAINER_ID php artisan migrate --force; then
|
||||
log "ERROR: Database migrations failed. Aborting."
|
||||
exit 1
|
||||
fi
|
||||
log "Database migrations completed successfully."
|
||||
}
|
||||
|
||||
optimize_cache() {
|
||||
log "Optimizing Laravel cache..."
|
||||
docker exec -it $CONTAINER_ID php artisan optimize
|
||||
if ! docker exec -i $CONTAINER_ID php artisan optimize; then
|
||||
log "ERROR: Cache optimization failed. Aborting."
|
||||
exit 1
|
||||
fi
|
||||
log "Laravel cache optimized successfully."
|
||||
}
|
||||
|
||||
@@ -38,6 +53,7 @@ create_user() {
|
||||
main() {
|
||||
log "Starting script..."
|
||||
generate_key
|
||||
run_migrations
|
||||
optimize_cache
|
||||
prompt_check_login
|
||||
create_user
|
||||
|
||||
Reference in New Issue
Block a user