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:
15
migrate.php
15
migrate.php
@@ -15,6 +15,21 @@ require_once __DIR__ . '/db.php';
|
||||
|
||||
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
|
||||
echo "1. Luodaan tietokantarakenne...\n";
|
||||
try {
|
||||
|
||||
Reference in New Issue
Block a user