<?php
include __DIR__ . '/config/database.php';
$db = (new Database())->getConnection();
$queries = [
  "ALTER TABLE cards ADD COLUMN IF NOT EXISTS currency VARCHAR(3) DEFAULT 'USD'",
  "ALTER TABLE cards ADD COLUMN IF NOT EXISTS daily_limit DECIMAL(15,2) DEFAULT 5000.00",
  "ALTER TABLE cards ADD COLUMN IF NOT EXISTS monthly_limit DECIMAL(15,2) DEFAULT 50000.00",
  "ALTER TABLE cards ADD COLUMN IF NOT EXISTS is_virtual TINYINT(1) DEFAULT 0",
  "CREATE TABLE IF NOT EXISTS notifications (id INT AUTO_INCREMENT PRIMARY KEY, user_id INT NOT NULL, title VARCHAR(255) NOT NULL, message TEXT NOT NULL, type ENUM('success','warning','info','error') DEFAULT 'info', is_read TINYINT(1) DEFAULT 0, created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP, FOREIGN KEY (user_id) REFERENCES users(id) ON DELETE CASCADE)",
  "CREATE TABLE IF NOT EXISTS payments (id INT AUTO_INCREMENT PRIMARY KEY, user_id INT NOT NULL, category VARCHAR(50) NOT NULL, provider VARCHAR(100) NOT NULL, account_number VARCHAR(100), amount DECIMAL(15,2) NOT NULL, status ENUM('completed','pending','failed') DEFAULT 'completed', created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP, FOREIGN KEY (user_id) REFERENCES users(id) ON DELETE CASCADE)"
];
foreach($queries as $i => $q) {
  try { $db->exec($q); echo "OK " . ($i+1) . "\n"; }
  catch(Exception $e) { echo "ERR " . ($i+1) . ": " . $e->getMessage() . "\n"; }
}
echo "Done\n";
