1.5 KiB
1.5 KiB
type, title, description, resource, tags, timestamp
| type | title | description | resource | tags | timestamp | |||||
|---|---|---|---|---|---|---|---|---|---|---|
| database | Admin Operation Tokens Migration | Forward-only migration that adds the `admin_operation_token` table and its indexes for destructive System-operation confirmation tokens. | backend/src/database/migrations/1700000000900-AddAdminOperationTokens.ts |
|
2026-07-23T12:04:50Z |
Purpose
Adds the admin_operation_token
table that backs the destructive operations under
/api/v1/admin/system/* (restore-backup, reset-scores,
wipe-challenges). Always fresh on a new database; on existing instances
the migration is a no-op if the table already exists.
Up
CREATE TABLE IF NOT EXISTS admin_operation_tokenwith the columns listed in the schema doc.CREATE UNIQUE INDEX IF NOT EXISTS uq_admin_op_token_hashontoken_hashto make one-shot use enforceable.CREATE INDEX IF NOT EXISTS idx_admin_op_token_user_opon(user_id, operation)for fast per-admin lookup.CREATE INDEX IF NOT EXISTS idx_admin_op_token_expiryonexpires_atso the periodic purge can use an index scan.
Down
Drops the indexes in reverse order and drops the table.
Wiring
The migration is registered in
backend/src/database/database.module.ts after the existing user
triggers migration. The entity is registered in the same ENTITIES
array so forFeature lets AdminSystemModule inject the repository.