diff --git a/src/bundle/RepositoryInstaller/Command/InstallPlatformCommand.php b/src/bundle/RepositoryInstaller/Command/InstallPlatformCommand.php index 0011d9d37c..8cdb8239b3 100644 --- a/src/bundle/RepositoryInstaller/Command/InstallPlatformCommand.php +++ b/src/bundle/RepositoryInstaller/Command/InstallPlatformCommand.php @@ -88,7 +88,7 @@ protected function execute(InputInterface $input, OutputInterface $output): int $schemaManager = $this->connection->getSchemaManager(); if (!empty($schemaManager->listTables())) { $io = new SymfonyStyle($input, $output); - if (!$io->confirm('Running this command will delete data in all Ibexa generated tables. Continue?', )) { + if (!$io->confirm('Running this command will delete data in all Ibexa generated tables. Continue?', false)) { return 0; } } diff --git a/src/bundle/RepositoryInstaller/Installer/CoreInstaller.php b/src/bundle/RepositoryInstaller/Installer/CoreInstaller.php index 6b05899ffe..fbfe5c31a0 100644 --- a/src/bundle/RepositoryInstaller/Installer/CoreInstaller.php +++ b/src/bundle/RepositoryInstaller/Installer/CoreInstaller.php @@ -99,9 +99,18 @@ protected function getDropSqlStatementsForExistingSchema( ): array { $existingSchema = $this->db->getSchemaManager()->createSchema(); $statements = []; - // reverse table order for clean-up (due to FKs) - $tables = array_reverse($newSchema->getTables()); - // cleanup pre-existing database + $tables = $newSchema->getTables(); + if ($databasePlatform->supportsForeignKeyConstraints()) { + // cleanup pre-existing database: drop foreign keys + foreach ($tables as $table) { + if ($existingSchema->hasTable($table->getName())) { + foreach ($this->db->getSchemaManager()->listTableForeignKeys($table->getName()) as $foreignKeyConstraint) { + $statements[] = $databasePlatform->getDropForeignKeySQL($foreignKeyConstraint->getName(), $table->getName()); + } + } + } + } + // cleanup pre-existing database: drop tables foreach ($tables as $table) { if ($existingSchema->hasTable($table->getName())) { $statements[] = $databasePlatform->getDropTableSQL($table);