<?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\Schema\AbstractTable;

defined( 'ABSPATH' ) || exit;

/**
 * Reservation adjustment table schema
 */
class ReservationAdjustmentSchema extends AbstractSchema
{
    public const TABLE_NAME = 'bflex_reservation_adjustments';

    public function define(): AbstractTable
    {
        // This returns the main reservation table
        // Other tables are created via additional methods
        return $this->defineReservationTable();
    }

    protected function defineReservationTable(): AbstractTable
    {
        $schema = $this->database->table(self::TABLE_NAME)->getSchema();
        $schema->column('id')->integer()->primary();
        $schema->column('name')->string(255)->defaultValue('');
        $schema->column('code')->string(30)->nullable()->defaultValue(null);
        $schema->column('source')->string(50);
        $schema->column('amount')->integer();
        $schema->column('active')->boolean();
        $schema->column('type')->string(10);
        $schema->column('mode')->string(3);
        $schema->column('currency')->string(3);
        $schema->column('strategy')->string(3);
        $schema->column('refundable')->boolean();
        $schema->column('adjustable_type')->string(250);
        $schema->column('adjustable_id')->integer();
        $this->addTimestamps($schema);

        return $schema;
    }
}
