<?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 Version20220824070809 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 department_id_seq INCREMENT BY 1 MINVALUE 1 START 1');
$this->addSql('CREATE SEQUENCE shift_period_id_seq INCREMENT BY 1 MINVALUE 1 START 1');
$this->addSql('CREATE TABLE department (id INT NOT NULL, name VARCHAR(100) NOT NULL, PRIMARY KEY(id))');
$this->addSql('CREATE TABLE shift_period (id INT NOT NULL, user_id INT DEFAULT NULL, type VARCHAR(50) NOT NULL, extra VARCHAR(50) DEFAULT NULL, day INT NOT NULL, month INT NOT NULL, year INT NOT NULL, PRIMARY KEY(id))');
$this->addSql('CREATE INDEX IDX_49608CDBA76ED395 ON shift_period (user_id)');
$this->addSql('ALTER TABLE shift_period ADD CONSTRAINT FK_49608CDBA76ED395 FOREIGN KEY (user_id) REFERENCES "users" (id) NOT DEFERRABLE INITIALLY IMMEDIATE');
$this->addSql('ALTER TABLE invoices ALTER discussion DROP DEFAULT');
$this->addSql('ALTER TABLE invoices ALTER discussion SET NOT NULL');
$this->addSql('ALTER TABLE users ADD department_id INT DEFAULT NULL');
$this->addSql('ALTER TABLE users ADD CONSTRAINT FK_1483A5E9AE80F5DF FOREIGN KEY (department_id) REFERENCES department (id) NOT DEFERRABLE INITIALLY IMMEDIATE');
$this->addSql('CREATE INDEX IDX_1483A5E9AE80F5DF ON users (department_id)');
$this->addSql('ALTER TABLE users_invoices_periods ALTER like_dialogs DROP DEFAULT');
$this->addSql('ALTER TABLE users_invoices_periods ALTER like_dialogs SET NOT NULL');
}
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 "users" DROP CONSTRAINT FK_1483A5E9AE80F5DF');
$this->addSql('DROP SEQUENCE department_id_seq CASCADE');
$this->addSql('DROP SEQUENCE shift_period_id_seq CASCADE');
$this->addSql('DROP TABLE department');
$this->addSql('DROP TABLE shift_period');
$this->addSql('ALTER TABLE "invoices" ALTER discussion SET DEFAULT \'false\'');
$this->addSql('ALTER TABLE "invoices" ALTER discussion DROP NOT NULL');
$this->addSql('ALTER TABLE "users_invoices_periods" ALTER like_dialogs SET DEFAULT 0');
$this->addSql('ALTER TABLE "users_invoices_periods" ALTER like_dialogs DROP NOT NULL');
$this->addSql('DROP INDEX IDX_1483A5E9AE80F5DF');
$this->addSql('ALTER TABLE "users" DROP department_id');
}
}