38676-vm/db/add_guaranteed_to_lootboxes.php
2026-02-22 22:20:10 +00:00

26 lines
771 B
PHP

<?php
require_once 'db/config.php';
$db = db();
$sqls = [
"CREATE TABLE IF NOT EXISTS lootbox_guaranteed_items (
id INT AUTO_INCREMENT PRIMARY KEY,
lootbox_id INT NOT NULL,
resource_slug VARCHAR(255) NOT NULL,
quantity_min INT NOT NULL DEFAULT 1,
quantity_max INT NOT NULL DEFAULT 1,
FOREIGN KEY (lootbox_id) REFERENCES lootboxes(id) ON DELETE CASCADE,
FOREIGN KEY (resource_slug) REFERENCES game_resources(slug) ON UPDATE CASCADE ON DELETE CASCADE
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;"
];
foreach ($sqls as $sql) {
try {
$db->exec($sql);
echo "Executed: " . substr($sql, 0, 50) . "...\n";
} catch (PDOException $e) {
echo "Error: " . $e->getMessage() . "\n";
}
}