fix: add explicit JoinClumn to MediaRequest media relation
Fixes intermittent NULL mediaId foreign key on media_request records byadding explicit @JoinColumn decorator to the media relation. Without this,TypeORM's implicit FK mapping was unreliable, causing orphaned requeststhat would crash the frontend when accessing user profiles. Also removes the redundant @Column decorator for mediaId which conflicted withthe relation, and removes explicit mediaId assignments in the constructorwhich are now handled correctly by TypeORM through the relation.
This commit is contained in:
@@ -21,6 +21,7 @@ import {
|
||||
AfterUpdate,
|
||||
Column,
|
||||
Entity,
|
||||
JoinColumn,
|
||||
ManyToOne,
|
||||
OneToMany,
|
||||
PrimaryGeneratedColumn,
|
||||
@@ -519,6 +520,7 @@ export class MediaRequest {
|
||||
eager: true,
|
||||
onDelete: 'CASCADE',
|
||||
})
|
||||
@JoinColumn({ name: 'mediaId' })
|
||||
public media: Media;
|
||||
|
||||
@ManyToOne(() => User, (user) => user.requests, {
|
||||
|
||||
Reference in New Issue
Block a user