migrations/Version20210706051743.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 Version20210706051743 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 invoices_comments_attachments  DROP CONSTRAINT IF EXISTS fk_17d73d2b1b50d8d');
  19.         $this->addSql('DROP SEQUENCE invoices_chats_comments_id_seq CASCADE');
  20.         $this->addSql('CREATE SEQUENCE "invoices_comments_id_seq" INCREMENT BY 1 MINVALUE 1 START 1');
  21.         $this->addSql('CREATE TABLE "invoices_comments" (id INT NOT NULL, invoice_id INT DEFAULT NULL, owner_id INT NOT NULL, created_at TIMESTAMP(0) WITHOUT TIME ZONE NOT NULL, message TEXT NOT NULL, PRIMARY KEY(id))');
  22.         $this->addSql('CREATE INDEX IDX_4190C1882989F1FD ON "invoices_comments" (invoice_id)');
  23.         $this->addSql('CREATE INDEX IDX_4190C1887E3C61F9 ON "invoices_comments" (owner_id)');
  24.         $this->addSql('ALTER TABLE "invoices_comments" ADD CONSTRAINT FK_4190C1882989F1FD FOREIGN KEY (invoice_id) REFERENCES "invoices" (id) NOT DEFERRABLE INITIALLY IMMEDIATE');
  25.         $this->addSql('ALTER TABLE "invoices_comments" ADD CONSTRAINT FK_4190C1887E3C61F9 FOREIGN KEY (owner_id) REFERENCES "users" (id) NOT DEFERRABLE INITIALLY IMMEDIATE');
  26.         $this->addSql('DROP TABLE invoices_chats_comments');
  27.         $this->addSql('ALTER TABLE invoices_comments_attachments DROP CONSTRAINT IF EXISTS FK_17D73D2B1B50D8D');
  28.         $this->addSql('ALTER TABLE invoices_comments_attachments ADD CONSTRAINT FK_17D73D2B1B50D8D FOREIGN KEY (invoice_comment_id) REFERENCES "invoices_comments" (id) NOT DEFERRABLE INITIALLY IMMEDIATE');
  29.     }
  30.     public function down(Schema $schema): void
  31.     {
  32.         // this down() migration is auto-generated, please modify it to your needs
  33.         $this->addSql('ALTER TABLE "invoices_comments_attachments" DROP CONSTRAINT FK_17D73D2B1B50D8D');
  34.         $this->addSql('DROP SEQUENCE "invoices_comments_id_seq" CASCADE');
  35.         $this->addSql('CREATE SEQUENCE invoices_chats_comments_id_seq INCREMENT BY 1 MINVALUE 1 START 1');
  36.         $this->addSql('CREATE TABLE invoices_chats_comments (id INT NOT NULL, invoice_id INT DEFAULT NULL, owner_id INT NOT NULL, created_at TIMESTAMP(0) WITHOUT TIME ZONE NOT NULL, message TEXT NOT NULL, PRIMARY KEY(id))');
  37.         $this->addSql('CREATE INDEX idx_2a5278187e3c61f9 ON invoices_chats_comments (owner_id)');
  38.         $this->addSql('CREATE INDEX idx_2a5278182989f1fd ON invoices_chats_comments (invoice_id)');
  39.         $this->addSql('ALTER TABLE invoices_chats_comments ADD CONSTRAINT fk_2a5278182989f1fd FOREIGN KEY (invoice_id) REFERENCES invoices (id) NOT DEFERRABLE INITIALLY IMMEDIATE');
  40.         $this->addSql('ALTER TABLE invoices_chats_comments ADD CONSTRAINT fk_2a5278187e3c61f9 FOREIGN KEY (owner_id) REFERENCES users (id) NOT DEFERRABLE INITIALLY IMMEDIATE');
  41.         $this->addSql('DROP TABLE "invoices_comments"');
  42.         $this->addSql('ALTER TABLE "invoices_comments_attachments" DROP CONSTRAINT fk_17d73d2b1b50d8d');
  43.         $this->addSql('ALTER TABLE "invoices_comments_attachments" ADD CONSTRAINT fk_17d73d2b1b50d8d FOREIGN KEY (invoice_comment_id) REFERENCES invoices_chats_comments (id) NOT DEFERRABLE INITIALLY IMMEDIATE');
  44.     }
  45. }