addSql('ALTER TABLE given_answer ADD question_id UUID DEFAULT NULL'); $this->addSql(<<<'SQL' UPDATE given_answer SET question_id = answer.question_id FROM answer WHERE answer.id = given_answer.answer_id SQL); $this->addSql('ALTER TABLE given_answer ALTER COLUMN question_id SET NOT NULL'); $this->addSql(<<<'SQL' ALTER TABLE given_answer ADD CONSTRAINT FK_9AC61A301E27F6BF FOREIGN KEY (question_id) REFERENCES question (id) NOT DEFERRABLE SQL); $this->addSql('CREATE INDEX IDX_9AC61A301E27F6BF ON given_answer (question_id)'); $this->addSql(<<<'SQL' CREATE UNIQUE INDEX UNIQ_9AC61A3091BD87811E27F6BF ON given_answer (candidate_id, question_id) WHERE (deleted_at IS NULL) SQL); } #[\Override] public function down(Schema $schema): void { // this down() migration is auto-generated, please modify it to your needs $this->addSql('ALTER TABLE given_answer DROP CONSTRAINT FK_9AC61A301E27F6BF'); $this->addSql('DROP INDEX IDX_9AC61A301E27F6BF'); $this->addSql('DROP INDEX UNIQ_9AC61A3091BD87811E27F6BF'); $this->addSql('ALTER TABLE given_answer DROP question_id'); } }