app/DoctrineMigrations/Version20210316120000.php line 1

Open in your IDE?
  1. <?php declare(strict_types=1);
  2. namespace DoctrineMigrations;
  3. use Doctrine\DBAL\Schema\Schema;
  4. use Doctrine\Migrations\AbstractMigration;
  5. /**
  6. * Auto-generated Migration: Please modify to your needs!
  7. */
  8. final class Version20210316120000 extends AbstractMigration
  9. {
  10. public function up(Schema $schema): void
  11. {
  12. // データ存在チェック
  13. $count = $this->connection->fetchOne("SELECT COUNT(*) FROM dtb_block WHERE block_name = 'カレンダー'");
  14. if ($count > 0) {
  15. return;
  16. }
  17. // idを取得する
  18. $id = $this->connection->fetchOne('SELECT MAX(id) FROM dtb_block');
  19. $id++;
  20. $this->addSql("INSERT INTO dtb_block (id, block_name, file_name, use_controller, deletable, create_date, update_date, device_type_id, discriminator_type) VALUES ($id, 'カレンダー', 'calendar', true, false, '2021-03-16 12:00:00', '2021-03-16 12:00:00', 10, 'block')");
  21. }
  22. public function down(Schema $schema): void
  23. {
  24. // this down() migration is auto-generated, please modify it to your needs
  25. }
  26. }