USE sistema_protocolos_minedu;
CREATE TABLE IF NOT EXISTS institution_settings (
 id INT PRIMARY KEY DEFAULT 1,
 name VARCHAR(200) DEFAULT '',
 modular_code VARCHAR(50) DEFAULT '',
 local_code VARCHAR(50) DEFAULT '',
 education_level VARCHAR(80) DEFAULT 'Educación Básica Regular',
 management_type VARCHAR(40) DEFAULT 'Pública',
 ugel VARCHAR(150) DEFAULT '',
 dre_gre VARCHAR(150) DEFAULT '',
 region VARCHAR(100) DEFAULT '',
 province VARCHAR(100) DEFAULT '',
 district VARCHAR(100) DEFAULT '',
 address VARCHAR(255) DEFAULT '',
 phone VARCHAR(80) DEFAULT '',
 email VARCHAR(160) DEFAULT '',
 director_name VARCHAR(160) DEFAULT '',
 convivencia_name VARCHAR(160) DEFAULT '',
 toe_name VARCHAR(160) DEFAULT '',
 school_year VARCHAR(20) DEFAULT '',
 period_name VARCHAR(80) DEFAULT '',
 modality VARCHAR(80) DEFAULT 'Presencial',
 logo_path VARCHAR(255) DEFAULT NULL,
 stamp_path VARCHAR(255) DEFAULT NULL,
 updated_by INT NULL,
 updated_at DATETIME NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
INSERT INTO institution_settings(id,name,education_level,management_type,school_year,modality,updated_at)
SELECT 1,'Institución Educativa Demo','Educación Básica Regular','Pública',YEAR(CURDATE()),'Presencial',NOW()
WHERE NOT EXISTS (SELECT 1 FROM institution_settings WHERE id=1);
