<?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 Version20210817120753 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 user_grade_report_id_seq INCREMENT BY 1 MINVALUE 1 START 1');
$this->addSql('CREATE TABLE user_grade_report (id INT NOT NULL, mooc_user_id INT NOT NULL, grade_report_id INT NOT NULL, grade INT NOT NULL, grades JSON NOT NULL, PRIMARY KEY(id))');
$this->addSql('CREATE INDEX IDX_64C8A98FD02C66A ON user_grade_report (mooc_user_id)');
$this->addSql('CREATE INDEX IDX_64C8A98399B3D8B ON user_grade_report (grade_report_id)');
$this->addSql('ALTER TABLE user_grade_report ADD CONSTRAINT FK_64C8A98FD02C66A FOREIGN KEY (mooc_user_id) REFERENCES "user" (id) NOT DEFERRABLE INITIALLY IMMEDIATE');
$this->addSql('ALTER TABLE user_grade_report ADD CONSTRAINT FK_64C8A98399B3D8B FOREIGN KEY (grade_report_id) REFERENCES grade_report (id) NOT DEFERRABLE INITIALLY IMMEDIATE');
$this->addSql('ALTER TABLE enrollments ADD csv VARCHAR(255) NOT NULL');
$this->addSql('ALTER TABLE enrollments DROP enrollments_dashboard');
$this->addSql('ALTER TABLE grade_report DROP CONSTRAINT fk_8680f69afd02c66a');
$this->addSql('DROP INDEX idx_8680f69afd02c66a');
$this->addSql('ALTER TABLE grade_report DROP mooc_user_id');
$this->addSql('ALTER TABLE grade_report DROP grade');
$this->addSql('ALTER TABLE grade_report DROP grades');
}
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('DROP SEQUENCE user_grade_report_id_seq CASCADE');
$this->addSql('DROP TABLE user_grade_report');
$this->addSql('ALTER TABLE grade_report ADD mooc_user_id INT NOT NULL');
$this->addSql('ALTER TABLE grade_report ADD grade INT NOT NULL');
$this->addSql('ALTER TABLE grade_report ADD grades JSON NOT NULL');
$this->addSql('ALTER TABLE grade_report ADD CONSTRAINT fk_8680f69afd02c66a FOREIGN KEY (mooc_user_id) REFERENCES "user" (id) NOT DEFERRABLE INITIALLY IMMEDIATE');
$this->addSql('CREATE INDEX idx_8680f69afd02c66a ON grade_report (mooc_user_id)');
$this->addSql('ALTER TABLE enrollments ADD enrollments_dashboard INT NOT NULL');
$this->addSql('ALTER TABLE enrollments DROP csv');
}
}