[icinga-checkins] icinga.org: icingaweb2-module-director/master: schema: add cnt_apply column

git at icinga.org git at icinga.org
Thu Nov 3 13:36:38 CET 2016


Module: icingaweb2-module-director
Branch: master
Commit: 92bb24b414c572ad41ef0955fb5a76f93c6e6d8b
URL:    https://git.icinga.org/?p=icingaweb2-module-director.git;a=commit;h=92bb24b414c572ad41ef0955fb5a76f93c6e6d8b

Author: Thomas Gelf <thomas at gelf.net>
Date:   Mon Oct 24 19:58:23 2016 +0000

schema: add cnt_apply column

---

 schema/mysql-migrations/upgrade_122.sql |   12 ++++++++++++
 schema/mysql.sql                        |    3 ++-
 schema/pgsql-migrations/upgrade_122.sql |   12 ++++++++++++
 schema/pgsql.sql                        |    3 ++-
 4 files changed, 28 insertions(+), 2 deletions(-)

diff --git a/schema/mysql-migrations/upgrade_122.sql b/schema/mysql-migrations/upgrade_122.sql
new file mode 100644
index 0000000..6a94e05
--- /dev/null
+++ b/schema/mysql-migrations/upgrade_122.sql
@@ -0,0 +1,12 @@
+ALTER TABLE director_generated_file
+  ADD COLUMN cnt_apply INT(10) UNSIGNED NOT NULL DEFAULT 0;
+
+UPDATE director_generated_file
+SET cnt_apply = ROUND(
+  (LENGTH(content) - LENGTH( REPLACE(content, 'apply ', '') ) )
+  / LENGTH('apply ')
+);
+
+INSERT INTO director_schema_migration
+  (schema_version, migration_time)
+  VALUES (122, NOW());
diff --git a/schema/mysql.sql b/schema/mysql.sql
index a6e46ed..ce7678e 100644
--- a/schema/mysql.sql
+++ b/schema/mysql.sql
@@ -47,6 +47,7 @@ CREATE TABLE director_generated_file (
   content MEDIUMTEXT NOT NULL,
   cnt_object INT(10) UNSIGNED NOT NULL DEFAULT 0,
   cnt_template INT(10) UNSIGNED NOT NULL DEFAULT 0,
+  cnt_apply INT(10) UNSIGNED NOT NULL DEFAULT 0,
   PRIMARY KEY (checksum)
 ) ENGINE=InnoDB DEFAULT CHARSET=utf8;
 
@@ -1354,4 +1355,4 @@ CREATE TABLE sync_run (
 
 INSERT INTO director_schema_migration
   (schema_version, migration_time)
-  VALUES (121, NOW());
+  VALUES (122, NOW());
diff --git a/schema/pgsql-migrations/upgrade_122.sql b/schema/pgsql-migrations/upgrade_122.sql
new file mode 100644
index 0000000..6f3f884
--- /dev/null
+++ b/schema/pgsql-migrations/upgrade_122.sql
@@ -0,0 +1,12 @@
+ALTER TABLE director_generated_file
+  ADD COLUMN cnt_apply SMALLINT NOT NULL DEFAULT 0;
+
+UPDATE director_generated_file
+SET cnt_apply = ROUND(
+  (LENGTH(content) - LENGTH( REPLACE(content, 'apply ', '') ) )
+  / LENGTH('apply ')
+);
+
+INSERT INTO director_schema_migration
+  (schema_version, migration_time)
+  VALUES (122, NOW());
diff --git a/schema/pgsql.sql b/schema/pgsql.sql
index 84fd2ac..e3198bc 100644
--- a/schema/pgsql.sql
+++ b/schema/pgsql.sql
@@ -95,6 +95,7 @@ CREATE TABLE director_generated_file (
   content text DEFAULT NULL,
   cnt_object SMALLINT NOT NULL DEFAULT 0,
   cnt_template SMALLINT NOT NULL DEFAULT 0,
+  cnt_apply SMALLINT NOT NULL DEFAULT 0,
   PRIMARY KEY (checksum)
 );
 
@@ -1581,4 +1582,4 @@ CREATE UNIQUE INDEX notification_inheritance ON icinga_notification_inheritance
 
 INSERT INTO director_schema_migration
   (schema_version, migration_time)
-  VALUES (121, NOW());
+  VALUES (122, NOW());



More information about the icinga-checkins mailing list