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

商品詳細ページにSNS共有ボタンを表示する #4916

Open
wants to merge 6 commits into
base: 4.3
Choose a base branch
from
Open
Changes from 1 commit
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
Prev Previous commit
Next Next commit
マイグレーションファイルの追加
  • Loading branch information
matsuoshi committed Feb 16, 2021
commit c977678776e7ea4697c4132de884eba5b01585e2
38 changes: 38 additions & 0 deletions app/DoctrineMigrations/Version20210216115000.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
<?php declare(strict_types=1);

namespace DoctrineMigrations;

use Doctrine\DBAL\Schema\Schema;
use Doctrine\Migrations\AbstractMigration;

/**
* Auto-generated Migration: Please modify to your needs!
*/
final class Version20210216115000 extends AbstractMigration
{
public function up(Schema $schema): void
{
$blockId = $this->connection->fetchColumn("SELECT id FROM dtb_block WHERE file_name = 'social_buttons'");

// dtb_block に ソーシャルブロックがなければ作成する
if (!$blockId) {
$blockId = $this->connection->fetchColumn('SELECT MAX(id) + 1 FROM dtb_block');

$this->addSql('INSERT INTO dtb_block (
id, device_type_id, block_name, file_name, create_date, update_date, use_controller, deletable, discriminator_type
) VALUES(
?, 10, "ソーシャルボタン", "social_buttons", "2021-02-12 14:00:00", "2021-02-12 14:00:00", 0, 0, "block"
)', [$blockId]);
}
}

public function down(Schema $schema): void
{
// dtb_block に ソーシャルブロックがあれば削除
$blockId = $this->connection->fetchColumn("SELECT id FROM dtb_block WHERE file_name = 'social_buttons'");
if ($blockId > 0) {
$this->addSql('DELETE FROM dtb_block_position WHERE block_id = ?', [$blockId]);
$this->addSql('DELETE FROM dtb_block WHERE file_name = "social_buttons"');
}
}
}