# Task 01: Setup Database Migrations

## Goal
Create all migration files in dependency order, including the new `product_stock_logs` table.

## Tables (migration order)
1. categories
2. products (with stock_quantity, low_stock_threshold, discount fields)
3. product_files
4. product_stock_logs  ← NEW
5. addresses
6. carts
7. cart_items (with original_price, discount_amount, price)
8. orders
9. order_items (with original_price, discount_amount, price)
10. digital_access

## Key Constraints
- `cart_items` → unique(`cart_id`, `product_id`, `type`)
- `digital_access` → unique(`user_id`, `product_id`, `order_id`)
- `product_stock_logs.movement_type` → enum(`initial`, `restock`, `sale`, `return`, `adjustment`)
- `product_stock_logs.direction` → enum(`+`, `−`), default `+`
- `product_stock_logs` → no `updated_at` column (append-only)
- `products.low_stock_threshold` → unsignedInt, default 5

## Files
- `database/migrations/xxxx_create_categories_table.php`
- `database/migrations/xxxx_create_products_table.php`
- `database/migrations/xxxx_create_product_files_table.php`
- `database/migrations/xxxx_create_product_stock_logs_table.php`
- `database/migrations/xxxx_create_addresses_table.php`
- `database/migrations/xxxx_create_carts_table.php`
- `database/migrations/xxxx_create_cart_items_table.php`
- `database/migrations/xxxx_create_orders_table.php`
- `database/migrations/xxxx_create_order_items_table.php`
- `database/migrations/xxxx_create_digital_access_table.php`

## Steps
1. Create all migrations in order above
2. In `product_stock_logs`: use `$table->timestamp('created_at')` only — no `updated_at`
3. Add `direction` column as enum(`+`, `−`) with default `+`
4. Add `note` as nullable text; `order_id` and `admin_id` as nullable FKs
5. Run `php artisan migrate` and verify
