migrations/Version20141017194844.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 Version20141017194844 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 estimate_stock (id INT AUTO_INCREMENT NOT NULL, estimate_id INT DEFAULT NULL, stock_id INT DEFAULT NULL, quantity INT DEFAULT NULL, deletedAt DATETIME DEFAULT NULL, INDEX IDX_3C7767AF85F23082 (estimate_id), INDEX IDX_3C7767AFDCD6110 (stock_id), PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8 COLLATE utf8_unicode_ci ENGINE = InnoDB');
  15.         $this->addSql('CREATE TABLE estimate_item (id INT AUTO_INCREMENT NOT NULL, estimate_id INT DEFAULT NULL, item VARCHAR(255) NOT NULL, price NUMERIC(8, 2) DEFAULT NULL, quantity INT DEFAULT NULL, deletedAt DATETIME DEFAULT NULL, INDEX IDX_591A7C1F85F23082 (estimate_id), PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8 COLLATE utf8_unicode_ci ENGINE = InnoDB');
  16.         $this->addSql('ALTER TABLE estimate_stock ADD CONSTRAINT FK_3C7767AF85F23082 FOREIGN KEY (estimate_id) REFERENCES estimate (id)');
  17.         $this->addSql('ALTER TABLE estimate_stock ADD CONSTRAINT FK_3C7767AFDCD6110 FOREIGN KEY (stock_id) REFERENCES stock_item (id)');
  18.         $this->addSql('ALTER TABLE estimate_item ADD CONSTRAINT FK_591A7C1F85F23082 FOREIGN KEY (estimate_id) REFERENCES estimate (id)');
  19.         $this->addSql('ALTER TABLE estimate ADD issued TINYINT(1) NOT NULL, ADD labour_time INT DEFAULT NULL, ADD travel_time INT DEFAULT NULL, CHANGE details details VARCHAR(255) DEFAULT NULL, CHANGE price price NUMERIC(10, 0) DEFAULT NULL, CHANGE awaitingresponse awaiting_response TINYINT(1) NOT NULL');
  20.         $this->addSql('ALTER TABLE estimate_event DROP FOREIGN KEY FK_4CEF3B68A9528F2F');
  21.         $this->addSql('DROP INDEX IDX_4CEF3B68A9528F2F ON estimate_event');
  22.         $this->addSql('ALTER TABLE estimate_event CHANGE estimateevents estimate_id INT DEFAULT NULL');
  23.         $this->addSql('ALTER TABLE estimate_event ADD CONSTRAINT FK_4CEF3B6885F23082 FOREIGN KEY (estimate_id) REFERENCES estimate (id)');
  24.         $this->addSql('CREATE INDEX IDX_4CEF3B6885F23082 ON estimate_event (estimate_id)');
  25.         $this->addSql('ALTER TABLE stock ADD oem_price NUMERIC(8, 2) DEFAULT NULL');
  26.     }
  27.     public function down(Schema $schema): void
  28.     {
  29.         // this down() migration is auto-generated, please modify it to your needs
  30.         $this->abortIf($this->connection->getDatabasePlatform()->getName() != 'mysql'"Migration can only be executed safely on 'mysql'.");
  31.         $this->addSql('DROP TABLE estimate_stock');
  32.         $this->addSql('DROP TABLE estimate_item');
  33.         $this->addSql('ALTER TABLE estimate ADD awaitingResponse TINYINT(1) NOT NULL, DROP awaiting_response, DROP issued, DROP labour_time, DROP travel_time, CHANGE details details VARCHAR(255) NOT NULL, CHANGE price price NUMERIC(10, 0) NOT NULL');
  34.         $this->addSql('ALTER TABLE estimate_event DROP FOREIGN KEY FK_4CEF3B6885F23082');
  35.         $this->addSql('DROP INDEX IDX_4CEF3B6885F23082 ON estimate_event');
  36.         $this->addSql('ALTER TABLE estimate_event CHANGE estimate_id estimateEvents INT DEFAULT NULL');
  37.         $this->addSql('ALTER TABLE estimate_event ADD CONSTRAINT FK_4CEF3B68A9528F2F FOREIGN KEY (estimateEvents) REFERENCES estimate (id)');
  38.         $this->addSql('CREATE INDEX IDX_4CEF3B68A9528F2F ON estimate_event (estimateEvents)');
  39.         $this->addSql('ALTER TABLE stock DROP oem_price');
  40.     }
  41. }