# Post-Migration Validation

Run these checks after restoring the app.

## PHP Syntax

```bash
cd /workspace/notifier
find . -path './.git' -prune -o -name '*.php' -print -exec php -l {} \;
```

## Nginx And PHP

```bash
sudo nginx -t
sudo systemctl status nginx --no-pager
sudo systemctl status php8.3-fpm --no-pager
curl -I https://www.tonki.dev/notifier/
curl -I https://www.tonki.dev/notifier/api/categories
```

Expected:

- `/notifier/` redirects unauthenticated users to `/notifier/login/`
- API returns `401` without session or `X-API-Token`

## Scheduler Status

```bash
cd /workspace/notifier
php scheduler.php --status
```

Healthy signs:

- lock held: no
- scheduler_state table exists
- pending work is understandable
- no PHP fatal errors

## Dry Run

```bash
php scheduler.php --dry-run
```

This should not send messages and should show work that would be processed.

## Cron Verification

```bash
crontab -l
tail -n 50 /workspace/notifier/logs/scheduler.log
tail -n 50 /workspace/notifier/logs/cron-health.log
```

After cron runs, verify `scheduler_state.last_run_at` changes:

```bash
sqlite3 /workspace/notifier/database.sqlite "select * from scheduler_state;"
```

## Telegram Verification

Do not use the production scheduler for the first test. Use the app's test-message or notification test route from the authenticated UI/API after checking `telegram_test` config.

Before enabling cron, confirm:

- bot token is valid
- chat id is correct
- messages can be sent
- image sends work if uploads are referenced

## Database Integrity

```bash
sqlite3 /workspace/notifier/database.sqlite "PRAGMA integrity_check;"
sqlite3 /workspace/notifier/database.sqlite "select version, applied_at from schema_migrations order by version;"
sqlite3 /workspace/notifier/database.sqlite "select status, count(*) from send_jobs group by status;"
```

Expected migration count from old server: 6.

## Permissions

```bash
test -r /workspace/notifier/config.php
test -r /workspace/notifier/database.sqlite
test -w /workspace/notifier/database.sqlite
test -d /workspace/notifier/uploads
test -w /workspace/notifier/uploads
test -d /workspace/notifier/logs
test -w /workspace/notifier/logs
```

Run these as the same user that executes cron and PHP-FPM where applicable.
