<?php

use Licenzo\Framework\Database\Migration\Migration;

if (!defined('ABSPATH')) exit; // Exit if accessed directly

return new class extends Migration {
    protected $table = 'licenzo_products';

    public function up()
    {
        return $this->create($this->table, [
            'id'                    => 'BIGINT UNSIGNED AUTO_INCREMENT PRIMARY KEY',
            'uuid'                  => 'VARCHAR(191) NOT NULL UNIQUE',
            'name'                  => 'VARCHAR(255) NULL',
            'slug'                  => 'VARCHAR(191) NULL UNIQUE',
            'description'           => 'LONGTEXT NULL',
            'type'                  => 'VARCHAR(100) DEFAULT "single"',
            'status'                => 'VARCHAR(50) DEFAULT "active"',
            'provider_product_name' => 'VARCHAR(255) NULL',
            'provider'              => 'VARCHAR(100) NULL',
            'provider_id'           => 'VARCHAR(255) DEFAULT NULL', // canonical provider product reference
            'product_link'          => 'VARCHAR(255) DEFAULT NULL',
            'created_at'            => 'TIMESTAMP DEFAULT CURRENT_TIMESTAMP',
            'updated_at'            => 'TIMESTAMP DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP'
        ]);
    }

    public function down()
    {
        return $this->drop($this->table);
    }
};
