<?php

use Licenzo\Framework\Database\Migration\Migration;

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

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

    public function up()
    {
        return $this->create($this->table, [
            'id'          => 'BIGINT UNSIGNED AUTO_INCREMENT PRIMARY KEY',
            'user_id'     => 'BIGINT UNSIGNED NULL',
            'provider'    => 'VARCHAR(100) NULL',
            'provider_id' => 'VARCHAR(255) NULL',
            'email'       => 'VARCHAR(192) NULL',
            'first_name'  => 'VARCHAR(192) NULL',
            'last_name'   => 'VARCHAR(192) NULL',
            'ip'          => 'VARCHAR(100) NULL',
            'settings'    => 'LONGTEXT NULL',
            'created_at'  => 'TIMESTAMP DEFAULT CURRENT_TIMESTAMP',
            'updated_at'  => 'TIMESTAMP DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP'
        ], [
            ['type' => 'KEY', 'name' => 'idx_user_id', 'columns' => ['user_id']],
        ]);
    }

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