-- Table: public.P00_MAIL
-- DROP TABLE IF EXISTS public."P00_MAIL";
CREATE TABLE IF NOT EXISTS public."P00_MAIL"
(
"P00_ID" bigint NOT NULL,
"P00_FROM" text COLLATE pg_catalog."default" NOT NULL,
"P00_TO" text COLLATE pg_catalog."default",
"P00_DATE_R" timestamp without time zone NOT NULL,
"P00_DATE_S" timestamp without time zone,
"P00_SUBJECT" text COLLATE pg_catalog."default",
"P00_DEV_ID" text COLLATE pg_catalog."default",
"P00_SUBJ_PART" integer,
"P00_SUBJ_TOTAL" integer,
"P00_ARCH" integer NOT NULL,
"P40_ID" bigint NOT NULL,
"P10_ID" bigint NOT NULL,
"P51_ID" bigint,
"P02_ID" bigint NOT NULL,
"P04_ID" bigint NOT NULL,
"P05_ID" bigint NOT NULL,
"P06_ID" bigint NOT NULL,
"P00_BODY" text COLLATE pg_catalog."default",
"P00_PARENT_ID" bigint NOT NULL,
"P10_ID_NEXT" bigint,
"P54_ID" bigint,
"P55_ID" bigint,
"P00_FRONT_LINK" text COLLATE pg_catalog."default",
"P53_ID" bigint,
CONSTRAINT "P00_MAIL_pkey" PRIMARY KEY ("P00_ID"),
CONSTRAINT "P00_MAIL_P55_ID_fkey" FOREIGN KEY ("P55_ID")
REFERENCES public."P55_PLACE" ("P55_ID") MATCH SIMPLE
ON UPDATE NO ACTION
ON DELETE NO ACTION,
CONSTRAINT "P02_FK" FOREIGN KEY ("P02_ID")
REFERENCES public."P02_OPER_TYPE" ("P02_ID") MATCH SIMPLE
ON UPDATE NO ACTION
ON DELETE NO ACTION
NOT VALID,
CONSTRAINT "P04_FK" FOREIGN KEY ("P04_ID")
REFERENCES public."P04_REP_TYPE" ("P04_ID") MATCH SIMPLE
ON UPDATE NO ACTION
ON DELETE NO ACTION
NOT VALID,
CONSTRAINT "P05_FK" FOREIGN KEY ("P05_ID")
REFERENCES public."P05_STATE" ("P05_ID") MATCH SIMPLE
ON UPDATE NO ACTION
ON DELETE NO ACTION
NOT VALID,
CONSTRAINT "P06_FK" FOREIGN KEY ("P06_ID")
REFERENCES public."P06_DIRECTION" ("P06_ID") MATCH SIMPLE
ON UPDATE NO ACTION
ON DELETE NO ACTION
NOT VALID,
CONSTRAINT "P10_FK" FOREIGN KEY ("P10_ID")
REFERENCES public."P10_MODULE" ("P10_ID") MATCH SIMPLE
ON UPDATE NO ACTION
ON DELETE NO ACTION
NOT VALID,
CONSTRAINT "P1_NEXT_FK" FOREIGN KEY ("P10_ID_NEXT")
REFERENCES public."P10_MODULE" ("P10_ID") MATCH SIMPLE
ON UPDATE NO ACTION
ON DELETE NO ACTION
NOT VALID,
CONSTRAINT "P40_FK" FOREIGN KEY ("P40_ID")
REFERENCES public."P40_ERROR" ("P40_ID") MATCH SIMPLE
ON UPDATE NO ACTION
ON DELETE NO ACTION
NOT VALID,
CONSTRAINT "P51_FK" FOREIGN KEY ("P51_ID")
REFERENCES public."P51_ABONENT" ("P51_ID") MATCH SIMPLE
ON UPDATE NO ACTION
ON DELETE NO ACTION
NOT VALID,
CONSTRAINT "P54_FK" FOREIGN KEY ("P54_ID")
REFERENCES public."P54_PUBLISH_PATH" ("P54_ID") MATCH SIMPLE
ON UPDATE NO ACTION
ON DELETE NO ACTION
NOT VALID
)
TABLESPACE pg_default;
ALTER TABLE IF EXISTS public."P00_MAIL"
OWNER to uta;
REVOKE ALL ON TABLE public."P00_MAIL" FROM PUBLIC;
GRANT ALL ON TABLE public."P00_MAIL" TO uta;
GRANT SELECT ON TABLE public."P00_MAIL" TO PUBLIC;
COMMENT ON TABLE public."P00_MAIL"
IS 'входящие сообщения';
-- Index: P00_DATE_R_IDX
-- DROP INDEX IF EXISTS public."P00_DATE_R_IDX";
CREATE INDEX IF NOT EXISTS "P00_DATE_R_IDX"
ON public."P00_MAIL" USING btree
("P00_DATE_R" ASC NULLS LAST)
TABLESPACE pg_default;
-- Index: P00_DEV_ID_IDX
-- DROP INDEX IF EXISTS public."P00_DEV_ID_IDX";
CREATE INDEX IF NOT EXISTS "P00_DEV_ID_IDX"
ON public."P00_MAIL" USING btree
("P00_DEV_ID" COLLATE pg_catalog."default" ASC NULLS LAST)
TABLESPACE pg_default;
-- Index: P00_PARENT_ID_IDX
-- DROP INDEX IF EXISTS public."P00_PARENT_ID_IDX";
CREATE INDEX IF NOT EXISTS "P00_PARENT_ID_IDX"
ON public."P00_MAIL" USING btree
("P00_PARENT_ID" ASC NULLS LAST)
TABLESPACE pg_default;
-- Index: P00_SUBJECT_IDX
-- DROP INDEX IF EXISTS public."P00_SUBJECT_IDX";
CREATE INDEX IF NOT EXISTS "P00_SUBJECT_IDX"
ON public."P00_MAIL" USING btree
("P00_SUBJECT" COLLATE pg_catalog."default" ASC NULLS LAST)
TABLESPACE pg_default;
-- Index: P10_ID_IDX
-- DROP INDEX IF EXISTS public."P10_ID_IDX";
CREATE INDEX IF NOT EXISTS "P10_ID_IDX"
ON public."P00_MAIL" USING btree
("P10_ID" ASC NULLS LAST)
TABLESPACE pg_default;
-- Index: P40_ID_IDX
-- DROP INDEX IF EXISTS public."P40_ID_IDX";
CREATE INDEX IF NOT EXISTS "P40_ID_IDX"
ON public."P00_MAIL" USING btree
("P40_ID" ASC NULLS LAST)
TABLESPACE pg_default;