migrations/Version20210817120753.php line 1

Open in your IDE?
  1. <?php
  2. declare(strict_types=1);
  3. namespace DoctrineMigrations;
  4. use Doctrine\DBAL\Schema\Schema;
  5. use Doctrine\Migrations\AbstractMigration;
  6. /**
  7.  * Auto-generated Migration: Please modify to your needs!
  8.  */
  9. final class Version20210817120753 extends AbstractMigration
  10. {
  11.     public function getDescription(): string
  12.     {
  13.         return '';
  14.     }
  15.     public function up(Schema $schema): void
  16.     {
  17.         // this up() migration is auto-generated, please modify it to your needs
  18.         $this->addSql('CREATE SEQUENCE user_grade_report_id_seq INCREMENT BY 1 MINVALUE 1 START 1');
  19.         $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))');
  20.         $this->addSql('CREATE INDEX IDX_64C8A98FD02C66A ON user_grade_report (mooc_user_id)');
  21.         $this->addSql('CREATE INDEX IDX_64C8A98399B3D8B ON user_grade_report (grade_report_id)');
  22.         $this->addSql('ALTER TABLE user_grade_report ADD CONSTRAINT FK_64C8A98FD02C66A FOREIGN KEY (mooc_user_id) REFERENCES "user" (id) NOT DEFERRABLE INITIALLY IMMEDIATE');
  23.         $this->addSql('ALTER TABLE user_grade_report ADD CONSTRAINT FK_64C8A98399B3D8B FOREIGN KEY (grade_report_id) REFERENCES grade_report (id) NOT DEFERRABLE INITIALLY IMMEDIATE');
  24.         $this->addSql('ALTER TABLE enrollments ADD csv VARCHAR(255) NOT NULL');
  25.         $this->addSql('ALTER TABLE enrollments DROP enrollments_dashboard');
  26.         $this->addSql('ALTER TABLE grade_report DROP CONSTRAINT fk_8680f69afd02c66a');
  27.         $this->addSql('DROP INDEX idx_8680f69afd02c66a');
  28.         $this->addSql('ALTER TABLE grade_report DROP mooc_user_id');
  29.         $this->addSql('ALTER TABLE grade_report DROP grade');
  30.         $this->addSql('ALTER TABLE grade_report DROP grades');
  31.     }
  32.     public function down(Schema $schema): void
  33.     {
  34.         // this down() migration is auto-generated, please modify it to your needs
  35.         $this->addSql('CREATE SCHEMA public');
  36.         $this->addSql('DROP SEQUENCE user_grade_report_id_seq CASCADE');
  37.         $this->addSql('DROP TABLE user_grade_report');
  38.         $this->addSql('ALTER TABLE grade_report ADD mooc_user_id INT NOT NULL');
  39.         $this->addSql('ALTER TABLE grade_report ADD grade INT NOT NULL');
  40.         $this->addSql('ALTER TABLE grade_report ADD grades JSON NOT NULL');
  41.         $this->addSql('ALTER TABLE grade_report ADD CONSTRAINT fk_8680f69afd02c66a FOREIGN KEY (mooc_user_id) REFERENCES "user" (id) NOT DEFERRABLE INITIALLY IMMEDIATE');
  42.         $this->addSql('CREATE INDEX idx_8680f69afd02c66a ON grade_report (mooc_user_id)');
  43.         $this->addSql('ALTER TABLE enrollments ADD enrollments_dashboard INT NOT NULL');
  44.         $this->addSql('ALTER TABLE enrollments DROP csv');
  45.     }
  46. }