apisub_admin.sql 675 Bytes
Newer Older
Stephane Crozat's avatar
Stephane Crozat committed
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28
BEGIN;

DROP TABLE IF EXISTS admins;
DROP TABLE IF EXISTS config CASCADE;

CREATE TABLE admins (
  utclogin TEXT PRIMARY KEY
);

INSERT INTO admins VALUES ('crozatst');
INSERT INTO admins VALUES ('dore');

CREATE TABLE config (
  closed BOOLEAN NOT NULL,
  openbegin DATE NOT NULL,
  openend DATE NOT NULL
);

INSERT INTO config VALUES ('FALSE', TO_DATE('20180101','YYYYMMDD'), TO_DATE('20191231','YYYYMMDD'));

CREATE OR REPLACE VIEW vconfig AS
SELECT
TO_CHAR(openbegin,'TMday FMDD TMmonth FMYYYY') AS openbegin,
TO_CHAR(openend,'TMday FMDD TMmonth FMYYYY') AS openend,
NOT(closed) AND CURRENT_DATE >= openbegin AND CURRENT_DATE <= openend AS isactive
FROM config;

COMMIT;