Commit 0b98d6c7 authored by Antony Le Courtes's avatar Antony Le Courtes
Browse files

Merge remote-tracking branch 'origin/master'

parents f87459f3 154c289c
Loading
Loading
Loading
Loading
+5 −1
Changes for admin/actions/test.php: 5 added lines, 1 removed line.
Original line number Diff line number Diff line
<?php

require_once dirname(__DIR__) . '/migration/v18Plafonds.php';

$oa->exec('UnicaenTbl build-procedures');
 No newline at end of file
$mm  = new MigrationManager($oa, new \BddAdmin\Ddl\Ddl(), []);
$v18 = new v18Plafonds($mm);

$v18->before();
 No newline at end of file
+51
Changes for admin/migration/v18Divers.php: 51 added lines, 0 removed lines.
Original line number Diff line number Diff line
<?php





class v18Divers extends AbstractMigration
{
    protected $contexte = self::CONTEXTE_PRE;



    public function description(): string
    {
        return "Migration OSE 17 vers OSE 18";
    }



    public function utile(): bool
    {
        return $this->manager->hasNew('table', 'PLAFOND_PERIMETRE');
    }



    public function action(string $contexte)
    {
        if ($contexte == self::CONTEXTE_PRE) {
            $this->before();
        } else {
            $this->after();
        }
    }



    public function before()
    {
        $bdd = $this->manager->getBdd();
        $c   = $this->manager->getOseAdmin()->getConsole();

        try {
            $bdd->exec("ALTER TABLE TYPE_INTERVENANT DROP CONSTRAINT TYPE_INTERVENANT_CODE_UN");
            $c->msg('Suppression de la contrainte TYPE_INTERVENANT_CODE_UN en prévision de sa recréation');
        } catch (\Exception $e) {
            // rien à faire : la contrainte a déjà du être supprimée
        }
    }

}
 No newline at end of file
+98
Changes for admin/migration/v18Plafonds.php: 98 added lines, 0 removed lines.
Original line number Diff line number Diff line
<?php





class v18Plafonds extends AbstractMigration
{
    protected $contexte = self::CONTEXTE_ALL;



    public function description(): string
    {
        return "Migration des plafonds de OSE 17 vers OSE 18";
    }



    public function utile(): bool
    {
        return $this->manager->hasNew('table', 'PLAFOND_PERIMETRE');
    }



    public function action(string $contexte)
    {
        if ($contexte == self::CONTEXTE_PRE) {
            $this->before();
        } else {
            $this->after();
        }
    }



    public function before()
    {
        $bdd = $this->manager->getBdd();
        $c   = $this->manager->getOseAdmin()->getConsole();

        if (empty($bdd->table()->get('SAVE_V18_STATUT'))) {
            $this->manager->sauvegarderTable('STATUT_INTERVENANT', 'SAVE_V18_STATUT');
            $c->msg('Anciens statuts "STATUT_INTERVENANT" sauvegardés dans "SAVE_V18_STATUT".');
        }

        if (empty($bdd->table()->get('SAVE_V18_STRUCTURE'))) {
            $this->manager->sauvegarderTable('STRUCTURE', 'SAVE_V18_STRUCTURE');
            $c->msg('Anciennes structures "STRUCTURE" sauvegardés dans "SAVE_V18_STRUCTURE".');
        }

        if (empty($bdd->table()->get('SAVE_V18_REFERENTIEL'))) {
            $this->manager->sauvegarderTable('FONCTION_REFERENTIEL', 'SAVE_V18_REFERENTIEL');
            $c->msg('Anciennes fonctions référentielles "FONCTION_REFERENTIEL" sauvegardées dans "SAVE_V18_REFERENTIEL".');
        }

        if (empty($bdd->table()->get('SAVE_V18_PLAFOND_APP'))) {
            $this->manager->sauvegarderTable('PLAFOND_APPLICATION', 'SAVE_V18_PLAFOND_APP');
            $c->msg('Anciens paramétrages des plafonds "PLAFOND_APPLICATION" sauvegardées dans "SAVE_V18_PLAFOND_APP".');
        }

        if (!empty($bdd->table()->get('PLAFOND_APPLICATION'))) {
            $bdd->exec('DROP TABLE PLAFOND_APPLICATION');
            $c->msg('Suppression des anciens paramétrages de plafonds');
        }

        if (empty($bdd->table()->get('SAVE_V18_PLAFOND'))) {
            $this->manager->sauvegarderTable('PLAFOND', 'SAVE_V18_PLAFOND');
            $c->msg('Anciens plafonds "PLAFOND" sauvegardées dans "SAVE_V18_PLAFOND".');
        }

        if (!empty($bdd->table()->get('PLAFOND'))) {
            $bdd->exec('DROP TABLE PLAFOND');
            $c->msg('Suppression des anciens plafonds');
        }
    }



    protected function after()
    {
        
    }



    public function preMigrationIndicateurs()
    {
        $bdd = $this->manager->getBdd();
        $c   = $this->manager->getOseAdmin()->getConsole();

        $c->begin('Préparation à la mise à jour des indicateurs');

        $c->end('Préparation à la migration des indicateurs terminée');
    }

}
 No newline at end of file
+736

File added.

Preview size limit exceeded, changes collapsed.

+4 −1
Changes for admin/src/MigrationManager.php: 4 added lines, 1 removed line.
Original line number Diff line number Diff line
@@ -38,7 +38,6 @@ class MigrationManager
        $this->oseAdmin = $oseAdmin;
        $this->ref      = $ref;
        $this->filtres  = DdlFilters::normalize($filters);
        $this->old      = $oseAdmin->getBdd()->getDdl($filters);
    }


@@ -270,6 +269,10 @@ class MigrationManager

    public function migration(string $context = 'pre', string $action = null)
    {
        if (!$this->old) {
            $this->old = $this->oseAdmin->getBdd()->getDdl($this->filters);
        }

        if (!is_dir($this->getMigrationDir())) return;
        $files = scandir($this->getMigrationDir());
        sort($files);
Loading