diff --git a/install.php b/install.php index 942f4ce..49786a8 100644 --- a/install.php +++ b/install.php @@ -28,6 +28,8 @@ function runSqlFile($pdo, $filePath) { strpos($msg, 'Duplicate key name') !== false || strpos($msg, 'Duplicate entry') !== false || strpos($msg, "Can't DROP") !== false || + strpos($msg, "Cannot drop index") !== false || + strpos($msg, "needed in a foreign key constraint") !== false || strpos($msg, 'check that column/key exists') !== false || strpos($msg, 'Unknown table') !== false ) { @@ -111,7 +113,9 @@ function has_permission(\$action, \$page = null, \$user_id = null) { file_put_contents(__DIR__ . '/db/config.php', $configContent); // Run initial schema - $migrations = glob(__DIR__ . '/db/migrations/*.sql'); sort($migrations); foreach ($migrations as $migration) { runSqlFile($pdo, $migration); } + $pdo->exec("SET FOREIGN_KEY_CHECKS = 0;"); + $migrations = glob(__DIR__ . "/db/migrations/*.sql"); sort($migrations); foreach ($migrations as $migration) { runSqlFile($pdo, $migration); } + $pdo->exec("SET FOREIGN_KEY_CHECKS = 1;"); $_SESSION['db_configured'] = true; header("Location: install.php?step=3");