migrations/Version20211202110827.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 Version20211202110827 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('ALTER TABLE order_item DROP CONSTRAINT fk_52ea1f095da0fb8');
  19. $this->addSql('DROP SEQUENCE cover_id_seq CASCADE');
  20. $this->addSql('DROP TABLE cover');
  21. $this->addSql('DROP INDEX IF EXISTS idx_52ea1f095da0fb8');
  22. $this->addSql('ALTER TABLE order_item ADD cover VARCHAR(255) NOT NULL');
  23. $this->addSql('ALTER TABLE order_item DROP template_id');
  24. $this->addSql('ALTER TABLE widget ALTER covers TYPE TEXT');
  25. $this->addSql('ALTER TABLE widget ALTER covers DROP DEFAULT');
  26. $this->addSql('COMMENT ON COLUMN widget.covers IS \'(DC2Type:array)\'');
  27. }
  28. public function down(Schema $schema): void
  29. {
  30. // this down() migration is auto-generated, please modify it to your needs
  31. $this->addSql('CREATE SCHEMA public');
  32. $this->addSql('CREATE SEQUENCE cover_id_seq INCREMENT BY 1 MINVALUE 1 START 1');
  33. $this->addSql('CREATE TABLE cover (id INT NOT NULL, widget_id UUID NOT NULL, filename VARCHAR(255) NOT NULL, sort_order INT NOT NULL, is_enabled BOOLEAN DEFAULT NULL, PRIMARY KEY(id))');
  34. $this->addSql('CREATE INDEX idx_8d0886c5fbe885e2 ON cover (widget_id)');
  35. $this->addSql('COMMENT ON COLUMN cover.widget_id IS \'(DC2Type:uuid)\'');
  36. $this->addSql('ALTER TABLE cover ADD CONSTRAINT fk_8d0886c5fbe885e2 FOREIGN KEY (widget_id) REFERENCES widget (id) NOT DEFERRABLE INITIALLY IMMEDIATE');
  37. $this->addSql('ALTER TABLE widget ALTER covers TYPE TEXT');
  38. $this->addSql('ALTER TABLE widget ALTER covers DROP DEFAULT');
  39. $this->addSql('COMMENT ON COLUMN widget.covers IS NULL');
  40. $this->addSql('ALTER TABLE order_item ADD template_id INT DEFAULT NULL');
  41. $this->addSql('ALTER TABLE order_item DROP cover');
  42. $this->addSql('ALTER TABLE order_item ADD CONSTRAINT fk_52ea1f095da0fb8 FOREIGN KEY (template_id) REFERENCES cover (id) NOT DEFERRABLE INITIALLY IMMEDIATE');
  43. $this->addSql('CREATE INDEX idx_52ea1f095da0fb8 ON order_item (template_id)');
  44. }
  45. }