[icinga-checkins] icinga.org: icingaweb2-module-director/master: schema/pgsql: add unix_timestamp function

git at icinga.org git at icinga.org
Sat May 21 00:59:31 CEST 2016


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

Author: Thomas Gelf <thomas at gelf.net>
Date:   Sat May 21 00:59:16 2016 +0200

schema/pgsql: add unix_timestamp function

---

 schema/pgsql-migrations/upgrade_98.sql |    7 +++++++
 schema/pgsql.sql                       |    7 ++++++-
 2 files changed, 13 insertions(+), 1 deletion(-)

diff --git a/schema/pgsql-migrations/upgrade_98.sql b/schema/pgsql-migrations/upgrade_98.sql
new file mode 100644
index 0000000..006ae88
--- /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 6bd336f..fc5df15 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());



More information about the icinga-checkins mailing list