metis-desk/apps/server/src/rename-workstations.ts
David 0e8e15c9c2 feat: Implement account deletion functionality with UI and API integration
- Added `removeAccessAccount` function to handle account deletion in the database, ensuring no external references exist.
- Created `deleteAccount` API function to facilitate account deletion requests from the client.
- Developed `AccountDeleteDialog` component for user confirmation before account deletion, integrating with the delete API.
- Introduced resource image handling with validation for PNG uploads, including UI components for image selection and preview.
- Implemented resource icon template evolution logic to maintain icon bindings without overwriting existing fields.
- Added scripts for auditing account deletion and usage checks, ensuring robust testing of the new features.
2026-10-27 11:39:53 +01:00

30 lines
1.1 KiB
TypeScript

import { QueryTypes } from "sequelize";
import { renameWorkstationsFromPrimaryAssets } from "../../../modules/assets/src/api/infrastructure/persistence/rename-workstations-from-primary-assets";
import { createDatabase, readDatabaseEnvironment } from "./config/database";
if (process.argv.slice(2).join(" ") !== "--apply") {
throw new Error("Corrección explícita de nombres: requiere --apply.");
}
const database = createDatabase(readDatabaseEnvironment(process.env));
try {
const administrators = await database.query<{ id: string }>(
"SELECT id FROM users WHERE isInitialAdmin=1 AND active=1",
{ type: QueryTypes.SELECT }
);
const administrator = administrators.length === 1 ? administrators[0] : undefined;
if (!administrator) {
throw new Error("La corrección requiere un único administrador inicial activo.");
}
const renamed = await renameWorkstationsFromPrimaryAssets(database, administrator.id);
process.stdout.write(
`Puestos renombrados: ${renamed}. Revisiones registradas con el administrador inicial.\n`
);
} finally {
await database.close();
}