migrations/Version20150929154027.php line 1

Open in your IDE?
  1. <?php
  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. class Version20150929154027 extends AbstractMigration
  9. {
  10.     public function up(Schema $schema): void
  11.     {
  12.         // this up() migration is auto-generated, please modify it to your needs
  13.         $this->abortIf($this->connection->getDatabasePlatform()->getName() != 'mysql''Migration can only be executed safely on \'mysql\'.');
  14.         $this->addSql('CREATE TABLE location (id INT AUTO_INCREMENT NOT NULL, engineer_id INT DEFAULT NULL, type VARCHAR(255) DEFAULT NULL, deletedAt DATETIME DEFAULT NULL, siteAddress_id INT DEFAULT NULL, billingAddress_id INT DEFAULT NULL, UNIQUE INDEX UNIQ_5E9E89CB917C7BCD (siteAddress_id), UNIQUE INDEX UNIQ_5E9E89CB43656FE6 (billingAddress_id), UNIQUE INDEX UNIQ_5E9E89CBF8D8CDF1 (engineer_id), PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8 COLLATE utf8_unicode_ci ENGINE = InnoDB');
  15.         $this->addSql('ALTER TABLE location ADD CONSTRAINT FK_5E9E89CB917C7BCD FOREIGN KEY (siteAddress_id) REFERENCES site_address (id) ON DELETE SET NULL');
  16.         $this->addSql('ALTER TABLE location ADD CONSTRAINT FK_5E9E89CB43656FE6 FOREIGN KEY (billingAddress_id) REFERENCES billing_address (id) ON DELETE SET NULL');
  17.         $this->addSql('ALTER TABLE location ADD CONSTRAINT FK_5E9E89CBF8D8CDF1 FOREIGN KEY (engineer_id) REFERENCES user (id) ON DELETE SET NULL');
  18.         $this->addSql('ALTER TABLE site_address ADD is_stock_location TINYINT(1) DEFAULT NULL');
  19.         $this->addSql('ALTER TABLE stock DROP location');
  20.         $this->addSql('ALTER TABLE stock_item ADD location_id INT DEFAULT NULL, DROP in_stock');
  21.         $this->addSql('ALTER TABLE stock_item ADD CONSTRAINT FK_6017DDA64D218E FOREIGN KEY (location_id) REFERENCES location (id)');
  22.         $this->addSql('CREATE INDEX IDX_6017DDA64D218E ON stock_item (location_id)');
  23.         $this->addSql('ALTER TABLE customer ADD is_internal_customer TINYINT(1) NOT NULL');
  24.         $this->addSql('ALTER TABLE user ADD location_id INT DEFAULT NULL');
  25.         $this->addSql('ALTER TABLE user ADD CONSTRAINT FK_8D93D64964D218E FOREIGN KEY (location_id) REFERENCES location (id)');
  26.         $this->addSql('CREATE INDEX IDX_8D93D64964D218E ON user (location_id)');
  27.         $this->addSql('ALTER TABLE billing_address ADD location_id INT DEFAULT NULL');
  28.         $this->addSql('ALTER TABLE billing_address ADD CONSTRAINT FK_6660E45664D218E FOREIGN KEY (location_id) REFERENCES location (id)');
  29.         $this->addSql('CREATE INDEX IDX_6660E45664D218E ON billing_address (location_id)');
  30.     }
  31.     public function down(Schema $schema): void
  32.     {
  33.         // this down() migration is auto-generated, please modify it to your needs
  34.         $this->abortIf($this->connection->getDatabasePlatform()->getName() != 'mysql''Migration can only be executed safely on \'mysql\'.');
  35.         $this->addSql('ALTER TABLE stock_item DROP FOREIGN KEY FK_6017DDA64D218E');
  36.         $this->addSql('ALTER TABLE user DROP FOREIGN KEY FK_8D93D64964D218E');
  37.         $this->addSql('ALTER TABLE billing_address DROP FOREIGN KEY FK_6660E45664D218E');
  38.         $this->addSql('DROP TABLE location');
  39.         $this->addSql('DROP INDEX IDX_6660E45664D218E ON billing_address');
  40.         $this->addSql('ALTER TABLE billing_address DROP location_id');
  41.         $this->addSql('ALTER TABLE customer DROP is_internal_customer');
  42.         $this->addSql('ALTER TABLE site_address DROP is_stock_location');
  43.         $this->addSql('ALTER TABLE stock ADD location VARCHAR(50) DEFAULT NULL');
  44.         $this->addSql('DROP INDEX IDX_6017DDA64D218E ON stock_item');
  45.         $this->addSql('ALTER TABLE stock_item ADD in_stock TINYINT(1) NOT NULL, DROP location_id');
  46.         $this->addSql('DROP INDEX IDX_8D93D64964D218E ON user');
  47.         $this->addSql('ALTER TABLE user DROP location_id');
  48.     }
  49. }