<?php
/**
 * BookiFlex Core
 *
 * @package    BookiFlex
 * @subpackage Core
 * @author     BookiFlex
 * @copyright  Copyright (c) 2025 BookiFlex
 * @license    GPL-2.0-or-later
 *
 * @link       https://bookiflex.com
 */

declare(strict_types=1);

namespace BookiFlex\Core\ORM\Schema;

use Cycle\Database\DatabaseInterface;
use Cycle\Database\Schema\AbstractTable;

defined( 'ABSPATH' ) || exit;

/**
 * Abstract Schema Definition
 */
abstract class AbstractSchema
{
    protected DatabaseInterface $database;

    public function __construct(DatabaseInterface $database)
    {
        $this->database = $database;
    }

    /**
     * Define table schema
     */
    abstract public function define(): AbstractTable;

    /**
     * Create foreign keys (optional)
     */
    public function createForeignKeys(): void
    {
        // Override in child classes if needed
    }

    /**
     * Add timestamps to table
     */
    protected function addTimestamps(AbstractTable $table): void
    {
        $table->column('created_at')->datetime();
        $table->column('updated_at')->datetime()->nullable();
    }
}
