Skip to content

Internal: Fix foreign key constraint on user deletion #5779

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
Show file tree
Hide file tree
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
Original file line number Diff line number Diff line change
Expand Up @@ -478,7 +478,7 @@ public function up(Schema $schema): void

// c_lp_category_rel_user
$this->addSql('ALTER TABLE c_lp_category_rel_user DROP FOREIGN KEY IF EXISTS FK_83D35829A76ED395');
$this->addSql('ALTER TABLE c_lp_category_rel_user ADD CONSTRAINT FK_83D35829A76ED395 FOREIGN KEY (user_id) REFERENCES user (id) ON DELETE CASCADE');
$this->addSql('ALTER TABLE c_lp_category_rel_user ADD CONSTRAINT FK_83D35829A76ED395 FOREIGN KEY (user_id) REFERENCES user (id) ON DELETE SET NULL');
$this->addSql('DROP INDEX IF EXISTS idx_61f042712469de2 ON c_lp_category_rel_user');
$this->addSql('CREATE INDEX IF NOT EXISTS IDX_83D3582912469DE2 ON c_lp_category_rel_user (category_id)');
$this->addSql('DROP INDEX IF EXISTS idx_61f0427a76ed395 ON c_lp_category_rel_user');
Expand Down
2 changes: 1 addition & 1 deletion src/CourseBundle/Entity/CLpCategoryRelUser.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ class CLpCategoryRelUser implements Stringable
protected CLpCategory $category;

#[ORM\ManyToOne(targetEntity: User::class)]
#[ORM\JoinColumn(name: 'user_id', referencedColumnName: 'id', onDelete: 'CASCADE')]
#[ORM\JoinColumn(name: 'user_id', referencedColumnName: 'id', onDelete: 'SET NULL')]
protected User $user;

public function __toString(): string
Expand Down
Loading