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
|
|
@ -3,8 +3,9 @@
|
|||
* SPDX-License-Identifier: AGPL-3.0-only
|
||||
*/
|
||||
|
||||
import { Entity, Column, Index, OneToOne, JoinColumn, PrimaryColumn } from 'typeorm';
|
||||
import { Entity, Column, Index, OneToOne, JoinColumn, PrimaryColumn, ManyToOne } from 'typeorm';
|
||||
import { type UserUnsignedFetchOption, userUnsignedFetchOptions } from '@/const.js';
|
||||
import { MiInstance } from '@/models/Instance.js';
|
||||
import { id } from './util/id.js';
|
||||
import { MiDriveFile } from './DriveFile.js';
|
||||
|
||||
|
|
@ -292,6 +293,16 @@ export class MiUser {
|
|||
})
|
||||
public host: string | null;
|
||||
|
||||
@ManyToOne(() => MiInstance, {
|
||||
onDelete: 'CASCADE',
|
||||
})
|
||||
@JoinColumn({
|
||||
name: 'host',
|
||||
foreignKeyConstraintName: 'FK_user_host',
|
||||
referencedColumnName: 'host',
|
||||
})
|
||||
public instance: MiInstance | null;
|
||||
|
||||
@Column('varchar', {
|
||||
length: 512, nullable: true,
|
||||
comment: 'The inbox URL of the User. It will be null if the origin of the user is local.',
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue