diff --git a/Classes/Domain/Model/WorkspaceDetails.php b/Classes/Domain/Model/WorkspaceDetails.php index e161267..2c44b77 100644 --- a/Classes/Domain/Model/WorkspaceDetails.php +++ b/Classes/Domain/Model/WorkspaceDetails.php @@ -40,6 +40,7 @@ class WorkspaceDetails /** * @ORM\OneToOne + * @ORM\JoinColumn(onDelete="CASCADE") * @Flow\Identity * @var Workspace */ diff --git a/Migrations/Mysql/Version20240108102400.php b/Migrations/Mysql/Version20240108102400.php new file mode 100644 index 0000000..9c15174 --- /dev/null +++ b/Migrations/Mysql/Version20240108102400.php @@ -0,0 +1,32 @@ +abortIf($this->connection->getDatabasePlatform()->getName() !== 'mysql', 'Migration can only be executed safely on \'mysql\'.'); + + $this->addSql('ALTER TABLE shel_neos_workspacemodule_domain_model_workspacedetails DROP FOREIGN KEY FK_923CCEA8D940019'); + $this->addSql('ALTER TABLE shel_neos_workspacemodule_domain_model_workspacedetails ADD CONSTRAINT FK_923CCEA8D940019 FOREIGN KEY (workspace) REFERENCES neos_contentrepository_domain_model_workspace (name) ON DELETE CASCADE'); + } + + public function down(Schema $schema): void + { + $this->abortIf($this->connection->getDatabasePlatform()->getName() !== 'mysql', 'Migration can only be executed safely on \'mysql\'.'); + + $this->addSql('ALTER TABLE shel_neos_workspacemodule_domain_model_workspacedetails DROP FOREIGN KEY FK_923CCEA8D940019'); + $this->addSql('ALTER TABLE shel_neos_workspacemodule_domain_model_workspacedetails ADD CONSTRAINT FK_923CCEA8D940019 FOREIGN KEY (workspace) REFERENCES neos_contentrepository_domain_model_workspace (name)'); + } +} diff --git a/Migrations/Postgresql/Version20240108102821.php b/Migrations/Postgresql/Version20240108102821.php new file mode 100644 index 0000000..11e211e --- /dev/null +++ b/Migrations/Postgresql/Version20240108102821.php @@ -0,0 +1,34 @@ +abortIf($this->connection->getDatabasePlatform()->getName() !== 'postgresql', 'Migration can only be executed safely on "postgresql".'); + + $this->addSql('ALTER TABLE shel_neos_workspacemodule_domain_model_workspacedetails DROP CONSTRAINT FK_923CCEA8D940019'); + $this->addSql('ALTER TABLE shel_neos_workspacemodule_domain_model_workspacedetails ALTER workspace DROP NOT NULL'); + $this->addSql('ALTER TABLE shel_neos_workspacemodule_domain_model_workspacedetails ADD CONSTRAINT FK_923CCEA8D940019 FOREIGN KEY (workspace) REFERENCES neos_contentrepository_domain_model_workspace (name) ON DELETE CASCADE NOT DEFERRABLE INITIALLY IMMEDIATE'); + } + + public function down(Schema $schema): void + { + $this->abortIf($this->connection->getDatabasePlatform()->getName() !== 'postgresql', 'Migration can only be executed safely on "postgresql".'); + + $this->addSql('ALTER TABLE shel_neos_workspacemodule_domain_model_workspacedetails DROP CONSTRAINT fk_923ccea8d940019'); + $this->addSql('ALTER TABLE shel_neos_workspacemodule_domain_model_workspacedetails ALTER workspace SET NOT NULL'); + $this->addSql('ALTER TABLE shel_neos_workspacemodule_domain_model_workspacedetails ADD CONSTRAINT fk_923ccea8d940019 FOREIGN KEY (workspace) REFERENCES neos_contentrepository_domain_model_workspace (name) NOT DEFERRABLE INITIALLY IMMEDIATE'); + } +}