# -- !Ups
CREATE TABLE "PostrunAction" (
  id INTEGER NOT NULL PRIMARY KEY,
  S_RUNNABLE CHARACTER VARYING NOT NULL,
  S_TITLE CHARACTER VARYING NOT NULL,
  S_DESCRIPTION CHARACTER VARYING NULL,
  S_OWNER CHARACTER VARYING NOT NULL,
  I_VERSION SMALLINT NOT NULL,
  T_CTIME TIMESTAMP WITH TIME ZONE
);

CREATE SEQUENCE "PostrunAction_id_seq"
START WITH 1
INCREMENT BY 1
NO MINVALUE
NO MAXVALUE
CACHE 1;
ALTER SEQUENCE "PostrunAction_id_seq" OWNED BY "PostrunAction".id;

ALTER TABLE public."PostrunAction_id_seq" OWNER TO projectlocker;
ALTER TABLE ONLY "PostrunAction" ALTER COLUMN id SET DEFAULT nextval('"PostrunAction_id_seq"'::regclass);

ALTER TABLE "PostrunAction" OWNER TO "projectlocker";

CREATE TABLE "PostrunAssociationRow" (
  id INTEGER NOT NULL PRIMARY KEY,
  K_PROJECTTYPE INTEGER NOT NULL,
  K_POSTRUN INTEGER NOT NULL
);

ALTER TABLE "PostrunAssociationRow" ADD CONSTRAINT "FK_PROJECT_TYPE" FOREIGN KEY (K_PROJECTTYPE) REFERENCES "ProjectType"(id) DEFERRABLE INITIALLY DEFERRED;
ALTER TABLE "PostrunAssociationRow" ADD CONSTRAINT "FK_POSTRUN_ENTRY" FOREIGN KEY (K_POSTRUN) REFERENCES "PostrunAction"(id) DEFERRABLE INITIALLY DEFERRED;

CREATE SEQUENCE "PostrunAssociationRow_id_seq"
START WITH 1
INCREMENT BY 1
NO MINVALUE
NO MAXVALUE
CACHE 1;
ALTER SEQUENCE "PostrunAssociationRow_id_seq" OWNED BY "PostrunAssociationRow".id;

ALTER TABLE public."PostrunAssociationRow_id_seq" OWNER TO projectlocker;

ALTER TABLE "PostrunAssociationRow_id_seq" OWNER TO "projectlocker";
ALTER TABLE ONLY "PostrunAssociationRow" ALTER COLUMN id SET DEFAULT nextval('"PostrunAssociationRow_id_seq"'::regclass);

# -- !Downs
DROP TABLE "PostrunAssociationRow";
DROP TABLE "PostrunAction";