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

fix foreign key constraint error when deleting file record related to banner_use_image (fixes #3786) #376

Open
wants to merge 1 commit into
base: old-master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions config/doctrine/schema.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion data/fixtures/000_revision.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
SnsConfig:
current_revision:
name: "OpenPNE_revision"
value: 47
value: 48
32 changes: 32 additions & 0 deletions data/migrations/3.9.0/048_fix_banner_use_image_constraint.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
<?php

/**
* This file is part of the OpenPNE package.
* (c) OpenPNE Project (http://www.openpne.jp/)
*
* For the full copyright and license information, please view the LICENSE
* file and the NOTICE file that were distributed with this source code.
*/

class Revision48_FixBannerUseImageConstraint extends Doctrine_Migration_Base
{
public function up()
{
$this->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',
));
}
}