# Basketloot schema reference

## Current application schema

The Laravel application schema is authoritative and is managed by the files in
`database/migrations`. User-facing monetary balances are stored as points/coins;
the presentation layer converts 1,000 coins to USD 1.00.

Core relationships:

- `users` owns balances, authentication, referrals, and profile state.
- `offerwalls` owns zero or more `provider_offers`.
- `leads` belongs to a user and represents an offer transaction/postback.
- `payments` describes cashout providers; `withdrawals` belongs to a user.
- `bonuses` is joined to users through `bonus_histories`.
- `support_tickets` owns `ticket_messages` and belongs to a user.
- `referral_events` links a referrer, optional referred user, and optional lead.
- `site_settings` is a key/value configuration store. Secret values must never
  be copied from an untrusted or production SQL dump into local configuration.

## Legacy server dump mapping

The MariaDB dump `database/trevvmne_tebkngl.sql` uses an older, incompatible
schema. It must be translated rather than executed against the current app.

| Legacy table | Current table | Important mapping |
| --- | --- | --- |
| `users` | `users` | `points` -> `current_points`; `privacy` -> `is_profile_private` |
| `users_geo_data` | `users` | IP, user agent, and last-login metadata |
| `users_referral_data` | `users` | referral code and referral earnings |
| `users_referrals` | `users`, `referral_events` | referrer relationship and signup event |
| `providers` | `offerwalls` | `url` -> `iframe_url`; display metadata retained |
| `offers` | `provider_offers` | provider name resolved to `offerwall_id` |
| `leads` | `leads` | provider/name/transaction/status translated directly |
| `cashout_methods` | `payments` | method name and image retained; currency is USD |
| `cashout_requests` | `withdrawals` | method, amount, address, and status retained |
| `bonuses` | `bonuses` | `reward_points` -> `points` |
| `bonus_usages` | `bonus_histories` | user and bonus relationship |
| `tickets` | `support_tickets`, `ticket_messages` | ticket body becomes the first message |
| `ticket_messages` | `ticket_messages` | ticket/user ownership remapped |
| `notifications` | `notifications` | unsupported legacy metadata omitted |
| `settings` | `site_settings` | only an explicit non-secret allowlist is imported |

Legacy tables without a current product equivalent remain in the source dump
and are reported by the importer; they are not forced into unrelated tables.
