feat: add ?reset parameter to migrate.php for clean re-run

Drops all tables (with FK checks disabled) before recreating.
Use: migrate.php?reset=1 or php migrate.php --reset

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
2026-03-10 16:28:42 +02:00
parent b074b7db28
commit 1fa366d3ff

View File

@@ -15,6 +15,21 @@ require_once __DIR__ . '/db.php';
echo "=== Noxus Intra: JSON → MySQL migraatio ===\n\n"; echo "=== Noxus Intra: JSON → MySQL migraatio ===\n\n";
// Reset-tila: ?reset=1 tyhjentää taulut ensin
if (isset($_GET['reset']) || (isset($argv[1]) && $argv[1] === '--reset')) {
echo "0. RESET: Poistetaan vanhat taulut...\n";
$db = getDb();
$db->query("SET FOREIGN_KEY_CHECKS = 0");
$tables = ['files','ticket_rules','mailboxes','changelog','archives','ticket_tags',
'ticket_messages','tickets','leads','customer_connections','customers',
'login_attempts','reset_tokens','config','user_signatures','user_companies','users','company_domains','companies'];
foreach ($tables as $t) {
$db->query("DROP TABLE IF EXISTS `$t`");
}
$db->query("SET FOREIGN_KEY_CHECKS = 1");
echo " ✓ Taulut poistettu\n\n";
}
// 1. Luo taulut // 1. Luo taulut
echo "1. Luodaan tietokantarakenne...\n"; echo "1. Luodaan tietokantarakenne...\n";
try { try {