summaryrefslogtreecommitdiff
path: root/src/db/rev.sql
diff options
context:
space:
mode:
Diffstat (limited to 'src/db/rev.sql')
-rw-r--r--src/db/rev.sql21
1 files changed, 21 insertions, 0 deletions
diff --git a/src/db/rev.sql b/src/db/rev.sql
new file mode 100644
index 0000000..bd02f3d
--- /dev/null
+++ b/src/db/rev.sql
@@ -0,0 +1,21 @@
+CREATE OR REPLACE FUNCTION curr_revision()
+RETURNS INTEGER
+LANGUAGE plpgsql VOLATILE
+AS $BODY$
+DECLARE
+ _revision INTEGER;
+BEGIN
+ BEGIN
+ SELECT curr_revision INTO _revision
+ FROM sys.database_info
+ WHERE name = current_database();
+ RETURN _revision;
+ EXCEPTION WHEN OTHERS THEN
+ RETURN 0;
+ END;
+END
+$BODY$;
+
+GRANT EXECUTE ON FUNCTION curr_revision() TO website;
+
+SELECT curr_revision();