<?php

namespace App\Models;

use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\Relations\BelongsTo;

class TableSnapshot extends Model
{
    use HasFactory;

    protected $fillable = [
        'website_id',
        'table_name',
        'row_count',
        'size_bytes',
        'last_updated_at',
        'structure',
    ];

    protected function casts(): array
    {
        return [
            'last_updated_at' => 'datetime',
            'structure' => 'array',
        ];
    }

    public function website(): BelongsTo
    {
        return $this->belongsTo(Website::class);
    }
}
