sync up with master
This commit is contained in:
commit
d1d4f882de
@ -1,10 +1,10 @@
|
||||
BEGIN TRANSACTION;
|
||||
--\conninfo
|
||||
DROP SCHEMA IF EXISTS evt cascade;
|
||||
DROP EXTENSION IF EXISTS ltree;
|
||||
CREATE EXTENSION ltree;
|
||||
--------------------------build schema----------------------------------------------
|
||||
|
||||
DROP EXTENSTION IF EXISTS ltree;
|
||||
CREATE EXTENSTION ltree;
|
||||
DROP SCHEMA IF EXISTS evt cascade;
|
||||
CREATE SCHEMA evt;
|
||||
COMMENT ON SCHEMA evt IS 'event log';
|
||||
|
||||
|
32
schema/suggested_data/periods.sql
Normal file
32
schema/suggested_data/periods.sql
Normal file
@ -0,0 +1,32 @@
|
||||
WITH
|
||||
--startign month
|
||||
startm AS (
|
||||
SELECT 1 as m
|
||||
)
|
||||
,m AS (
|
||||
SELECT
|
||||
g.s calendar_month
|
||||
,startm.m starting_month
|
||||
,g.s + CASE WHEN g.s < startm.m THEN startm.m +1 ELSE -startm.m +1 END fisc_month
|
||||
FROM
|
||||
generate_series(1,12,1) g(s)
|
||||
CROSS JOIN startm
|
||||
)
|
||||
--select * from m
|
||||
INSERT INTO
|
||||
evt.fspr
|
||||
SELECT
|
||||
--TO_CHAR(gs.d,'YYYY.MM.DD')::ltree t1
|
||||
(
|
||||
--year
|
||||
to_char(extract(year from gs.d),'FM0000')
|
||||
--month
|
||||
||'.'||to_char(m.fisc_month,'FM00')
|
||||
)::ltree t2
|
||||
,tstzrange(gs.d,gs.d + '1 month'::interval) r
|
||||
FROM
|
||||
generate_series('2018-01-01 00:00'::timestamptz,'2099-12-01 00:00'::timestamptz,'1 month') gs(d)
|
||||
INNER JOIN m ON
|
||||
m.calendar_month = extract(month from gs.d)
|
||||
ORDER BY
|
||||
gs.d ASC
|
@ -7,4 +7,4 @@ CREATE TABLE evt.fspr (
|
||||
COMMENT ON COLUMN evt.fspr.id IS 'fiscal period';
|
||||
COMMENT ON COLUMN evt.fspr.dur IS 'duration of period as timestamp range';
|
||||
|
||||
CREATE INDEX id_gist ON evt.fspr USING GIST (id);
|
||||
CREATE INDEX id_gist ON evt.fspr USING GIST (id);
|
||||
|
Loading…
Reference in New Issue
Block a user