RATED PRIVATE SERVER TEMPLATE

Files
- worker.js: Cloudflare Worker API and admin panel
- schema.sql: base D1 schema
- migrations/002_community_features.sql: adds contributor and moderation fields
- migrations/001_add_ip_hash.sql: optional for older databases that do not have reviews.ip_hash
- wrangler.toml: example Wrangler configuration

NEW DATABASE
1. Create a D1 database named rated-db, or change database_name in wrangler.toml.
2. Run schema.sql against the remote database.
3. Run migrations/002_community_features.sql once.
4. Replace the database_id in wrangler.toml with the D1 ID.
5. Set JWT_SECRET and ADMIN_TOKEN as Worker secrets.
6. Keep SERVER_MODE=private and set SERVER_NAME to the name users should see.
7. Deploy the Worker.

EXISTING DATABASE
Back up the database first. Run schema.sql, then run migration 001 only if reviews.ip_hash is missing. Run migration 002 only if its four columns have not already been added. Do not rerun migrations that have already succeeded.

The Worker must have a D1 binding named DB. The server URL can then be added in Rated under Add a custom server.
