# Deployment

## What the scripts do

- `scripts/migrate-wordpress.ps1`
  - Dumps the existing WordPress MySQL database to `migration-backups/<timestamp>/wordpress.sql`
  - Copies `wp-content/uploads` out of the legacy WordPress container into `static/wp-content/uploads`
  - Keeps an archive copy of the uploads in `migration-backups/<timestamp>/uploads`

- `scripts/deploy.ps1`
  - Optionally runs the migration step first
  - Optionally shuts down the legacy compose stack
  - Validates the new compose file
  - Builds and starts the new stack
  - Waits for `http://localhost/api/health` to return success

## Before cutover

1. Fill in `.env` from `.env.example`
2. Make sure the legacy WordPress stack is still running
3. Identify:
   - the legacy WordPress container name
   - the legacy MySQL container name
   - the legacy compose file path if you want the deploy script to shut it down for you
   - the WordPress MySQL database name, user, and password

## Example

```powershell
powershell -ExecutionPolicy Bypass -File .\scripts\deploy.ps1 `
  -RunMigration `
  -LegacyComposeFile C:\deploy\wordpress\docker-compose.yml `
  -LegacyProjectName goodwalk-wordpress `
  -LegacyWordPressContainer goodwalk-wordpress-1 `
  -LegacyDatabaseContainer goodwalk-db-1 `
  -MySqlDatabase wordpress `
  -MySqlUser wordpress `
  -MySqlPassword 'replace-me'
```

## Notes

- The new app now uses root-relative `/wp-content/uploads/...` paths, so the copied uploads are served by the SvelteKit stack after cutover.
- The deployment script does not destroy the legacy database dump. It writes a fresh backup on every migration run.
- If you want to keep the legacy stack running while testing, omit `-LegacyComposeFile` or add `-SkipLegacyShutdown`.
