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:
2026-07-23 12:10:41 +00:00
parent 6bac67fad7
commit 470ddd30c3
42 changed files with 3996 additions and 55 deletions
@@ -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;
}