summaryrefslogtreecommitdiffstats
path: root/upgrades/dbpatches/1.3/postgresql/patch/hosts_templates.sql
diff options
context:
space:
mode:
Diffstat (limited to 'upgrades/dbpatches/1.3/postgresql/patch/hosts_templates.sql')
-rw-r--r--upgrades/dbpatches/1.3/postgresql/patch/hosts_templates.sql23
1 files changed, 23 insertions, 0 deletions
diff --git a/upgrades/dbpatches/1.3/postgresql/patch/hosts_templates.sql b/upgrades/dbpatches/1.3/postgresql/patch/hosts_templates.sql
new file mode 100644
index 00000000..98dc2df0
--- /dev/null
+++ b/upgrades/dbpatches/1.3/postgresql/patch/hosts_templates.sql
@@ -0,0 +1,23 @@
+CREATE TABLE hosts_templates_tmp (
+ hosttemplateid bigint unsigned NOT NULL auto_increment,
+ hostid bigint unsigned DEFAULT '0' NOT NULL,
+ templateid bigint unsigned DEFAULT '0' NOT NULL,
+ PRIMARY KEY (hosttemplateid)
+) ENGINE=InnoDB;
+CREATE UNIQUE INDEX hosts_templates_1 on hosts_templates_tmp (hostid,templateid);
+
+insert into hosts_templates_tmp select NULL,hostid,templateid from hosts_templates;
+drop table hosts_templates;
+alter table hosts_templates_tmp rename hosts_templates;
+
+CREATE TABLE hosts_templates_tmp (
+ hosttemplateid bigint unsigned DEFAULT '0' NOT NULL,
+ hostid bigint unsigned DEFAULT '0' NOT NULL,
+ templateid bigint unsigned DEFAULT '0' NOT NULL,
+ PRIMARY KEY (hosttemplateid)
+) ENGINE=InnoDB;
+CREATE UNIQUE INDEX hosts_templates_1 on hosts_templates_tmp (hostid,templateid);
+
+insert into hosts_templates_tmp select * from hosts_templates;
+drop table hosts_templates;
+alter table hosts_templates_tmp rename hosts_templates;