<?php
declare(strict_types=1);
namespace DoctrineMigrations;
use Doctrine\DBAL\Schema\Schema;
use Doctrine\Migrations\AbstractMigration;
/**
* Auto-generated Migration: Please modify to your needs!
*/
final class Version20220706093516 extends AbstractMigration
{
public function getDescription(): string
{
return '';
}
public function up(Schema $schema): void
{
// this up() migration is auto-generated, please modify it to your needs
$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');
$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');
$this->addSql('ALTER TABLE chat ADD CONSTRAINT FK_659DF2AA49E67092 FOREIGN KEY (participant_one_id) REFERENCES user_profile (id)');
$this->addSql('ALTER TABLE chat ADD CONSTRAINT FK_659DF2AA22BA975D FOREIGN KEY (participant_two_id) REFERENCES user_profile (id)');
$this->addSql('ALTER TABLE chat_message ADD CONSTRAINT FK_FAB3FC161A9A7125 FOREIGN KEY (chat_id) REFERENCES chat (id)');
$this->addSql('ALTER TABLE chat_message ADD CONSTRAINT FK_FAB3FC16752148F5 FOREIGN KEY (origin_profile_id) REFERENCES user_profile (id)');
$this->addSql('ALTER TABLE chat_message ADD CONSTRAINT FK_FAB3FC16DDF69D73 FOREIGN KEY (destiny_profile_id) REFERENCES user_profile (id)');
}
public function down(Schema $schema): void
{
// this down() migration is auto-generated, please modify it to your needs
$this->addSql('ALTER TABLE chat_message DROP FOREIGN KEY FK_FAB3FC161A9A7125');
$this->addSql('DROP TABLE chat');
$this->addSql('DROP TABLE chat_message');
}
}