feat(herramientas): agregar soporte de fotografias y evidencias para herramientas, kits y asignaciones de custodia

This commit is contained in:
2026-11-01 03:11:33 -05:00
parent c07162c375
commit b361e4a9b4
11 changed files with 379 additions and 42 deletions
+10
View File
@@ -184,6 +184,7 @@ async function setup() {
estado ENUM('operativo', 'en_mantenimiento', 'danado', 'baja') DEFAULT 'operativo',
ubicacion_bodega VARCHAR(150) NULL,
notas TEXT NULL,
foto_url VARCHAR(255) NULL,
created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
updated_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
INDEX (company_id),
@@ -202,6 +203,7 @@ async function setup() {
codigo VARCHAR(50) NULL,
descripcion TEXT NULL,
categoria VARCHAR(100) DEFAULT 'general',
foto_url VARCHAR(255) NULL,
is_active TINYINT(1) DEFAULT 1,
created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
updated_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
@@ -238,7 +240,9 @@ async function setup() {
fecha_devolucion DATETIME NULL,
estado ENUM('asignado', 'devuelto', 'observado') DEFAULT 'asignado',
observaciones_entrega TEXT NULL,
foto_entrega_url VARCHAR(255) NULL,
observaciones_devolucion TEXT NULL,
foto_devolucion_url VARCHAR(255) NULL,
asignado_por INT NULL,
created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
updated_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
@@ -254,6 +258,12 @@ async function setup() {
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
`);
// Migraciones de columnas para fotografías y evidencias
await migrateColumn('herramientas', 'foto_url', 'foto_url VARCHAR(255) NULL AFTER notas');
await migrateColumn('herramientas_sets', 'foto_url', 'foto_url VARCHAR(255) NULL AFTER descripcion');
await migrateColumn('tecnico_herramientas_asignaciones', 'foto_entrega_url', 'foto_entrega_url VARCHAR(255) NULL AFTER observaciones_entrega');
await migrateColumn('tecnico_herramientas_asignaciones', 'foto_devolucion_url', 'foto_devolucion_url VARCHAR(255) NULL AFTER observaciones_devolucion');
// Seed herramientas y sets iniciales para Telcotronics si no existen
const [existingTools] = await conn.query('SELECT COUNT(*) as c FROM herramientas WHERE company_id = 1');
if (existingTools[0].c === 0) {