[FIX] reset-demo.sql: adatta a struttura reale DB (incident_timeline, capa_actions, email_log, users)
- incident_timeline: join su incidents (no organization_id diretto) - corrective_actions → capa_actions, non_conformity_id → ncr_id - email_log: filtra per recipient LIKE '%.demo%' (no organization_id) - users INSERT: first_name/last_name/status → full_name/is_active Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
parent
fca3ab3cf8
commit
eddc2fe79d
@ -15,7 +15,8 @@ SET FOREIGN_KEY_CHECKS = 0;
|
|||||||
-- ── Dati operativi generati dalla simulazione ─────────────────────────────
|
-- ── Dati operativi generati dalla simulazione ─────────────────────────────
|
||||||
|
|
||||||
-- Notifiche incidenti / timeline
|
-- Notifiche incidenti / timeline
|
||||||
DELETE FROM incident_timeline WHERE organization_id > 4;
|
DELETE FROM incident_timeline
|
||||||
|
WHERE incident_id IN (SELECT id FROM incidents WHERE organization_id > 4);
|
||||||
DELETE FROM incidents WHERE organization_id > 4;
|
DELETE FROM incidents WHERE organization_id > 4;
|
||||||
|
|
||||||
-- Rischi e trattamenti
|
-- Rischi e trattamenti
|
||||||
@ -46,7 +47,7 @@ DELETE FROM compliance_controls WHERE organization_id > 4;
|
|||||||
DELETE FROM evidence_files WHERE organization_id > 4;
|
DELETE FROM evidence_files WHERE organization_id > 4;
|
||||||
|
|
||||||
-- Non conformità e CAPA
|
-- Non conformità e CAPA
|
||||||
DELETE FROM corrective_actions WHERE non_conformity_id IN (SELECT id FROM non_conformities WHERE organization_id > 4);
|
DELETE FROM capa_actions WHERE ncr_id IN (SELECT id FROM non_conformities WHERE organization_id > 4);
|
||||||
DELETE FROM non_conformities WHERE organization_id > 4;
|
DELETE FROM non_conformities WHERE organization_id > 4;
|
||||||
|
|
||||||
-- Whistleblowing
|
-- Whistleblowing
|
||||||
@ -71,8 +72,8 @@ DELETE FROM audit_violations WHERE organization_id > 4;
|
|||||||
-- AI interactions
|
-- AI interactions
|
||||||
DELETE FROM ai_interactions WHERE organization_id > 4;
|
DELETE FROM ai_interactions WHERE organization_id > 4;
|
||||||
|
|
||||||
-- Email log
|
-- Email log (no organization_id — pulisce solo email con indirizzo demo)
|
||||||
DELETE FROM email_log WHERE organization_id > 4;
|
DELETE FROM email_log WHERE recipient LIKE '%.demo%';
|
||||||
|
|
||||||
-- ── Membership utenti ─────────────────────────────────────────────────────
|
-- ── Membership utenti ─────────────────────────────────────────────────────
|
||||||
|
|
||||||
@ -98,15 +99,15 @@ DELETE rt FROM refresh_tokens rt
|
|||||||
JOIN users u ON rt.user_id = u.id
|
JOIN users u ON rt.user_id = u.id
|
||||||
WHERE u.email = 'cristiano.benassati@gmail.com';
|
WHERE u.email = 'cristiano.benassati@gmail.com';
|
||||||
|
|
||||||
INSERT INTO users (email, password_hash, first_name, last_name, role, status)
|
INSERT INTO users (email, password_hash, full_name, role, is_active)
|
||||||
VALUES (
|
VALUES (
|
||||||
'cristiano.benassati@gmail.com',
|
'cristiano.benassati@gmail.com',
|
||||||
'$2y$12$H/AJ7SgBowihcOcpblQ7PeanmoTXzgruv3mRvC.vexoRodNa7rAUi',
|
'$2y$12$H/AJ7SgBowihcOcpblQ7PeanmoTXzgruv3mRvC.vexoRodNa7rAUi',
|
||||||
'Cristiano', 'Benassati', 'super_admin', 'active'
|
'Cristiano Benassati', 'super_admin', 1
|
||||||
)
|
)
|
||||||
ON DUPLICATE KEY UPDATE
|
ON DUPLICATE KEY UPDATE
|
||||||
role = 'super_admin',
|
role = 'super_admin',
|
||||||
status = 'active',
|
is_active = 1,
|
||||||
password_hash = '$2y$12$H/AJ7SgBowihcOcpblQ7PeanmoTXzgruv3mRvC.vexoRodNa7rAUi';
|
password_hash = '$2y$12$H/AJ7SgBowihcOcpblQ7PeanmoTXzgruv3mRvC.vexoRodNa7rAUi';
|
||||||
|
|
||||||
-- ── Ripristino FK ─────────────────────────────────────────────────────────
|
-- ── Ripristino FK ─────────────────────────────────────────────────────────
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user