<?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 Version20240909123417 extends AbstractMigration
{
public function getDescription(): string
{
return 'Database initialization';
}
public function up(Schema $schema): void
{
// this up() migration is auto-generated, please modify it to your needs
$this->addSql('CREATE SEQUENCE active_id_seq INCREMENT BY 1 MINVALUE 1 START 1');
$this->addSql('CREATE SEQUENCE conversation_id_seq INCREMENT BY 1 MINVALUE 1 START 1');
$this->addSql('CREATE SEQUENCE conversation_notification_id_seq INCREMENT BY 1 MINVALUE 1 START 1');
$this->addSql('CREATE SEQUENCE help_id_seq INCREMENT BY 1 MINVALUE 1 START 1');
$this->addSql('CREATE SEQUENCE message_id_seq INCREMENT BY 1 MINVALUE 1 START 1');
$this->addSql('CREATE SEQUENCE mobile_id_seq INCREMENT BY 1 MINVALUE 1 START 1');
$this->addSql('CREATE SEQUENCE tag_id_seq INCREMENT BY 1 MINVALUE 1 START 1');
$this->addSql('CREATE SEQUENCE tag_user_id_seq INCREMENT BY 1 MINVALUE 1 START 1');
$this->addSql('CREATE SEQUENCE "user_id_seq" INCREMENT BY 1 MINVALUE 1 START 1');
$this->addSql('CREATE TABLE active (id INT NOT NULL, PRIMARY KEY(id))');
$this->addSql('CREATE TABLE conversation (id INT NOT NULL, created_at TIMESTAMP(0) WITHOUT TIME ZONE NOT NULL, PRIMARY KEY(id))');
$this->addSql('CREATE TABLE conversation_user (conversation_id INT NOT NULL, user_id INT NOT NULL, PRIMARY KEY(conversation_id, user_id))');
$this->addSql('CREATE INDEX IDX_5AECB5559AC0396 ON conversation_user (conversation_id)');
$this->addSql('CREATE INDEX IDX_5AECB555A76ED395 ON conversation_user (user_id)');
$this->addSql('CREATE TABLE conversation_notification (id INT NOT NULL, conversation_id INT NOT NULL, _user_id INT NOT NULL, count INT NOT NULL, PRIMARY KEY(id))');
$this->addSql('CREATE INDEX IDX_EFBF188B9AC0396 ON conversation_notification (conversation_id)');
$this->addSql('CREATE INDEX IDX_EFBF188BD32632E8 ON conversation_notification (_user_id)');
$this->addSql('CREATE TABLE help (id INT NOT NULL, display VARCHAR(255) NOT NULL, msg VARCHAR(255) NOT NULL, actif BOOLEAN NOT NULL, PRIMARY KEY(id))');
$this->addSql('CREATE TABLE message (id INT NOT NULL, author_id INT NOT NULL, conversation_id INT DEFAULT NULL, message TEXT NOT NULL, created_at TIMESTAMP(0) WITHOUT TIME ZONE NOT NULL, is_post BOOLEAN DEFAULT NULL, updated_at TIMESTAMP(0) WITHOUT TIME ZONE NOT NULL, abuse BOOLEAN DEFAULT NULL, PRIMARY KEY(id))');
$this->addSql('CREATE INDEX IDX_B6BD307FF675F31B ON message (author_id)');
$this->addSql('CREATE INDEX IDX_B6BD307F9AC0396 ON message (conversation_id)');
$this->addSql('CREATE TABLE message_tag (message_id INT NOT NULL, tag_id INT NOT NULL, PRIMARY KEY(message_id, tag_id))');
$this->addSql('CREATE INDEX IDX_2ABC3D6F537A1329 ON message_tag (message_id)');
$this->addSql('CREATE INDEX IDX_2ABC3D6FBAD26311 ON message_tag (tag_id)');
$this->addSql('CREATE TABLE message_user (message_id INT NOT NULL, user_id INT NOT NULL, PRIMARY KEY(message_id, user_id))');
$this->addSql('CREATE INDEX IDX_24064D90537A1329 ON message_user (message_id)');
$this->addSql('CREATE INDEX IDX_24064D90A76ED395 ON message_user (user_id)');
$this->addSql('CREATE TABLE mobile (id INT NOT NULL, user_mobile_id INT DEFAULT NULL, created_at TIMESTAMP(0) WITHOUT TIME ZONE NOT NULL, token VARCHAR(255) NOT NULL, active BOOLEAN DEFAULT NULL, PRIMARY KEY(id))');
$this->addSql('CREATE INDEX IDX_3C7323E0B8E6CFAF ON mobile (user_mobile_id)');
$this->addSql('CREATE TABLE tag (id INT NOT NULL, name VARCHAR(255) NOT NULL, created_at TIMESTAMP(0) WITHOUT TIME ZONE NOT NULL, community VARCHAR(255) DEFAULT NULL, PRIMARY KEY(id))');
$this->addSql('CREATE TABLE tag_user (id INT NOT NULL, tag_id INT NOT NULL, user_tag_id INT NOT NULL, state INT DEFAULT NULL, PRIMARY KEY(id))');
$this->addSql('CREATE INDEX IDX_639C69FFBAD26311 ON tag_user (tag_id)');
$this->addSql('CREATE INDEX IDX_639C69FFDF80782C ON tag_user (user_tag_id)');
$this->addSql('CREATE TABLE "user" (id INT NOT NULL, help_id INT DEFAULT NULL, email VARCHAR(180) NOT NULL, roles JSON NOT NULL, password VARCHAR(255) NOT NULL, is_verified BOOLEAN NOT NULL, community VARCHAR(255) DEFAULT NULL, image_name VARCHAR(255) DEFAULT NULL, updated_at TIMESTAMP(0) WITHOUT TIME ZONE DEFAULT NULL, created_at TIMESTAMP(0) WITHOUT TIME ZONE DEFAULT NULL, username VARCHAR(255) DEFAULT NULL, firstname VARCHAR(255) DEFAULT NULL, abuse BOOLEAN DEFAULT NULL, block BOOLEAN DEFAULT NULL, description VARCHAR(255) DEFAULT NULL, phone_number VARCHAR(15) DEFAULT NULL, activation_token VARCHAR(8) DEFAULT NULL, PRIMARY KEY(id))');
$this->addSql('CREATE UNIQUE INDEX UNIQ_8D93D649E7927C74 ON "user" (email)');
$this->addSql('CREATE INDEX IDX_8D93D649D3F165E7 ON "user" (help_id)');
$this->addSql('ALTER TABLE conversation_user ADD CONSTRAINT FK_5AECB5559AC0396 FOREIGN KEY (conversation_id) REFERENCES conversation (id) ON DELETE CASCADE NOT DEFERRABLE INITIALLY IMMEDIATE');
$this->addSql('ALTER TABLE conversation_user ADD CONSTRAINT FK_5AECB555A76ED395 FOREIGN KEY (user_id) REFERENCES "user" (id) ON DELETE CASCADE NOT DEFERRABLE INITIALLY IMMEDIATE');
$this->addSql('ALTER TABLE conversation_notification ADD CONSTRAINT FK_EFBF188B9AC0396 FOREIGN KEY (conversation_id) REFERENCES conversation (id) NOT DEFERRABLE INITIALLY IMMEDIATE');
$this->addSql('ALTER TABLE conversation_notification ADD CONSTRAINT FK_EFBF188BD32632E8 FOREIGN KEY (_user_id) REFERENCES "user" (id) NOT DEFERRABLE INITIALLY IMMEDIATE');
$this->addSql('ALTER TABLE message ADD CONSTRAINT FK_B6BD307FF675F31B FOREIGN KEY (author_id) REFERENCES "user" (id) NOT DEFERRABLE INITIALLY IMMEDIATE');
$this->addSql('ALTER TABLE message ADD CONSTRAINT FK_B6BD307F9AC0396 FOREIGN KEY (conversation_id) REFERENCES conversation (id) NOT DEFERRABLE INITIALLY IMMEDIATE');
$this->addSql('ALTER TABLE message_tag ADD CONSTRAINT FK_2ABC3D6F537A1329 FOREIGN KEY (message_id) REFERENCES message (id) ON DELETE CASCADE NOT DEFERRABLE INITIALLY IMMEDIATE');
$this->addSql('ALTER TABLE message_tag ADD CONSTRAINT FK_2ABC3D6FBAD26311 FOREIGN KEY (tag_id) REFERENCES tag (id) ON DELETE CASCADE NOT DEFERRABLE INITIALLY IMMEDIATE');
$this->addSql('ALTER TABLE message_user ADD CONSTRAINT FK_24064D90537A1329 FOREIGN KEY (message_id) REFERENCES message (id) ON DELETE CASCADE NOT DEFERRABLE INITIALLY IMMEDIATE');
$this->addSql('ALTER TABLE message_user ADD CONSTRAINT FK_24064D90A76ED395 FOREIGN KEY (user_id) REFERENCES "user" (id) ON DELETE CASCADE NOT DEFERRABLE INITIALLY IMMEDIATE');
$this->addSql('ALTER TABLE mobile ADD CONSTRAINT FK_3C7323E0B8E6CFAF FOREIGN KEY (user_mobile_id) REFERENCES "user" (id) NOT DEFERRABLE INITIALLY IMMEDIATE');
$this->addSql('ALTER TABLE tag_user ADD CONSTRAINT FK_639C69FFBAD26311 FOREIGN KEY (tag_id) REFERENCES tag (id) NOT DEFERRABLE INITIALLY IMMEDIATE');
$this->addSql('ALTER TABLE tag_user ADD CONSTRAINT FK_639C69FFDF80782C FOREIGN KEY (user_tag_id) REFERENCES "user" (id) NOT DEFERRABLE INITIALLY IMMEDIATE');
$this->addSql('ALTER TABLE "user" ADD CONSTRAINT FK_8D93D649D3F165E7 FOREIGN KEY (help_id) REFERENCES help (id) NOT DEFERRABLE INITIALLY IMMEDIATE');
}
public function down(Schema $schema): void
{
// this down() migration is auto-generated, please modify it to your needs
$this->addSql('CREATE SCHEMA public');
$this->addSql('ALTER TABLE conversation_user DROP CONSTRAINT FK_5AECB5559AC0396');
$this->addSql('ALTER TABLE conversation_notification DROP CONSTRAINT FK_EFBF188B9AC0396');
$this->addSql('ALTER TABLE message DROP CONSTRAINT FK_B6BD307F9AC0396');
$this->addSql('ALTER TABLE "user" DROP CONSTRAINT FK_8D93D649D3F165E7');
$this->addSql('ALTER TABLE message_tag DROP CONSTRAINT FK_2ABC3D6F537A1329');
$this->addSql('ALTER TABLE message_user DROP CONSTRAINT FK_24064D90537A1329');
$this->addSql('ALTER TABLE message_tag DROP CONSTRAINT FK_2ABC3D6FBAD26311');
$this->addSql('ALTER TABLE tag_user DROP CONSTRAINT FK_639C69FFBAD26311');
$this->addSql('ALTER TABLE conversation_user DROP CONSTRAINT FK_5AECB555A76ED395');
$this->addSql('ALTER TABLE conversation_notification DROP CONSTRAINT FK_EFBF188BD32632E8');
$this->addSql('ALTER TABLE message DROP CONSTRAINT FK_B6BD307FF675F31B');
$this->addSql('ALTER TABLE message_user DROP CONSTRAINT FK_24064D90A76ED395');
$this->addSql('ALTER TABLE mobile DROP CONSTRAINT FK_3C7323E0B8E6CFAF');
$this->addSql('ALTER TABLE tag_user DROP CONSTRAINT FK_639C69FFDF80782C');
$this->addSql('DROP SEQUENCE active_id_seq CASCADE');
$this->addSql('DROP SEQUENCE conversation_id_seq CASCADE');
$this->addSql('DROP SEQUENCE conversation_notification_id_seq CASCADE');
$this->addSql('DROP SEQUENCE help_id_seq CASCADE');
$this->addSql('DROP SEQUENCE message_id_seq CASCADE');
$this->addSql('DROP SEQUENCE mobile_id_seq CASCADE');
$this->addSql('DROP SEQUENCE tag_id_seq CASCADE');
$this->addSql('DROP SEQUENCE tag_user_id_seq CASCADE');
$this->addSql('DROP SEQUENCE "user_id_seq" CASCADE');
$this->addSql('DROP TABLE active');
$this->addSql('DROP TABLE conversation');
$this->addSql('DROP TABLE conversation_user');
$this->addSql('DROP TABLE conversation_notification');
$this->addSql('DROP TABLE help');
$this->addSql('DROP TABLE message');
$this->addSql('DROP TABLE message_tag');
$this->addSql('DROP TABLE message_user');
$this->addSql('DROP TABLE mobile');
$this->addSql('DROP TABLE tag');
$this->addSql('DROP TABLE tag_user');
$this->addSql('DROP TABLE "user"');
}
}