Schema update to avoid using JSON columns until internal CICD is updated

This commit is contained in:
fbsanchez 2021-09-30 11:18:13 +02:00
parent 696c59b258
commit 18b1a1e14e
3 changed files with 30 additions and 13 deletions

View File

@ -35,16 +35,23 @@ CREATE TABLE IF NOT EXISTS `tncm_template_scripts` (
FOREIGN KEY (`id_script`) REFERENCES `tncm_script`(`id`) ON UPDATE CASCADE ON DELETE CASCADE
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
CREATE TABLE IF NOT EXISTS `tncm_agent_templates` (
`id` serial,
CREATE TABLE IF NOT EXISTS `tncm_agent` (
`id_agent` int(10) unsigned NOT NULL,
`id_template` bigint(20) unsigned NOT NULL,
`vendor` text,
`model` text,
`protocol` int unsigned not null default 0,
`cred_key` varchar(100),
PRIMARY KEY (`id`),
PRIMARY KEY (`id_agent`),
FOREIGN KEY (`id_agent`) REFERENCES `tagente`(`id_agente`) ON UPDATE CASCADE ON DELETE CASCADE,
FOREIGN KEY (`id_template`) REFERENCES `tncm_template`(`id`) ON UPDATE CASCADE ON DELETE CASCADE,
FOREIGN KEY (`cred_key`) REFERENCES `tcredential_store`(`identifier`) ON UPDATE CASCADE ON DELETE SET NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
CREATE TABLE IF NOT EXISTS `tncm_agent_templates` (
`id_agent` int(10) unsigned NOT NULL,
`id_template` bigint(20) unsigned NOT NULL,
PRIMARY KEY (`id_agent`, `id_template`),
FOREIGN KEY (`id_agent`) REFERENCES `tagente`(`id_agente`) ON UPDATE CASCADE ON DELETE CASCADE,
FOREIGN KEY (`id_template`) REFERENCES `tncm_template`(`id`) ON UPDATE CASCADE ON DELETE CASCADE
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
COMMIT;

View File

@ -4122,17 +4122,27 @@ CREATE TABLE IF NOT EXISTS `tncm_template_scripts` (
FOREIGN KEY (`id_script`) REFERENCES `tncm_script`(`id`) ON UPDATE CASCADE ON DELETE CASCADE
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
-- ----------------------------------------------------------------------
-- Table `tncm_agents`
-- ----------------------------------------------------------------------
CREATE TABLE IF NOT EXISTS `tncm_agent` (
`id_agent` int(10) unsigned NOT NULL,
`vendor` text,
`model` text,
`protocol` int unsigned not null default 0,
`cred_key` varchar(100),
PRIMARY KEY (`id_agent`),
FOREIGN KEY (`id_agent`) REFERENCES `tagente`(`id_agente`) ON UPDATE CASCADE ON DELETE CASCADE,
FOREIGN KEY (`cred_key`) REFERENCES `tcredential_store`(`identifier`) ON UPDATE CASCADE ON DELETE SET NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
-- ----------------------------------------------------------------------
-- Table `tncm_agent_templates`
-- ----------------------------------------------------------------------
CREATE TABLE IF NOT EXISTS `tncm_agent_templates` (
`id` serial,
`id_agent` int(10) unsigned NOT NULL,
`id_template` bigint(20) unsigned NOT NULL,
`protocol` int unsigned not null default 0,
`cred_key` varchar(100),
PRIMARY KEY (`id`),
PRIMARY KEY (`id_agent`, `id_template`),
FOREIGN KEY (`id_agent`) REFERENCES `tagente`(`id_agente`) ON UPDATE CASCADE ON DELETE CASCADE,
FOREIGN KEY (`id_template`) REFERENCES `tncm_template`(`id`) ON UPDATE CASCADE ON DELETE CASCADE,
FOREIGN KEY (`cred_key`) REFERENCES `tcredential_store`(`identifier`) ON UPDATE CASCADE ON DELETE SET NULL
FOREIGN KEY (`id_template`) REFERENCES `tncm_template`(`id`) ON UPDATE CASCADE ON DELETE CASCADE
) ENGINE=InnoDB DEFAULT CHARSET=utf8;

View File

@ -4030,8 +4030,8 @@ CREATE TABLE IF NOT EXISTS `tsync_queue` (
-- ----------------------------------------------------------------------
CREATE TABLE IF NOT EXISTS `tncm_template` (
`id` serial,
`vendor` json,
`model` json,
`vendor` text,
`model` text,
PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;