"Fossies" - the Fresh Open Source Software Archive

Member "neos-development-collection-7.0.1/Neos.Media/Migrations/Postgresql/Version20190314150745.php" (23 Feb 2021, 2510 Bytes) of package /linux/www/neos-development-collection-7.0.1.tar.gz:


As a special service "Fossies" has tried to format the requested source page into HTML format using (guessed) PHP source code syntax highlighting (style: standard) with prefixed line numbers and code folding option. Alternatively you can here view or download the uninterpreted source code file. For more information about "Version20190314150745.php" see the Fossies "Dox" file reference documentation.

    1 <?php
    2 namespace Neos\Flow\Persistence\Doctrine\Migrations;
    3 
    4 use Doctrine\Migrations\AbstractMigration;
    5 use Doctrine\DBAL\Schema\Schema;
    6 
    7 /**
    8  * Introduce variant presets
    9  */
   10 class Version20190314150745 extends AbstractMigration
   11 {
   12 
   13     /**
   14      * @return string
   15      */
   16     public function getDescription(): string 
   17     {
   18         return 'Introduce variant presets';
   19     }
   20 
   21     /**
   22      * @param Schema $schema
   23      * @return void
   24      * @throws \Doctrine\DBAL\DBALException
   25      * @throws \Doctrine\DBAL\Migrations\AbortMigrationException
   26      */
   27     public function up(Schema $schema): void 
   28     {
   29         $this->abortIf($this->connection->getDatabasePlatform()->getName() != 'postgresql', 'Migration can only be executed safely on "postgresql".');
   30 
   31         // It is now safe the remove the default value from the database schema, as we only needed it during migration of earlier Neos versions:
   32         $this->addSql('ALTER TABLE neos_media_domain_model_asset ALTER assetsourceidentifier DROP DEFAULT');
   33         $this->addSql('ALTER TABLE neos_media_domain_model_asset ALTER assetsourceidentifier SET NOT NULL');
   34 
   35         // Add Doctrine hint for DateTimeImmutable:
   36         $this->addSql('COMMENT ON COLUMN neos_media_domain_model_importedasset.importedat IS \'(DC2Type:datetime_immutable)\'');
   37 
   38         // Introduce variant preset fields:
   39         $this->addSql('ALTER TABLE neos_media_domain_model_imagevariant ADD presetidentifier VARCHAR(255) DEFAULT NULL');
   40         $this->addSql('ALTER TABLE neos_media_domain_model_imagevariant ADD presetvariantname VARCHAR(255) DEFAULT NULL');
   41     }
   42 
   43     /**
   44      * @param Schema $schema
   45      * @return void
   46      * @throws \Doctrine\DBAL\DBALException
   47      * @throws \Doctrine\DBAL\Migrations\AbortMigrationException
   48      */
   49     public function down(Schema $schema): void 
   50     {
   51         $this->abortIf($this->connection->getDatabasePlatform()->getName() != 'postgresql', 'Migration can only be executed safely on "postgresql".');
   52         
   53         $this->addSql('ALTER TABLE neos_media_domain_model_asset ALTER assetsourceidentifier SET DEFAULT \'neos\'');
   54         $this->addSql('ALTER TABLE neos_media_domain_model_asset ALTER assetsourceidentifier DROP NOT NULL');
   55         $this->addSql('ALTER TABLE neos_media_domain_model_imagevariant DROP presetidentifier');
   56         $this->addSql('ALTER TABLE neos_media_domain_model_imagevariant DROP presetvariantname');
   57         $this->addSql('COMMENT ON COLUMN neos_media_domain_model_importedasset.importedat IS NULL');
   58     }
   59 }