app/DoctrineMigrations/Version20201218044542.php line 1

Open in your IDE?
  1. <?php
  2. declare(strict_types=1);
  3. /*
  4. * This file is part of EC-CUBE
  5. *
  6. * Copyright(c) EC-CUBE CO.,LTD. All Rights Reserved.
  7. *
  8. * http://www.ec-cube.co.jp/
  9. *
  10. * For the full copyright and license information, please view the LICENSE
  11. * file that was distributed with this source code.
  12. */
  13. namespace DoctrineMigrations;
  14. use Doctrine\DBAL\Schema\Schema;
  15. use Doctrine\Migrations\AbstractMigration;
  16. /**
  17. * Auto-generated Migration: Please modify to your needs!
  18. */
  19. final class Version20201218044542 extends AbstractMigration
  20. {
  21. public function up(Schema $schema): void
  22. {
  23. $pointExists = $this->connection->fetchOne("SELECT COUNT(*) FROM dtb_csv WHERE csv_type_id = 2 AND field_name = 'point'");
  24. if ($pointExists == 0) {
  25. $sortNo = $this->connection->fetchOne('SELECT MAX(sort_no) + 1 FROM dtb_csv WHERE csv_type_id = 2');
  26. $this->addSql("INSERT INTO dtb_csv (
  27. csv_type_id, creator_id, entity_name, field_name, disp_name, sort_no, enabled, create_date, update_date, discriminator_type
  28. ) VALUES (
  29. 2, null, ?, 'point', 'ポイント', $sortNo, false, CURRENT_TIMESTAMP, CURRENT_TIMESTAMP, 'csv'
  30. )",
  31. ['Eccube\\\\Entity\\\\Customer']);
  32. }
  33. }
  34. public function down(Schema $schema): void
  35. {
  36. // this down() migration is auto-generated, please modify it to your needs
  37. }
  38. }