jedmund-svelte/scripts
Justin Edmund 974781b685 fix: Svelte 5 migration and linting improvements (61 errors fixed)
Complete Svelte 5 runes migration and fix remaining ESLint errors:

**Svelte 5 Migration (40 errors):**
- Add $state() and $state.raw() for reactive variables and DOM refs
- Replace deprecated on:event directives with onevent syntax
- Fix closure capture issues in derived values
- Replace svelte:self with direct component imports
- Fix state initialization and reactivity issues

**TypeScript/ESLint (8 errors):**
- Replace explicit any types with proper types (Prisma.MediaWhereInput, unknown)
- Remove unused imports and rename unused variables with underscore prefix
- Convert require() to ES6 import syntax

**Other Fixes (13 errors):**
- Disable custom element props warnings for form components
- Fix self-closing textarea tags
- Add aria-labels to icon-only buttons
- Add keyboard handlers for interactive elements
- Refactor map popup to use Svelte component instead of HTML strings

Files modified: 28 components, 2 scripts, 1 utility
New file: MapPopup.svelte for geolocation popup content
2025-11-24 04:47:22 -08:00
..
analyze-image-colors.ts feat(colors): improve color analysis with better algorithms and scripts 2025-06-24 01:13:12 +01:00
backup-db.sh feat: add database backup and restore functionality 2025-06-19 01:58:37 +01:00
check-photo-colors.ts feat(colors): improve color analysis with better algorithms and scripts 2025-06-24 01:13:12 +01:00
cloudinary-cleanup.ts feat: add Cloudinary audit functionality 2025-06-16 16:56:05 +01:00
debug-photos.md Unify fullscreen editors 2025-06-13 14:17:26 -04:00
find-image-colors.ts feat(colors): improve color analysis with better algorithms and scripts 2025-06-24 01:13:12 +01:00
init-db.sh Merge branch 'universe/posts' of github.com:jedmund/jedmund-svelte into universe/posts 2025-06-02 15:34:40 -07:00
init-db.ts fix: Svelte 5 migration and linting improvements (61 errors fixed) 2025-11-24 04:47:22 -08:00
list-backups.sh feat: add database backup and restore functionality 2025-06-19 01:58:37 +01:00
migrate-alttext-to-description.sql Simplify photos architecture 2025-06-13 06:55:21 -04:00
migrate-photos-to-media.ts Unify fullscreen editors 2025-06-13 14:17:26 -04:00
railway-build.sh fix: continuing to migrate to pnpm 2025-11-23 03:25:20 -08:00
README.md feat(colors): improve color analysis with better algorithms and scripts 2025-06-24 01:13:12 +01:00
reanalyze-colors.ts fix: Svelte 5 migration and linting improvements (61 errors fixed) 2025-11-24 04:47:22 -08:00
restore-db.sh feat: add database backup and restore functionality 2025-06-19 01:58:37 +01:00
setup-local.sh Admin WIP 2025-05-27 16:57:51 -07:00
test-media-sharing.ts Unify fullscreen editors 2025-06-13 14:17:26 -04:00

Database Backup Scripts

This directory contains scripts for backing up and restoring the PostgreSQL database.

Prerequisites

  • PostgreSQL client tools (pg_dump, psql) must be installed
  • Environment variables must be set in .env or .env.local:
    • DATABASE_URL - Local database connection string
    • REMOTE_DATABASE_URL or DATABASE_URL_PRODUCTION - Remote database connection string

Available Commands

Backup Commands

# Backup local database
npm run db:backup:local

# Backup remote database
npm run db:backup:remote

# Sync remote database to local (backs up both, then restores remote to local)
npm run db:backup:sync

# List all backups
npm run db:backups

Restore Commands

# Restore a specific backup (interactive - will show available backups)
npm run db:restore

# Restore to local database (default)
npm run db:restore ./backups/backup_file.sql.gz

# Restore to remote database (requires extra confirmation)
npm run db:restore ./backups/backup_file.sql.gz remote

Direct Script Usage

You can also run the scripts directly:

# Backup operations
./scripts/backup-db.sh local
./scripts/backup-db.sh remote
./scripts/backup-db.sh sync

# Restore operations
./scripts/restore-db.sh <backup-file> [local|remote]

# List backups
./scripts/list-backups.sh [all|local|remote|recent]

Backup Storage

All backups are stored in the ./backups/ directory with timestamps:

  • Local backups: local_YYYYMMDD_HHMMSS.sql.gz
  • Remote backups: remote_YYYYMMDD_HHMMSS.sql.gz

Safety Features

  1. Automatic Backups: The sync operation creates backups of both databases before syncing
  2. Confirmation Prompts: Destructive operations require confirmation
  3. Extra Protection for Remote: Restoring to remote requires typing "RESTORE REMOTE"
  4. Compressed Storage: Backups are automatically compressed with gzip
  5. Timestamp Naming: All backups include timestamps to prevent overwrites

Common Use Cases

Daily Local Development

# Start your day by syncing the remote database to local
npm run db:backup:sync

Before Deploying Changes

# Backup remote database before deploying schema changes
npm run db:backup:remote

Restore from Accident

# List recent backups
npm run db:backups

# Restore a specific backup
npm run db:restore ./backups/local_20240615_143022.sql.gz

Environment Variables

You can set these in .env.local (git-ignored) for local overrides:

# Required for local operations
DATABASE_URL="postgresql://user:password@localhost:5432/dbname"

# Required for remote operations (one of these)
REMOTE_DATABASE_URL="postgresql://user:password@remote-host:5432/dbname"
DATABASE_URL_PRODUCTION="postgresql://user:password@remote-host:5432/dbname"

Troubleshooting

"pg_dump: command not found"

Install PostgreSQL client tools:

# macOS
brew install postgresql

# Ubuntu/Debian
sudo apt-get install postgresql-client

# Arch Linux
sudo pacman -S postgresql

"FATAL: password authentication failed"

Check that your database URLs are correct and include the password.

Backup seems stuck

Large databases may take time. The scripts show progress. For very large databases, consider using pg_dump directly with custom options.