schema: fix legacy booleans stored as strings

fixes #12526
This commit is contained in:
Thomas Gelf 2016-09-23 16:22:35 +00:00
parent 348cb1aa63
commit 0e133daa8b
4 changed files with 210 additions and 2 deletions

View File

@ -0,0 +1,104 @@
UPDATE icinga_host_var
SET varvalue = 'false',
format = 'json'
WHERE varvalue = 'n'
AND varname IN (
SELECT DISTINCT varname
FROM director_datafield
WHERE datatype LIKE '%DataTypeBoolean'
);
UPDATE icinga_host_var
SET varvalue = 'true',
format = 'json'
WHERE varvalue = 'y'
AND varname IN (
SELECT DISTINCT varname
FROM director_datafield
WHERE datatype LIKE '%DataTypeBoolean'
);
UPDATE icinga_service_var
SET varvalue = 'false',
format = 'json'
WHERE varvalue = 'n'
AND varname IN (
SELECT DISTINCT varname
FROM director_datafield
WHERE datatype LIKE '%DataTypeBoolean'
);
UPDATE icinga_service_var
SET varvalue = 'true',
format = 'json'
WHERE varvalue = 'y'
AND varname IN (
SELECT DISTINCT varname
FROM director_datafield
WHERE datatype LIKE '%DataTypeBoolean'
);
UPDATE icinga_command_var
SET varvalue = 'false',
format = 'json'
WHERE varvalue = 'n'
AND varname IN (
SELECT DISTINCT varname
FROM director_datafield
WHERE datatype LIKE '%DataTypeBoolean'
);
UPDATE icinga_command_var
SET varvalue = 'true',
format = 'json'
WHERE varvalue = 'y'
AND varname IN (
SELECT DISTINCT varname
FROM director_datafield
WHERE datatype LIKE '%DataTypeBoolean'
);
UPDATE icinga_user_var
SET varvalue = 'false',
format = 'json'
WHERE varvalue = 'n'
AND varname IN (
SELECT DISTINCT varname
FROM director_datafield
WHERE datatype LIKE '%DataTypeBoolean'
);
UPDATE icinga_user_var
SET varvalue = 'true',
format = 'json'
WHERE varvalue = 'y'
AND varname IN (
SELECT DISTINCT varname
FROM director_datafield
WHERE datatype LIKE '%DataTypeBoolean'
);
UPDATE icinga_notification_var
SET varvalue = 'false',
format = 'json'
WHERE varvalue = 'n'
AND varname IN (
SELECT DISTINCT varname
FROM director_datafield
WHERE datatype LIKE '%DataTypeBoolean'
);
UPDATE icinga_notification_var
SET varvalue = 'true',
format = 'json'
WHERE varvalue = 'y'
AND varname IN (
SELECT DISTINCT varname
FROM director_datafield
WHERE datatype LIKE '%DataTypeBoolean'
);
INSERT INTO director_schema_migration
(schema_version, migration_time)
VALUES (110, NOW());

View File

@ -1326,4 +1326,4 @@ CREATE TABLE sync_run (
INSERT INTO director_schema_migration
SET migration_time = NOW(),
schema_version = 109;
schema_version = 110;

View File

@ -0,0 +1,104 @@
UPDATE icinga_host_var
SET varvalue = 'false',
format = 'json'
WHERE varvalue = 'n'
AND varname IN (
SELECT DISTINCT varname
FROM director_datafield
WHERE datatype LIKE '%DataTypeBoolean'
);
UPDATE icinga_host_var
SET varvalue = 'true',
format = 'json'
WHERE varvalue = 'y'
AND varname IN (
SELECT DISTINCT varname
FROM director_datafield
WHERE datatype LIKE '%DataTypeBoolean'
);
UPDATE icinga_service_var
SET varvalue = 'false',
format = 'json'
WHERE varvalue = 'n'
AND varname IN (
SELECT DISTINCT varname
FROM director_datafield
WHERE datatype LIKE '%DataTypeBoolean'
);
UPDATE icinga_service_var
SET varvalue = 'true',
format = 'json'
WHERE varvalue = 'y'
AND varname IN (
SELECT DISTINCT varname
FROM director_datafield
WHERE datatype LIKE '%DataTypeBoolean'
);
UPDATE icinga_command_var
SET varvalue = 'false',
format = 'json'
WHERE varvalue = 'n'
AND varname IN (
SELECT DISTINCT varname
FROM director_datafield
WHERE datatype LIKE '%DataTypeBoolean'
);
UPDATE icinga_command_var
SET varvalue = 'true',
format = 'json'
WHERE varvalue = 'y'
AND varname IN (
SELECT DISTINCT varname
FROM director_datafield
WHERE datatype LIKE '%DataTypeBoolean'
);
UPDATE icinga_user_var
SET varvalue = 'false',
format = 'json'
WHERE varvalue = 'n'
AND varname IN (
SELECT DISTINCT varname
FROM director_datafield
WHERE datatype LIKE '%DataTypeBoolean'
);
UPDATE icinga_user_var
SET varvalue = 'true',
format = 'json'
WHERE varvalue = 'y'
AND varname IN (
SELECT DISTINCT varname
FROM director_datafield
WHERE datatype LIKE '%DataTypeBoolean'
);
UPDATE icinga_notification_var
SET varvalue = 'false',
format = 'json'
WHERE varvalue = 'n'
AND varname IN (
SELECT DISTINCT varname
FROM director_datafield
WHERE datatype LIKE '%DataTypeBoolean'
);
UPDATE icinga_notification_var
SET varvalue = 'true',
format = 'json'
WHERE varvalue = 'y'
AND varname IN (
SELECT DISTINCT varname
FROM director_datafield
WHERE datatype LIKE '%DataTypeBoolean'
);
INSERT INTO director_schema_migration
(schema_version, migration_time)
VALUES (110, NOW());

View File

@ -1545,4 +1545,4 @@ CREATE UNIQUE INDEX notification_inheritance ON icinga_notification_inheritance
INSERT INTO director_schema_migration
(schema_version, migration_time)
VALUES (109, NOW());
VALUES (110, NOW());