diff --git a/config/doctrine/schema.yml b/config/doctrine/schema.yml index 4dd5f54ad..7c004a036 100644 --- a/config/doctrine/schema.yml +++ b/config/doctrine/schema.yml @@ -484,8 +484,8 @@ BannerUseImage: banner_id: { type: integer(4), notnull: true, comment: "Banner id" } banner_image_id: { type: integer(4), notnull: true, comment: "BannerImage id" } relations: - Banner: { local: banner_id, foreign: id } - BannerImage: { local: banner_image_id, foreign: id } + Banner: { local: banner_id, foreign: id, onDelete: cascade } + BannerImage: { local: banner_image_id, foreign: id, onDelete: cascade } options: type: INNODB collate: utf8_unicode_ci diff --git a/data/fixtures/000_revision.yml b/data/fixtures/000_revision.yml index 8e23eda1e..97b733ef8 100644 --- a/data/fixtures/000_revision.yml +++ b/data/fixtures/000_revision.yml @@ -1,4 +1,4 @@ SnsConfig: current_revision: name: "OpenPNE_revision" - value: 47 + value: 48 diff --git a/data/migrations/3.9.0/048_fix_banner_use_image_constraint.php b/data/migrations/3.9.0/048_fix_banner_use_image_constraint.php new file mode 100644 index 000000000..fce8c7f48 --- /dev/null +++ b/data/migrations/3.9.0/048_fix_banner_use_image_constraint.php @@ -0,0 +1,32 @@ +dropForeignKey('banner_use_image', 'banner_use_image_banner_id_banner_id'); + $this->dropForeignKey('banner_use_image', 'banner_use_image_banner_image_id_banner_image_id'); + + $this->createForeignKey('banner_use_image', 'banner_use_image_banner_id_banner_id', array( + 'local' => 'banner_id', + 'foreignTable' => 'banner', + 'foreign' => 'id', + 'onDelete' => 'cascade', + )); + + $this->createForeignKey('banner_use_image', 'banner_use_image_banner_image_id_banner_image_id', array( + 'local' => 'banner_image_id', + 'foreignTable' => 'banner_image', + 'foreign' => 'id', + 'onDelete' => 'cascade', + )); + } +}