migrations/Version20200124183550.php line 1

Open in your IDE?
  1. <?php
  2. declare(strict_types=1);
  3. namespace DoctrineMigrations;
  4. use Doctrine\DBAL\Schema\Schema;
  5. use Doctrine\Migrations\AbstractMigration;
  6. /**
  7.  * Auto-generated Migration: Please modify to your needs!
  8.  */
  9. final class Version20200124183550 extends AbstractMigration
  10. {
  11.     public function getDescription() : string
  12.     {
  13.         return '';
  14.     }
  15.     public function up(Schema $schema) : void
  16.     {
  17.         // this up() migration is auto-generated, please modify it to your needs
  18.         $this->abortIf($this->connection->getDatabasePlatform()->getName() !== 'mysql''Migration can only be executed safely on \'mysql\'.');
  19.         $this->addSql('CREATE TABLE resource_email_template (resource_id INT NOT NULL, email_template_id INT NOT NULL, INDEX IDX_EE488B6989329D25 (resource_id), INDEX IDX_EE488B69131A730F (email_template_id), PRIMARY KEY(resource_id, email_template_id)) DEFAULT CHARACTER SET utf8mb4 COLLATE `utf8mb4_unicode_ci` ENGINE = InnoDB');
  20.         $this->addSql('CREATE TABLE email_template (id INT AUTO_INCREMENT NOT NULL, recipient VARCHAR(128) NOT NULL, subject VARCHAR(255) NOT NULL, template LONGTEXT NOT NULL, name VARCHAR(255) NOT NULL, PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8mb4 COLLATE `utf8mb4_unicode_ci` ENGINE = InnoDB');
  21.         $this->addSql('ALTER TABLE resource_email_template ADD CONSTRAINT FK_EE488B6989329D25 FOREIGN KEY (resource_id) REFERENCES resource (id) ON DELETE CASCADE');
  22.         $this->addSql('ALTER TABLE resource_email_template ADD CONSTRAINT FK_EE488B69131A730F FOREIGN KEY (email_template_id) REFERENCES email_template (id) ON DELETE CASCADE');
  23.         $this->addSql('INSERT INTO email_template (recipient, subject, template, name) VALUES (\'{{ouEmail}}\', \'Enquiry: {{resourcesText}}\', \'<p>From: {{booking.customer.displayName}}<br />
  24. Resource(s): {{resourcesText}}<br />
  25. Email: {{booking.customer.email}}<br />
  26. Mobile: {{booking.customer.telephone}}<br />
  27. Date: {{ booking.start | date(&#39;d-M-Y&#39;) }}</p>
  28. <p>{{ booking.notes|nl2br }}</p>
  29. <p>Go to the Dashboard: <a href=\"{{ homeUrl }}\">{{ homeUrl }}</a></p>
  30. <p>Go to the Enquiry: <a href=\"{{ bookingUrl }}\">{{ bookingUrl }}</a></p>\', \'Booking notification\')');
  31.     }
  32.     public function down(Schema $schema) : void
  33.     {
  34.         // this down() migration is auto-generated, please modify it to your needs
  35.         $this->abortIf($this->connection->getDatabasePlatform()->getName() !== 'mysql''Migration can only be executed safely on \'mysql\'.');
  36.         $this->addSql('ALTER TABLE resource_email_template DROP FOREIGN KEY FK_EE488B69131A730F');
  37.         $this->addSql('DROP TABLE resource_email_template');
  38.         $this->addSql('DROP TABLE email_template');
  39.     }
  40. }