AI Implementation feature(871): Admin Area System: Database Backup/Restore and Danger Zone (#61)
This commit was merged in pull request #61.
This commit is contained in:
@@ -0,0 +1,41 @@
|
||||
import { Entity, PrimaryColumn, Column, Index, ManyToOne, JoinColumn } from 'typeorm';
|
||||
import { UserEntity } from './user.entity';
|
||||
|
||||
export const ADMIN_OPERATION_KINDS = [
|
||||
'restore-backup',
|
||||
'reset-scores',
|
||||
'wipe-challenges',
|
||||
] as const;
|
||||
|
||||
export type AdminOperationKind = (typeof ADMIN_OPERATION_KINDS)[number];
|
||||
|
||||
@Entity('admin_operation_token')
|
||||
export class AdminOperationTokenEntity {
|
||||
@PrimaryColumn('text')
|
||||
id!: string;
|
||||
|
||||
@Index()
|
||||
@Column('text', { name: 'user_id' })
|
||||
userId!: string;
|
||||
|
||||
@ManyToOne(() => UserEntity, { onDelete: 'CASCADE' })
|
||||
@JoinColumn({ name: 'user_id' })
|
||||
user?: UserEntity;
|
||||
|
||||
@Column('text')
|
||||
operation!: AdminOperationKind;
|
||||
|
||||
@Index({ unique: true })
|
||||
@Column('text', { name: 'token_hash' })
|
||||
tokenHash!: string;
|
||||
|
||||
@Column('text', { name: 'issued_at' })
|
||||
issuedAt!: string;
|
||||
|
||||
@Index()
|
||||
@Column('text', { name: 'expires_at' })
|
||||
expiresAt!: string;
|
||||
|
||||
@Column('text', { name: 'consumed_at', nullable: true })
|
||||
consumedAt!: string | null;
|
||||
}
|
||||
Reference in New Issue
Block a user