fix images

This commit is contained in:
Stefan Hardegger
2025-10-20 12:30:28 +02:00
parent c9d58173f3
commit 6a38189ef0
4 changed files with 106 additions and 3 deletions

View File

@@ -0,0 +1,54 @@
#!/bin/bash
# Script to apply backup_jobs table migration to all library databases
# This should be run from the backend directory
set -e
# Use full docker path
DOCKER="/usr/local/bin/docker"
echo "Applying backup_jobs table migration..."
# Get database connection details from environment or use defaults
DB_HOST="${POSTGRES_HOST:-postgres}"
DB_PORT="${POSTGRES_PORT:-5432}"
DB_USER="${POSTGRES_USER:-storycove}"
DB_PASSWORD="${POSTGRES_PASSWORD:-password}"
# List of databases to update
DATABASES=("storycove" "storycove_afterdark")
for DB_NAME in "${DATABASES[@]}"; do
echo ""
echo "Applying migration to database: $DB_NAME"
# Check if database exists
if $DOCKER exec storycove-postgres-1 psql -U "$DB_USER" -lqt | cut -d \| -f 1 | grep -qw "$DB_NAME"; then
echo "Database $DB_NAME exists, applying migration..."
# Apply migration
$DOCKER exec -i storycove-postgres-1 psql -U "$DB_USER" -d "$DB_NAME" < create_backup_jobs_table.sql
if [ $? -eq 0 ]; then
echo "✓ Migration applied successfully to $DB_NAME"
else
echo "✗ Failed to apply migration to $DB_NAME"
exit 1
fi
else
echo "⚠ Database $DB_NAME does not exist, skipping..."
fi
done
echo ""
echo "Migration complete!"
echo ""
echo "Verifying table creation..."
for DB_NAME in "${DATABASES[@]}"; do
if $DOCKER exec storycove-postgres-1 psql -U "$DB_USER" -lqt | cut -d \| -f 1 | grep -qw "$DB_NAME"; then
echo ""
echo "Checking $DB_NAME:"
$DOCKER exec storycove-postgres-1 psql -U "$DB_USER" -d "$DB_NAME" -c "\d backup_jobs" 2>/dev/null || echo " Table not found in $DB_NAME"
fi
done

View File

@@ -0,0 +1,29 @@
-- Create backup_jobs table for async backup job tracking
-- This should be run on all library databases (default and afterdark)
CREATE TABLE IF NOT EXISTS backup_jobs (
id UUID PRIMARY KEY,
library_id VARCHAR(255) NOT NULL,
type VARCHAR(50) NOT NULL CHECK (type IN ('DATABASE_ONLY', 'COMPLETE')),
status VARCHAR(50) NOT NULL CHECK (status IN ('PENDING', 'IN_PROGRESS', 'COMPLETED', 'FAILED', 'EXPIRED')),
file_path VARCHAR(1000),
file_size_bytes BIGINT,
progress_percent INTEGER,
error_message VARCHAR(1000),
created_at TIMESTAMP NOT NULL,
started_at TIMESTAMP,
completed_at TIMESTAMP,
expires_at TIMESTAMP
);
-- Create index on library_id for faster lookups
CREATE INDEX IF NOT EXISTS idx_backup_jobs_library_id ON backup_jobs(library_id);
-- Create index on status for cleanup queries
CREATE INDEX IF NOT EXISTS idx_backup_jobs_status ON backup_jobs(status);
-- Create index on expires_at for cleanup queries
CREATE INDEX IF NOT EXISTS idx_backup_jobs_expires_at ON backup_jobs(expires_at);
-- Create index on created_at for ordering
CREATE INDEX IF NOT EXISTS idx_backup_jobs_created_at ON backup_jobs(created_at DESC);