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

declare(strict_types=1);

namespace BookiFlex\Extensions\Payment\ORM\Schema;

use BookiFlex\Core\ORM\Schema\AbstractSchema;
use Cycle\Database\Schema\AbstractTable;

defined( 'ABSPATH' ) || exit;

/**
 * Payment tokens table schema
 */
class PaymentTokenSchema extends AbstractSchema
{
    public const TABLE_NAME             = 'bflex_payment_tokens';

    public function define(): AbstractTable
    {
        $schema = $this->database->table(self::TABLE_NAME)->getSchema();
        //        $paymentTokenSchema->column('id')->string(50);
        $schema->column('hash')->string(50);
        $schema->column('details')->text()->nullable();
        $schema->column('after_url')->text()->nullable();
        $schema->column('target_url')->text();
        $schema->column('gateway_name')->string();
        $this->addTimestamps($schema);

        // Indexes
        $schema->index(['hash'])->unique();

        return $schema;
    }
}
