<?php

use ZenoChatbot\Framework\Database\Migration\Migration;

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

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

    public function up()
    {
        return $this->create($this->table, [
            'id' => 'BIGINT UNSIGNED AUTO_INCREMENT PRIMARY KEY',
            'name' => 'VARCHAR(255) NULL',
            'email' => 'VARCHAR(255) NULL',
            'user_id' => 'BIGINT UNSIGNED NULL',
            'created_at' => 'TIMESTAMP DEFAULT CURRENT_TIMESTAMP',
            'updated_at' => 'TIMESTAMP DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP'
        ], [
            'INDEX idx_email (email)',
            'INDEX idx_user_id (user_id)',
            'INDEX idx_created_at (created_at)',
            'INDEX idx_email_user_id (email, user_id)',
            'INDEX idx_user_id_created_at (user_id, created_at)'
        ]);
    }

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