Skip to content

Internal: Add migration file to remove user in gradebook links and evaluations. #5719

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Aug 10, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
44 changes: 44 additions & 0 deletions src/CoreBundle/Migrations/Schema/V200/Version20240809124000.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
<?php

declare(strict_types=1);

/* For licensing terms, see /license.txt */

namespace Chamilo\CoreBundle\Migrations\Schema\V200;

use Doctrine\DBAL\Schema\Schema;
use Doctrine\Migrations\AbstractMigration;

final class Version20240809124000 extends AbstractMigration
{
public function getDescription(): string
{
return 'Remove user_id foreign key and column from gradebook_link and gradebook_evaluation tables.';
}

public function up(Schema $schema): void
{
// Drop foreign key and index from gradebook_link
$this->addSql('ALTER TABLE gradebook_link DROP FOREIGN KEY FK_4F0F595FA76ED395');
$this->addSql('DROP INDEX IDX_4F0F595FA76ED395 ON gradebook_link');
$this->addSql('ALTER TABLE gradebook_link DROP COLUMN user_id');

// Drop foreign key and index from gradebook_evaluation
$this->addSql('ALTER TABLE gradebook_evaluation DROP FOREIGN KEY FK_DDDED804A76ED395');
$this->addSql('DROP INDEX IDX_DDDED804A76ED395 ON gradebook_evaluation');
$this->addSql('ALTER TABLE gradebook_evaluation DROP COLUMN user_id');
}

public function down(Schema $schema): void
{
// Re-add the user_id column and foreign key to gradebook_link
$this->addSql('ALTER TABLE gradebook_link ADD user_id INT DEFAULT NULL');
$this->addSql('ALTER TABLE gradebook_link ADD CONSTRAINT FK_4F0F595FA76ED395 FOREIGN KEY (user_id) REFERENCES user (id) ON DELETE CASCADE');
$this->addSql('CREATE INDEX IDX_4F0F595FA76ED395 ON gradebook_link (user_id)');

// Re-add the user_id column and foreign key to gradebook_evaluation
$this->addSql('ALTER TABLE gradebook_evaluation ADD user_id INT DEFAULT NULL');
$this->addSql('ALTER TABLE gradebook_evaluation ADD CONSTRAINT FK_DDDED804A76ED395 FOREIGN KEY (user_id) REFERENCES user (id) ON DELETE CASCADE');
$this->addSql('CREATE INDEX IDX_DDDED804A76ED395 ON gradebook_evaluation (user_id)');
}
}
Loading