Commit 300d8d88 authored by Antony Le Courtes's avatar Antony Le Courtes
Browse files

Script de pre migration pour renommage colonne.

parent 7cbf5661
Loading
Loading
Loading
Loading
+58
Changes for admin/migration/MigrationDepartement.php: 58 added lines, 0 removed lines.
Original line number Diff line number Diff line
<?php





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



    public function description(): string
    {
        return "Migration de la table DEPARTEMENT";
    }



    public function utile(): bool
    {
        return $this->manager->hasOldColumn('DEPARTEMENT', 'LIBELLE_COURT')
            && $this->manager->hasOldColumn('DEPARTEMENT', 'LIBELLE_LONG')
            && $this->manager->hasNewColumn('DEPARTEMENT', 'LIBELLE');
    }



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



    protected function before()
    {
        $bdd     = $this->manager->getBdd();
        $console = $this->manager->getOseAdmin()->getConsole();
        $console->println("Renommage de la colonne LIBELLE_LONG en LIBELLE dans la table DEPARTEMENT");
        $sql = "ALTER TABLE DEPARTEMENT RENAME COLUMN LIBELLE_LONG TO LIBELLE";
        $console->println($sql);
        $bdd->exec($sql);
        $console->println("Renommage de la colonne effectué");
    }



    protected function after()
    {

    }
}
+57
Changes for admin/migration/MigrationStatutIntervenant.php: 57 added lines, 0 removed lines.
Original line number Diff line number Diff line
<?php





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



    public function description(): string
    {
        return "Migration de la table STATUT_INTERVENANT";
    }



    public function utile(): bool
    {
        return $this->manager->hasOldColumn('PAYS', 'SOURCE_CODE')
            && $this->manager->hasNewColumn('PAYS', 'CODE');
    }



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



    protected function before()
    {
        $bdd     = $this->manager->getBdd();
        $console = $this->manager->getOseAdmin()->getConsole();
        $console->println("Renommage de la colonne SOURCE_CODE en LIBELLE dans la table STATUT_INTERVENANT");
        $sql = "ALTER TABLE STATUT_INTERVENANT RENAME COLUMN SOURCE_CODE TO CODE";
        $console->println($sql);
        $bdd->exec($sql);
        $console->println("Renommage de la colonne effectué");
    }



    protected function after()
    {

    }
}