migrations/Version20140710110709.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 Version20140710110709 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 supplier_stock (id INT AUTO_INCREMENT NOT NULL, supplier_id INT DEFAULT NULL, quantity_on_order INT NOT NULL, units INT NOT NULL, cost_price DOUBLE PRECISION DEFAULT NULL, carriage_price DOUBLE PRECISION DEFAULT NULL, supplier_notes LONGTEXT DEFAULT NULL, stockItem_id INT DEFAULT NULL, INDEX IDX_922D544AEEC75ED7 (stockItem_id), INDEX IDX_922D544A2ADD6D8C (supplier_id), PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8 COLLATE utf8_unicode_ci ENGINE = InnoDB');
  15.         $this->addSql('ALTER TABLE supplier_stock ADD CONSTRAINT FK_922D544AEEC75ED7 FOREIGN KEY (stockItem_id) REFERENCES stock (id) ON DELETE SET NULL');
  16.         $this->addSql('ALTER TABLE supplier_stock ADD CONSTRAINT FK_922D544A2ADD6D8C FOREIGN KEY (supplier_id) REFERENCES supplier (id) ON DELETE SET NULL');
  17.         $this->addSql('ALTER TABLE stock DROP FOREIGN KEY FK_4B3656602ADD6D8C');
  18.         $this->addSql('DROP INDEX IDX_4B3656602ADD6D8C ON stock');
  19.         $this->addSql('ALTER TABLE stock DROP supplier_id, DROP units, DROP order_quantity, DROP cost_price, DROP carriage_price, DROP supplier_notes');
  20.     }
  21.     public function down(Schema $schema): void
  22.     {
  23.         // this down() migration is auto-generated, please modify it to your needs
  24.         $this->abortIf($this->connection->getDatabasePlatform()->getName() != 'mysql'"Migration can only be executed safely on 'mysql'.");
  25.         $this->addSql('DROP TABLE supplier_stock');
  26.         $this->addSql('ALTER TABLE stock ADD supplier_id INT DEFAULT NULL, ADD units INT NOT NULL, ADD order_quantity INT NOT NULL, ADD cost_price DOUBLE PRECISION DEFAULT NULL, ADD carriage_price DOUBLE PRECISION DEFAULT NULL, ADD supplier_notes LONGTEXT DEFAULT NULL');
  27.         $this->addSql('ALTER TABLE stock ADD CONSTRAINT FK_4B3656602ADD6D8C FOREIGN KEY (supplier_id) REFERENCES supplier (id) ON DELETE SET NULL');
  28.         $this->addSql('CREATE INDEX IDX_4B3656602ADD6D8C ON stock (supplier_id)');
  29.     }
  30. }