· 8 years ago · Aug 10, 2018, 05:48 PM
1create schema if not exists utils;
2
3create table utils.replaceable_now ( the_time timestamp with time zone );
4
5CREATE OR REPLACE FUNCTION replaceable_now() RETURNS timestamp with time zone AS $AA$
6 SELECT coalesce((select the_time from utils.replaceable_now limit 1), now());
7$AA$ LANGUAGE SQL STABLE;
8
9/*
10-- run in prod:
11drop table utils.replaceable_now;
12
13CREATE OR REPLACE FUNCTION replaceable_now() RETURNS timestamp with time zone AS $AA$
14 SELECT now()
15$AA$ LANGUAGE SQL STABLE;
16
17*/