migrations/Version20220802115310.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 Version20220802115310 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 category (id VARCHAR(255) NOT NULL, name VARCHAR(80) NOT NULL, slug VARCHAR(80) NOT NULL, name_alt VARCHAR(80) DEFAULT NULL, slug_alt VARCHAR(80) DEFAULT NULL, woo_commerce_id INT DEFAULT NULL, woo_commerce_id_alt INT DEFAULT NULL, created_at DATETIME NOT NULL, updated_at DATETIME NOT NULL, PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8mb4 COLLATE `utf8mb4_unicode_ci` ENGINE = InnoDB');
  19. $this->addSql('ALTER TABLE product DROP FOREIGN KEY FK_D34A04AD12469DE2');
  20. $this->addSql('ALTER TABLE product ADD category_id VARCHAR(255) DEFAULT NULL, ADD sale_price DOUBLE PRECISION DEFAULT NULL, ADD featured TINYINT(1) NOT NULL');
  21. $this->addSql('ALTER TABLE product ADD CONSTRAINT FK_D34A04AD12469DE2 FOREIGN KEY (category_id) REFERENCES category (id)');
  22. $this->addSql('CREATE INDEX IDX_D34A04AD12469DE2 ON product (category_id)');
  23. }
  24. public function down(Schema $schema): void
  25. {
  26. // this down() migration is auto-generated, please modify it to your needs
  27. $this->addSql('ALTER TABLE product DROP FOREIGN KEY FK_D34A04AD12469DE2');
  28. $this->addSql('DROP TABLE category');
  29. $this->addSql('ALTER TABLE product DROP FOREIGN KEY FK_D34A04AD44F5D008');
  30. $this->addSql('ALTER TABLE product DROP FOREIGN KEY FK_D34A04AD12469DE2');
  31. $this->addSql('DROP INDEX IDX_D34A04AD12469DE2 ON product');
  32. $this->addSql('ALTER TABLE product DROP category_id, DROP sale_price, DROP featured');
  33. $this->addSql('ALTER TABLE product ADD CONSTRAINT FK_D34A04AD12469DE2 FOREIGN KEY (brand_id) REFERENCES brand (id)');
  34. }
  35. }