From eab8b5c9babf6384c212f52eef0c8236411ea9af Mon Sep 17 00:00:00 2001 From: Thomas Gelf Date: Tue, 26 Jul 2016 13:50:42 +0200 Subject: [PATCH] schema: shorten history large deployment logs... ...and free related disk space --- schema/mysql-migrations/upgrade_102.sql | 13 +++++++++++++ schema/mysql.sql | 2 +- schema/pgsql-migrations/upgrade_102.sql | 13 +++++++++++++ schema/pgsql.sql | 2 +- 4 files changed, 28 insertions(+), 2 deletions(-) create mode 100644 schema/mysql-migrations/upgrade_102.sql create mode 100644 schema/pgsql-migrations/upgrade_102.sql diff --git a/schema/mysql-migrations/upgrade_102.sql b/schema/mysql-migrations/upgrade_102.sql new file mode 100644 index 00000000..5607f1ed --- /dev/null +++ b/schema/mysql-migrations/upgrade_102.sql @@ -0,0 +1,13 @@ +UPDATE director_deployment_log SET startup_log = LEFT(startup_log, 20480) || ' + +[..] shortened ' +|| (LENGTH(startup_log) - 40960) +|| ' bytes by Director on schema upgrade [..] + +' || RIGHT(startup_log, 20480) WHERE LENGTH(startup_log) > 61440; + +OPTIMIZE TABLE director_deployment_log; + +INSERT INTO director_schema_migration + (schema_version, migration_time) + VALUES (102, NOW()); diff --git a/schema/mysql.sql b/schema/mysql.sql index bfdd1a81..c8427dab 100644 --- a/schema/mysql.sql +++ b/schema/mysql.sql @@ -1312,4 +1312,4 @@ CREATE TABLE sync_run ( INSERT INTO director_schema_migration SET migration_time = NOW(), - schema_version = 100; + schema_version = 102; diff --git a/schema/pgsql-migrations/upgrade_102.sql b/schema/pgsql-migrations/upgrade_102.sql new file mode 100644 index 00000000..4805d8a2 --- /dev/null +++ b/schema/pgsql-migrations/upgrade_102.sql @@ -0,0 +1,13 @@ +UPDATE director_deployment_log SET startup_log = LEFT(startup_log, 20480) || ' + +[..] shortened ' +|| (LENGTH(startup_log) - 40960) +|| ' bytes by Director on schema upgrade [..] + +' || RIGHT(startup_log, 20480) WHERE LENGTH(startup_log) > 61440; + +VACUUM FULL director_deployment_log; + +INSERT INTO director_schema_migration + (schema_version, migration_time) + VALUES (102, NOW()); diff --git a/schema/pgsql.sql b/schema/pgsql.sql index dab834b7..41ff5fc6 100644 --- a/schema/pgsql.sql +++ b/schema/pgsql.sql @@ -1532,4 +1532,4 @@ CREATE UNIQUE INDEX notification_inheritance ON icinga_notification_inheritance INSERT INTO director_schema_migration (schema_version, migration_time) - VALUES (100, NOW()); + VALUES (102, NOW());