<?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 Version20221004091331 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 message (id INT AUTO_INCREMENT NOT NULL, sender_id INT DEFAULT NULL, conversation_id INT DEFAULT NULL, created_at DATETIME NOT NULL, type VARCHAR(255) DEFAULT NULL, content LONGTEXT DEFAULT NULL, is_readed TINYINT(1) DEFAULT NULL, INDEX IDX_B6BD307FF624B39D (sender_id), INDEX IDX_B6BD307F9AC0396 (conversation_id), PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8mb4 COLLATE `utf8mb4_unicode_ci` ENGINE = InnoDB');
$this->addSql('ALTER TABLE message ADD CONSTRAINT FK_B6BD307FF624B39D FOREIGN KEY (sender_id) REFERENCES user (id)');
$this->addSql('ALTER TABLE message ADD CONSTRAINT FK_B6BD307F9AC0396 FOREIGN KEY (conversation_id) REFERENCES conversation (id)');
$this->addSql('ALTER TABLE message_file ADD message_id INT DEFAULT NULL');
$this->addSql('ALTER TABLE message_file ADD CONSTRAINT FK_250AADC9537A1329 FOREIGN KEY (message_id) REFERENCES message (id)');
$this->addSql('CREATE INDEX IDX_250AADC9537A1329 ON message_file (message_id)');
}
public function down(Schema $schema): void
{
// this down() migration is auto-generated, please modify it to your needs
$this->addSql('ALTER TABLE message_file DROP FOREIGN KEY FK_250AADC9537A1329');
$this->addSql('ALTER TABLE message DROP FOREIGN KEY FK_B6BD307FF624B39D');
$this->addSql('ALTER TABLE message DROP FOREIGN KEY FK_B6BD307F9AC0396');
$this->addSql('DROP TABLE message');
$this->addSql('DROP INDEX IDX_250AADC9537A1329 ON message_file');
$this->addSql('ALTER TABLE message_file DROP message_id');
}
}