# System Blueprint

## 1) Project Overview

### Platform purpose
This Laravel platform manages the full lifecycle of vehicle sourcing, reservation, purchase, payment, and delivery.

It combines:
- Auction intake (admin-managed auction inventory)
- Vehicle catalog and sales (public + seller inventory)
- Reservation-based selling (seller/admin to customer)
- Order and payment orchestration (including split wallet + external payments)
- Shipment tracking to completion

### Core modules
- Auction:
  - Auction cars are captured with sourcing and logistics costs.
  - Admin sets `selling_price` and marks readiness indirectly via status/linked vehicle.
- Vehicles:
  - Sellable inventory, optionally linked 1:1 to auction cars.
  - Includes stock and sale status (`stock_status`, `status`, `is_locked`).
- Reservations:
  - Time-bound hold records for a customer on a vehicle or auction target.
  - Supports wallet usage at reserve-time.
- Orders:
  - Commercial contract snapshot with price/deposit/shipping metadata.
  - Supports reservation-origin and direct-checkout origin.
- Payments:
  - Multi-record payment ledger with pending/completed/failed/refunded states.
  - Supports multiple partial payments per order.
- Wallet:
  - Ledger-based wallet with `credit` and `debit` transactions.
  - Used during reservation and checkout.
- Shipment:
  - Shipment records tied to order + vehicle.
  - Drives delivery progression and updates order shipping snapshot.

### High-level flow (Auction -> Customer Purchase)
1. Admin records `auction_cars` and cost details.
2. Vehicle may be created/linked from auction data.
3. Seller or admin creates `vehicle_reservations` for a customer.
4. Customer opens reservation checkout.
5. If vehicle exists: customer reaches purchase page; if not: reservation order can still be created and payment can start.
6. Payments accumulate over time until remaining balance is zero.
7. Shipment records advance order logistics status.
8. Order reaches delivered/completed milestones.

---

## 2) Database Schema (Full)

This section has two parts:
- A) Deep details for business-critical tables (requested core set)
- B) Full inventory appendix for all tables (auto-derived from live DB metadata)

### A) Core business tables (detailed)

#### `users`
| Column | Type | Required | Key | Notes |
|---|---|---|---|---|
| id | bigint unsigned | yes | PK | User id |
| name | varchar(255) | yes | - | |
| email | varchar(255) | yes | UNIQUE | |
| role | varchar(255) | no | - | admin/seller/customer |
| phone, address, country | mixed | no | - | profile/contact |
| created_at, updated_at | timestamp | no | - | standard |

Relationships:
- 1:N `users` -> `vehicles` (seller_id)
- 1:N `users` -> `orders` (user_id)
- 1:N `users` -> `vehicle_reservations` (user_id/seller_id/reserved_by)
- 1:N `users` -> `wallet_transactions`

Important indexes:
- `users_email_unique`

#### `vehicles`
| Column | Type | Required | Key | Notes |
|---|---|---|---|---|
| id | bigint unsigned | yes | PK | |
| seller_id | bigint unsigned | no | MUL | nullable seller support |
| auction_car_id | bigint unsigned | no | UNIQUE/MUL | 1:1-ish auction link |
| make_id, model_id, vehicle_type_id | bigint unsigned | no | MUL | normalized catalog refs |
| make, model, chassis, year, mileage | mixed | mixed | - | identity/spec fields |
| price | decimal | yes | - | base/fallback pricing |
| stock_status | enum | yes | MUL | available/sold/reserved |
| status | enum | yes | MUL | draft/published/reserved/sold |
| is_locked | tinyint/bool | yes | - | reservation lock |
| created_at, updated_at | timestamp | no | - | |

FKs:
- `seller_id` -> `users.id`
- `auction_car_id` -> `auction_cars.id`
- `make_id` -> `makes.id`
- `model_id` -> `models.id`

Important indexes:
- primary key, `vehicles_auction_car_id_unique`, status/stock and FK indexes

#### `auction_cars`
| Column | Type | Required | Key | Notes |
|---|---|---|---|---|
| id | bigint unsigned | yes | PK | |
| make_id, model_id, vehicle_type_id | bigint unsigned | no | MUL | normalized refs |
| chassis_no | varchar(255) | no | UNIQUE/MUL | unique after normalization |
| cost fields | decimal | mostly no | - | auction_fee/inspection/freight/etc |
| total | decimal | no | - | derived aggregate |
| selling_price | decimal | no | - | customer-facing sale value |
| status | enum | yes | MUL | pending/completed |
| region_id, auction_house_id | bigint unsigned | no | MUL | location context |

FKs:
- make/model/vehicle_type/region/auction_house references

Important indexes:
- primary key, status, chassis_no unique, make+model lookups

#### `vehicle_reservations`
| Column | Type | Required | Key | Notes |
|---|---|---|---|---|
| id | bigint unsigned | yes | PK | |
| vehicle_id | bigint unsigned | no | MUL | nullable (reservation may start before vehicle) |
| auction_id | bigint unsigned | no | MUL | legacy alias |
| auction_car_id | bigint unsigned | no | MUL | unified auction target |
| user_id | bigint unsigned | yes | MUL | customer |
| seller_id | bigint unsigned | no | MUL | nullable for company/admin flow |
| reserved_by | bigint unsigned | no | MUL | actor creating reservation |
| wallet_amount_used | decimal | no | - | wallet debit at reserve time |
| reserved_at | timestamp | yes | - | start time |
| expires_at | timestamp | no | MUL | expiry cutoff |
| status | varchar | yes | MUL | active/expired/converted |
| order_id | bigint unsigned | no | MUL | linked order |

FKs:
- `vehicle_id` -> `vehicles.id`
- `auction_id` / `auction_car_id` -> `auction_cars.id`
- `user_id`, `seller_id`, `reserved_by` -> `users.id`
- `order_id` -> `orders.id`

Important indexes:
- vehicle+status
- user+status
- expires_at
- vehicle+status+expires composite

#### `orders`
| Column | Type | Required | Key | Notes |
|---|---|---|---|---|
| id | bigint unsigned | yes | PK | |
| user_id | bigint unsigned | yes | MUL | customer |
| vehicle_id | bigint unsigned | no | MUL | nullable by design |
| reservation_id | bigint unsigned | no | MUL | reservation-origin link |
| seller_id | bigint unsigned | no | MUL | nullable seller/company |
| source | varchar(32) | no | MUL | checkout/reservation |
| status | varchar(32) | yes | MUL | purchase status |
| customer_status | enum | yes | MUL | reservation/payment/shipment stages |
| total_price, vehicle_price | decimal | no | - | locked financials |
| paid_amount, remaining_balance | decimal | no | - | synced from completed payments |
| deposit fields | decimal | no | - | min_deposit_amount + percentages |
| CIF fields | decimal | no | - | freight/inspection/insurance/cif_total |
| shipping fields | mixed | no | MUL | shipping country/port/type/addresses |
| timeline fields | dates/timestamps | no | - | buy/departure/arrival/dhl/etc |

Current `customer_status` enum values:
- reserved
- payment_pending
- partially_paid
- paid
- shipment_pending
- shipped
- arrived
- delivered
- completed

FKs:
- `user_id` -> `users.id`
- `vehicle_id` -> `vehicles.id` (nullable)
- `reservation_id` -> `vehicle_reservations.id`
- `seller_id` -> `users.id`
- `shipping_country_id` -> `shipping_countries.id`
- `shipping_port_id` -> `ports.id`

Important indexes:
- user_id, vehicle_id, reservation_id, seller_id, status, customer_status

#### `payments`
| Column | Type | Required | Key | Notes |
|---|---|---|---|---|
| id | bigint unsigned | yes | PK | |
| order_id | bigint unsigned | yes | MUL | target order |
| method / payment_method | varchar | mixed | MUL | wallet/card/bank_transfer |
| amount | decimal | yes | - | per-payment amount |
| status | varchar(32) | yes | MUL | pending/completed/failed/refunded |
| bank_account_id | bigint unsigned | no | MUL | for transfer |
| payment_proof, bank_reference | varchar | no | - | transfer evidence |
| payment_data | json | no | - | audit payload |
| created_by, approved_by | bigint unsigned | no | MUL | actor refs |
| paid_at | timestamp | no | - | completion time |

FKs:
- `order_id` -> `orders.id`
- `bank_account_id` -> `bank_accounts.id`
- created/approved user refs

Important indexes:
- order_id, status, method, created_by

#### `payment_allocations`
| Column | Type | Required | Key | Notes |
|---|---|---|---|---|
| id | bigint unsigned | yes | PK | |
| payment_id | bigint unsigned | yes | MUL | payment parent |
| order_id | bigint unsigned | yes | MUL | order parent |
| vehicle_id | bigint unsigned | no | MUL | optional vehicle-scoped allocation |
| amount | decimal | yes | - | allocated amount |

FKs:
- `payment_id` -> `payments.id`
- `order_id` -> `orders.id`
- `vehicle_id` -> `vehicles.id` (nullable)

Important indexes:
- payment/order indexes and vehicle-related composites

#### `wallet_transactions`
| Column | Type | Required | Key | Notes |
|---|---|---|---|---|
| id | bigint unsigned | yes | PK | |
| user_id | bigint unsigned | yes | MUL | wallet owner |
| type | enum/varchar | yes | MUL | credit/debit |
| amount | decimal | yes | - | transaction amount |
| source | varchar | yes | MUL | reservation/checkout/manual/etc |
| reference_type | varchar | no | - | related object type |
| reference_id | bigint unsigned | no | MUL | related object id |
| created_by | bigint unsigned | no | MUL | actor |
| created_at, updated_at | timestamp | no | - | |

FKs:
- `user_id` -> `users.id`
- `created_by` -> `users.id` (if enforced)

Important indexes:
- user_id + type + source/reference lookups

#### `shipments`
| Column | Type | Required | Key | Notes |
|---|---|---|---|---|
| id | bigint unsigned | yes | PK | |
| order_id | bigint unsigned | yes | MUL | order parent |
| vehicle_id | bigint unsigned | yes | MUL | shipment vehicle |
| status | varchar(32) | yes | MUL | shipment_pending/shipped/in_transit/arrived/delivered |
| tracking_number | varchar | no | - | carrier ref |
| origin_port, destination_port | varchar | no | - | route info |
| shipping_approved_date | date | no | - | shipment readiness |
| departure_date | date | no | - | sail date |
| arrival_date | date | no | - | destination arrival |
| local_dispatch_date | date | no | - | local handoff |
| buy_date, ship_ok_date | date | no | - | legacy-compat fields |

FKs:
- `order_id` -> `orders.id`
- `vehicle_id` -> `vehicles.id`

Important indexes:
- order_id, vehicle_id, status

### B) Full schema inventory
The complete table-by-table schema (all tables in current DB) is appended at the end of this document under **Appendix A**.

---

## 3) Role-Based System Behavior

### ADMIN behavior
Admin can:
- Manage auction intake (`admin/auction-cars*`), pricing setup, and configuration tables.
- Manage vehicles and documents.
- Create reservations for customers (with optional `vehicle_id` or `auction_car_id`).
- View/manage all orders and mark payments paid.
- Create/update shipment records and advance logistics timeline.

Reservation capabilities:
- Admin reservation endpoint accepts customer + vehicle/auction target.
- Can reserve without seller assignment (company-direct path).

Vehicle creation:
- Admin can create vehicles directly or from auction pipeline.
- Vehicle linkage to `auction_cars` influences sale readiness and downstream status.

Shipment responsibilities:
- Create/update shipment per order vehicle.
- Shipment dates/status write back to order shipping snapshot fields.

### SELLER behavior
Seller can:
- Manage own vehicles and associated documents.
- See auction pool and reserve auction/vehicle for a customer.
- Search/create customer records and manage seller-customer list.
- View own orders; mark paid in seller flow.

My Vehicles:
- Seller CRUD on vehicles and docs under `seller/vehicles*`.

Auction Pool:
- Seller can select auction units and create reservations.

Reservation flow:
- `seller/reservations` store accepts either `vehicle_id` or `auction_car_id`.
- Reservation writes `reserved_by` as seller user id.

Customer handling:
- Seller has customer search and creation endpoints.

### CUSTOMER behavior
Customer can:
- See dashboard with order tabs and reserved units.
- Enter checkout via public vehicle flow or reservation flow.
- Pay by wallet, external, or mixed split.
- View order details and payment history.
- Manage consignee/remitter profiles.

Dashboard tabs:
- Vehicle list tabs are computed in front-end using mapped order rows.
- Reserved units tab consumes reservation dataset from backend.

Reservation view:
- Active reservations include checkout URL.
- If seller missing, seller display becomes `Direct Purchase`.

Checkout:
- Vehicle checkout page for direct purchase.
- Reservation checkout supports missing vehicle by creating payment-pending order and redirecting to payment.

Payments:
- Multiple partial payments supported.
- First payment min-deposit rule enforced.

Wallet usage:
- Wallet can be applied at reservation and checkout/payment stages.

---

## 4) Reservation Flow (Critical)

### Reservation statuses
- `active`: reservation currently valid and unexpired.
- `expired`: no longer valid.
- `converted`: converted to order lifecycle after first completed payment.

### Admin reservation flow
1. Admin chooses target (`vehicle_id` or `auction_car_id`) + customer.
2. Reservation is created with `reserved_by=admin`.
3. Optional wallet debit captured as `wallet_amount_used` and wallet transaction.
4. Customer opens reservation checkout URL.
5. If order already exists: redirected to payment page.
6. If vehicle exists: customer can open purchase page.
7. If vehicle missing: system creates `orders` row (`payment_pending`) from reservation and redirects to payment.
8. On first completed payment, reservation becomes `converted`.

### Seller reservation flow
1. Seller reserves auction/vehicle for a customer.
2. Reservation gets seller ownership + customer linkage.
3. Customer opens reservation checkout route.
4. Same conversion behavior as admin flow.

### Relation to order
- Reservation may exist before order.
- On checkout start, reservation gets `order_id`.
- As vehicle becomes available later, order `vehicle_id` may be backfilled from reservation target.
- First successful completed payment triggers reservation conversion.

---

## 5) Order Flow

### Order creation paths
- Direct vehicle checkout:
  - Creates order with full pricing snapshot and linked vehicle.
- Reservation checkout with vehicle present:
  - Proceeds through purchase page and creates standard order.
- Reservation checkout without vehicle:
  - Creates or reuses order directly from reservation with nullable `vehicle_id`.

### Required order fields in practice
Hard-required in flow:
- `user_id`
- `status`
- `total_price` / pricing baseline

Commonly populated:
- `vehicle_id` (nullable)
- `reservation_id` (for reservation source)
- `seller_id` (nullable for company/admin reservation)
- `source` (`checkout` or `reservation`)
- `currency`, `type`, snapshot financial/shipping fields

### Relations
- Order -> reservation via `reservation_id`
- Order -> vehicle via nullable `vehicle_id`
- Order -> seller via nullable `seller_id`

### Status fields
- `status` (system progression)
- `customer_status` (customer-facing progression enum)

Current customer-facing lifecycle:
- reserved -> payment_pending -> partially_paid -> paid -> shipment_pending -> shipped -> arrived -> delivered -> completed

### Status transition triggers
- PaymentService `syncOrderPaymentTotals`:
  - `remaining_balance <= 0` => `status=paid`
  - `paid_amount > 0` and not fully paid => `status=payment_pending`
  - no paid amount => `status=reserved`
- Shipment updates:
  - shipment dates/status update order timeline and can advance shipping status.

---

## 6) Payment Flow

### Payment record behavior
- Every payment operation creates a new `payments` row.
- No overwrite of existing payment row for normal submissions.
- Completed payments only are counted in order paid totals.

### Partial payments
Current `completeRemainingBalance` behavior:
- Input split: `wallet_amount` + `external_amount`.
- `amount = wallet + external`.
- Reject if amount <= 0.
- Reject if amount > `remaining_balance`.

### First payment rule
- On first payment only (no prior pending/completed payments), enforce minimum deposit:
  - Uses max of stored `min_deposit_amount` and computed percentage-based minimum.
- If first payment amount is below minimum => validation rejection.

### After first payment
- Any number of additional partial payments are accepted (subject to remaining balance and wallet checks).

### Remaining balance calculation
- `paid_amount` = sum of completed payment amounts.
- `remaining_balance` = order financial total - `paid_amount` (floored at zero).
- Sync occurs when payment status changes to completed/refunded/failed via service logic.

### Payment allocations
- `payment_allocations` created per payment.
- Supports optional `vehicle_id` for vehicle-scoped allocations.
- Used to track how each payment amount is distributed.

---

## 7) Wallet System

### Balance model
Wallet is ledger-based:
- Credits: sum(`wallet_transactions.amount` where type=credit)
- Debits: sum(`wallet_transactions.amount` where type=debit)
- Balance = credits - debits

### Table usage
`wallet_transactions` stores:
- user, type, amount, source, reference_type/reference_id, created_by

### Credit vs debit
- credit() creates positive ledger credit entry.
- debit() checks available balance first, then writes debit entry.

### Where wallet is used
- Reservation creation (`wallet_amount_used` + debit transaction when > 0)
- Checkout/payment flows (`wallet_amount` mixed with external amount)

### Overdraft protection
- WalletService rejects debit when `balance < amount`.
- Validation errors surface as `Insufficient wallet balance`.

---

## 8) Shipment Flow

### Lifecycle
Operational sequence:
- reserved -> paid -> shipment_pending -> shipped -> arrived -> delivered -> completed

Shipment status derivation:
- local_dispatch_date => delivered
- arrival_date => arrived
- in_transit explicit => in_transit
- departure_date or shipped flag => shipped
- otherwise => shipment_pending

### Where data is stored
- `shipments`: operational shipment events and dates.
- `orders`: shipping snapshot fields (`from_port`, `arrival_port`, `departure_date`, `arrival_date`, `dhl_date`, `tracking_number`).
- `vehicles`/`auction_cars`: source context and route metadata used for fallback display.

### Admin responsibilities
- Create/update shipment rows for order vehicles.
- Ensure selected vehicle belongs to order items.
- Keep order timeline/snapshot aligned from shipment events.

---

## 9) Customer Dashboard Logic

Source of data:
- Backend `Customer\DashboardController` maps orders to row objects.
- Frontend `Customer/Dashboard.vue` computes tab subsets.

### Tab conditions
- Reserved Units:
  - Uses `reservedVehicles` array from backend.
  - Backend condition: `vehicle_reservations.user_id = current user`, `status=active`, `expires_at > now`.
- All Cars:
  - All mapped order rows.
- Fully Completed:
  - `resolvedStatus(vehicleRow) === 'completed'`.
- Shipped Units with Balance:
  - `resolvedStatus(vehicleRow) === 'shipped' && balanceValue(vehicleRow) > 0`.
- Waiting for Departure:
  - `resolvedStatus(vehicleRow) === 'confirmed' && !vehicle.departure_date`.
- Further Deposit Required:
  - `paidValue(vehicleRow) < minimumDepositAmount(vehicleRow)`.

Notes:
- `minimumDepositAmount = total * (min_deposit_percent / 100)`.
- `resolvedStatus` uses `status || customer_status` lowercased.

---

## 10) Edge Cases

### Reservation without vehicle
Handled:
- Reservation checkout can proceed even if vehicle is unresolved.
- System creates order with nullable `vehicle_id` and redirects to payment.

### Vehicle created after order
Handled:
- Reservation vehicle resolution checks `reservation.vehicle_id` then `vehicles.auction_car_id`.
- If order exists and `orders.vehicle_id` is null, it backfills vehicle id.

### Partial payments
Handled:
- Multiple partial payments supported.
- Overpayment blocked against remaining balance.
- First payment minimum deposit enforced only once.

### Missing shipment data
Handled by fallback:
- Order resolved status derives from available shipment/order dates.
- Missing fields produce lower stage (`shipment_pending`/`reserved`) and placeholder UI values.

### Wallet + external mix
Handled:
- Wallet and external amounts can be mixed per payment call.
- Wallet insufficient -> validation fail.
- Completed wallet payment immediately affects paid totals; external pending waits for completion.

---

## 11) Current Issues / Inconsistencies

1. Status vocabulary mismatch in dashboard tab logic:
- `Waiting for Departure` uses `status === 'confirmed'`, but status flows are `reserved/payment_pending/paid/shipment_pending/...`.
- This can leave the tab underpopulated or empty.

2. Dual status fields (`status` vs `customer_status`) can diverge:
- Some logic reads one, some reads fallback from both.
- Potential for inconsistent UI/business interpretation.

3. Reservation table has both `auction_id` and `auction_car_id`:
- Legacy alias and new unified target coexist.
- High risk of drift when one field is populated and the other is not.

4. Reservation seller ownership inconsistency:
- Some seller release logic assumes `reservation.seller_id == auth seller`.
- Admin/company reservations intentionally allow null seller.
- Mixed assumptions can cause authorization or validation friction.

5. Shipment/order status coupling complexity:
- Shipment updates order `status`, while payment sync also updates status.
- Concurrent updates can create non-linear transitions if not carefully sequenced.

6. Reservation checkout debug hook exists:
- `debug_checkout` path calls `dd(...)` in controller.
- Safe only when explicitly toggled, but should be removed in production-hardening pass.

7. Financial duplication across entities:
- Values distributed across auction, vehicle, order (`selling_price`, `price`, `vehicle_price`, `total_price`, `cif_total`).
- Risks stale snapshots or conflicting totals without strict source-of-truth policy.

8. Historical enum migration changed semantics:
- `departed` mapped to `shipped` during enum update.
- Operationally valid but may blur legacy analytics if not documented in BI/reporting.

---

## 12) Data Flow Diagram (Text)

AuctionCar
  -> (optional) Vehicle
  -> Reservation (vehicle_id or auction_car_id)
  -> Checkout (customer)
    -> if vehicle exists: purchase page
    -> if vehicle missing: create payment_pending order
  -> Order (reservation_id, vehicle_id nullable)
  -> Payment(s) [wallet + external, multiple partials]
  -> Payment allocations
  -> Shipment updates
  -> Order status progression
  -> Completed

Extended payment state progression:
- First payment enforces minimum deposit.
- Subsequent payments can be any positive amount within remaining balance.
- On first completed payment from reservation order: reservation moves active -> converted.

---

## Appendix A - Full Table Inventory (Auto-Derived)

The following appendix is generated from live DB metadata (`SHOW TABLES`, `SHOW COLUMNS`, `SHOW INDEX`, and information_schema FK data) at documentation time.



## Full Table Inventory (Auto-Derived)

### `attribute_values`

| Column | Type | Required | Key | Default |
|---|---|---|---|---|
| `id` | bigint(20) unsigned | YES | PRI | NULL |
| `attribute_id` | bigint(20) unsigned | YES | MUL | NULL |
| `value` | varchar(255) | YES | - | NULL |
| `created_at` | timestamp | NO | - | NULL |
| `updated_at` | timestamp | NO | - | NULL |

Foreign keys:
- `attribute_id` -> `attributes.id` (on update RESTRICT, on delete CASCADE)

Indexes:
- `PRIMARY` (UNIQUE/PK) on [id]
- `attribute_values_attribute_id_value_unique` (UNIQUE/PK) on [attribute_id, value]
- `attribute_values_attribute_id_value_index` (NON-UNIQUE) on [attribute_id, value]

### `attributes`

| Column | Type | Required | Key | Default |
|---|---|---|---|---|
| `id` | bigint(20) unsigned | YES | PRI | NULL |
| `name` | varchar(255) | YES | UNI | NULL |
| `type` | enum('select','multi_select','range','boolean') | YES | MUL | NULL |
| `created_at` | timestamp | NO | - | NULL |
| `updated_at` | timestamp | NO | - | NULL |

Foreign keys:
- None

Indexes:
- `PRIMARY` (UNIQUE/PK) on [id]
- `attributes_name_unique` (UNIQUE/PK) on [name]
- `attributes_type_index` (NON-UNIQUE) on [type]

### `auction_cars`

| Column | Type | Required | Key | Default |
|---|---|---|---|---|
| `id` | bigint(20) unsigned | YES | PRI | NULL |
| `make_id` | bigint(20) unsigned | NO | MUL | NULL |
| `model_id` | bigint(20) unsigned | NO | MUL | NULL |
| `vehicle_type_id` | bigint(20) unsigned | NO | MUL | NULL |
| `chassis_no` | varchar(255) | NO | UNI | NULL |
| `purchase_date` | date | NO | - | NULL |
| `auction_price` | decimal(12,2) | YES | - | NULL |
| `auction_fee` | decimal(12,2) | NO | - | NULL |
| `inspection` | decimal(12,2) | NO | - | NULL |
| `transportation` | decimal(12,2) | NO | - | NULL |
| `h_charge` | decimal(12,2) | NO | - | NULL |
| `van` | decimal(12,2) | NO | - | NULL |
| `insurance` | decimal(12,2) | NO | - | NULL |
| `freight` | decimal(12,2) | NO | - | NULL |
| `extra` | decimal(12,2) | NO | - | NULL |
| `shipper` | decimal(12,2) | NO | - | NULL |
| `storage` | decimal(12,2) | NO | - | NULL |
| `total` | decimal(12,2) | NO | - | NULL |
| `selling_price` | decimal(12,2) | NO | - | NULL |
| `vessel` | varchar(255) | NO | - | NULL |
| `bl_files` | longtext | NO | - | NULL |
| `sailing_date` | date | NO | - | NULL |
| `region` | varchar(255) | NO | - | NULL |
| `region_id` | bigint(20) unsigned | NO | MUL | NULL |
| `city` | varchar(255) | NO | - | NULL |
| `auction_house` | varchar(255) | NO | - | NULL |
| `auction_house_id` | bigint(20) unsigned | NO | MUL | NULL |
| `admin_notes` | text | NO | - | NULL |
| `status` | enum('pending','completed') | YES | MUL | pending |
| `created_at` | timestamp | NO | - | NULL |
| `updated_at` | timestamp | NO | - | NULL |

Foreign keys:
- `auction_house_id` -> `auction_houses.id` (on update RESTRICT, on delete SET NULL)
- `make_id` -> `makes.id` (on update RESTRICT, on delete SET NULL)
- `model_id` -> `models.id` (on update RESTRICT, on delete SET NULL)
- `region_id` -> `regions.id` (on update RESTRICT, on delete SET NULL)
- `vehicle_type_id` -> `attribute_values.id` (on update RESTRICT, on delete SET NULL)

Indexes:
- `PRIMARY` (UNIQUE/PK) on [id]
- `auction_cars_chassis_no_unique` (UNIQUE/PK) on [chassis_no]
- `auction_cars_model_id_foreign` (NON-UNIQUE) on [model_id]
- `auction_cars_status_index` (NON-UNIQUE) on [status]
- `auction_cars_chassis_no_index` (NON-UNIQUE) on [chassis_no]
- `auction_cars_make_id_model_id_index` (NON-UNIQUE) on [make_id, model_id]
- `auction_cars_region_id_foreign` (NON-UNIQUE) on [region_id]
- `auction_cars_auction_house_id_foreign` (NON-UNIQUE) on [auction_house_id]
- `auction_cars_vehicle_type_id_index` (NON-UNIQUE) on [vehicle_type_id]

### `auction_houses`

| Column | Type | Required | Key | Default |
|---|---|---|---|---|
| `id` | bigint(20) unsigned | YES | PRI | NULL |
| `name` | varchar(255) | YES | - | NULL |
| `region_id` | bigint(20) unsigned | NO | MUL | NULL |
| `created_at` | timestamp | NO | - | NULL |
| `updated_at` | timestamp | NO | - | NULL |

Foreign keys:
- `region_id` -> `regions.id` (on update RESTRICT, on delete SET NULL)

Indexes:
- `PRIMARY` (UNIQUE/PK) on [id]
- `auction_houses_region_id_foreign` (NON-UNIQUE) on [region_id]

### `bank_accounts`

| Column | Type | Required | Key | Default |
|---|---|---|---|---|
| `id` | bigint(20) unsigned | YES | PRI | NULL |
| `bank_name` | varchar(255) | YES | - | NULL |
| `account_title` | varchar(255) | YES | - | NULL |
| `account_number` | varchar(255) | YES | - | NULL |
| `iban` | varchar(255) | NO | - | NULL |
| `swift_code` | varchar(255) | NO | - | NULL |
| `branch` | varchar(255) | NO | - | NULL |
| `is_active` | tinyint(1) | YES | - | 1 |
| `created_at` | timestamp | NO | - | NULL |
| `updated_at` | timestamp | NO | - | NULL |

Foreign keys:
- None

Indexes:
- `PRIMARY` (UNIQUE/PK) on [id]

### `cache`

| Column | Type | Required | Key | Default |
|---|---|---|---|---|
| `key` | varchar(255) | YES | PRI | NULL |
| `value` | mediumtext | YES | - | NULL |
| `expiration` | int(11) | YES | MUL | NULL |

Foreign keys:
- None

Indexes:
- `PRIMARY` (UNIQUE/PK) on [key]
- `cache_expiration_index` (NON-UNIQUE) on [expiration]

### `cache_locks`

| Column | Type | Required | Key | Default |
|---|---|---|---|---|
| `key` | varchar(255) | YES | PRI | NULL |
| `owner` | varchar(255) | YES | - | NULL |
| `expiration` | int(11) | YES | MUL | NULL |

Foreign keys:
- None

Indexes:
- `PRIMARY` (UNIQUE/PK) on [key]
- `cache_locks_expiration_index` (NON-UNIQUE) on [expiration]

### `carts`

| Column | Type | Required | Key | Default |
|---|---|---|---|---|
| `id` | bigint(20) unsigned | YES | PRI | NULL |
| `user_id` | bigint(20) unsigned | YES | MUL | NULL |
| `vehicle_id` | bigint(20) unsigned | YES | MUL | NULL |
| `quantity` | int(11) | YES | - | 1 |
| `created_at` | timestamp | NO | - | NULL |
| `updated_at` | timestamp | NO | - | NULL |

Foreign keys:
- `user_id` -> `users.id` (on update RESTRICT, on delete CASCADE)
- `vehicle_id` -> `vehicles.id` (on update RESTRICT, on delete CASCADE)

Indexes:
- `PRIMARY` (UNIQUE/PK) on [id]
- `carts_user_id_vehicle_id_unique` (UNIQUE/PK) on [user_id, vehicle_id]
- `carts_vehicle_id_foreign` (NON-UNIQUE) on [vehicle_id]

### `consignees`

| Column | Type | Required | Key | Default |
|---|---|---|---|---|
| `id` | bigint(20) unsigned | YES | PRI | NULL |
| `user_id` | bigint(20) unsigned | YES | MUL | NULL |
| `name` | varchar(255) | YES | - | NULL |
| `email` | varchar(255) | NO | - | NULL |
| `phone` | varchar(255) | YES | - | NULL |
| `address` | text | YES | - | NULL |
| `city` | varchar(255) | YES | - | NULL |
| `country` | varchar(255) | YES | - | NULL |
| `postal_code` | varchar(255) | NO | - | NULL |
| `is_default` | tinyint(1) | YES | - | 0 |
| `created_at` | timestamp | NO | - | NULL |
| `updated_at` | timestamp | NO | - | NULL |

Foreign keys:
- `user_id` -> `users.id` (on update RESTRICT, on delete CASCADE)

Indexes:
- `PRIMARY` (UNIQUE/PK) on [id]
- `consignees_user_id_index` (NON-UNIQUE) on [user_id]

### `currencies`

| Column | Type | Required | Key | Default |
|---|---|---|---|---|
| `id` | bigint(20) unsigned | YES | PRI | NULL |
| `name` | varchar(255) | YES | - | NULL |
| `code` | char(3) | YES | UNI | NULL |
| `symbol` | varchar(255) | NO | - | NULL |
| `created_at` | timestamp | NO | - | NULL |
| `updated_at` | timestamp | NO | - | NULL |

Foreign keys:
- None

Indexes:
- `PRIMARY` (UNIQUE/PK) on [id]
- `currencies_code_unique` (UNIQUE/PK) on [code]

### `deposit_settings`

| Column | Type | Required | Key | Default |
|---|---|---|---|---|
| `id` | bigint(20) unsigned | YES | PRI | NULL |
| `type` | varchar(20) | YES | - | NULL |
| `value` | decimal(12,2) | YES | - | NULL |
| `is_active` | tinyint(1) | YES | MUL | 1 |
| `created_at` | timestamp | NO | - | NULL |
| `updated_at` | timestamp | NO | - | NULL |

Foreign keys:
- None

Indexes:
- `PRIMARY` (UNIQUE/PK) on [id]
- `deposit_settings_is_active_index` (NON-UNIQUE) on [is_active]

### `failed_jobs`

| Column | Type | Required | Key | Default |
|---|---|---|---|---|
| `id` | bigint(20) unsigned | YES | PRI | NULL |
| `uuid` | varchar(255) | YES | UNI | NULL |
| `connection` | text | YES | - | NULL |
| `queue` | text | YES | - | NULL |
| `payload` | longtext | YES | - | NULL |
| `exception` | longtext | YES | - | NULL |
| `failed_at` | timestamp | YES | - | current_timestamp() |

Foreign keys:
- None

Indexes:
- `PRIMARY` (UNIQUE/PK) on [id]
- `failed_jobs_uuid_unique` (UNIQUE/PK) on [uuid]

### `job_batches`

| Column | Type | Required | Key | Default |
|---|---|---|---|---|
| `id` | varchar(255) | YES | PRI | NULL |
| `name` | varchar(255) | YES | - | NULL |
| `total_jobs` | int(11) | YES | - | NULL |
| `pending_jobs` | int(11) | YES | - | NULL |
| `failed_jobs` | int(11) | YES | - | NULL |
| `failed_job_ids` | longtext | YES | - | NULL |
| `options` | mediumtext | NO | - | NULL |
| `cancelled_at` | int(11) | NO | - | NULL |
| `created_at` | int(11) | YES | - | NULL |
| `finished_at` | int(11) | NO | - | NULL |

Foreign keys:
- None

Indexes:
- `PRIMARY` (UNIQUE/PK) on [id]

### `jobs`

| Column | Type | Required | Key | Default |
|---|---|---|---|---|
| `id` | bigint(20) unsigned | YES | PRI | NULL |
| `queue` | varchar(255) | YES | MUL | NULL |
| `payload` | longtext | YES | - | NULL |
| `attempts` | tinyint(3) unsigned | YES | - | NULL |
| `reserved_at` | int(10) unsigned | NO | - | NULL |
| `available_at` | int(10) unsigned | YES | - | NULL |
| `created_at` | int(10) unsigned | YES | - | NULL |

Foreign keys:
- None

Indexes:
- `PRIMARY` (UNIQUE/PK) on [id]
- `jobs_queue_index` (NON-UNIQUE) on [queue]

### `make_attributes`

| Column | Type | Required | Key | Default |
|---|---|---|---|---|
| `id` | bigint(20) unsigned | YES | PRI | NULL |
| `make_id` | bigint(20) unsigned | YES | MUL | NULL |
| `attribute_id` | bigint(20) unsigned | YES | MUL | NULL |
| `min_value` | int(10) unsigned | NO | - | NULL |
| `max_value` | int(10) unsigned | NO | - | NULL |
| `default_value_id` | bigint(20) unsigned | NO | MUL | NULL |
| `default_raw_value` | varchar(255) | NO | - | NULL |
| `created_at` | timestamp | NO | - | NULL |
| `updated_at` | timestamp | NO | - | NULL |

Foreign keys:
- `attribute_id` -> `attributes.id` (on update RESTRICT, on delete CASCADE)
- `default_value_id` -> `attribute_values.id` (on update RESTRICT, on delete SET NULL)
- `make_id` -> `makes.id` (on update RESTRICT, on delete CASCADE)

Indexes:
- `PRIMARY` (UNIQUE/PK) on [id]
- `make_attributes_make_id_attribute_id_unique` (UNIQUE/PK) on [make_id, attribute_id]
- `make_attributes_attribute_id_foreign` (NON-UNIQUE) on [attribute_id]
- `make_attributes_default_value_id_foreign` (NON-UNIQUE) on [default_value_id]

### `makes`

| Column | Type | Required | Key | Default |
|---|---|---|---|---|
| `id` | bigint(20) unsigned | YES | PRI | NULL |
| `name` | varchar(255) | YES | UNI | NULL |
| `created_at` | timestamp | NO | - | NULL |
| `updated_at` | timestamp | NO | - | NULL |

Foreign keys:
- None

Indexes:
- `PRIMARY` (UNIQUE/PK) on [id]
- `makes_name_unique` (UNIQUE/PK) on [name]

### `migrations`

| Column | Type | Required | Key | Default |
|---|---|---|---|---|
| `id` | int(10) unsigned | YES | PRI | NULL |
| `migration` | varchar(255) | YES | - | NULL |
| `batch` | int(11) | YES | - | NULL |

Foreign keys:
- None

Indexes:
- `PRIMARY` (UNIQUE/PK) on [id]

### `model_attribute_defaults`

| Column | Type | Required | Key | Default |
|---|---|---|---|---|
| `id` | bigint(20) unsigned | YES | PRI | NULL |
| `model_id` | bigint(20) unsigned | YES | MUL | NULL |
| `attribute_id` | bigint(20) unsigned | YES | MUL | NULL |
| `value_id` | bigint(20) unsigned | NO | MUL | NULL |
| `raw_value` | varchar(255) | NO | - | NULL |
| `created_at` | timestamp | NO | - | NULL |
| `updated_at` | timestamp | NO | - | NULL |

Foreign keys:
- `attribute_id` -> `attributes.id` (on update RESTRICT, on delete CASCADE)
- `model_id` -> `models.id` (on update RESTRICT, on delete CASCADE)
- `value_id` -> `attribute_values.id` (on update RESTRICT, on delete SET NULL)

Indexes:
- `PRIMARY` (UNIQUE/PK) on [id]
- `model_attribute_defaults_model_id_attribute_id_unique` (UNIQUE/PK) on [model_id, attribute_id]
- `model_attribute_defaults_attribute_id_foreign` (NON-UNIQUE) on [attribute_id]
- `model_attribute_defaults_value_id_foreign` (NON-UNIQUE) on [value_id]

### `model_attributes`

| Column | Type | Required | Key | Default |
|---|---|---|---|---|
| `id` | bigint(20) unsigned | YES | PRI | NULL |
| `model_id` | bigint(20) unsigned | YES | MUL | NULL |
| `attribute_id` | bigint(20) unsigned | YES | MUL | NULL |
| `min_numeric_value` | int(10) unsigned | NO | - | NULL |
| `max_numeric_value` | int(10) unsigned | NO | - | NULL |
| `min_value` | decimal(12,2) | NO | - | NULL |
| `max_value` | decimal(12,2) | NO | - | NULL |
| `default_value_id` | bigint(20) unsigned | NO | MUL | NULL |
| `default_raw_value` | varchar(255) | NO | - | NULL |
| `default_value` | longtext | NO | - | NULL |
| `created_at` | timestamp | NO | - | NULL |
| `updated_at` | timestamp | NO | - | NULL |

Foreign keys:
- `attribute_id` -> `attributes.id` (on update RESTRICT, on delete CASCADE)
- `default_value_id` -> `attribute_values.id` (on update RESTRICT, on delete SET NULL)
- `model_id` -> `models.id` (on update RESTRICT, on delete CASCADE)

Indexes:
- `PRIMARY` (UNIQUE/PK) on [id]
- `model_attributes_model_id_attribute_id_unique` (UNIQUE/PK) on [model_id, attribute_id]
- `model_attributes_attribute_id_foreign` (NON-UNIQUE) on [attribute_id]
- `model_attributes_default_value_id_foreign` (NON-UNIQUE) on [default_value_id]

### `models`

| Column | Type | Required | Key | Default |
|---|---|---|---|---|
| `id` | bigint(20) unsigned | YES | PRI | NULL |
| `make_id` | bigint(20) unsigned | YES | MUL | NULL |
| `name` | varchar(255) | YES | MUL | NULL |
| `model_code` | varchar(255) | NO | MUL | NULL |
| `created_at` | timestamp | NO | - | NULL |
| `updated_at` | timestamp | NO | - | NULL |

Foreign keys:
- `make_id` -> `makes.id` (on update RESTRICT, on delete CASCADE)

Indexes:
- `PRIMARY` (UNIQUE/PK) on [id]
- `models_make_id_name_unique` (UNIQUE/PK) on [make_id, name]
- `models_name_make_id_index` (NON-UNIQUE) on [name, make_id]
- `models_model_code_index` (NON-UNIQUE) on [model_code]

### `order_items`

| Column | Type | Required | Key | Default |
|---|---|---|---|---|
| `id` | bigint(20) unsigned | YES | PRI | NULL |
| `order_id` | bigint(20) unsigned | YES | MUL | NULL |
| `vehicle_id` | bigint(20) unsigned | YES | MUL | NULL |
| `quantity` | int(11) | YES | - | 1 |
| `price` | decimal(12,2) | YES | - | NULL |
| `discount_applied` | decimal(12,2) | YES | - | 0.00 |
| `created_at` | timestamp | NO | - | NULL |
| `updated_at` | timestamp | NO | - | NULL |

Foreign keys:
- `order_id` -> `orders.id` (on update RESTRICT, on delete CASCADE)
- `vehicle_id` -> `vehicles.id` (on update RESTRICT, on delete CASCADE)

Indexes:
- `PRIMARY` (UNIQUE/PK) on [id]
- `order_items_order_id_foreign` (NON-UNIQUE) on [order_id]
- `order_items_vehicle_id_foreign` (NON-UNIQUE) on [vehicle_id]

### `orders`

| Column | Type | Required | Key | Default |
|---|---|---|---|---|
| `id` | bigint(20) unsigned | YES | PRI | NULL |
| `user_id` | bigint(20) unsigned | YES | MUL | NULL |
| `vehicle_id` | bigint(20) unsigned | NO | MUL | NULL |
| `reservation_id` | bigint(20) unsigned | NO | MUL | NULL |
| `seller_id` | bigint(20) unsigned | NO | MUL | NULL |
| `source` | varchar(32) | NO | MUL | checkout |
| `consignee_id` | bigint(20) unsigned | NO | MUL | NULL |
| `remitter_id` | bigint(20) unsigned | NO | MUL | NULL |
| `consignee_name` | varchar(255) | NO | - | NULL |
| `consignee_email` | varchar(255) | NO | - | NULL |
| `consignee_phone` | varchar(50) | NO | - | NULL |
| `consignee_address` | text | NO | - | NULL |
| `consignee_country` | varchar(255) | NO | - | NULL |
| `remitter_name` | varchar(255) | NO | - | NULL |
| `remitter_email` | varchar(255) | NO | - | NULL |
| `remitter_phone` | varchar(50) | NO | - | NULL |
| `remitter_address` | text | NO | - | NULL |
| `remitter_country` | varchar(255) | NO | - | NULL |
| `status` | varchar(255) | YES | - | pending |
| `customer_status` | enum('reserved','payment_pending','partially_paid','paid','shipment_pending','shipped','arrived','delivered','completed') | YES | - | reserved |
| `total_price` | decimal(10,2) | YES | - | NULL |
| `vehicle_price` | decimal(12,2) | NO | - | NULL |
| `currency` | varchar(3) | YES | - | USD |
| `type` | varchar(255) | YES | - | C&F |
| `discount_amount` | decimal(10,2) | YES | - | 0.00 |
| `paid_amount` | decimal(12,2) | YES | - | 0.00 |
| `remaining_balance` | decimal(12,2) | YES | - | 0.00 |
| `min_ship_deposit_percentage` | decimal(5,2) | YES | - | 30.00 |
| `shipping_cost` | decimal(10,2) | YES | - | 0.00 |
| `freight_cost` | decimal(10,2) | NO | - | NULL |
| `inspection_fee` | decimal(10,2) | NO | - | NULL |
| `insurance_fee` | decimal(10,2) | NO | - | NULL |
| `cif_total` | decimal(12,2) | NO | - | NULL |
| `deposit_percentage` | decimal(5,2) | NO | - | NULL |
| `min_deposit_amount` | decimal(12,2) | NO | - | NULL |
| `shipping_country_id` | bigint(20) unsigned | NO | MUL | NULL |
| `shipping_port_id` | bigint(20) unsigned | NO | MUL | NULL |
| `shipping_type` | varchar(50) | NO | - | NULL |
| `inspection_enabled` | tinyint(1) | YES | - | 0 |
| `insurance_enabled` | tinyint(1) | YES | - | 0 |
| `shipping_cost_reason` | text | NO | - | NULL |
| `tracking_number` | varchar(255) | NO | - | NULL |
| `shipping_address` | text | NO | - | NULL |
| `from_port` | varchar(255) | NO | - | NULL |
| `arrival_port` | varchar(255) | NO | - | NULL |
| `notes` | text | NO | - | NULL |
| `documents` | longtext | NO | - | NULL |
| `order_date` | timestamp | YES | - | current_timestamp() |
| `buy_date` | timestamp | NO | - | NULL |
| `shipped_at` | timestamp | NO | - | NULL |
| `departure_date` | timestamp | NO | - | NULL |
| `arrival_date` | timestamp | NO | - | NULL |
| `dhl_date` | timestamp | NO | - | NULL |
| `delivered_at` | timestamp | NO | - | NULL |
| `created_at` | timestamp | NO | - | NULL |
| `updated_at` | timestamp | NO | - | NULL |

Foreign keys:
- `consignee_id` -> `consignees.id` (on update RESTRICT, on delete SET NULL)
- `remitter_id` -> `remitters.id` (on update RESTRICT, on delete SET NULL)
- `reservation_id` -> `vehicle_reservations.id` (on update RESTRICT, on delete SET NULL)
- `seller_id` -> `users.id` (on update RESTRICT, on delete SET NULL)
- `shipping_country_id` -> `shipping_countries.id` (on update RESTRICT, on delete SET NULL)
- `shipping_port_id` -> `ports.id` (on update RESTRICT, on delete SET NULL)
- `user_id` -> `users.id` (on update RESTRICT, on delete CASCADE)
- `vehicle_id` -> `vehicles.id` (on update RESTRICT, on delete SET NULL)

Indexes:
- `PRIMARY` (UNIQUE/PK) on [id]
- `orders_user_id_foreign` (NON-UNIQUE) on [user_id]
- `orders_consignee_id_foreign` (NON-UNIQUE) on [consignee_id]
- `orders_remitter_id_foreign` (NON-UNIQUE) on [remitter_id]
- `orders_shipping_country_id_foreign` (NON-UNIQUE) on [shipping_country_id]
- `orders_shipping_port_id_foreign` (NON-UNIQUE) on [shipping_port_id]
- `orders_vehicle_id_index` (NON-UNIQUE) on [vehicle_id]
- `orders_seller_id_index` (NON-UNIQUE) on [seller_id]
- `orders_source_index` (NON-UNIQUE) on [source]
- `orders_reservation_id_foreign` (NON-UNIQUE) on [reservation_id]

### `password_reset_tokens`

| Column | Type | Required | Key | Default |
|---|---|---|---|---|
| `email` | varchar(255) | YES | PRI | NULL |
| `token` | varchar(255) | YES | - | NULL |
| `created_at` | timestamp | NO | - | NULL |

Foreign keys:
- None

Indexes:
- `PRIMARY` (UNIQUE/PK) on [email]

### `payment_allocations`

| Column | Type | Required | Key | Default |
|---|---|---|---|---|
| `id` | bigint(20) unsigned | YES | PRI | NULL |
| `payment_id` | bigint(20) unsigned | YES | MUL | NULL |
| `vehicle_id` | bigint(20) unsigned | NO | MUL | NULL |
| `order_id` | bigint(20) unsigned | YES | MUL | NULL |
| `amount` | decimal(12,2) | YES | - | NULL |
| `created_at` | timestamp | NO | - | NULL |
| `updated_at` | timestamp | NO | - | NULL |

Foreign keys:
- `order_id` -> `orders.id` (on update RESTRICT, on delete CASCADE)
- `payment_id` -> `payments.id` (on update RESTRICT, on delete CASCADE)
- `vehicle_id` -> `vehicles.id` (on update RESTRICT, on delete SET NULL)

Indexes:
- `PRIMARY` (UNIQUE/PK) on [id]
- `payment_allocations_payment_id_index` (NON-UNIQUE) on [payment_id]
- `payment_allocations_order_id_index` (NON-UNIQUE) on [order_id]
- `payment_allocations_vehicle_id_foreign` (NON-UNIQUE) on [vehicle_id]

### `payment_histories`

| Column | Type | Required | Key | Default |
|---|---|---|---|---|
| `id` | bigint(20) unsigned | YES | PRI | NULL |
| `user_id` | bigint(20) unsigned | YES | MUL | NULL |
| `order_id` | bigint(20) unsigned | YES | MUL | NULL |
| `currency` | varchar(3) | YES | - | USD |
| `received_amount` | decimal(12,2) | YES | - | NULL |
| `allocated_amount` | decimal(12,2) | YES | - | 0.00 |
| `balance_amount` | decimal(12,2) | YES | - | 0.00 |
| `payment_type` | varchar(255) | YES | - | deposit |
| `payment_method` | varchar(255) | YES | - | NULL |
| `transaction_id` | varchar(255) | NO | - | NULL |
| `notes` | text | NO | - | NULL |
| `receive_date` | timestamp | YES | - | current_timestamp() |
| `created_at` | timestamp | NO | - | NULL |
| `updated_at` | timestamp | NO | - | NULL |

Foreign keys:
- `order_id` -> `orders.id` (on update RESTRICT, on delete CASCADE)
- `user_id` -> `users.id` (on update RESTRICT, on delete CASCADE)

Indexes:
- `PRIMARY` (UNIQUE/PK) on [id]
- `payment_histories_user_id_foreign` (NON-UNIQUE) on [user_id]
- `payment_histories_order_id_foreign` (NON-UNIQUE) on [order_id]

### `payments`

| Column | Type | Required | Key | Default |
|---|---|---|---|---|
| `id` | bigint(20) unsigned | YES | PRI | NULL |
| `order_id` | bigint(20) unsigned | YES | MUL | NULL |
| `bank_account_id` | bigint(20) unsigned | NO | MUL | NULL |
| `payment_method` | varchar(255) | YES | - | NULL |
| `transaction_id` | varchar(255) | NO | - | NULL |
| `amount` | decimal(10,2) | YES | - | NULL |
| `method` | varchar(40) | NO | - | NULL |
| `created_by` | bigint(20) unsigned | NO | MUL | NULL |
| `status` | varchar(255) | YES | - | pending |
| `payment_data` | longtext | NO | - | NULL |
| `payment_proof` | varchar(255) | NO | - | NULL |
| `bank_reference` | varchar(255) | NO | - | NULL |
| `approved_by` | bigint(20) unsigned | NO | MUL | NULL |
| `paid_at` | timestamp | NO | - | NULL |
| `created_at` | timestamp | NO | - | NULL |
| `updated_at` | timestamp | NO | - | NULL |

Foreign keys:
- `approved_by` -> `users.id` (on update RESTRICT, on delete SET NULL)
- `bank_account_id` -> `bank_accounts.id` (on update RESTRICT, on delete SET NULL)
- `created_by` -> `users.id` (on update RESTRICT, on delete SET NULL)
- `order_id` -> `orders.id` (on update RESTRICT, on delete CASCADE)

Indexes:
- `PRIMARY` (UNIQUE/PK) on [id]
- `payments_bank_account_id_foreign` (NON-UNIQUE) on [bank_account_id]
- `payments_approved_by_foreign` (NON-UNIQUE) on [approved_by]
- `payments_order_method_idx` (NON-UNIQUE) on [order_id, method]
- `payments_created_by_created_at_idx` (NON-UNIQUE) on [created_by, created_at]

### `personal_access_tokens`

| Column | Type | Required | Key | Default |
|---|---|---|---|---|
| `id` | bigint(20) unsigned | YES | PRI | NULL |
| `tokenable_type` | varchar(255) | YES | MUL | NULL |
| `tokenable_id` | bigint(20) unsigned | YES | - | NULL |
| `name` | text | YES | - | NULL |
| `token` | varchar(64) | YES | UNI | NULL |
| `abilities` | text | NO | - | NULL |
| `last_used_at` | timestamp | NO | - | NULL |
| `expires_at` | timestamp | NO | MUL | NULL |
| `created_at` | timestamp | NO | - | NULL |
| `updated_at` | timestamp | NO | - | NULL |

Foreign keys:
- None

Indexes:
- `PRIMARY` (UNIQUE/PK) on [id]
- `personal_access_tokens_token_unique` (UNIQUE/PK) on [token]
- `personal_access_tokens_tokenable_type_tokenable_id_index` (NON-UNIQUE) on [tokenable_type, tokenable_id]
- `personal_access_tokens_expires_at_index` (NON-UNIQUE) on [expires_at]

### `ports`

| Column | Type | Required | Key | Default |
|---|---|---|---|---|
| `id` | bigint(20) unsigned | YES | PRI | NULL |
| `country_id` | bigint(20) unsigned | YES | MUL | NULL |
| `name` | varchar(255) | YES | - | NULL |
| `is_active` | tinyint(1) | YES | - | 1 |
| `created_at` | timestamp | NO | - | NULL |
| `updated_at` | timestamp | NO | - | NULL |

Foreign keys:
- `country_id` -> `shipping_countries.id` (on update RESTRICT, on delete CASCADE)

Indexes:
- `PRIMARY` (UNIQUE/PK) on [id]
- `ports_country_id_name_unique` (UNIQUE/PK) on [country_id, name]
- `ports_country_id_index` (NON-UNIQUE) on [country_id]

### `pricing_rules`

| Column | Type | Required | Key | Default |
|---|---|---|---|---|
| `id` | bigint(20) unsigned | YES | PRI | NULL |
| `type` | enum('inspection','insurance') | YES | MUL | NULL |
| `country_id` | bigint(20) unsigned | NO | MUL | NULL |
| `port_id` | bigint(20) unsigned | NO | MUL | NULL |
| `vehicle_type` | varchar(255) | NO | - | NULL |
| `value` | decimal(12,2) | YES | - | NULL |
| `value_type` | enum('fixed','percentage') | YES | - | fixed |
| `is_active` | tinyint(1) | YES | - | 1 |
| `created_at` | timestamp | NO | - | NULL |
| `updated_at` | timestamp | NO | - | NULL |

Foreign keys:
- `country_id` -> `shipping_countries.id` (on update RESTRICT, on delete SET NULL)
- `port_id` -> `ports.id` (on update RESTRICT, on delete SET NULL)

Indexes:
- `PRIMARY` (UNIQUE/PK) on [id]
- `pricing_rules_port_id_foreign` (NON-UNIQUE) on [port_id]
- `pricing_rules_type_is_active_index` (NON-UNIQUE) on [type, is_active]
- `pricing_rules_country_id_port_id_index` (NON-UNIQUE) on [country_id, port_id]

### `regions`

| Column | Type | Required | Key | Default |
|---|---|---|---|---|
| `id` | bigint(20) unsigned | YES | PRI | NULL |
| `name` | varchar(255) | YES | UNI | NULL |
| `country_id` | bigint(20) unsigned | NO | MUL | NULL |
| `created_at` | timestamp | NO | - | NULL |
| `updated_at` | timestamp | NO | - | NULL |

Foreign keys:
- `country_id` -> `shipping_countries.id` (on update RESTRICT, on delete SET NULL)

Indexes:
- `PRIMARY` (UNIQUE/PK) on [id]
- `regions_name_unique` (UNIQUE/PK) on [name]
- `regions_country_id_foreign` (NON-UNIQUE) on [country_id]

### `remitters`

| Column | Type | Required | Key | Default |
|---|---|---|---|---|
| `id` | bigint(20) unsigned | YES | PRI | NULL |
| `user_id` | bigint(20) unsigned | YES | MUL | NULL |
| `name` | varchar(255) | YES | - | NULL |
| `email` | varchar(255) | NO | - | NULL |
| `phone` | varchar(255) | YES | - | NULL |
| `address` | text | YES | - | NULL |
| `city` | varchar(255) | YES | - | NULL |
| `country` | varchar(255) | YES | - | NULL |
| `postal_code` | varchar(255) | NO | - | NULL |
| `is_default` | tinyint(1) | YES | - | 0 |
| `created_at` | timestamp | NO | - | NULL |
| `updated_at` | timestamp | NO | - | NULL |

Foreign keys:
- `user_id` -> `users.id` (on update RESTRICT, on delete CASCADE)

Indexes:
- `PRIMARY` (UNIQUE/PK) on [id]
- `remitters_user_id_index` (NON-UNIQUE) on [user_id]

### `sessions`

| Column | Type | Required | Key | Default |
|---|---|---|---|---|
| `id` | varchar(255) | YES | PRI | NULL |
| `user_id` | bigint(20) unsigned | NO | MUL | NULL |
| `ip_address` | varchar(45) | NO | - | NULL |
| `user_agent` | text | NO | - | NULL |
| `payload` | longtext | YES | - | NULL |
| `last_activity` | int(11) | YES | MUL | NULL |

Foreign keys:
- None

Indexes:
- `PRIMARY` (UNIQUE/PK) on [id]
- `sessions_user_id_index` (NON-UNIQUE) on [user_id]
- `sessions_last_activity_index` (NON-UNIQUE) on [last_activity]

### `settings`

| Column | Type | Required | Key | Default |
|---|---|---|---|---|
| `id` | bigint(20) unsigned | YES | PRI | NULL |
| `key` | varchar(255) | YES | UNI | NULL |
| `value` | text | NO | - | NULL |
| `created_at` | timestamp | NO | - | NULL |
| `updated_at` | timestamp | NO | - | NULL |

Foreign keys:
- None

Indexes:
- `PRIMARY` (UNIQUE/PK) on [id]
- `settings_key_unique` (UNIQUE/PK) on [key]

### `shipments`

| Column | Type | Required | Key | Default |
|---|---|---|---|---|
| `id` | bigint(20) unsigned | YES | PRI | NULL |
| `order_id` | bigint(20) unsigned | YES | MUL | NULL |
| `vehicle_id` | bigint(20) unsigned | YES | MUL | NULL |
| `arrival_port` | varchar(255) | YES | - | NULL |
| `buy_date` | date | NO | - | NULL |
| `ship_ok_date` | date | NO | - | NULL |
| `departure_date` | date | NO | - | NULL |
| `arrival_date` | date | NO | - | NULL |
| `local_dispatch_date` | date | NO | - | NULL |
| `status` | varchar(255) | NO | MUL | NULL |
| `tracking_number` | varchar(255) | NO | - | NULL |
| `origin_port` | varchar(255) | NO | - | NULL |
| `destination_port` | varchar(255) | NO | - | NULL |
| `shipping_approved_date` | date | NO | - | NULL |
| `created_at` | timestamp | NO | - | NULL |
| `updated_at` | timestamp | NO | - | NULL |

Foreign keys:
- `order_id` -> `orders.id` (on update RESTRICT, on delete CASCADE)
- `vehicle_id` -> `vehicles.id` (on update RESTRICT, on delete CASCADE)

Indexes:
- `PRIMARY` (UNIQUE/PK) on [id]
- `shipments_order_id_index` (NON-UNIQUE) on [order_id]
- `shipments_vehicle_id_index` (NON-UNIQUE) on [vehicle_id]
- `shipments_status_index` (NON-UNIQUE) on [status]

### `shipping_countries`

| Column | Type | Required | Key | Default |
|---|---|---|---|---|
| `id` | bigint(20) unsigned | YES | PRI | NULL |
| `name` | varchar(255) | YES | UNI | NULL |
| `code` | varchar(8) | NO | MUL | NULL |
| `currency_id` | bigint(20) unsigned | NO | MUL | NULL |
| `is_active` | tinyint(1) | YES | - | 1 |
| `created_at` | timestamp | NO | - | NULL |
| `updated_at` | timestamp | NO | - | NULL |

Foreign keys:
- `currency_id` -> `currencies.id` (on update RESTRICT, on delete SET NULL)

Indexes:
- `PRIMARY` (UNIQUE/PK) on [id]
- `shipping_countries_name_unique` (UNIQUE/PK) on [name]
- `shipping_countries_code_index` (NON-UNIQUE) on [code]
- `shipping_countries_currency_id_foreign` (NON-UNIQUE) on [currency_id]

### `shipping_rates`

| Column | Type | Required | Key | Default |
|---|---|---|---|---|
| `id` | bigint(20) unsigned | YES | PRI | NULL |
| `country_id` | bigint(20) unsigned | YES | MUL | NULL |
| `port_id` | bigint(20) unsigned | YES | MUL | NULL |
| `vehicle_type` | varchar(255) | YES | - | NULL |
| `shipping_type` | enum('roro','container') | YES | - | NULL |
| `price` | decimal(12,2) | YES | - | NULL |
| `currency` | varchar(3) | YES | - | USD |
| `created_at` | timestamp | NO | - | NULL |
| `updated_at` | timestamp | NO | - | NULL |

Foreign keys:
- `country_id` -> `shipping_countries.id` (on update RESTRICT, on delete CASCADE)
- `port_id` -> `ports.id` (on update RESTRICT, on delete CASCADE)

Indexes:
- `PRIMARY` (UNIQUE/PK) on [id]
- `shipping_rates_unique_lookup` (UNIQUE/PK) on [country_id, port_id, vehicle_type, shipping_type]
- `shipping_rates_country_id_index` (NON-UNIQUE) on [country_id]
- `shipping_rates_port_id_index` (NON-UNIQUE) on [port_id]
- `shipping_rates_lookup_index` (NON-UNIQUE) on [country_id, port_id, vehicle_type, shipping_type]

### `team_invitations`

| Column | Type | Required | Key | Default |
|---|---|---|---|---|
| `id` | bigint(20) unsigned | YES | PRI | NULL |
| `team_id` | bigint(20) unsigned | YES | MUL | NULL |
| `email` | varchar(255) | YES | - | NULL |
| `role` | varchar(255) | NO | - | NULL |
| `created_at` | timestamp | NO | - | NULL |
| `updated_at` | timestamp | NO | - | NULL |

Foreign keys:
- `team_id` -> `teams.id` (on update RESTRICT, on delete CASCADE)

Indexes:
- `PRIMARY` (UNIQUE/PK) on [id]
- `team_invitations_team_id_email_unique` (UNIQUE/PK) on [team_id, email]

### `team_user`

| Column | Type | Required | Key | Default |
|---|---|---|---|---|
| `id` | bigint(20) unsigned | YES | PRI | NULL |
| `team_id` | bigint(20) unsigned | YES | MUL | NULL |
| `user_id` | bigint(20) unsigned | YES | - | NULL |
| `role` | varchar(255) | NO | - | NULL |
| `created_at` | timestamp | NO | - | NULL |
| `updated_at` | timestamp | NO | - | NULL |

Foreign keys:
- None

Indexes:
- `PRIMARY` (UNIQUE/PK) on [id]
- `team_user_team_id_user_id_unique` (UNIQUE/PK) on [team_id, user_id]

### `teams`

| Column | Type | Required | Key | Default |
|---|---|---|---|---|
| `id` | bigint(20) unsigned | YES | PRI | NULL |
| `user_id` | bigint(20) unsigned | YES | MUL | NULL |
| `name` | varchar(255) | YES | - | NULL |
| `personal_team` | tinyint(1) | YES | - | NULL |
| `created_at` | timestamp | NO | - | NULL |
| `updated_at` | timestamp | NO | - | NULL |

Foreign keys:
- None

Indexes:
- `PRIMARY` (UNIQUE/PK) on [id]
- `teams_user_id_index` (NON-UNIQUE) on [user_id]

### `users`

| Column | Type | Required | Key | Default |
|---|---|---|---|---|
| `id` | bigint(20) unsigned | YES | PRI | NULL |
| `name` | varchar(255) | YES | - | NULL |
| `email` | varchar(255) | YES | UNI | NULL |
| `phone` | varchar(255) | NO | - | NULL |
| `address` | text | NO | - | NULL |
| `country` | varchar(255) | NO | - | NULL |
| `email_verified_at` | timestamp | NO | - | NULL |
| `password` | varchar(255) | YES | - | NULL |
| `role` | varchar(255) | YES | - | customer |
| `two_factor_secret` | text | NO | - | NULL |
| `two_factor_recovery_codes` | text | NO | - | NULL |
| `two_factor_confirmed_at` | timestamp | NO | - | NULL |
| `remember_token` | varchar(100) | NO | - | NULL |
| `current_team_id` | bigint(20) unsigned | NO | - | NULL |
| `profile_photo_path` | varchar(2048) | NO | - | NULL |
| `created_at` | timestamp | NO | - | NULL |
| `updated_at` | timestamp | NO | - | NULL |

Foreign keys:
- None

Indexes:
- `PRIMARY` (UNIQUE/PK) on [id]
- `users_email_unique` (UNIQUE/PK) on [email]

### `vehicle_attribute_values`

| Column | Type | Required | Key | Default |
|---|---|---|---|---|
| `id` | bigint(20) unsigned | YES | PRI | NULL |
| `vehicle_id` | bigint(20) unsigned | YES | MUL | NULL |
| `attribute_id` | bigint(20) unsigned | YES | MUL | NULL |
| `value_id` | bigint(20) unsigned | NO | MUL | NULL |
| `raw_value` | varchar(255) | NO | - | NULL |
| `created_at` | timestamp | NO | - | NULL |
| `updated_at` | timestamp | NO | - | NULL |

Foreign keys:
- `attribute_id` -> `attributes.id` (on update RESTRICT, on delete CASCADE)
- `value_id` -> `attribute_values.id` (on update RESTRICT, on delete SET NULL)
- `vehicle_id` -> `vehicles.id` (on update RESTRICT, on delete CASCADE)

Indexes:
- `PRIMARY` (UNIQUE/PK) on [id]
- `vehicle_attribute_values_unique` (UNIQUE/PK) on [vehicle_id, attribute_id, value_id, raw_value]
- `vehicle_attribute_values_value_id_foreign` (NON-UNIQUE) on [value_id]
- `vehicle_attribute_values_vehicle_id_attribute_id_index` (NON-UNIQUE) on [vehicle_id, attribute_id]
- `vehicle_attribute_values_attribute_id_value_id_index` (NON-UNIQUE) on [attribute_id, value_id]
- `vehicle_attribute_values_vehicle_id_index` (NON-UNIQUE) on [vehicle_id]

### `vehicle_documents`

| Column | Type | Required | Key | Default |
|---|---|---|---|---|
| `id` | bigint(20) unsigned | YES | PRI | NULL |
| `vehicle_id` | bigint(20) unsigned | YES | MUL | NULL |
| `uploaded_by` | bigint(20) unsigned | YES | MUL | NULL |
| `document_name` | varchar(255) | YES | - | NULL |
| `file_path` | varchar(255) | YES | - | NULL |
| `file_name` | varchar(255) | YES | - | NULL |
| `mime_type` | varchar(255) | YES | - | application/pdf |
| `file_size` | bigint(20) unsigned | YES | - | 0 |
| `document_type` | varchar(255) | YES | - | general |
| `description` | text | NO | - | NULL |
| `is_required` | tinyint(1) | YES | - | 0 |
| `issued_date` | timestamp | NO | - | NULL |
| `expiry_date` | timestamp | NO | - | NULL |
| `created_at` | timestamp | NO | - | NULL |
| `updated_at` | timestamp | NO | - | NULL |

Foreign keys:
- `uploaded_by` -> `users.id` (on update RESTRICT, on delete CASCADE)
- `vehicle_id` -> `vehicles.id` (on update RESTRICT, on delete CASCADE)

Indexes:
- `PRIMARY` (UNIQUE/PK) on [id]
- `vehicle_documents_vehicle_id_foreign` (NON-UNIQUE) on [vehicle_id]
- `vehicle_documents_uploaded_by_foreign` (NON-UNIQUE) on [uploaded_by]

### `vehicle_images`

| Column | Type | Required | Key | Default |
|---|---|---|---|---|
| `id` | bigint(20) unsigned | YES | PRI | NULL |
| `vehicle_id` | bigint(20) unsigned | YES | MUL | NULL |
| `image_path` | varchar(255) | YES | - | NULL |
| `created_at` | timestamp | NO | - | NULL |
| `updated_at` | timestamp | NO | - | NULL |

Foreign keys:
- `vehicle_id` -> `vehicles.id` (on update RESTRICT, on delete CASCADE)

Indexes:
- `PRIMARY` (UNIQUE/PK) on [id]
- `vehicle_images_vehicle_id_foreign` (NON-UNIQUE) on [vehicle_id]

### `vehicle_reservations`

| Column | Type | Required | Key | Default |
|---|---|---|---|---|
| `id` | bigint(20) unsigned | YES | PRI | NULL |
| `auction_id` | bigint(20) unsigned | NO | MUL | NULL |
| `auction_car_id` | bigint(20) unsigned | NO | MUL | NULL |
| `seller_id` | bigint(20) unsigned | YES | MUL | NULL |
| `vehicle_id` | bigint(20) unsigned | NO | MUL | NULL |
| `user_id` | bigint(20) unsigned | YES | MUL | NULL |
| `reserved_by` | bigint(20) unsigned | NO | MUL | NULL |
| `wallet_amount_used` | decimal(12,2) | YES | - | 0.00 |
| `reserved_at` | timestamp | YES | - | current_timestamp() |
| `expires_at` | timestamp | NO | MUL | NULL |
| `status` | varchar(32) | YES | - | NULL |
| `order_id` | bigint(20) unsigned | NO | MUL | NULL |
| `created_at` | timestamp | NO | - | NULL |
| `updated_at` | timestamp | NO | - | NULL |

Foreign keys:
- `auction_car_id` -> `auction_cars.id` (on update RESTRICT, on delete CASCADE)
- `auction_id` -> `auction_cars.id` (on update RESTRICT, on delete CASCADE)
- `order_id` -> `orders.id` (on update RESTRICT, on delete SET NULL)
- `reserved_by` -> `users.id` (on update RESTRICT, on delete SET NULL)
- `seller_id` -> `users.id` (on update RESTRICT, on delete CASCADE)
- `user_id` -> `users.id` (on update RESTRICT, on delete CASCADE)
- `vehicle_id` -> `vehicles.id` (on update RESTRICT, on delete CASCADE)

Indexes:
- `PRIMARY` (UNIQUE/PK) on [id]
- `vehicle_reservations_vehicle_id_status_index` (NON-UNIQUE) on [vehicle_id, status]
- `vehicle_reservations_user_id_status_index` (NON-UNIQUE) on [user_id, status]
- `vehicle_reservations_expires_at_index` (NON-UNIQUE) on [expires_at]
- `vr_vehicle_status_expires_idx` (NON-UNIQUE) on [vehicle_id, status, expires_at]
- `vehicle_reservations_seller_id_foreign` (NON-UNIQUE) on [seller_id]
- `vr_auction_status_expires_idx` (NON-UNIQUE) on [auction_id, status, expires_at]
- `vehicle_reservations_order_id_foreign` (NON-UNIQUE) on [order_id]
- `vr_auction_car_status_expires_idx` (NON-UNIQUE) on [auction_car_id, status, expires_at]
- `vr_vehicle_status_expires_idx_2` (NON-UNIQUE) on [vehicle_id, status, expires_at]
- `vr_reserved_by_status_idx` (NON-UNIQUE) on [reserved_by, status]

### `vehicle_types`

| Column | Type | Required | Key | Default |
|---|---|---|---|---|
| `id` | bigint(20) unsigned | YES | PRI | NULL |
| `name` | varchar(255) | YES | UNI | NULL |
| `slug` | varchar(255) | YES | UNI | NULL |
| `is_active` | tinyint(1) | YES | - | 1 |
| `created_at` | timestamp | NO | - | NULL |
| `updated_at` | timestamp | NO | - | NULL |

Foreign keys:
- None

Indexes:
- `PRIMARY` (UNIQUE/PK) on [id]
- `vehicle_types_name_unique` (UNIQUE/PK) on [name]
- `vehicle_types_slug_unique` (UNIQUE/PK) on [slug]

### `vehicles`

| Column | Type | Required | Key | Default |
|---|---|---|---|---|
| `id` | bigint(20) unsigned | YES | PRI | NULL |
| `rec_no` | varchar(255) | YES | UNI | NULL |
| `seller_id` | bigint(20) unsigned | NO | MUL | NULL |
| `auction_car_id` | bigint(20) unsigned | NO | UNI | NULL |
| `make_id` | bigint(20) unsigned | NO | MUL | NULL |
| `model_id` | bigint(20) unsigned | NO | MUL | NULL |
| `vehicle_type_id` | bigint(20) unsigned | NO | MUL | NULL |
| `make` | varchar(255) | YES | - | NULL |
| `model` | varchar(255) | YES | - | NULL |
| `model_code` | varchar(255) | NO | MUL | NULL |
| `chassis` | varchar(255) | NO | - | NULL |
| `grade` | varchar(255) | NO | - | NULL |
| `registration_year` | varchar(255) | NO | - | NULL |
| `manufacture_year` | year(4) | NO | - | NULL |
| `year` | year(4) | YES | - | NULL |
| `mileage` | int(11) | YES | - | NULL |
| `location` | varchar(255) | NO | - | NULL |
| `country_id` | bigint(20) unsigned | NO | MUL | NULL |
| `stock_country` | varchar(255) | NO | - | NULL |
| `price` | decimal(10,2) | YES | - | NULL |
| `discount_percentage` | decimal(5,2) | YES | - | 0.00 |
| `discount_amount` | decimal(10,2) | YES | - | 0.00 |
| `is_featured` | tinyint(1) | YES | - | 0 |
| `is_clearance` | tinyint(1) | YES | - | 0 |
| `condition` | enum('new','used') | YES | - | used |
| `vehicle_type` | varchar(255) | NO | - | NULL |
| `color` | varchar(255) | NO | - | NULL |
| `transmission` | varchar(255) | NO | - | NULL |
| `fuel_type` | varchar(255) | NO | - | NULL |
| `length_m` | decimal(4,2) | NO | - | NULL |
| `width_m` | decimal(4,2) | NO | - | NULL |
| `height_m` | decimal(4,2) | NO | - | NULL |
| `volume_m3` | decimal(5,3) | NO | - | NULL |
| `seats` | int(11) | NO | - | NULL |
| `doors` | int(11) | NO | - | NULL |
| `engine_capacity` | int(10) unsigned | NO | - | NULL |
| `primary_image` | varchar(255) | NO | - | NULL |
| `stock_status` | enum('available','sold') | YES | - | available |
| `status` | enum('draft','published','reserved','sold') | YES | MUL | draft |
| `is_locked` | tinyint(1) | YES | - | 0 |
| `is_ready_for_sale` | tinyint(1) | YES | MUL | 1 |
| `created_at` | timestamp | NO | - | NULL |
| `updated_at` | timestamp | NO | - | NULL |

Foreign keys:
- `auction_car_id` -> `auction_cars.id` (on update RESTRICT, on delete SET NULL)
- `country_id` -> `shipping_countries.id` (on update RESTRICT, on delete SET NULL)
- `make_id` -> `makes.id` (on update RESTRICT, on delete SET NULL)
- `model_id` -> `models.id` (on update RESTRICT, on delete SET NULL)
- `seller_id` -> `users.id` (on update RESTRICT, on delete SET NULL)
- `vehicle_type_id` -> `attribute_values.id` (on update RESTRICT, on delete SET NULL)

Indexes:
- `PRIMARY` (UNIQUE/PK) on [id]
- `vehicles_rec_no_unique` (UNIQUE/PK) on [rec_no]
- `vehicles_auction_car_id_unique` (UNIQUE/PK) on [auction_car_id]
- `vehicles_status_index` (NON-UNIQUE) on [status]
- `vehicles_model_id_foreign` (NON-UNIQUE) on [model_id]
- `vehicles_make_id_model_id_index` (NON-UNIQUE) on [make_id, model_id]
- `vehicles_model_code_index` (NON-UNIQUE) on [model_code]
- `vehicles_seller_id_foreign` (NON-UNIQUE) on [seller_id]
- `vehicles_is_ready_for_sale_index` (NON-UNIQUE) on [is_ready_for_sale]
- `vehicles_country_id_foreign` (NON-UNIQUE) on [country_id]
- `vehicles_vehicle_type_id_index` (NON-UNIQUE) on [vehicle_type_id]

### `wallet_transactions`

| Column | Type | Required | Key | Default |
|---|---|---|---|---|
| `id` | bigint(20) unsigned | YES | PRI | NULL |
| `user_id` | bigint(20) unsigned | YES | MUL | NULL |
| `type` | varchar(20) | YES | - | NULL |
| `amount` | decimal(12,2) | YES | - | NULL |
| `source` | varchar(40) | YES | - | NULL |
| `reference_type` | varchar(40) | NO | MUL | NULL |
| `reference_id` | bigint(20) unsigned | NO | - | NULL |
| `created_by` | bigint(20) unsigned | NO | MUL | NULL |
| `created_at` | timestamp | NO | - | NULL |
| `updated_at` | timestamp | NO | - | NULL |

Foreign keys:
- `created_by` -> `users.id` (on update RESTRICT, on delete SET NULL)
- `user_id` -> `users.id` (on update RESTRICT, on delete CASCADE)

Indexes:
- `PRIMARY` (UNIQUE/PK) on [id]
- `wallet_transactions_created_by_foreign` (NON-UNIQUE) on [created_by]
- `wallet_transactions_user_id_type_index` (NON-UNIQUE) on [user_id, type]
- `wallet_transactions_user_id_created_at_index` (NON-UNIQUE) on [user_id, created_at]
- `wallet_transactions_reference_type_reference_id_index` (NON-UNIQUE) on [reference_type, reference_id]
