Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

IBX-9617: Fixed DB schema reinstallation #485

Open
wants to merge 6 commits into
base: 4.6
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 5 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
}
Expand Down
12 changes: 11 additions & 1 deletion src/bundle/RepositoryInstaller/Installer/CoreInstaller.php
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,17 @@ protected function getDropSqlStatementsForExistingSchema(
$statements = [];
// reverse table order for clean-up (due to FKs)
$tables = array_reverse($newSchema->getTables());
// cleanup pre-existing database
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);
Expand Down
Loading