|
|
|
@@ -0,0 +1,165 @@
|
|
|
|
|
-- Migracion de datos UNICA VEZ: reset de Proyectos + baja de un usuario especifico,
|
|
|
|
|
-- pedido explicitamente por el superadmin (ver historial de conversacion). Guardada por
|
|
|
|
|
-- un marcador en system_settings ('seed_it_baseline_2026_09') para que NUNCA se repita en un deploy futuro
|
|
|
|
|
-- (si se repitiera, borraria proyectos reales creados despues de este cambio).
|
|
|
|
|
SET NAMES utf8mb4;
|
|
|
|
|
|
|
|
|
|
SET @already := (SELECT COUNT(*) FROM system_settings WHERE `key` = 'seed_it_baseline_2026_09');
|
|
|
|
|
|
|
|
|
|
SET @sql := IF(@already = 0, 'DELETE FROM comments WHERE entity_type IN (\'project\',\'activity\')', 'SELECT 1');
|
|
|
|
|
PREPARE stmt FROM @sql; EXECUTE stmt; DEALLOCATE PREPARE stmt;
|
|
|
|
|
SET @sql := IF(@already = 0, 'DELETE FROM attachments WHERE entity_type IN (\'project\',\'activity\')', 'SELECT 1');
|
|
|
|
|
PREPARE stmt FROM @sql; EXECUTE stmt; DEALLOCATE PREPARE stmt;
|
|
|
|
|
SET @sql := IF(@already = 0, 'DELETE FROM notifications WHERE entity_type IN (\'project\',\'activity\')', 'SELECT 1');
|
|
|
|
|
PREPARE stmt FROM @sql; EXECUTE stmt; DEALLOCATE PREPARE stmt;
|
|
|
|
|
SET @sql := IF(@already = 0, 'DELETE FROM projects', 'SELECT 1');
|
|
|
|
|
PREPARE stmt FROM @sql; EXECUTE stmt; DEALLOCATE PREPARE stmt;
|
|
|
|
|
SET @sql := IF(@already = 0, 'ALTER TABLE projects AUTO_INCREMENT = 1', 'SELECT 1');
|
|
|
|
|
PREPARE stmt FROM @sql; EXECUTE stmt; DEALLOCATE PREPARE stmt;
|
|
|
|
|
SET @sql := IF(@already = 0, 'ALTER TABLE activities AUTO_INCREMENT = 1', 'SELECT 1');
|
|
|
|
|
PREPARE stmt FROM @sql; EXECUTE stmt; DEALLOCATE PREPARE stmt;
|
|
|
|
|
SET @sql := IF(@already = 0, 'DELETE FROM users WHERE email = \'pflores@hotmail.es\'', 'SELECT 1');
|
|
|
|
|
PREPARE stmt FROM @sql; EXECUTE stmt; DEALLOCATE PREPARE stmt;
|
|
|
|
|
|
|
|
|
|
-- Proyecto: Cumplimiento legal y proteccion de datos
|
|
|
|
|
SET @sql := IF(@already = 0, 'INSERT INTO projects (code, name, priority_id, status_id, owner_user_id, risk_level, created_by) VALUES (\'PENDING\', \'Cumplimiento legal y proteccion de datos\', 2, 1, 1, \'low\', 1)', 'SELECT 1');
|
|
|
|
|
PREPARE stmt FROM @sql; EXECUTE stmt; DEALLOCATE PREPARE stmt;
|
|
|
|
|
SET @p := LAST_INSERT_ID();
|
|
|
|
|
SET @sql := IF(@already = 0, 'UPDATE projects SET code = CONCAT(\'PRY-\', LPAD(@p,4,\'0\')) WHERE id = @p', 'SELECT 1');
|
|
|
|
|
PREPARE stmt FROM @sql; EXECUTE stmt; DEALLOCATE PREPARE stmt;
|
|
|
|
|
SET @sql := IF(@already = 0, 'INSERT IGNORE INTO project_members (project_id, user_id, role_in_project) VALUES (@p, 1, \'owner\')', 'SELECT 1');
|
|
|
|
|
PREPARE stmt FROM @sql; EXECUTE stmt; DEALLOCATE PREPARE stmt;
|
|
|
|
|
|
|
|
|
|
SET @sql := IF(@already = 0, 'INSERT INTO activities (project_id, code, name, priority_id, status_id, created_by) VALUES (@p, \'PENDING\', \'Implementar LOPD/LODPD\', 2, 1, 1)', 'SELECT 1');
|
|
|
|
|
PREPARE stmt FROM @sql; EXECUTE stmt; DEALLOCATE PREPARE stmt;
|
|
|
|
|
SET @a := LAST_INSERT_ID();
|
|
|
|
|
SET @sql := IF(@already = 0, 'UPDATE activities SET code = CONCAT(\'ACT-\', LPAD(@a,4,\'0\')) WHERE id = @a', 'SELECT 1');
|
|
|
|
|
PREPARE stmt FROM @sql; EXECUTE stmt; DEALLOCATE PREPARE stmt;
|
|
|
|
|
SET @sql := IF(@already = 0, 'INSERT INTO activities (project_id, code, name, priority_id, status_id, created_by) VALUES (@p, \'PENDING\', \'Politica de cookies\', 2, 1, 1)', 'SELECT 1');
|
|
|
|
|
PREPARE stmt FROM @sql; EXECUTE stmt; DEALLOCATE PREPARE stmt;
|
|
|
|
|
SET @a := LAST_INSERT_ID();
|
|
|
|
|
SET @sql := IF(@already = 0, 'UPDATE activities SET code = CONCAT(\'ACT-\', LPAD(@a,4,\'0\')) WHERE id = @a', 'SELECT 1');
|
|
|
|
|
PREPARE stmt FROM @sql; EXECUTE stmt; DEALLOCATE PREPARE stmt;
|
|
|
|
|
SET @sql := IF(@already = 0, 'INSERT INTO activities (project_id, code, name, priority_id, status_id, created_by) VALUES (@p, \'PENDING\', \'Cumplimiento WhatsApp Business\', 2, 1, 1)', 'SELECT 1');
|
|
|
|
|
PREPARE stmt FROM @sql; EXECUTE stmt; DEALLOCATE PREPARE stmt;
|
|
|
|
|
SET @a := LAST_INSERT_ID();
|
|
|
|
|
SET @sql := IF(@already = 0, 'UPDATE activities SET code = CONCAT(\'ACT-\', LPAD(@a,4,\'0\')) WHERE id = @a', 'SELECT 1');
|
|
|
|
|
PREPARE stmt FROM @sql; EXECUTE stmt; DEALLOCATE PREPARE stmt;
|
|
|
|
|
SET @sql := IF(@already = 0, 'INSERT INTO activities (project_id, code, name, priority_id, status_id, created_by) VALUES (@p, \'PENDING\', \'Leyendas obligatorias en facturas\', 2, 1, 1)', 'SELECT 1');
|
|
|
|
|
PREPARE stmt FROM @sql; EXECUTE stmt; DEALLOCATE PREPARE stmt;
|
|
|
|
|
SET @a := LAST_INSERT_ID();
|
|
|
|
|
SET @sql := IF(@already = 0, 'UPDATE activities SET code = CONCAT(\'ACT-\', LPAD(@a,4,\'0\')) WHERE id = @a', 'SELECT 1');
|
|
|
|
|
PREPARE stmt FROM @sql; EXECUTE stmt; DEALLOCATE PREPARE stmt;
|
|
|
|
|
|
|
|
|
|
-- Proyecto: Estandarizar correos corporativos
|
|
|
|
|
SET @sql := IF(@already = 0, 'INSERT INTO projects (code, name, priority_id, status_id, owner_user_id, risk_level, created_by) VALUES (\'PENDING\', \'Estandarizar correos corporativos\', 2, 1, 1, \'low\', 1)', 'SELECT 1');
|
|
|
|
|
PREPARE stmt FROM @sql; EXECUTE stmt; DEALLOCATE PREPARE stmt;
|
|
|
|
|
SET @p := LAST_INSERT_ID();
|
|
|
|
|
SET @sql := IF(@already = 0, 'UPDATE projects SET code = CONCAT(\'PRY-\', LPAD(@p,4,\'0\')) WHERE id = @p', 'SELECT 1');
|
|
|
|
|
PREPARE stmt FROM @sql; EXECUTE stmt; DEALLOCATE PREPARE stmt;
|
|
|
|
|
SET @sql := IF(@already = 0, 'INSERT IGNORE INTO project_members (project_id, user_id, role_in_project) VALUES (@p, 1, \'owner\')', 'SELECT 1');
|
|
|
|
|
PREPARE stmt FROM @sql; EXECUTE stmt; DEALLOCATE PREPARE stmt;
|
|
|
|
|
|
|
|
|
|
SET @sql := IF(@already = 0, 'INSERT INTO activities (project_id, code, name, priority_id, status_id, created_by) VALUES (@p, \'PENDING\', \'Cambiar los correos al nuevo formato (inicial + apellido, 2da inicial si duplica)\', 2, 1, 1)', 'SELECT 1');
|
|
|
|
|
PREPARE stmt FROM @sql; EXECUTE stmt; DEALLOCATE PREPARE stmt;
|
|
|
|
|
SET @a := LAST_INSERT_ID();
|
|
|
|
|
SET @sql := IF(@already = 0, 'UPDATE activities SET code = CONCAT(\'ACT-\', LPAD(@a,4,\'0\')) WHERE id = @a', 'SELECT 1');
|
|
|
|
|
PREPARE stmt FROM @sql; EXECUTE stmt; DEALLOCATE PREPARE stmt;
|
|
|
|
|
|
|
|
|
|
-- Proyecto: Gestion de equipos y activos de TI
|
|
|
|
|
SET @sql := IF(@already = 0, 'INSERT INTO projects (code, name, priority_id, status_id, owner_user_id, risk_level, created_by) VALUES (\'PENDING\', \'Gestion de equipos y activos de TI\', 2, 1, 1, \'low\', 1)', 'SELECT 1');
|
|
|
|
|
PREPARE stmt FROM @sql; EXECUTE stmt; DEALLOCATE PREPARE stmt;
|
|
|
|
|
SET @p := LAST_INSERT_ID();
|
|
|
|
|
SET @sql := IF(@already = 0, 'UPDATE projects SET code = CONCAT(\'PRY-\', LPAD(@p,4,\'0\')) WHERE id = @p', 'SELECT 1');
|
|
|
|
|
PREPARE stmt FROM @sql; EXECUTE stmt; DEALLOCATE PREPARE stmt;
|
|
|
|
|
SET @sql := IF(@already = 0, 'INSERT IGNORE INTO project_members (project_id, user_id, role_in_project) VALUES (@p, 1, \'owner\')', 'SELECT 1');
|
|
|
|
|
PREPARE stmt FROM @sql; EXECUTE stmt; DEALLOCATE PREPARE stmt;
|
|
|
|
|
|
|
|
|
|
SET @sql := IF(@already = 0, 'INSERT INTO activities (project_id, code, name, priority_id, status_id, created_by) VALUES (@p, \'PENDING\', \'Inventario de equipos (codigos / sistema de activos)\', 2, 1, 1)', 'SELECT 1');
|
|
|
|
|
PREPARE stmt FROM @sql; EXECUTE stmt; DEALLOCATE PREPARE stmt;
|
|
|
|
|
SET @a := LAST_INSERT_ID();
|
|
|
|
|
SET @sql := IF(@already = 0, 'UPDATE activities SET code = CONCAT(\'ACT-\', LPAD(@a,4,\'0\')) WHERE id = @a', 'SELECT 1');
|
|
|
|
|
PREPARE stmt FROM @sql; EXECUTE stmt; DEALLOCATE PREPARE stmt;
|
|
|
|
|
SET @sql := IF(@already = 0, 'INSERT INTO activities (project_id, code, name, priority_id, status_id, created_by) VALUES (@p, \'PENDING\', \'Revision periodica de equipos\', 2, 1, 1)', 'SELECT 1');
|
|
|
|
|
PREPARE stmt FROM @sql; EXECUTE stmt; DEALLOCATE PREPARE stmt;
|
|
|
|
|
SET @a := LAST_INSERT_ID();
|
|
|
|
|
SET @sql := IF(@already = 0, 'UPDATE activities SET code = CONCAT(\'ACT-\', LPAD(@a,4,\'0\')) WHERE id = @a', 'SELECT 1');
|
|
|
|
|
PREPARE stmt FROM @sql; EXECUTE stmt; DEALLOCATE PREPARE stmt;
|
|
|
|
|
SET @sql := IF(@already = 0, 'INSERT INTO activities (project_id, code, name, priority_id, status_id, created_by) VALUES (@p, \'PENDING\', \'Limpieza y mejoras de equipos\', 2, 1, 1)', 'SELECT 1');
|
|
|
|
|
PREPARE stmt FROM @sql; EXECUTE stmt; DEALLOCATE PREPARE stmt;
|
|
|
|
|
SET @a := LAST_INSERT_ID();
|
|
|
|
|
SET @sql := IF(@already = 0, 'UPDATE activities SET code = CONCAT(\'ACT-\', LPAD(@a,4,\'0\')) WHERE id = @a', 'SELECT 1');
|
|
|
|
|
PREPARE stmt FROM @sql; EXECUTE stmt; DEALLOCATE PREPARE stmt;
|
|
|
|
|
SET @sql := IF(@already = 0, 'INSERT INTO activities (project_id, code, name, priority_id, status_id, created_by) VALUES (@p, \'PENDING\', \'Respuestas automaticas de correo cuando alguien sale de la empresa\', 2, 1, 1)', 'SELECT 1');
|
|
|
|
|
PREPARE stmt FROM @sql; EXECUTE stmt; DEALLOCATE PREPARE stmt;
|
|
|
|
|
SET @a := LAST_INSERT_ID();
|
|
|
|
|
SET @sql := IF(@already = 0, 'UPDATE activities SET code = CONCAT(\'ACT-\', LPAD(@a,4,\'0\')) WHERE id = @a', 'SELECT 1');
|
|
|
|
|
PREPARE stmt FROM @sql; EXECUTE stmt; DEALLOCATE PREPARE stmt;
|
|
|
|
|
|
|
|
|
|
-- Proyecto: Gestion de credenciales y licencias
|
|
|
|
|
SET @sql := IF(@already = 0, 'INSERT INTO projects (code, name, priority_id, status_id, owner_user_id, risk_level, created_by) VALUES (\'PENDING\', \'Gestion de credenciales y licencias\', 2, 1, 1, \'low\', 1)', 'SELECT 1');
|
|
|
|
|
PREPARE stmt FROM @sql; EXECUTE stmt; DEALLOCATE PREPARE stmt;
|
|
|
|
|
SET @p := LAST_INSERT_ID();
|
|
|
|
|
SET @sql := IF(@already = 0, 'UPDATE projects SET code = CONCAT(\'PRY-\', LPAD(@p,4,\'0\')) WHERE id = @p', 'SELECT 1');
|
|
|
|
|
PREPARE stmt FROM @sql; EXECUTE stmt; DEALLOCATE PREPARE stmt;
|
|
|
|
|
SET @sql := IF(@already = 0, 'INSERT IGNORE INTO project_members (project_id, user_id, role_in_project) VALUES (@p, 1, \'owner\')', 'SELECT 1');
|
|
|
|
|
PREPARE stmt FROM @sql; EXECUTE stmt; DEALLOCATE PREPARE stmt;
|
|
|
|
|
|
|
|
|
|
SET @sql := IF(@already = 0, 'INSERT INTO activities (project_id, code, name, priority_id, status_id, created_by) VALUES (@p, \'PENDING\', \'Archivo general de claves de sistemas y usuarios (BitWarden)\', 2, 1, 1)', 'SELECT 1');
|
|
|
|
|
PREPARE stmt FROM @sql; EXECUTE stmt; DEALLOCATE PREPARE stmt;
|
|
|
|
|
SET @a := LAST_INSERT_ID();
|
|
|
|
|
SET @sql := IF(@already = 0, 'UPDATE activities SET code = CONCAT(\'ACT-\', LPAD(@a,4,\'0\')) WHERE id = @a', 'SELECT 1');
|
|
|
|
|
PREPARE stmt FROM @sql; EXECUTE stmt; DEALLOCATE PREPARE stmt;
|
|
|
|
|
SET @sql := IF(@already = 0, 'INSERT INTO activities (project_id, code, name, priority_id, status_id, created_by) VALUES (@p, \'PENDING\', \'Inventario de licencias de equipos\', 2, 1, 1)', 'SELECT 1');
|
|
|
|
|
PREPARE stmt FROM @sql; EXECUTE stmt; DEALLOCATE PREPARE stmt;
|
|
|
|
|
SET @a := LAST_INSERT_ID();
|
|
|
|
|
SET @sql := IF(@already = 0, 'UPDATE activities SET code = CONCAT(\'ACT-\', LPAD(@a,4,\'0\')) WHERE id = @a', 'SELECT 1');
|
|
|
|
|
PREPARE stmt FROM @sql; EXECUTE stmt; DEALLOCATE PREPARE stmt;
|
|
|
|
|
|
|
|
|
|
-- Proyecto: Infraestructura y redes
|
|
|
|
|
SET @sql := IF(@already = 0, 'INSERT INTO projects (code, name, priority_id, status_id, owner_user_id, risk_level, created_by) VALUES (\'PENDING\', \'Infraestructura y redes\', 2, 1, 1, \'low\', 1)', 'SELECT 1');
|
|
|
|
|
PREPARE stmt FROM @sql; EXECUTE stmt; DEALLOCATE PREPARE stmt;
|
|
|
|
|
SET @p := LAST_INSERT_ID();
|
|
|
|
|
SET @sql := IF(@already = 0, 'UPDATE projects SET code = CONCAT(\'PRY-\', LPAD(@p,4,\'0\')) WHERE id = @p', 'SELECT 1');
|
|
|
|
|
PREPARE stmt FROM @sql; EXECUTE stmt; DEALLOCATE PREPARE stmt;
|
|
|
|
|
SET @sql := IF(@already = 0, 'INSERT IGNORE INTO project_members (project_id, user_id, role_in_project) VALUES (@p, 1, \'owner\')', 'SELECT 1');
|
|
|
|
|
PREPARE stmt FROM @sql; EXECUTE stmt; DEALLOCATE PREPARE stmt;
|
|
|
|
|
|
|
|
|
|
SET @sql := IF(@already = 0, 'INSERT INTO activities (project_id, code, name, priority_id, status_id, created_by) VALUES (@p, \'PENDING\', \'Redes con el proveedor\', 2, 1, 1)', 'SELECT 1');
|
|
|
|
|
PREPARE stmt FROM @sql; EXECUTE stmt; DEALLOCATE PREPARE stmt;
|
|
|
|
|
SET @a := LAST_INSERT_ID();
|
|
|
|
|
SET @sql := IF(@already = 0, 'UPDATE activities SET code = CONCAT(\'ACT-\', LPAD(@a,4,\'0\')) WHERE id = @a', 'SELECT 1');
|
|
|
|
|
PREPARE stmt FROM @sql; EXECUTE stmt; DEALLOCATE PREPARE stmt;
|
|
|
|
|
SET @sql := IF(@already = 0, 'INSERT INTO activities (project_id, code, name, priority_id, status_id, created_by) VALUES (@p, \'PENDING\', \'Server\', 2, 1, 1)', 'SELECT 1');
|
|
|
|
|
PREPARE stmt FROM @sql; EXECUTE stmt; DEALLOCATE PREPARE stmt;
|
|
|
|
|
SET @a := LAST_INSERT_ID();
|
|
|
|
|
SET @sql := IF(@already = 0, 'UPDATE activities SET code = CONCAT(\'ACT-\', LPAD(@a,4,\'0\')) WHERE id = @a', 'SELECT 1');
|
|
|
|
|
PREPARE stmt FROM @sql; EXECUTE stmt; DEALLOCATE PREPARE stmt;
|
|
|
|
|
SET @sql := IF(@already = 0, 'INSERT INTO activities (project_id, code, name, priority_id, status_id, created_by) VALUES (@p, \'PENDING\', \'Controlar el acceso a internet\', 2, 1, 1)', 'SELECT 1');
|
|
|
|
|
PREPARE stmt FROM @sql; EXECUTE stmt; DEALLOCATE PREPARE stmt;
|
|
|
|
|
SET @a := LAST_INSERT_ID();
|
|
|
|
|
SET @sql := IF(@already = 0, 'UPDATE activities SET code = CONCAT(\'ACT-\', LPAD(@a,4,\'0\')) WHERE id = @a', 'SELECT 1');
|
|
|
|
|
PREPARE stmt FROM @sql; EXECUTE stmt; DEALLOCATE PREPARE stmt;
|
|
|
|
|
SET @sql := IF(@already = 0, 'INSERT INTO activities (project_id, code, name, priority_id, status_id, created_by) VALUES (@p, \'PENDING\', \'Mejoras continuas de la red\', 2, 1, 1)', 'SELECT 1');
|
|
|
|
|
PREPARE stmt FROM @sql; EXECUTE stmt; DEALLOCATE PREPARE stmt;
|
|
|
|
|
SET @a := LAST_INSERT_ID();
|
|
|
|
|
SET @sql := IF(@already = 0, 'UPDATE activities SET code = CONCAT(\'ACT-\', LPAD(@a,4,\'0\')) WHERE id = @a', 'SELECT 1');
|
|
|
|
|
PREPARE stmt FROM @sql; EXECUTE stmt; DEALLOCATE PREPARE stmt;
|
|
|
|
|
|
|
|
|
|
-- Proyecto: Mejoras al sistema SAGA
|
|
|
|
|
SET @sql := IF(@already = 0, 'INSERT INTO projects (code, name, priority_id, status_id, owner_user_id, risk_level, created_by) VALUES (\'PENDING\', \'Mejoras al sistema SAGA\', 2, 1, 1, \'low\', 1)', 'SELECT 1');
|
|
|
|
|
PREPARE stmt FROM @sql; EXECUTE stmt; DEALLOCATE PREPARE stmt;
|
|
|
|
|
SET @p := LAST_INSERT_ID();
|
|
|
|
|
SET @sql := IF(@already = 0, 'UPDATE projects SET code = CONCAT(\'PRY-\', LPAD(@p,4,\'0\')) WHERE id = @p', 'SELECT 1');
|
|
|
|
|
PREPARE stmt FROM @sql; EXECUTE stmt; DEALLOCATE PREPARE stmt;
|
|
|
|
|
SET @sql := IF(@already = 0, 'INSERT IGNORE INTO project_members (project_id, user_id, role_in_project) VALUES (@p, 1, \'owner\')', 'SELECT 1');
|
|
|
|
|
PREPARE stmt FROM @sql; EXECUTE stmt; DEALLOCATE PREPARE stmt;
|
|
|
|
|
|
|
|
|
|
SET @sql := IF(@already = 0, 'INSERT INTO activities (project_id, code, name, priority_id, status_id, created_by) VALUES (@p, \'PENDING\', \'Sistematizar mejoras en el sistema de SAGA\', 2, 1, 1)', 'SELECT 1');
|
|
|
|
|
PREPARE stmt FROM @sql; EXECUTE stmt; DEALLOCATE PREPARE stmt;
|
|
|
|
|
SET @a := LAST_INSERT_ID();
|
|
|
|
|
SET @sql := IF(@already = 0, 'UPDATE activities SET code = CONCAT(\'ACT-\', LPAD(@a,4,\'0\')) WHERE id = @a', 'SELECT 1');
|
|
|
|
|
PREPARE stmt FROM @sql; EXECUTE stmt; DEALLOCATE PREPARE stmt;
|
|
|
|
|
|
|
|
|
|
SET @sql := IF(@already = 0, 'INSERT INTO system_settings (`key`, `value`) VALUES (\'seed_it_baseline_2026_09\', NOW())', 'SELECT 1');
|
|
|
|
|
PREPARE stmt FROM @sql; EXECUTE stmt; DEALLOCATE PREPARE stmt;
|