<?php
require_once __DIR__ . '/../../config/db.php';

try {
    $sql = "CREATE TABLE IF NOT EXISTS cliq_payments (
        id INT AUTO_INCREMENT PRIMARY KEY,
        fingerprint VARCHAR(255) NOT NULL,
        reference_code VARCHAR(20) NOT NULL UNIQUE,
        amount DECIMAL(10,2) NOT NULL,
        plan VARCHAR(50) NOT NULL,
        status ENUM('pending', 'paid', 'expired') DEFAULT 'pending',
        created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
        updated_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
        INDEX (reference_code),
        INDEX (fingerprint)
    ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;";

    $pdo->exec($sql);
    echo "Table 'cliq_payments' created or already exists successfully.";
} catch (PDOException $e) {
    echo "Error creating table: " . $e->getMessage();
}
