diff --git a/packages/backend/migration/1727659258948-add_latest_note.js b/packages/backend/migration/1727659258948-add_latest_note.js index b63133cb38..739aaf0775 100644 --- a/packages/backend/migration/1727659258948-add_latest_note.js +++ b/packages/backend/migration/1727659258948-add_latest_note.js @@ -2,9 +2,9 @@ export class AddLatestNote1727659258948 { name = 'AddLatestNote1727659258948'; async up(queryRunner) { - await queryRunner.query('CREATE TABLE "latest_note" ("user_id" character varying(32) NOT NULL, "note_id" character varying(32) NOT NULL, "userId" character varying(32), "noteId" character varying(32), CONSTRAINT "PK_f619b62bfaafabe68f52fb50c9a" PRIMARY KEY ("user_id"))'); - await queryRunner.query('ALTER TABLE "latest_note" ADD CONSTRAINT "FK_20e346fffe4a2174585005d6d80" FOREIGN KEY ("userId") REFERENCES "user"("id") ON DELETE CASCADE ON UPDATE NO ACTION'); - await queryRunner.query('ALTER TABLE "latest_note" ADD CONSTRAINT "FK_47a38b1c13de6ce4e5090fb1acd" FOREIGN KEY ("noteId") REFERENCES "note"("id") ON DELETE CASCADE ON UPDATE NO ACTION'); + await queryRunner.query('CREATE TABLE "latest_note" ("user_id" character varying(32) NOT NULL, "note_id" character varying(32) NOT NULL, CONSTRAINT "PK_f619b62bfaafabe68f52fb50c9a" PRIMARY KEY ("user_id"))'); + await queryRunner.query('ALTER TABLE "latest_note" ADD CONSTRAINT "FK_20e346fffe4a2174585005d6d80" FOREIGN KEY ("user_id") REFERENCES "user"("id") ON DELETE CASCADE ON UPDATE NO ACTION'); + await queryRunner.query('ALTER TABLE "latest_note" ADD CONSTRAINT "FK_47a38b1c13de6ce4e5090fb1acd" FOREIGN KEY ("note_id") REFERENCES "note"("id") ON DELETE CASCADE ON UPDATE NO ACTION'); } async down(queryRunner) { diff --git a/packages/backend/src/models/LatestNote.ts b/packages/backend/src/models/LatestNote.ts index 24cb9607b0..4b81c46d43 100644 --- a/packages/backend/src/models/LatestNote.ts +++ b/packages/backend/src/models/LatestNote.ts @@ -19,7 +19,9 @@ export class LatestNote { @ManyToOne(() => MiUser, { onDelete: 'CASCADE', }) - @JoinColumn() + @JoinColumn({ + name: 'user_id', + }) public user: MiUser | null; @Column({ @@ -32,7 +34,9 @@ export class LatestNote { @ManyToOne(() => MiNote, { onDelete: 'CASCADE', }) - @JoinColumn() + @JoinColumn({ + name: 'note_id', + }) public note: MiNote | null; constructor(data: Partial) {