<?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 Version20220120225731 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 SEQUENCE integration__connection_id_seq INCREMENT BY 1 MINVALUE 1 START 1');
$this->addSql('CREATE SEQUENCE user__user_id_seq INCREMENT BY 1 MINVALUE 1 START 1');
$this->addSql('CREATE TABLE integration__connection (id INT NOT NULL, name VARCHAR(100) NOT NULL, username VARCHAR(100) NOT NULL, password VARCHAR(500) NOT NULL, host VARCHAR(100) NOT NULL, port INT DEFAULT NULL, discr VARCHAR(255) NOT NULL, PRIMARY KEY(id))');
$this->addSql('CREATE TABLE integration__connection_pim (id INT NOT NULL, PRIMARY KEY(id))');
$this->addSql('CREATE TABLE integration__connection_shoper (id INT NOT NULL, user_id INT DEFAULT NULL, pim_id INT DEFAULT NULL, PRIMARY KEY(id))');
$this->addSql('CREATE INDEX IDX_C667E511A76ED395 ON integration__connection_shoper (user_id)');
$this->addSql('CREATE INDEX IDX_C667E5117E8E8AA2 ON integration__connection_shoper (pim_id)');
$this->addSql('CREATE TABLE user__user (id INT NOT NULL, username VARCHAR(180) NOT NULL, email VARCHAR(180) NOT NULL, roles TEXT NOT NULL, password VARCHAR(255) NOT NULL, api_token TEXT DEFAULT NULL, PRIMARY KEY(id))');
$this->addSql('CREATE UNIQUE INDEX UNIQ_32745D0AF85E0677 ON user__user (username)');
$this->addSql('CREATE UNIQUE INDEX UNIQ_32745D0AE7927C74 ON user__user (email)');
$this->addSql('CREATE UNIQUE INDEX UNIQ_32745D0A7BA2F5EB ON user__user (api_token)');
$this->addSql('COMMENT ON COLUMN user__user.roles IS \'(DC2Type:array)\'');
$this->addSql('ALTER TABLE integration__connection_pim ADD CONSTRAINT FK_338B274EBF396750 FOREIGN KEY (id) REFERENCES integration__connection (id) ON DELETE CASCADE NOT DEFERRABLE INITIALLY IMMEDIATE');
$this->addSql('ALTER TABLE integration__connection_shoper ADD CONSTRAINT FK_C667E511A76ED395 FOREIGN KEY (user_id) REFERENCES user__user (id) ON DELETE SET NULL NOT DEFERRABLE INITIALLY IMMEDIATE');
$this->addSql('ALTER TABLE integration__connection_shoper ADD CONSTRAINT FK_C667E5117E8E8AA2 FOREIGN KEY (pim_id) REFERENCES integration__connection_pim (id) ON DELETE SET NULL NOT DEFERRABLE INITIALLY IMMEDIATE');
$this->addSql('ALTER TABLE integration__connection_shoper ADD CONSTRAINT FK_C667E511BF396750 FOREIGN KEY (id) REFERENCES integration__connection (id) ON DELETE CASCADE 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 integration__connection_pim DROP CONSTRAINT FK_338B274EBF396750');
$this->addSql('ALTER TABLE integration__connection_shoper DROP CONSTRAINT FK_C667E511BF396750');
$this->addSql('ALTER TABLE integration__connection_shoper DROP CONSTRAINT FK_C667E5117E8E8AA2');
$this->addSql('ALTER TABLE integration__connection_shoper DROP CONSTRAINT FK_C667E511A76ED395');
$this->addSql('DROP SEQUENCE integration__connection_id_seq CASCADE');
$this->addSql('DROP SEQUENCE user__user_id_seq CASCADE');
$this->addSql('DROP TABLE integration__connection');
$this->addSql('DROP TABLE integration__connection_pim');
$this->addSql('DROP TABLE integration__connection_shoper');
$this->addSql('DROP TABLE user__user');
}
}