38676-vm/db/update_unit_rewards_table.php
2026-03-07 18:42:15 +00:00

17 lines
687 B
PHP

<?php
require_once __DIR__ . '/config.php';
$db = db();
try {
// Add lootbox_id column and make resource_id and amount nullable
$db->exec("ALTER TABLE unit_rewards ADD COLUMN lootbox_id INT NULL AFTER action_type");
$db->exec("ALTER TABLE unit_rewards MODIFY COLUMN resource_id INT NULL");
$db->exec("ALTER TABLE unit_rewards MODIFY COLUMN amount INT NULL");
$db->exec("ALTER TABLE unit_rewards ADD CONSTRAINT fk_unit_rewards_lootbox FOREIGN KEY (lootbox_id) REFERENCES lootboxes(id) ON DELETE SET NULL");
echo "Migration completed: unit_rewards table updated.\n";
} catch (PDOException $e) {
echo "Migration info/error: " . $e->getMessage() . "\n";
}