AppReports/init.sql
2019-07-04 12:21:37 +02:00

32 lines
925 B
SQL

-- sql file will be automatically executed to setup the database
-- create table
CREATE TABLE IF NOT EXISTS public."Log"
(
"ID" BIGSERIAL,
"App" character(4) NOT NULL,
"Client" character varying(64) NOT NULL,
"Timestamp" timestamp without time zone NOT NULL DEFAULT now(),
"Message" text NOT NULL,
"Misc" text,
"Stack" text
);
-- create view
CREATE OR REPLACE VIEW public."LogView" AS
SELECT 'Timestamp'::text AS "Timestamp",
'App'::bpchar AS "App",
'Client'::character varying AS "Client",
'Message'::text AS "Message",
'Misc'::text AS "Misc",
'Stack'::text AS "Stack",
'0'::bigint AS "ID"
UNION ALL
SELECT COALESCE(to_char("Log"."Timestamp", 'YYYY-MM-DD HH24:MI:SS'::text), ''::text) AS "Timestamp",
"Log"."App",
"Log"."Client",
"Log"."Message",
"Log"."Misc",
"Log"."Stack",
"Log"."ID"
FROM "Log"
ORDER BY 7;