fix images
This commit is contained in:
54
backend/apply_backup_jobs_migration.sh
Executable file
54
backend/apply_backup_jobs_migration.sh
Executable 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
|
||||
29
backend/create_backup_jobs_table.sql
Normal file
29
backend/create_backup_jobs_table.sql
Normal 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);
|
||||
19
deploy.sh
19
deploy.sh
@@ -55,6 +55,25 @@ if [ $RETRY_COUNT -eq $MAX_RETRIES ]; then
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# Apply database migrations
|
||||
echo -e "${YELLOW}🗄️ Applying database migrations...${NC}"
|
||||
if [ -f "backend/create_backup_jobs_table.sql" ]; then
|
||||
echo "Applying backup_jobs table migration..."
|
||||
|
||||
# Get list of databases
|
||||
DATABASES=$(docker-compose exec -T postgres psql -U storycove -lqt | cut -d \| -f 1 | grep -E '^ storycove' | sed 's/^[ \t]*//')
|
||||
|
||||
# Apply migration to each database
|
||||
for DB_NAME in $DATABASES; do
|
||||
echo " - Applying to database: $DB_NAME"
|
||||
docker-compose exec -T postgres psql -U storycove -d "$DB_NAME" < backend/create_backup_jobs_table.sql 2>&1 | grep -E "(CREATE|ERROR)" || true
|
||||
done
|
||||
|
||||
echo -e "${GREEN}✅ Database migrations applied${NC}"
|
||||
else
|
||||
echo -e "${YELLOW}⚠️ No migration files found, skipping...${NC}"
|
||||
fi
|
||||
|
||||
# Check if Solr is ready
|
||||
echo -e "${YELLOW}🔍 Checking Solr health...${NC}"
|
||||
RETRY_COUNT=0
|
||||
|
||||
@@ -114,9 +114,10 @@ const htmlToSlate = (html: string): Descendant[] => {
|
||||
const img = element as HTMLImageElement;
|
||||
results.push({
|
||||
type: 'image',
|
||||
src: img.src || img.getAttribute('src') || '',
|
||||
alt: img.alt || img.getAttribute('alt') || '',
|
||||
caption: img.title || img.getAttribute('title') || '',
|
||||
// Use getAttribute to preserve relative URLs instead of .src which converts to absolute
|
||||
src: img.getAttribute('src') || '',
|
||||
alt: img.getAttribute('alt') || '',
|
||||
caption: img.getAttribute('title') || '',
|
||||
children: [{ text: '' }] // Images need children in Slate
|
||||
});
|
||||
break;
|
||||
|
||||
Reference in New Issue
Block a user