migrations\Version20210719204520.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 Version20210719204520 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->addSql('CREATE TABLE visitation (id INT AUTO_INCREMENT NOT NULL, parking_slot_id INT NOT NULL, company_id INT NOT NULL, created_by INT NOT NULL, `from` DATETIME NOT NULL, `to` DATETIME NOT NULL, gate_open_from DATETIME DEFAULT NULL, gate_open_to DATETIME DEFAULT NULL, first_name VARCHAR(40) NOT NULL, last_name VARCHAR(40) NOT NULL, email VARCHAR(40) NOT NULL, car_plate VARCHAR(40) NOT NULL, internal_contact VARCHAR(40) NOT NULL, visitation_place VARCHAR(40) NOT NULL, price DOUBLE PRECISION NOT NULL, is_cancelled TINYINT(1) NOT NULL, created_at DATETIME NOT NULL, updated_at DATETIME NOT NULL, INDEX IDX_B39D86AD70FE946 (parking_slot_id), INDEX IDX_B39D86A979B1AD6 (company_id), INDEX IDX_B39D86ADE12AB56 (created_by), PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8mb4 COLLATE `utf8mb4_unicode_ci` ENGINE = InnoDB');
  19.         $this->addSql('ALTER TABLE visitation ADD CONSTRAINT FK_B39D86AD70FE946 FOREIGN KEY (parking_slot_id) REFERENCES parkingslot (id)');
  20.         $this->addSql('ALTER TABLE visitation ADD CONSTRAINT FK_B39D86A979B1AD6 FOREIGN KEY (company_id) REFERENCES company (id)');
  21.         $this->addSql('ALTER TABLE visitation ADD CONSTRAINT FK_B39D86ADE12AB56 FOREIGN KEY (created_by) REFERENCES user (id)');
  22.         $this->addSql('ALTER TABLE parkingslot ADD company_id INT DEFAULT NULL, ADD is_active TINYINT(1) NOT NULL');
  23.         $this->addSql('ALTER TABLE parkingslot ADD CONSTRAINT FK_72DCE8D5979B1AD6 FOREIGN KEY (company_id) REFERENCES company (id)');
  24.         $this->addSql('CREATE INDEX IDX_72DCE8D5979B1AD6 ON parkingslot (company_id)');
  25.     }
  26.     public function down(Schema $schema): void
  27.     {
  28.         // this down() migration is auto-generated, please modify it to your needs
  29.         $this->addSql('DROP TABLE visitation');
  30.         $this->addSql('ALTER TABLE parkingslot DROP FOREIGN KEY FK_72DCE8D5979B1AD6');
  31.         $this->addSql('DROP INDEX IDX_72DCE8D5979B1AD6 ON parkingslot');
  32.         $this->addSql('ALTER TABLE parkingslot DROP company_id, DROP is_active');
  33.     }
  34. }