
CREATE TABLE icac_error (
    file VARCHAR(254) NOT NULL,
    line MEDIUMINT UNSIGNED not null DEFAULT '0',
    error_type VARCHAR(16) NOT NULL DEFAULT 'php',
    coded VARCHAR(32) not null,
    first_seen DATETIME NOT NULL,
    last_seen DATETIME NOT NULL,
    seen_times MEDIUMINT UNSIGNED NOT NULL DEFAULT '1',
    error_message TEXT,
    status enum('Bug','Fixed','Wont Fix') NOT NULL DEFAULT 'Bug',
    last_fixed DATETIME NULL,
    fixes SMALLINT UNSIGNED NOT NULL DEFAULT '0',
    note TEXT,
    PRIMARY KEY (file, line, error_type, coded),
    KEY listme(status,last_seen)
) ENGINE=Innodb DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci COMMENT='Bitacora de errores detectados';

CREATE TABLE IF NOT EXISTS ia_dime (
    file VARCHAR(254) NOT NULL,
    line MEDIUMINT UNSIGNED not null DEFAULT '0',
    error_type VARCHAR(16) NOT NULL DEFAULT 'php',
    coded VARCHAR(32) not null,
    first_seen DATETIME NOT NULL,
    last_seen DATETIME NOT NULL,
    seen_times MEDIUMINT UNSIGNED NOT NULL DEFAULT '1',
    error_message TEXT,
    status enum('Bug','Fixed','Wont Fix') NOT NULL DEFAULT 'Bug',
    last_fixed DATETIME NULL,
    fixes SMALLINT UNSIGNED NOT NULL DEFAULT '0',
    note TEXT,
    PRIMARY KEY (file, line, error_type, coded),
    KEY listme(status,last_seen)
) ENGINE=Innodb DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci COMMENT='Avisos del comportamiento del sistema';

CREATE TABLE IF NOT EXISTS iaFiller (
    iaFiller_id MEDIUMINT UNSIGNED NOT NULL AUTO_INCREMENT PRIMARY KEY,
    nombre VARCHAR(64) NOT NULL COMMENT 'nombre de los valores a llenar',
    descripcion  VARCHAR(128) NOT NULL DEFAULT '' COMMENT 'Descripcion para recordar que quiere decir el nombre',
    tag VARCHAR(64) NOT NULL COMMENT 'clasificacion de la plantilla',
    color VARCHAR(32) NOT NULL DEFAULT 'iaFillerNormal' COMMENT 'css class de la plantilla',
    vals LONGTEXT COMMENT 'json con los valores a llenar',
    alta_db DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT 'fecha de alta',
    ultimo_cambio  DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT 'ultima fecha en que se actualizo',
    UNIQUE KEY nombre_unico(tag,nombre)
) ENGINE=Innodb DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci COMMENT 'Plantillas de iaFiller';

CREATE TABLE iac_help(
    iac_help_id SMALLINT UNSIGNED NOT NULL AUTO_INCREMENT PRIMARY KEY,
    titled VARCHAR(128) NOT NULL DEFAULT '',
    concept LONGTEXT,
    remarks LONGTEXT,
    param VARCHAR(64) NOT NULL,
    url VARCHAR(128) NOT NULL DEFAULT '',
    parent_id SMALLINT UNSIGNED NOT NULL DEFAULT '0',
    iac_order SMALLINT UNSIGNED NOT NULL DEFAULT '1000',
    iac_order_indx SMALLINT UNSIGNED NOT NULL DEFAULT '0',
    UNIQUE KEY by_param(param),
    KEY prtSorted(parent_id,iac_order,titled),
    KEY sorted(iac_order,titled),
    KEY iac_order_indx_sorted(iac_order_indx,titled)

)ENGINE=Innodb DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci COMMENT='Help screens';

--qTODO issues

--@TODO workday
