From 525377330d54e9e28f522d401c1fe3d9b0257a95 Mon Sep 17 00:00:00 2001 From: Steeve TITECA Date: Tue, 22 Dec 2020 16:42:53 +0100 Subject: [PATCH] add onDelete cascade on foreign key constraint between MenuUpdate and Scope --- .../Schema/OroCommerceMenuBundleInstaller.php | 5 +-- .../Schema/v1_8/AddScopeToMenuUpdateTable.php | 36 +++++++++++++++++++ 2 files changed, 39 insertions(+), 2 deletions(-) create mode 100644 src/Oro/Bundle/CommerceMenuBundle/Migrations/Schema/v1_8/AddScopeToMenuUpdateTable.php diff --git a/src/Oro/Bundle/CommerceMenuBundle/Migrations/Schema/OroCommerceMenuBundleInstaller.php b/src/Oro/Bundle/CommerceMenuBundle/Migrations/Schema/OroCommerceMenuBundleInstaller.php index 0da178377..61aaab4e5 100644 --- a/src/Oro/Bundle/CommerceMenuBundle/Migrations/Schema/OroCommerceMenuBundleInstaller.php +++ b/src/Oro/Bundle/CommerceMenuBundle/Migrations/Schema/OroCommerceMenuBundleInstaller.php @@ -29,7 +29,7 @@ class OroCommerceMenuBundleInstaller implements */ public function getMigrationVersion() { - return 'v1_7'; + return 'v1_8'; } /** @@ -188,7 +188,8 @@ protected function addOroCommerceMenuUpdateForeignKeys(Schema $schema) $table->addForeignKeyConstraint( $schema->getTable('oro_scope'), ['scope_id'], - ['id'] + ['id'], + ['onUpdate' => null, 'onDelete' => 'CASCADE'] ); $table->addForeignKeyConstraint( $schema->getTable('oro_web_catalog_content_node'), diff --git a/src/Oro/Bundle/CommerceMenuBundle/Migrations/Schema/v1_8/AddScopeToMenuUpdateTable.php b/src/Oro/Bundle/CommerceMenuBundle/Migrations/Schema/v1_8/AddScopeToMenuUpdateTable.php new file mode 100644 index 000000000..1749674b8 --- /dev/null +++ b/src/Oro/Bundle/CommerceMenuBundle/Migrations/Schema/v1_8/AddScopeToMenuUpdateTable.php @@ -0,0 +1,36 @@ +addOroCommerceMenuUpdateForeignKeys($schema); + } + + /** + * Add oro_commerce_menu_upd foreign keys. + * + * @param Schema $schema + */ + protected function addOroCommerceMenuUpdateForeignKeys(Schema $schema) + { + $table = $schema->getTable('oro_commerce_menu_upd'); + $table->addForeignKeyConstraint( + $schema->getTable('oro_scope'), + ['scope_id'], + ['id'], + ['onUpdate' => null, 'onDelete' => 'CASCADE'] + ); + } +}