add foreign keys to note/user where instance is referenced
This commit is contained in:
parent
f3eca0b5cf
commit
59099a2b2a
3 changed files with 73 additions and 1 deletions
|
|
@ -5,6 +5,7 @@
|
|||
|
||||
import { Entity, Index, JoinColumn, Column, PrimaryColumn, ManyToOne } from 'typeorm';
|
||||
import { noteVisibilities } from '@/types.js';
|
||||
import { MiInstance } from '@/models/Instance.js';
|
||||
import { id } from './util/id.js';
|
||||
import { MiUser } from './User.js';
|
||||
import { MiChannel } from './Channel.js';
|
||||
|
|
@ -222,6 +223,16 @@ export class MiNote {
|
|||
})
|
||||
public userHost: string | null;
|
||||
|
||||
@ManyToOne(() => MiInstance, {
|
||||
onDelete: 'CASCADE',
|
||||
})
|
||||
@JoinColumn({
|
||||
name: 'userHost',
|
||||
foreignKeyConstraintName: 'FK_note_userHost',
|
||||
referencedColumnName: 'host',
|
||||
})
|
||||
public userInstance: MiInstance | null;
|
||||
|
||||
@Column({
|
||||
...id(),
|
||||
nullable: true,
|
||||
|
|
@ -235,6 +246,16 @@ export class MiNote {
|
|||
})
|
||||
public replyUserHost: string | null;
|
||||
|
||||
@ManyToOne(() => MiInstance, {
|
||||
onDelete: 'CASCADE',
|
||||
})
|
||||
@JoinColumn({
|
||||
name: 'replyUserHost',
|
||||
foreignKeyConstraintName: 'FK_note_replyUserHost',
|
||||
referencedColumnName: 'host',
|
||||
})
|
||||
public replyUserInstance: MiInstance | null;
|
||||
|
||||
@Column({
|
||||
...id(),
|
||||
nullable: true,
|
||||
|
|
@ -247,6 +268,16 @@ export class MiNote {
|
|||
comment: '[Denormalized]',
|
||||
})
|
||||
public renoteUserHost: string | null;
|
||||
|
||||
@ManyToOne(() => MiInstance, {
|
||||
onDelete: 'CASCADE',
|
||||
})
|
||||
@JoinColumn({
|
||||
name: 'renoteUserHost',
|
||||
foreignKeyConstraintName: 'FK_note_renoteUserHost',
|
||||
referencedColumnName: 'host',
|
||||
})
|
||||
public renoteUserInstance: MiInstance | null;
|
||||
//#endregion
|
||||
|
||||
constructor(data: Partial<MiNote>) {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue