mirror of
https://github.com/hedgedoc/hedgedoc.git
synced 2025-05-14 15:14:56 -04:00

To better handle deletion of entities, all necessary other entities got the option onDelete CASCADE set. So everything that does not make any sense if something else is deleted will be deleted along side of it. Signed-off-by: Philip Molares <philip.molares@udo.edu>
53 lines
889 B
TypeScript
53 lines
889 B
TypeScript
/*
|
|
* SPDX-FileCopyrightText: 2021 The HedgeDoc developers (see AUTHORS file)
|
|
*
|
|
* SPDX-License-Identifier: AGPL-3.0-only
|
|
*/
|
|
|
|
import {
|
|
Column,
|
|
CreateDateColumn,
|
|
Entity,
|
|
ManyToOne,
|
|
PrimaryGeneratedColumn,
|
|
UpdateDateColumn,
|
|
} from 'typeorm';
|
|
import { User } from './user.entity';
|
|
|
|
@Entity()
|
|
export class Identity {
|
|
@PrimaryGeneratedColumn()
|
|
id: number;
|
|
|
|
@ManyToOne((_) => User, (user) => user.identities, {
|
|
onDelete: 'CASCADE', // This deletes the Identity, when the associated User is deleted
|
|
})
|
|
user: User;
|
|
|
|
@Column()
|
|
providerName: string;
|
|
|
|
@Column()
|
|
syncSource: boolean;
|
|
|
|
@CreateDateColumn()
|
|
createdAt: Date;
|
|
|
|
@UpdateDateColumn()
|
|
updatedAt: Date;
|
|
|
|
@Column({
|
|
nullable: true,
|
|
})
|
|
providerUserId?: string;
|
|
|
|
@Column({
|
|
nullable: true,
|
|
})
|
|
oAuthAccessToken?: string;
|
|
|
|
@Column({
|
|
nullable: true,
|
|
})
|
|
passwordHash?: string;
|
|
}
|