<?php

namespace Database\Factories;

use App\Models\TableSnapshot;
use App\Models\Website;
use Illuminate\Database\Eloquent\Factories\Factory;

/**
 * @extends Factory<TableSnapshot>
 */
class TableSnapshotFactory extends Factory
{
    protected $model = TableSnapshot::class;

    public function definition(): array
    {
        return [
            'website_id' => Website::factory(),
            'table_name' => fake()->randomElement(['users', 'orders', 'products', 'logs', 'posts', 'settings']).'_'.fake()->numberBetween(1, 999),
            'row_count' => fake()->numberBetween(20, 250000),
            'size_bytes' => fake()->numberBetween(3000, 80_000_000),
            'last_updated_at' => now()->subMinutes(fake()->numberBetween(2, 1440)),
            'structure' => [
                'columns' => [
                    ['name' => 'id', 'type' => 'bigint', 'nullable' => false, 'default' => null],
                    ['name' => 'name', 'type' => 'varchar(255)', 'nullable' => false, 'default' => null],
                    ['name' => 'created_at', 'type' => 'timestamp', 'nullable' => true, 'default' => null],
                ],
                'indexes' => ['primary'],
                'foreign_keys' => [],
            ],
        ];
    }
}
