migrations/Version20220706093516.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 Version20220706093516 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 chat (id INT AUTO_INCREMENT NOT NULL, participant_one_id INT DEFAULT NULL, participant_two_id INT DEFAULT NULL, created_at DATETIME NOT NULL, INDEX IDX_659DF2AA49E67092 (participant_one_id), INDEX IDX_659DF2AA22BA975D (participant_two_id), PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8mb4 COLLATE `utf8mb4_unicode_ci` ENGINE = InnoDB');
  19.         $this->addSql('CREATE TABLE chat_message (id INT AUTO_INCREMENT NOT NULL, chat_id INT DEFAULT NULL, origin_profile_id INT DEFAULT NULL, destiny_profile_id INT DEFAULT NULL, message LONGTEXT NOT NULL, unread TINYINT(1) NOT NULL, created_at DATETIME NOT NULL, INDEX IDX_FAB3FC161A9A7125 (chat_id), INDEX IDX_FAB3FC16752148F5 (origin_profile_id), INDEX IDX_FAB3FC16DDF69D73 (destiny_profile_id), PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8mb4 COLLATE `utf8mb4_unicode_ci` ENGINE = InnoDB');
  20.         $this->addSql('ALTER TABLE chat ADD CONSTRAINT FK_659DF2AA49E67092 FOREIGN KEY (participant_one_id) REFERENCES user_profile (id)');
  21.         $this->addSql('ALTER TABLE chat ADD CONSTRAINT FK_659DF2AA22BA975D FOREIGN KEY (participant_two_id) REFERENCES user_profile (id)');
  22.         $this->addSql('ALTER TABLE chat_message ADD CONSTRAINT FK_FAB3FC161A9A7125 FOREIGN KEY (chat_id) REFERENCES chat (id)');
  23.         $this->addSql('ALTER TABLE chat_message ADD CONSTRAINT FK_FAB3FC16752148F5 FOREIGN KEY (origin_profile_id) REFERENCES user_profile (id)');
  24.         $this->addSql('ALTER TABLE chat_message ADD CONSTRAINT FK_FAB3FC16DDF69D73 FOREIGN KEY (destiny_profile_id) REFERENCES user_profile (id)');
  25.     }
  26.     public function down(Schema $schema): void
  27.     {
  28.         // this down() migration is auto-generated, please modify it to your needs
  29.         $this->addSql('ALTER TABLE chat_message DROP FOREIGN KEY FK_FAB3FC161A9A7125');
  30.         $this->addSql('DROP TABLE chat');
  31.         $this->addSql('DROP TABLE chat_message');
  32.     }
  33. }