DROP TABLE kfoqsdb."Benachrichtigung";
DROP TABLE kfoqsdb."Auswertung";
CREATE TABLE kfoqsdb."Auswertung"
(
  "ID" bigint NOT NULL DEFAULT nextval('kfoqsdb_seq'::regclass),
  "DokumentId" character varying,
  "Mandant" character varying,
  "Produkt" character varying,
  "Titel" character varying,
  "TraegerId" character varying,
  version bigint NOT NULL DEFAULT 0,
  "File" bytea,
  "Erstelldatum" timestamp without time zone NOT NULL,
  CONSTRAINT "PK_Auswertung" PRIMARY KEY ("ID"),
  CONSTRAINT "FK_Auswertung_Traeger" FOREIGN KEY ("TraegerId")
      REFERENCES kfoqsdb."Traeger" ("Code") MATCH SIMPLE
      ON UPDATE NO ACTION ON DELETE NO ACTION
)
WITH (
  OIDS=FALSE
);
ALTER TABLE kfoqsdb."Auswertung"
  OWNER TO kfoqsdb;

CREATE TABLE kfoqsdb."Benachrichtigung"
(
  "ID" bigint NOT NULL DEFAULT nextval('kfoqsdb_seq'::regclass),
  "Gelesen" boolean,
  "Titel" character varying,
  "Text" character varying,
  "TraegerId" character varying,
  "AuswertungId" bigint,
  version bigint NOT NULL DEFAULT 0,
  "Erstelldatum" timestamp without time zone NOT NULL,
  CONSTRAINT "PK_Benachrichtigung" PRIMARY KEY ("ID"),
  CONSTRAINT "FK_Benachrichtigung_Auswertung" FOREIGN KEY ("AuswertungId")
      REFERENCES kfoqsdb."Auswertung" ("ID") MATCH SIMPLE
      ON UPDATE NO ACTION ON DELETE NO ACTION,
  CONSTRAINT "FK_Benachrichtigung_Traeger" FOREIGN KEY ("TraegerId")
      REFERENCES kfoqsdb."Traeger" ("Code") MATCH SIMPLE
      ON UPDATE NO ACTION ON DELETE NO ACTION
)
WITH (
  OIDS=FALSE
);
ALTER TABLE kfoqsdb."Benachrichtigung"
  OWNER TO kfoqsdb;

ALTER TABLE kfoqsdb."Traeger" ADD COLUMN "version" bigint NOT NULL default 0;