From 0605c5acc8cce97f280cd01f494305bd166afbb0 Mon Sep 17 00:00:00 2001 From: Thomas Gelf Date: Sat, 21 May 2016 00:59:16 +0200 Subject: [PATCH] schema/pgsql: add unix_timestamp function --- schema/pgsql-migrations/upgrade_98.sql | 7 +++++++ schema/pgsql.sql | 7 ++++++- 2 files changed, 13 insertions(+), 1 deletion(-) create mode 100644 schema/pgsql-migrations/upgrade_98.sql diff --git a/schema/pgsql-migrations/upgrade_98.sql b/schema/pgsql-migrations/upgrade_98.sql new file mode 100644 index 00000000..006ae888 --- /dev/null +++ b/schema/pgsql-migrations/upgrade_98.sql @@ -0,0 +1,7 @@ +CREATE OR REPLACE FUNCTION unix_timestamp(timestamp with time zone) RETURNS bigint AS ' + SELECT EXTRACT(EPOCH FROM $1)::bigint AS result +' LANGUAGE sql; + +INSERT INTO director_schema_migration + (schema_version, migration_time) + VALUES (98, NOW()); diff --git a/schema/pgsql.sql b/schema/pgsql.sql index 6bd336fa..fc5df156 100644 --- a/schema/pgsql.sql +++ b/schema/pgsql.sql @@ -49,6 +49,11 @@ CREATE TYPE enum_sync_state AS ENUM( CREATE TYPE enum_host_service AS ENUM('host', 'service'); +CREATE OR REPLACE FUNCTION unix_timestamp(timestamp with time zone) RETURNS bigint AS ' + SELECT EXTRACT(EPOCH FROM $1)::bigint AS result +' LANGUAGE sql; + + CREATE TABLE director_activity_log ( id bigserial, object_type character varying(64) NOT NULL, @@ -1524,4 +1529,4 @@ CREATE UNIQUE INDEX notification_inheritance ON icinga_notification_inheritance INSERT INTO director_schema_migration (schema_version, migration_time) - VALUES (97, NOW()); + VALUES (98, NOW());