<?php

use App\Database\Migration;

class CreatePasswordResetsTable extends Migration
{
    public function up(): void
    {
        $this->db->query("
            CREATE TABLE IF NOT EXISTS iw_password_resets (
                id          INT AUTO_INCREMENT PRIMARY KEY,
                email       VARCHAR(255) NOT NULL,
                token       VARCHAR(64)  NOT NULL UNIQUE,
                expires_at  DATETIME     NOT NULL,
                created_at  DATETIME     NOT NULL DEFAULT CURRENT_TIMESTAMP,
                INDEX idx_email (email),
                INDEX idx_token (token)
            ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci
        ");
    }

    public function down(): void
    {
        $this->db->query("DROP TABLE IF EXISTS iw_password_resets");
    }
}
