V15.0.1.20191025_3__structured_log.sql 1.16 KB
Newer Older
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
29
30
31
CREATE SEQUENCE project_log_entry_sequence
  INCREMENT 1
  MINVALUE 1
  MAXVALUE 9223372036854775807
  START 1
  CACHE 1;

CREATE TABLE project_log_entry_table
(
  id integer NOT NULL DEFAULT nextval('project_log_entry_sequence'::regclass),
  severity varchar NOT NULL,
  type varchar NOT NULL,
  object_identifier varchar,
  object_class varchar,
  map_name varchar,
  project_id integer not null,
  content text,

  CONSTRAINT project_log_entry_pk PRIMARY KEY (id),
  CONSTRAINT project_log_entry_project_fk FOREIGN KEY (project_id)
      REFERENCES project_table (id) MATCH SIMPLE
      ON UPDATE NO ACTION ON DELETE NO ACTION
)
WITH (
  OIDS=FALSE
);

insert into project_log_entry_table (content, project_id, severity, type) SELECT s.token, id, 'WARNING', 'OTHER' from project_table t, unnest(string_to_array(t.warnings, E'\n')) s(token);
insert into project_log_entry_table (content, project_id, severity, type) SELECT s.token, id, 'ERROR', 'OTHER' from project_table t, unnest(string_to_array(t.errors, E'\n')) s(token);
alter table project_table drop column warnings;
alter table project_table drop column errors;
32
alter table project_log_entry_table add column source varchar;