Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

BUGFIX: Stabilize doctrine migrations #3519

Draft
wants to merge 2 commits into
base: 7.3
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
9 changes: 7 additions & 2 deletions Neos.Media/Migrations/Mysql/Version20130522131641.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,15 @@ class Version20130522131641 extends AbstractMigration
public function up(Schema $schema): void
{
$this->abortIf($this->connection->getDatabasePlatform()->getName() != "mysql");
$tableNames = $this->sm->listTableNames();

// new tables for Asset, Document, Video, Audio
$this->addSql("CREATE TABLE typo3_media_domain_model_asset (persistence_object_identifier VARCHAR(40) NOT NULL, dtype VARCHAR(255) NOT NULL, resource VARCHAR(40) DEFAULT NULL, title VARCHAR(255) NOT NULL, INDEX IDX_B8306B8EBC91F416 (resource), PRIMARY KEY(persistence_object_identifier)) DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci ENGINE = InnoDB");
$this->addSql("ALTER TABLE typo3_media_domain_model_asset ADD CONSTRAINT FK_B8306B8EBC91F416 FOREIGN KEY (resource) REFERENCES typo3_flow_resource_resource (persistence_object_identifier)");
if (in_array('typo3_flow3_resource_resource', $tableNames, true)) {
$this->addSql("ALTER TABLE typo3_media_domain_model_asset ADD CONSTRAINT FK_B8306B8EBC91F416 FOREIGN KEY (resource) REFERENCES typo3_flow3_resource_resource (persistence_object_identifier)");
} elseif (in_array('typo3_flow_resource_resource', $tableNames, true)) {
$this->addSql("ALTER TABLE typo3_media_domain_model_asset ADD CONSTRAINT FK_B8306B8EBC91F416 FOREIGN KEY (resource) REFERENCES typo3_flow_resource_resource (persistence_object_identifier)");
}

$this->addSql("CREATE TABLE typo3_media_domain_model_document (persistence_object_identifier VARCHAR(40) NOT NULL, PRIMARY KEY(persistence_object_identifier)) DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci ENGINE = InnoDB");
$this->addSql("ALTER TABLE typo3_media_domain_model_document ADD CONSTRAINT FK_F089E2F547A46B0A FOREIGN KEY (persistence_object_identifier) REFERENCES typo3_media_domain_model_asset (persistence_object_identifier) ON DELETE CASCADE");
Expand All @@ -32,7 +37,7 @@ public function up(Schema $schema): void
$this->addSql("INSERT INTO typo3_media_domain_model_asset (persistence_object_identifier, dtype, resource, title) SELECT persistence_object_identifier, 'typo3_media_image', resource, title FROM typo3_media_domain_model_image");

// adjust Image table
$this->addSql("ALTER TABLE typo3_media_domain_model_image DROP FOREIGN KEY typo3_media_domain_model_image_ibfk_1");
$this->addSql("ALTER TABLE typo3_media_domain_model_image DROP FOREIGN KEY IF EXISTS typo3_media_domain_model_image_ibfk_1");
$this->addSql("DROP INDEX IDX_7FA2358DBC91F416 ON typo3_media_domain_model_image");
$this->addSql("ALTER TABLE typo3_media_domain_model_image DROP resource, DROP title");
$this->addSql("ALTER TABLE typo3_media_domain_model_image ADD CONSTRAINT FK_7FA2358D47A46B0A FOREIGN KEY (persistence_object_identifier) REFERENCES typo3_media_domain_model_asset (persistence_object_identifier) ON DELETE CASCADE");
Expand Down
5 changes: 4 additions & 1 deletion Neos.Media/Migrations/Mysql/Version20141118172322.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,10 @@ public function up(Schema $schema): void
$this->addSql("ALTER TABLE typo3_media_domain_model_imagevariant ADD CONSTRAINT FK_758EDEBD55FF4171 FOREIGN KEY (originalasset) REFERENCES typo3_media_domain_model_image (persistence_object_identifier)");
$this->addSql("ALTER TABLE typo3_media_domain_model_imagevariant ADD CONSTRAINT FK_758EDEBD47A46B0A FOREIGN KEY (persistence_object_identifier) REFERENCES typo3_media_domain_model_asset (persistence_object_identifier) ON DELETE CASCADE");
$this->addSql("ALTER TABLE typo3_media_domain_model_thumbnail ADD CONSTRAINT FK_B7CE141455FF4171 FOREIGN KEY (originalasset) REFERENCES typo3_media_domain_model_asset (persistence_object_identifier)");
$this->addSql("ALTER TABLE typo3_media_domain_model_thumbnail ADD CONSTRAINT FK_B7CE1414BC91F416 FOREIGN KEY (resource) REFERENCES typo3_flow_resource_resource (persistence_object_identifier)");
$tableNames = $this->sm->listTableNames();
if (in_array('typo3_flow_resource_resource', $tableNames, true)) {
$this->addSql("ALTER TABLE typo3_typo3_domain_model_media_image ADD CONSTRAINT typo3_typo3_domain_model_media_image_ibfk_1 FOREIGN KEY (flow3_resource_resource) REFERENCES typo3_flow_resource_resource(flow3_persistence_identifier)");
}
$this->addSql("ALTER TABLE typo3_media_domain_model_asset DROP INDEX IDX_B8306B8EBC91F416, ADD UNIQUE INDEX UNIQ_B8306B8EBC91F416 (resource)");
$this->addSql("ALTER TABLE typo3_media_domain_model_image DROP type, DROP imagevariants");
}
Expand Down
4 changes: 2 additions & 2 deletions Neos.Media/Migrations/Mysql/Version20170110130217.php
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ public function up(Schema $schema): void
$this->addSql('DROP INDEX idx_84416fdca76d06e6 ON neos_media_domain_model_adjustment_abstractimageadjustment');
$this->addSql('CREATE INDEX IDX_8B2F26F8A76D06E6 ON neos_media_domain_model_adjustment_abstractimageadjustment (imagevariant)');
$this->addSql('ALTER TABLE neos_media_domain_model_adjustment_abstractimageadjustment ADD CONSTRAINT FK_84416FDCA76D06E6 FOREIGN KEY (imagevariant) REFERENCES neos_media_domain_model_imagevariant (persistence_object_identifier)');
$this->addSql('ALTER TABLE neos_media_domain_model_asset DROP FOREIGN KEY FK_B8306B8EBC91F416');
$this->addSql('ALTER TABLE neos_media_domain_model_asset DROP FOREIGN KEY IF EXISTS FK_B8306B8EBC91F416');
$this->addSql('DROP INDEX uniq_b8306b8ebc91f416 ON neos_media_domain_model_asset');
$this->addSql('CREATE UNIQUE INDEX UNIQ_675F9550BC91F416 ON neos_media_domain_model_asset (resource)');
$this->addSql('ALTER TABLE neos_media_domain_model_asset ADD CONSTRAINT FK_B8306B8EBC91F416 FOREIGN KEY (resource) REFERENCES neos_flow_resourcemanagement_persistentresource (persistence_object_identifier)');
Expand Down Expand Up @@ -76,7 +76,7 @@ public function up(Schema $schema): void
$this->addSql('CREATE INDEX IDX_C4BF979F55FF4171 ON neos_media_domain_model_imagevariant (originalasset)');
$this->addSql('ALTER TABLE neos_media_domain_model_imagevariant ADD CONSTRAINT FK_758EDEBD55FF4171 FOREIGN KEY (originalasset) REFERENCES neos_media_domain_model_image (persistence_object_identifier)');
$this->addSql('ALTER TABLE neos_media_domain_model_thumbnail DROP FOREIGN KEY FK_B7CE141455FF4171');
$this->addSql('ALTER TABLE neos_media_domain_model_thumbnail DROP FOREIGN KEY FK_B7CE1414BC91F416');
$this->addSql('ALTER TABLE neos_media_domain_model_thumbnail DROP FOREIGN KEY IF EXISTS FK_B7CE1414BC91F416');
$this->addSql('DROP INDEX idx_b7ce141455ff4171 ON neos_media_domain_model_thumbnail');
$this->addSql('CREATE INDEX IDX_3A163C4955FF4171 ON neos_media_domain_model_thumbnail (originalasset)');
$this->addSql('DROP INDEX uniq_b7ce1414bc91f416 ON neos_media_domain_model_thumbnail');
Expand Down
7 changes: 6 additions & 1 deletion Neos.Neos/Migrations/Mysql/Version20110919164835.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,12 @@ public function up(Schema $schema): void
$this->abortIf($this->connection->getDatabasePlatform()->getName() != "mysql");

$this->addSql("CREATE TABLE typo3_typo3_domain_model_media_image (flow3_persistence_identifier VARCHAR(40) NOT NULL, flow3_resource_resource VARCHAR(40) DEFAULT NULL, UNIQUE INDEX UNIQ_E5EA82E211FFD19F (flow3_resource_resource), PRIMARY KEY(flow3_persistence_identifier)) DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci ENGINE = InnoDB");
$this->addSql("ALTER TABLE typo3_typo3_domain_model_media_image ADD CONSTRAINT typo3_typo3_domain_model_media_image_ibfk_1 FOREIGN KEY (flow3_resource_resource) REFERENCES typo3_flow3_resource_resource(flow3_persistence_identifier)");
$tableNames = $this->sm->listTableNames();
if (in_array('typo3_flow3_resource_resource', $tableNames, true)) {
$this->addSql("ALTER TABLE typo3_typo3_domain_model_media_image ADD CONSTRAINT typo3_typo3_domain_model_media_image_ibfk_1 FOREIGN KEY (flow3_resource_resource) REFERENCES typo3_flow3_resource_resource(flow3_persistence_identifier)");
} elseif (in_array('typo3_flow_resource_resource', $tableNames, true)) {
$this->addSql("ALTER TABLE typo3_typo3_domain_model_media_image ADD CONSTRAINT typo3_typo3_domain_model_media_image_ibfk_1 FOREIGN KEY (flow3_resource_resource) REFERENCES typo3_flow_resource_resource(flow3_persistence_identifier)");
}
}

/**
Expand Down
16 changes: 11 additions & 5 deletions Neos.Neos/Migrations/Mysql/Version20110923125538.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,16 +17,22 @@ public function up(Schema $schema): void
{
$this->abortIf($this->connection->getDatabasePlatform()->getName() != "mysql");

$this->addSql("ALTER TABLE typo3_typo3_domain_model_domain DROP FOREIGN KEY typo3_typo3_domain_model_domain_ibfk_1");
$this->addSql("DROP INDEX IDX_64D1A917E12C6E67 ON typo3_typo3_domain_model_domain");
$tableNames = $this->sm->listTableNames();

$this->addSql("ALTER TABLE typo3_typo3_domain_model_domain DROP FOREIGN KEY IF EXISTS typo3_typo3_domain_model_domain_ibfk_1");
$this->addSql("DROP INDEX IF EXISTS IDX_64D1A917E12C6E67 ON typo3_typo3_domain_model_domain");
$this->addSql("ALTER TABLE typo3_typo3_domain_model_domain CHANGE typo3_site site VARCHAR(40) DEFAULT NULL");
$this->addSql("ALTER TABLE typo3_typo3_domain_model_domain ADD CONSTRAINT typo3_typo3_domain_model_domain_ibfk_1 FOREIGN KEY (site) REFERENCES typo3_typo3_domain_model_site(flow3_persistence_identifier)");
$this->addSql("CREATE INDEX IDX_F227E8F6694309E4 ON typo3_typo3_domain_model_domain (site)");

$this->addSql("ALTER TABLE typo3_typo3_domain_model_media_image DROP FOREIGN KEY typo3_typo3_domain_model_media_image_ibfk_1");
$this->addSql("ALTER TABLE typo3_typo3_domain_model_media_image DROP FOREIGN KEY IF EXISTS typo3_typo3_domain_model_media_image_ibfk_1");
$this->addSql("DROP INDEX UNIQ_E5EA82E211FFD19F ON typo3_typo3_domain_model_media_image");
$this->addSql("ALTER TABLE typo3_typo3_domain_model_media_image CHANGE flow3_resource_resource resource VARCHAR(40) DEFAULT NULL");
$this->addSql("ALTER TABLE typo3_typo3_domain_model_media_image ADD CONSTRAINT typo3_typo3_domain_model_media_image_ibfk_1 FOREIGN KEY (resource) REFERENCES typo3_flow3_resource_resource(flow3_persistence_identifier)");
if (in_array('typo3_flow3_resource_resource', $tableNames, true)) {
$this->addSql("ALTER TABLE typo3_typo3_domain_model_media_image ADD CONSTRAINT typo3_typo3_domain_model_media_image_ibfk_1 FOREIGN KEY (resource) REFERENCES typo3_flow3_resource_resource(flow3_persistence_identifier)");
} elseif (in_array('typo3_flow_resource_resource', $tableNames, true)) {
$this->addSql("ALTER TABLE typo3_typo3_domain_model_media_image ADD CONSTRAINT typo3_typo3_domain_model_media_image_ibfk_1 FOREIGN KEY (resource) REFERENCES typo3_flow_resource_resource(flow3_persistence_identifier)");
}
$this->addSql("CREATE UNIQUE INDEX UNIQ_E5EA82E2BC91F416 ON typo3_typo3_domain_model_media_image (resource)");

$this->addSql("ALTER TABLE typo3_typo3_domain_model_user DROP FOREIGN KEY typo3_typo3_domain_model_user_ibfk_1");
Expand All @@ -44,7 +50,7 @@ public function down(Schema $schema): void
{
$this->abortIf($this->connection->getDatabasePlatform()->getName() != "mysql");

$this->addSql("ALTER TABLE typo3_typo3_domain_model_domain DROP FOREIGN KEY typo3_typo3_domain_model_domain_ibfk_1");
$this->addSql("ALTER TABLE typo3_typo3_domain_model_domain DROP FOREIGN KEY IF EXISTS typo3_typo3_domain_model_domain_ibfk_1");
$this->addSql("DROP INDEX IDX_F227E8F6694309E4 ON typo3_typo3_domain_model_domain");
$this->addSql("ALTER TABLE typo3_typo3_domain_model_domain CHANGE site typo3_site VARCHAR(40) DEFAULT NULL");
$this->addSql("ALTER TABLE typo3_typo3_domain_model_domain ADD CONSTRAINT typo3_typo3_domain_model_domain_ibfk_1 FOREIGN KEY (typo3_site) REFERENCES typo3_typo3_domain_model_site(flow3_persistence_identifier)");
Expand Down
7 changes: 6 additions & 1 deletion Neos.Neos/Migrations/Mysql/Version20110925123119.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,11 @@ public function down(Schema $schema): void
$this->abortIf($this->connection->getDatabasePlatform()->getName() != "mysql");

$this->addSql("CREATE TABLE typo3_typo3_domain_model_media_image (flow3_persistence_identifier VARCHAR(40) NOT NULL, resource VARCHAR(40) DEFAULT NULL, UNIQUE INDEX UNIQ_E5EA82E2BC91F416 (resource), PRIMARY KEY(flow3_persistence_identifier)) DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci ENGINE = InnoDB");
$this->addSql("ALTER TABLE typo3_typo3_domain_model_media_image ADD CONSTRAINT typo3_typo3_domain_model_media_image_ibfk_1 FOREIGN KEY (resource) REFERENCES typo3_flow3_resource_resource(flow3_persistence_identifier)");
$tableNames = $this->sm->listTableNames();
if (in_array('typo3_flow3_resource_resource', $tableNames, true)) {
$this->addSql("ALTER TABLE typo3_typo3_domain_model_media_image ADD CONSTRAINT typo3_typo3_domain_model_media_image_ibfk_1 FOREIGN KEY (resource) REFERENCES typo3_flow3_resource_resource(flow3_persistence_identifier)");
} elseif (in_array('typo3_flow_resource_resource', $tableNames, true)) {
$this->addSql("ALTER TABLE typo3_typo3_domain_model_media_image ADD CONSTRAINT typo3_typo3_domain_model_media_image_ibfk_1 FOREIGN KEY (resource) REFERENCES typo3_flow_resource_resource(flow3_persistence_identifier)");
}
}
}