--
-- Name: artifact; Type: TABLE; Schema: public; Owner: jbpm; Tablespace: 
--

CREATE TABLE artifact (
    id bigint NOT NULL,
    artifact_id character varying(100) NOT NULL,
    classifier character varying(100),
    extension character varying(100) NOT NULL,
    git_hash character varying(40),
    group_id character varying(100) NOT NULL,
    level integer NOT NULL,
    version character varying(100) NOT NULL
);

--
-- Name: calamus_seq; Type: SEQUENCE; Schema: public; Owner: jbpm
--

CREATE SEQUENCE calamus_seq
    START WITH 1
    INCREMENT BY 1
    NO MINVALUE
    NO MAXVALUE
    CACHE 1;

--
-- Name: context_mapping_info; Type: TABLE; Schema: public; Owner: jbpm; Tablespace: 
--

CREATE TABLE context_mapping_info (
    mapping_id bigint NOT NULL,
    context_id character varying(255) NOT NULL,
    ksession_id integer NOT NULL,
    owner_id character varying(255),
    optlock integer
);

--
-- Name: context_mapping_info_id_seq; Type: SEQUENCE; Schema: public; Owner: jbpm
--

CREATE SEQUENCE context_mapping_info_id_seq
    START WITH 1
    INCREMENT BY 1
    NO MINVALUE
    NO MAXVALUE
    CACHE 1;

--
-- Name: correlation_key_id_seq; Type: SEQUENCE; Schema: public; Owner: jbpm
--

CREATE SEQUENCE correlation_key_id_seq
    START WITH 1
    INCREMENT BY 1
    NO MINVALUE
    NO MAXVALUE
    CACHE 1;

--
-- Name: correlation_key_info; Type: TABLE; Schema: public; Owner: jbpm; Tablespace: 
--

CREATE TABLE correlation_key_info (
    key_id bigint NOT NULL,
    name character varying(255),
    process_instance_id bigint NOT NULL,
    optlock integer
);

--
-- Name: correlation_prop_id_seq; Type: SEQUENCE; Schema: public; Owner: jbpm
--

CREATE SEQUENCE correlation_prop_id_seq
    START WITH 1
    INCREMENT BY 1
    NO MINVALUE
    NO MAXVALUE
    CACHE 1;

--
-- Name: correlation_property_info; Type: TABLE; Schema: public; Owner: jbpm; Tablespace: 
--

CREATE TABLE correlation_property_info (
    property_id bigint NOT NULL,
    name character varying(255),
    value character varying(255),
    optlock integer,
    correlation_key bigint
);

--
-- Name: event_types; Type: TABLE; Schema: public; Owner: jbpm; Tablespace: 
--

CREATE TABLE event_types (
    instance_id bigint NOT NULL,
    element character varying(255)
);

--
-- Name: node_inst_log_id_seq; Type: SEQUENCE; Schema: public; Owner: jbpm
--

CREATE SEQUENCE node_inst_log_id_seq
    START WITH 1
    INCREMENT BY 1
    NO MINVALUE
    NO MAXVALUE
    CACHE 1;

--
-- Name: node_instance_log; Type: TABLE; Schema: public; Owner: jbpm; Tablespace: 
--

CREATE TABLE node_instance_log (
    id bigint NOT NULL,
    connection character varying(255),
    log_date timestamp without time zone,
    external_id character varying(255),
    node_id character varying(255),
    node_instance_id character varying(255),
    node_name character varying(255),
    node_type character varying(255),
    process_id character varying(255),
    process_instance_id bigint NOT NULL,
    type integer NOT NULL,
    work_item_id bigint
);

--
-- Name: proc_inst_log_id_seq; Type: SEQUENCE; Schema: public; Owner: jbpm
--

CREATE SEQUENCE proc_inst_log_id_seq
    START WITH 1
    INCREMENT BY 1
    NO MINVALUE
    NO MAXVALUE
    CACHE 1;

--
-- Name: process; Type: TABLE; Schema: public; Owner: jbpm; Tablespace: 
--

CREATE TABLE process (
    id bigint NOT NULL,
    jbpm_process_id character varying(100) NOT NULL,
    name character varying(100) NOT NULL
);

--
-- Name: process_instance_info; Type: TABLE; Schema: public; Owner: jbpm; Tablespace: 
--

CREATE TABLE process_instance_info (
    instance_id bigint NOT NULL,
    last_modification_date timestamp without time zone,
    last_read_date timestamp without time zone,
    process_id character varying(255),
    process_instance_byte_array oid,
    start_date timestamp without time zone,
    state integer NOT NULL,
    optlock integer
);

--
-- Name: process_instance_info_id_seq; Type: SEQUENCE; Schema: public; Owner: jbpm
--

CREATE SEQUENCE process_instance_info_id_seq
    START WITH 1
    INCREMENT BY 1
    NO MINVALUE
    NO MAXVALUE
    CACHE 1;

--
-- Name: process_instance_log; Type: TABLE; Schema: public; Owner: jbpm; Tablespace: 
--

CREATE TABLE process_instance_log (
    id bigint NOT NULL,
    duration bigint,
    end_date timestamp without time zone,
    external_id character varying(255),
    user_identity character varying(255),
    outcome character varying(255),
    parent_process_instance_id bigint,
    process_id character varying(255),
    process_instance_id bigint NOT NULL,
    process_name character varying(255),
    process_version character varying(255),
    start_date timestamp without time zone,
    status integer
);

--
-- Name: process_trigger; Type: TABLE; Schema: public; Owner: jbpm; Tablespace: 
--

CREATE TABLE process_trigger (
    id bigint NOT NULL,
    mvel character varying(1000),
    process bigint
);

--
-- Name: session_info; Type: TABLE; Schema: public; Owner: jbpm; Tablespace: 
--

CREATE TABLE session_info (
    id integer NOT NULL,
    last_modification_date timestamp without time zone,
    rules_byte_array oid,
    start_date timestamp without time zone,
    optlock integer
);

--
-- Name: sessioninfo_id_seq; Type: SEQUENCE; Schema: public; Owner: jbpm
--

CREATE SEQUENCE sessioninfo_id_seq
    START WITH 1
    INCREMENT BY 1
    NO MINVALUE
    NO MAXVALUE
    CACHE 1;

--
-- Name: var_inst_log_id_seq; Type: SEQUENCE; Schema: public; Owner: jbpm
--

CREATE SEQUENCE var_inst_log_id_seq
    START WITH 1
    INCREMENT BY 1
    NO MINVALUE
    NO MAXVALUE
    CACHE 1;

--
-- Name: variable_instance_log; Type: TABLE; Schema: public; Owner: jbpm; Tablespace: 
--

CREATE TABLE variable_instance_log (
    id bigint NOT NULL,
    log_date timestamp without time zone,
    external_id character varying(255),
    old_value character varying(255),
    process_id character varying(255),
    process_instance_id bigint NOT NULL,
    value character varying(255),
    variable_id character varying(255),
    variable_instance_id character varying(255)
);

--
-- Name: work_item_info; Type: TABLE; Schema: public; Owner: jbpm; Tablespace: 
--

CREATE TABLE work_item_info (
    work_item_id bigint NOT NULL,
    creation_date timestamp without time zone,
    name character varying(255),
    process_instance_id bigint NOT NULL,
    state bigint NOT NULL,
    optlock integer,
    work_item_byte_array oid
);

--
-- Name: workiteminfo_id_seq; Type: SEQUENCE; Schema: public; Owner: jbpm
--

CREATE SEQUENCE workiteminfo_id_seq
    START WITH 1
    INCREMENT BY 1
    NO MINVALUE
    NO MAXVALUE
    CACHE 1;

--
-- Name: artifact_pkey; Type: CONSTRAINT; Schema: public; Owner: jbpm; Tablespace: 
--

ALTER TABLE ONLY artifact
    ADD CONSTRAINT artifact_pkey PRIMARY KEY (id);


--
-- Name: context_mapping_info_pkey; Type: CONSTRAINT; Schema: public; Owner: jbpm; Tablespace: 
--

ALTER TABLE ONLY context_mapping_info
    ADD CONSTRAINT context_mapping_info_pkey PRIMARY KEY (mapping_id);


--
-- Name: correlation_key_info_pkey; Type: CONSTRAINT; Schema: public; Owner: jbpm; Tablespace: 
--

ALTER TABLE ONLY correlation_key_info
    ADD CONSTRAINT correlation_key_info_pkey PRIMARY KEY (key_id);


--
-- Name: correlation_property_info_pkey; Type: CONSTRAINT; Schema: public; Owner: jbpm; Tablespace: 
--

ALTER TABLE ONLY correlation_property_info
    ADD CONSTRAINT correlation_property_info_pkey PRIMARY KEY (property_id);


--
-- Name: node_instance_log_pkey; Type: CONSTRAINT; Schema: public; Owner: jbpm; Tablespace: 
--

ALTER TABLE ONLY node_instance_log
    ADD CONSTRAINT node_instance_log_pkey PRIMARY KEY (id);


--
-- Name: process_instance_info_pkey; Type: CONSTRAINT; Schema: public; Owner: jbpm; Tablespace: 
--

ALTER TABLE ONLY process_instance_info
    ADD CONSTRAINT process_instance_info_pkey PRIMARY KEY (instance_id);


--
-- Name: process_instance_log_pkey; Type: CONSTRAINT; Schema: public; Owner: jbpm; Tablespace: 
--

ALTER TABLE ONLY process_instance_log
    ADD CONSTRAINT process_instance_log_pkey PRIMARY KEY (id);


--
-- Name: process_pkey; Type: CONSTRAINT; Schema: public; Owner: jbpm; Tablespace: 
--

ALTER TABLE ONLY process
    ADD CONSTRAINT process_pkey PRIMARY KEY (id);


--
-- Name: process_trigger_pkey; Type: CONSTRAINT; Schema: public; Owner: jbpm; Tablespace: 
--

ALTER TABLE ONLY process_trigger
    ADD CONSTRAINT process_trigger_pkey PRIMARY KEY (id);

--
-- Name: session_info_pkey; Type: CONSTRAINT; Schema: public; Owner: jbpm; Tablespace: 
--

ALTER TABLE ONLY session_info
    ADD CONSTRAINT session_info_pkey PRIMARY KEY (id);


--
-- Name: variable_instance_log_pkey; Type: CONSTRAINT; Schema: public; Owner: jbpm; Tablespace: 
--

ALTER TABLE ONLY variable_instance_log
    ADD CONSTRAINT variable_instance_log_pkey PRIMARY KEY (id);


--
-- Name: work_item_info_pkey; Type: CONSTRAINT; Schema: public; Owner: jbpm; Tablespace: 
--

ALTER TABLE ONLY work_item_info
    ADD CONSTRAINT work_item_info_pkey PRIMARY KEY (work_item_id);


--
-- Name: fk_8p498uslw0dnuqbms6ifwcw0a; Type: FK CONSTRAINT; Schema: public; Owner: jbpm
--

ALTER TABLE ONLY correlation_property_info
    ADD CONSTRAINT fk_8p498uslw0dnuqbms6ifwcw0a FOREIGN KEY (correlation_key) REFERENCES correlation_key_info(key_id);


--
-- Name: fk_mofjkjce7y19e7uee8xc0ua6; Type: FK CONSTRAINT; Schema: public; Owner: jbpm
--

ALTER TABLE ONLY process_trigger
    ADD CONSTRAINT fk_mofjkjce7y19e7uee8xc0ua6 FOREIGN KEY (process) REFERENCES process(id);


--
-- Name: fk_ryp64oh29vgawmqgodvnvuh2o; Type: FK CONSTRAINT; Schema: public; Owner: jbpm
--

ALTER TABLE ONLY event_types
    ADD CONSTRAINT fk_ryp64oh29vgawmqgodvnvuh2o FOREIGN KEY (instance_id) REFERENCES process_instance_info(instance_id);
