# PocketBase Setup ## 1. Download & run PocketBase Download the binary for your OS from https://pocketbase.io/docs/ and run it: ```bash ./pocketbase serve # Admin UI: http://127.0.0.1:8090/_/ ``` Create your admin account on first launch via the Admin UI. --- ## 2. Create the `economy_users` collection In the Admin UI → **Collections** → **New collection** → name it exactly `economy_users`. Add the following fields: | Field name | Type | Required | Default | |-------------------|-----------|----------|---------| | `user_id` | Text | ✅ | - | | `balance` | Number | | `0` | | `exp` | Number | | `0` | | `daily_streak` | Number | | `0` | | `last_daily` | Text | | - | | `last_work` | Text | | - | | `last_beg` | Text | | - | | `last_crime` | Text | | - | | `last_rob` | Text | | - | | `last_streak_date`| Text | | - | | `jailed_until` | Text | | - | | `items` | JSON | | `[]` | | `item_uses` | JSON | | `{}` | | `reminders` | JSON | | `[]` | | `eco_banned` | Bool | | `false` | > **Tip:** Set `user_id` as a unique index under **Indexes** tab. Set **API rules** (all four: list, view, create, update) to admin-only (leave blank / locked). --- ## 3. Configure .env Add to your `.env`: ``` PB_URL=http://127.0.0.1:8090 PB_ADMIN_EMAIL=your-admin@email.com PB_ADMIN_PASSWORD=your-admin-password ``` --- ## 4. Migrate existing data (one-time) If you have existing data in `data/economy.json`, run the migration script **once** before starting the bot: ```bash python migrate_to_pb.py ``` --- ## 5. Production On a server, run PocketBase as a background service (systemd, Docker, etc.) and update `PB_URL` in `.env` to the server's address. PocketBase stores all data in `pb_data/` - back this directory up regularly.