From 53ba5c479b5f089b25623053ba8bc08a3fddd3a5 Mon Sep 17 00:00:00 2001 From: Stefan Hagspiel Date: Tue, 27 Aug 2024 08:53:56 +0200 Subject: [PATCH] fix migration and installer --- UPGRADE.md | 3 +++ src/Migrations/Version20240819150642.php | 9 +++++++-- src/Tool/Install.php | 6 ++++++ 3 files changed, 16 insertions(+), 2 deletions(-) diff --git a/UPGRADE.md b/UPGRADE.md index 8a33647f..30525bf0 100644 --- a/UPGRADE.md +++ b/UPGRADE.md @@ -1,5 +1,8 @@ # Upgrade Notes +## 5.1.1 +- **[BUGFIX]** Fix Migration and Installer + ## 5.1.0 - **[SECURITY FEATURE]** Double-Opt-In Feature, read more about it [here](./docs/04_DoubleOptIn.md) - **[SECURITY FEATURE]** Email Checker Validator [#471](https://github.com/dachcom-digital/pimcore-formbuilder/issues/471), read more about it [here](./docs/03_SpamProtection.md#email-checker) diff --git a/src/Migrations/Version20240819150642.php b/src/Migrations/Version20240819150642.php index 6e7698a7..c110748d 100644 --- a/src/Migrations/Version20240819150642.php +++ b/src/Migrations/Version20240819150642.php @@ -24,11 +24,16 @@ public function up(Schema $schema): void $installer = $this->container->get(Install::class); $installer->updateTranslations(); - $this->addSql('ALTER TABLE formbuilder_forms DROP mailLayout;'); + if ($schema->getTable('formbuilder_forms')->hasColumn('mailLayout')) { + $this->addSql('ALTER TABLE formbuilder_forms DROP mailLayout;'); + } + + if ($schema->hasTable('formbuilder_double_opt_in_session')) { + return; + } $this->addSql('CREATE TABLE formbuilder_double_opt_in_session (token BINARY(16) NOT NULL COMMENT "(DC2Type:uuid)", form_definition INT DEFAULT NULL, email VARCHAR(190) NOT NULL, additional_data LONGTEXT DEFAULT NULL COMMENT "(DC2Type:array)", dispatch_location LONGTEXT DEFAULT NULL, applied TINYINT(1) DEFAULT 0 NOT NULL, creationDate DATETIME NOT NULL, INDEX IDX_88815C4F61F7634C (form_definition), INDEX token_form (token, form_definition, applied), UNIQUE INDEX email_form_definition (email, form_definition, applied), PRIMARY KEY(token)) DEFAULT CHARACTER SET UTF8MB4 COLLATE `utf8mb4_general_ci` ENGINE = InnoDB;'); $this->addSql('ALTER TABLE formbuilder_double_opt_in_session ADD CONSTRAINT FK_88815C4F61F7634C FOREIGN KEY (form_definition) REFERENCES formbuilder_forms (id) ON DELETE CASCADE;'); - } public function down(Schema $schema): void diff --git a/src/Tool/Install.php b/src/Tool/Install.php index ab9b8a2b..f78cda24 100644 --- a/src/Tool/Install.php +++ b/src/Tool/Install.php @@ -2,6 +2,7 @@ namespace FormBuilderBundle\Tool; +use FormBuilderBundle\Migrations\Version20240819150642; use Pimcore\Extension\Bundle\Installer\Exception\InstallationException; use Pimcore\Extension\Bundle\Installer\SettingsStoreAwareInstaller; use Pimcore\Model\Asset; @@ -27,6 +28,11 @@ public function install(): void parent::install(); } + public function getLastMigrationVersionClassName(): ?string + { + return Version20240819150642::class; + } + public function updateTranslations(): void { $this->installTranslations();