preparing for multiple event types
This commit is contained in:
31
updates/0.sql
Normal file
31
updates/0.sql
Normal file
@ -0,0 +1,31 @@
|
||||
-- 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;
|
32
updates/1.sql
Normal file
32
updates/1.sql
Normal file
@ -0,0 +1,32 @@
|
||||
-- drop view to remove dependencies
|
||||
DROP VIEW public."LogView";
|
||||
|
||||
-- add type column
|
||||
ALTER TABLE public."Log"
|
||||
ADD COLUMN "Type" character varying(64) NOT NULL DEFAULT 'Error';
|
||||
|
||||
-- change app column to varying 64
|
||||
ALTER TABLE public."Log"
|
||||
ALTER COLUMN "App" TYPE character varying(64);
|
||||
|
||||
-- recreate view
|
||||
CREATE OR REPLACE VIEW public."LogView" AS
|
||||
SELECT 'Timestamp'::text AS "Timestamp",
|
||||
'App'::character varying AS "App",
|
||||
'Type'::character varying AS "Type",
|
||||
'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"."Type",
|
||||
"Log"."Client",
|
||||
"Log"."Message",
|
||||
"Log"."Misc",
|
||||
"Log"."Stack",
|
||||
"Log"."ID"
|
||||
FROM "Log"
|
||||
ORDER BY 8;
|
Reference in New Issue
Block a user