Commit d46081ef authored by Bertrand Gauthier's avatar Bertrand Gauthier
Browse files

[FIX] Synchro : la suppression systématique de la table intermédiaire...

[FIX] Synchro : la suppression systématique de la table intermédiaire temporaire n'était plus optionnelle depuis longtemps.
parent bd4068b6
Loading
Loading
Loading
Loading
+1 −0
Changes for CHANGELOG.md: 1 added line, 0 removed lines.
Original line number Diff line number Diff line
@@ -13,6 +13,7 @@ Changelog
- Migration des lignes de commandes d'import/synchro au format Symfony (lancer `vendor/bin/laminas` pour avoir la liste des commandes).
- Configuration : navigation déplacée dans config/unicaen-db-import.global.php.dist pour ne pas imposer le menu du module.
- Nouveau filtre de valeur de colonne CallableColumnValueFilter.
- [FIX] Synchro : la suppression systématique de la table intermédiaire temporaire n'était plus optionnelle depuis longtemps.
- [FIX] Logs : ils étaient recherchés dans la connection orm_default alors qu'ils se trouvent dans la connection destination de l'import/synchro.
- [FIX] Ajouts de strtolower/strtoupper() faisant défaut.
- [FIX] SQL d'interrogation de la vue différentielle : préfixages oubliés des colonnes de la vue. 
+1 −15
Changes for src/UnicaenDbImport/Domain/Destination.php: 1 added line, 15 removed lines.
Original line number Diff line number Diff line
@@ -76,7 +76,7 @@ class Destination implements DestinationInterface
            $this->getTable(),
            $this->getWhere() ? ' WHERE ' . $this->getWhere() : null,
            $this->usesIntermediateTable ?
                'Via ' . $this->getIntermediateTable() . ' (auto_drop = ' . (int)$this->getIntermediateTableAutoDrop() . ')' :
                'Via ' . $this->getIntermediateTable() :
                null,
        ]));
    }
@@ -211,15 +211,6 @@ class Destination implements DestinationInterface
        return static::INTERMEDIATE_TABLE_NAME_PREFIX . $this->getTable();
    }

    /**
     * @deprecated Suppression de intermediate_table_auto_drop à venir
     * TODO : à supprimer
     */
    public function getIntermediateTableAutoDrop(): bool
    {
        return (bool) $this->config->get('intermediate_table_auto_drop', false);
    }

    public function getLogTable(): string
    {
        return $this->config->get('log_table', DestinationInterface::LOG_TABLE_DEFAULT_NAME);
@@ -281,11 +272,6 @@ class Destination implements DestinationInterface
        $this->config->set('intermediate_table', $intermediateTable);
    }

    public function setIntermediateTableAutoDrop(?bool $intermediateTableAutoDrop): void
    {
        $this->config->set('intermediate_table_auto_drop', $intermediateTableAutoDrop);
    }

    public function setLogTable(?string $logTable): void
    {
        $this->config->set('log_table', $logTable);
+0 −12
Changes for src/UnicaenDbImport/Domain/DestinationInterface.php: 0 added lines, 12 removed lines.
Original line number Diff line number Diff line
@@ -132,13 +132,6 @@ interface DestinationInterface
     */
    public function getIntermediateTable(): string;

    /**
     * Indique si la suppression automatique de la table intermédiaire est activée.
     *
     * @return bool
     */
    public function getIntermediateTableAutoDrop(): bool;

    /**
     * Retourne le nom de la table des logs.
     *
@@ -214,11 +207,6 @@ interface DestinationInterface
     */
    public function setIntermediateTable(?string $intermediateTable): void;

    /**
     * Indique si la suppression automatique de la table intermédiaire est activée.
     */
    public function setIntermediateTableAutoDrop(?bool $intermediateTableAutoDrop): void;

    /**
     * Spécifie le nom de la table des logs.
     */
+0 −18
Changes for src/UnicaenDbImport/Service/Database/DatabaseService.php: 0 added lines, 18 removed lines.
Original line number Diff line number Diff line
@@ -140,24 +140,6 @@ class DatabaseService extends AbstractDatabaseService
        }
    }

    /**
     * @throws \UnicaenDbImport\Service\Exception\DatabaseServiceException
     */
    public function checkIntermediateTableNotExists(string $intermediateTable): void
    {
        try {
            $this->assertTableExistsInDestination($intermediateTable);
        } catch (DatabaseServiceException $e) {
            // :-) la table n'existe pas
            return;
        }

        throw DatabaseServiceException::error(
            "Une table $intermediateTable existe déjà. Veuillez la supprimer ou alors spécifier dans la config " .
            "le nom à utiliser pour générer la table intermédiaire nécessaire à l'import dans la table " .
            $this->destination->getTable());
    }

    /**
     * @throws \UnicaenDbImport\Service\Exception\DatabaseServiceException
     */
+3 −16
Changes for src/UnicaenDbImport/Service/Facade/SynchroFacadeService.php: 3 added lines, 16 removed lines.
Original line number Diff line number Diff line
@@ -52,13 +52,10 @@ class SynchroFacadeService extends AbstractFacadeService

        if ($this->requiresIntermediateTable) {
            $this->fetchSource();

            $intermediateTable = $this->destination->getIntermediateTable();
            if ($this->destination->getIntermediateTableAutoDrop()) {
            $this->logger->info("Suppression de la table intermédiaire $intermediateTable");
            $this->databaseService->dropIntermediateTable($intermediateTable);
            } else {
                $this->databaseService->checkIntermediateTableNotExists($intermediateTable);
            }

            $this->logger->info("Création de la table intermédiaire $intermediateTable");
            $this->databaseService->createIntermediateTable($intermediateTable);
@@ -87,13 +84,10 @@ class SynchroFacadeService extends AbstractFacadeService

        if ($this->requiresIntermediateTable) {
            $this->fetchSource();

            $intermediateTable = $this->destination->getIntermediateTable();
            if ($this->destination->getIntermediateTableAutoDrop()) {
            $this->logger->info("Suppression de la table intermédiaire $intermediateTable");
            $this->databaseService->dropIntermediateTable($intermediateTable);
            } else {
                $this->databaseService->checkIntermediateTableNotExists($intermediateTable);
            }

            $this->logger->info("Création de la table intermédiaire $intermediateTable");
            $this->databaseService->createIntermediateTable($intermediateTable);
@@ -122,13 +116,10 @@ class SynchroFacadeService extends AbstractFacadeService

        if ($this->requiresIntermediateTable) {
            $this->fetchSource();

            $intermediateTable = $this->destination->getIntermediateTable();
            if ($this->destination->getIntermediateTableAutoDrop()) {
            $this->logger->info("Suppression de la table intermédiaire $intermediateTable");
            $this->databaseService->dropIntermediateTable($intermediateTable);
            } else {
                $this->databaseService->checkIntermediateTableNotExists($intermediateTable);
            }

            $this->logger->info("Création de la table intermédiaire $intermediateTable");
            $this->databaseService->createIntermediateTable($intermediateTable);
@@ -168,12 +159,8 @@ class SynchroFacadeService extends AbstractFacadeService
            $this->fetchSource();

            $intermediateTable = $this->destination->getIntermediateTable();
            if ($this->destination->getIntermediateTableAutoDrop()) {
            $this->logger->info("Suppression de la table intermédiaire $intermediateTable");
            $this->databaseService->dropIntermediateTable($intermediateTable);
            } else {
                $this->databaseService->checkIntermediateTableNotExists($intermediateTable);
            }

            $this->logger->info("Création de la table intermédiaire $intermediateTable");
            $this->databaseService->createIntermediateTable($intermediateTable);
Loading