fix: Add JoinColumn decorators to InviteCode entity relations
Some checks failed
ParentFlow CI/CD Pipeline / Backend Tests (push) Has been cancelled
ParentFlow CI/CD Pipeline / Frontend Tests (push) Has been cancelled
ParentFlow CI/CD Pipeline / Security Scanning (push) Has been cancelled
ParentFlow CI/CD Pipeline / Build Docker Images (map[context:maternal-app/maternal-app-backend dockerfile:Dockerfile.production name:backend]) (push) Has been cancelled
ParentFlow CI/CD Pipeline / Build Docker Images (map[context:maternal-web dockerfile:Dockerfile.production name:frontend]) (push) Has been cancelled
ParentFlow CI/CD Pipeline / Deploy to Development (push) Has been cancelled
ParentFlow CI/CD Pipeline / Deploy to Production (push) Has been cancelled
CI/CD Pipeline / Lint and Test (push) Has been cancelled
CI/CD Pipeline / E2E Tests (push) Has been cancelled
CI/CD Pipeline / Build Application (push) Has been cancelled

Fixed TypeORM query error where column 'creatorId' was not found. The database uses 'created_by' but TypeORM was defaulting to 'creatorId' for the ManyToOne relation. Added @JoinColumn decorators to specify correct column names for all relations.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
Andrei
2025-10-08 10:50:08 +00:00
parent 45150860ce
commit 3b51b82098

View File

@@ -1,4 +1,4 @@
import { Entity, Column, PrimaryGeneratedColumn, CreateDateColumn, UpdateDateColumn, ManyToOne, OneToMany } from 'typeorm'; import { Entity, Column, PrimaryGeneratedColumn, CreateDateColumn, UpdateDateColumn, ManyToOne, OneToMany, JoinColumn } from 'typeorm';
import { User } from '../../database/entities/user.entity'; import { User } from '../../database/entities/user.entity';
@Entity('invite_codes') @Entity('invite_codes')
@@ -13,6 +13,7 @@ export class InviteCode {
createdBy: string; createdBy: string;
@ManyToOne(() => User, { nullable: true }) @ManyToOne(() => User, { nullable: true })
@JoinColumn({ name: 'created_by' })
creator?: User; creator?: User;
@Column({ default: 0 }) @Column({ default: 0 })
@@ -52,12 +53,14 @@ export class InviteCodeUse {
inviteCodeId: string; inviteCodeId: string;
@ManyToOne(() => InviteCode, code => code.usages) @ManyToOne(() => InviteCode, code => code.usages)
@JoinColumn({ name: 'invite_code_id' })
inviteCode: InviteCode; inviteCode: InviteCode;
@Column({ name: 'used_by' }) @Column({ name: 'used_by' })
usedBy: string; usedBy: string;
@ManyToOne(() => User) @ManyToOne(() => User)
@JoinColumn({ name: 'used_by' })
user: User; user: User;
@Column({ name: 'user_email' }) @Column({ name: 'user_email' })