<?php
require_once __DIR__ . '/config/database.php';
function sendError($msg, $code) { echo "Error: $msg ($code)\n"; }

$db = getDb();

$queries = [
    "ALTER TABLE addresses ADD COLUMN address_type ENUM('home', 'work', 'other') NOT NULL DEFAULT 'home' AFTER user_id",
    "ALTER TABLE addresses ADD COLUMN full_name VARCHAR(255) NOT NULL AFTER address_type",
    "ALTER TABLE addresses ADD COLUMN phone VARCHAR(20) NOT NULL AFTER full_name",
    "ALTER TABLE addresses ADD COLUMN landmark VARCHAR(255) DEFAULT NULL AFTER address",
    "ALTER TABLE addresses MODIFY COLUMN pincode VARCHAR(10) NOT NULL",
    "ALTER TABLE addresses ADD COLUMN is_default TINYINT(1) NOT NULL DEFAULT 0 AFTER pincode"
];

foreach ($queries as $query) {
    echo "Executing: $query\n";
    if ($db->query($query)) {
        echo "Success\n";
    } else {
        echo "Error: " . $db->error . "\n";
    }
}
