Skip to content

Commit

Permalink
schema: add cnt_apply column
Browse files Browse the repository at this point in the history
  • Loading branch information
Thomas-Gelf committed Nov 3, 2016
1 parent c073278 commit 92bb24b
Show file tree
Hide file tree
Showing 4 changed files with 28 additions and 2 deletions.
12 changes: 12 additions & 0 deletions schema/mysql-migrations/upgrade_122.sql
Original file line number Diff line number Diff line change
@@ -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());
3 changes: 2 additions & 1 deletion schema/mysql.sql
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down Expand Up @@ -1354,4 +1355,4 @@ CREATE TABLE sync_run (

INSERT INTO director_schema_migration
(schema_version, migration_time)
VALUES (121, NOW());
VALUES (122, NOW());
12 changes: 12 additions & 0 deletions schema/pgsql-migrations/upgrade_122.sql
Original file line number Diff line number Diff line change
@@ -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());
3 changes: 2 additions & 1 deletion schema/pgsql.sql
Original file line number Diff line number Diff line change
Expand Up @@ -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)
);

Expand Down Expand Up @@ -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());

0 comments on commit 92bb24b

Please sign in to comment.