migrations/Version20151009104255.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 Version20151009104255 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 stock_transaction (id INT AUTO_INCREMENT NOT NULL, job_id INT DEFAULT NULL, date DATETIME NOT NULL, createdAt DATETIME NOT NULL, updatedAt DATETIME NOT NULL, deletedAt DATETIME DEFAULT NULL, quantity INT NOT NULL, purchaseOrder_id INT DEFAULT NULL, transactionCategory_id INT DEFAULT NULL, INDEX IDX_ADF9A3E5BE04EA9 (job_id), INDEX IDX_ADF9A3E51B7B246A (purchaseOrder_id), INDEX IDX_ADF9A3E51807D5FC (transactionCategory_id), PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8 COLLATE utf8_unicode_ci ENGINE = InnoDB');
  15.         $this->addSql('CREATE TABLE stock_stocktransaction (stock_id INT NOT NULL, stocktransaction_id INT NOT NULL, INDEX IDX_1E053800DCD6110 (stock_id), INDEX IDX_1E05380040FA1C5 (stocktransaction_id), PRIMARY KEY(stock_id, stocktransaction_id)) DEFAULT CHARACTER SET utf8 COLLATE utf8_unicode_ci ENGINE = InnoDB');
  16.         $this->addSql('CREATE TABLE transaction_category (id INT AUTO_INCREMENT NOT NULL, type VARCHAR(255) NOT NULL, createdAt DATETIME NOT NULL, updatedAt DATETIME NOT NULL, deletedAt DATETIME DEFAULT NULL, PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8 COLLATE utf8_unicode_ci ENGINE = InnoDB');
  17.         $this->addSql('ALTER TABLE stock_transaction ADD CONSTRAINT FK_ADF9A3E5BE04EA9 FOREIGN KEY (job_id) REFERENCES job (id)');
  18.         $this->addSql('ALTER TABLE stock_transaction ADD CONSTRAINT FK_ADF9A3E51B7B246A FOREIGN KEY (purchaseOrder_id) REFERENCES purchase_order (id)');
  19.         $this->addSql('ALTER TABLE stock_transaction ADD CONSTRAINT FK_ADF9A3E51807D5FC FOREIGN KEY (transactionCategory_id) REFERENCES transaction_category (id)');
  20.         $this->addSql('ALTER TABLE stock_stocktransaction ADD CONSTRAINT FK_1E053800DCD6110 FOREIGN KEY (stock_id) REFERENCES stock (id) ON DELETE CASCADE');
  21.         $this->addSql('ALTER TABLE stock_stocktransaction ADD CONSTRAINT FK_1E05380040FA1C5 FOREIGN KEY (stocktransaction_id) REFERENCES stock_transaction (id) ON DELETE CASCADE');
  22.     }
  23.     public function down(Schema $schema): void
  24.     {
  25.         // this down() migration is auto-generated, please modify it to your needs
  26.         $this->abortIf($this->connection->getDatabasePlatform()->getName() != 'mysql''Migration can only be executed safely on \'mysql\'.');
  27.         $this->addSql('ALTER TABLE stock_stocktransaction DROP FOREIGN KEY FK_1E05380040FA1C5');
  28.         $this->addSql('ALTER TABLE stock_transaction DROP FOREIGN KEY FK_ADF9A3E51807D5FC');
  29.         $this->addSql('DROP TABLE stock_transaction');
  30.         $this->addSql('DROP TABLE stock_stocktransaction');
  31.         $this->addSql('DROP TABLE transaction_category');
  32.     }
  33. }