--
--


-- Started on 2020-10-25 14:44:37


--
-- TOC entry 516 (class 1259 OID 32899)
-- Name: sap_connections_seq; Type: SEQUENCE; Schema: public; Owner: postgres
--

CREATE SEQUENCE public.sap_connections_seq
    START WITH 1
    INCREMENT BY 1
    NO MINVALUE
    NO MAXVALUE
    CACHE 1;


ALTER TABLE public.sap_connections_seq OWNER TO postgres;



--
-- TOC entry 509 (class 1259 OID 24707)
-- Name: sap_sync; Type: TABLE; Schema: public; Owner: postgres
--

CREATE TABLE public.sap_sync (
    id character varying(16) NOT NULL,
    sync_name character varying(64) NOT NULL,
    connection_id integer,
    function_type character varying(32) NOT NULL,
    function character varying(64) NOT NULL,
    source_type character varying(16),
    source text,
    last_sync_by character varying(32),
    last_sync_at timestamp(6) without time zone,
    created_by character varying(32) NOT NULL,
    created_at timestamp(6) without time zone NOT NULL,
    updated_by character varying,
    updated_at character varying
);


ALTER TABLE public.sap_sync OWNER TO postgres;

--
-- TOC entry 511 (class 1259 OID 24724)
-- Name: sap_sync_log; Type: TABLE; Schema: public; Owner: postgres
--

CREATE TABLE public.sap_sync_log (
    "timestamp" timestamp(6) without time zone NOT NULL,
    sap_sync_task_id integer NOT NULL,
    type character varying(16) NOT NULL,
    message text NOT NULL
);


ALTER TABLE public.sap_sync_log OWNER TO postgres;

--
-- TOC entry 517 (class 1259 OID 32902)
-- Name: sap_sync_menus_seq; Type: SEQUENCE; Schema: public; Owner: postgres
--

CREATE SEQUENCE public.sap_sync_menus_seq
    START WITH 1
    INCREMENT BY 1
    NO MINVALUE
    NO MAXVALUE
    CACHE 1;


ALTER TABLE public.sap_sync_menus_seq OWNER TO postgres;

--
-- TOC entry 514 (class 1259 OID 24745)
-- Name: sap_sync_menus; Type: TABLE; Schema: public; Owner: postgres
--

CREATE TABLE public.sap_sync_menus (
    id integer DEFAULT nextval('public.sap_sync_menus_seq'::regclass) NOT NULL,
    menu character varying(64) NOT NULL,
    sap_sync_id character varying(64) NOT NULL,
    key text,
    icon text,
    attributes text,
    sequence integer NOT NULL,
    parent_id integer NOT NULL
);


ALTER TABLE public.sap_sync_menus OWNER TO postgres;

--
-- TOC entry 518 (class 1259 OID 32904)
-- Name: sap_sync_param_mapping_seq; Type: SEQUENCE; Schema: public; Owner: postgres
--

CREATE SEQUENCE public.sap_sync_param_mapping_seq
    START WITH 13
    INCREMENT BY 1
    NO MINVALUE
    NO MAXVALUE
    CACHE 1;


ALTER TABLE public.sap_sync_param_mapping_seq OWNER TO postgres;

--
-- TOC entry 513 (class 1259 OID 24739)
-- Name: sap_sync_param_mapping; Type: TABLE; Schema: public; Owner: postgres
--

CREATE TABLE public.sap_sync_param_mapping (
    id integer DEFAULT nextval('public.sap_sync_param_mapping_seq'::regclass) NOT NULL,
    sap_sync_param_id integer NOT NULL,
    data_type character varying(32),
    source_column character varying(64),
    sap_column character varying(64),
    update integer NOT NULL
);


ALTER TABLE public.sap_sync_param_mapping OWNER TO postgres;

--
-- TOC entry 519 (class 1259 OID 32906)
-- Name: sap_sync_params_seq; Type: SEQUENCE; Schema: public; Owner: postgres
--

CREATE SEQUENCE public.sap_sync_params_seq
    START WITH 7
    INCREMENT BY 1
    NO MINVALUE
    NO MAXVALUE
    CACHE 1;


ALTER TABLE public.sap_sync_params_seq OWNER TO postgres;

--
-- TOC entry 512 (class 1259 OID 24730)
-- Name: sap_sync_params; Type: TABLE; Schema: public; Owner: postgres
--

CREATE TABLE public.sap_sync_params (
    id integer DEFAULT nextval('public.sap_sync_params_seq'::regclass) NOT NULL,
    sap_sync_id character varying(16) NOT NULL,
    param_type character varying(8) NOT NULL,
    data_type character varying(16) NOT NULL,
    source_type character varying(16),
    source text,
    source_key text,
    sap_ref character varying(64),
    sap_key text
);


ALTER TABLE public.sap_sync_params OWNER TO postgres;

--
-- TOC entry 520 (class 1259 OID 32913)
-- Name: sap_sync_tasks_seq; Type: SEQUENCE; Schema: public; Owner: postgres
--

CREATE SEQUENCE public.sap_sync_tasks_seq
    START WITH 1
    INCREMENT BY 1
    NO MINVALUE
    NO MAXVALUE
    CACHE 1;


ALTER TABLE public.sap_sync_tasks_seq OWNER TO postgres;

--
-- TOC entry 515 (class 1259 OID 24763)
-- Name: sap_sync_tasks; Type: TABLE; Schema: public; Owner: postgres
--

CREATE TABLE public.sap_sync_tasks (
    id integer DEFAULT nextval('public.sap_sync_tasks_seq'::regclass) NOT NULL,
    sap_sync_id character varying(16) NOT NULL,
    connection_id integer NOT NULL,
    key text,
    requested_by character varying(32) NOT NULL,
    requested_at timestamp(6) without time zone NOT NULL,
    executed_at timestamp(6) without time zone,
    done_at timestamp(6) without time zone,
    status smallint NOT NULL
);


ALTER TABLE public.sap_sync_tasks OWNER TO postgres;


--
-- TOC entry 3891 (class 0 OID 24707)
-- Dependencies: 509
-- Data for Name: sap_sync; Type: TABLE DATA; Schema: public; Owner: postgres
--

INSERT INTO public.sap_sync VALUES ('SI_MasterialType', 'SI_MasterialType', NULL, 'PI', 'ZMATERIAL_TYPE_GET', 'object', 'MaterialType-Code', NULL, NULL, 'system', '2020-10-04 08:15:25', NULL, NULL);
INSERT INTO public.sap_sync VALUES ('SI_MasterCompany', 'SI_MasterCompany', NULL, 'PI', 'ZCOMPANY_GET', 'object', 'CompanyCode-Code', NULL, NULL, 'system', '2020-10-04 08:15:25', NULL, NULL);


--
-- TOC entry 3893 (class 0 OID 24724)
-- Dependencies: 511
-- Data for Name: sap_sync_log; Type: TABLE DATA; Schema: public; Owner: postgres
--



--
-- TOC entry 3896 (class 0 OID 24745)
-- Dependencies: 514
-- Data for Name: sap_sync_menus; Type: TABLE DATA; Schema: public; Owner: postgres
--



--
-- TOC entry 3895 (class 0 OID 24739)
-- Dependencies: 513
-- Data for Name: sap_sync_param_mapping; Type: TABLE DATA; Schema: public; Owner: postgres
--

INSERT INTO public.sap_sync_param_mapping VALUES (5, 4, 'string', 'company_description', '${BUTXT}', 1);
INSERT INTO public.sap_sync_param_mapping VALUES (4, 4, 'string', 'company_code', '${BUKRS}', 1);
INSERT INTO public.sap_sync_param_mapping VALUES (6, 4, 'string', 'client_code', '1', 1);
INSERT INTO public.sap_sync_param_mapping VALUES (7, 6, 'string', 'code', '${MTART}', 1);
INSERT INTO public.sap_sync_param_mapping VALUES (8, 6, 'string', 'description', '${MTBEZ}', 1);
INSERT INTO public.sap_sync_param_mapping VALUES (9, 6, 'string', 'acc_cat_ref_code', '${KKREF}', 1);
INSERT INTO public.sap_sync_param_mapping VALUES (10, 6, 'string', 'maintenance_status', '${PSTAT}', 1);
INSERT INTO public.sap_sync_param_mapping VALUES (12, 6, 'strng', 'client_code', '1', 1);
INSERT INTO public.sap_sync_param_mapping VALUES (11, 6, 'string', 'price_control_code', '${VPRSV}', 1);


--
-- TOC entry 3894 (class 0 OID 24730)
-- Dependencies: 512
-- Data for Name: sap_sync_params; Type: TABLE DATA; Schema: public; Owner: postgres
--

INSERT INTO public.sap_sync_params VALUES (3, 'SI_MasterCompany', 'input', 'json', NULL, NULL, NULL, 'T_DATA', '[

    {

        "BUKRS" : "", 

        "BUTXT" : ""

    }

]');
INSERT INTO public.sap_sync_params VALUES (4, 'SI_MasterCompany', 'output', 'table', 'object', 'CompanyCode-Code', '%', 'T_DATA', '${BUKRS}');
INSERT INTO public.sap_sync_params VALUES (5, 'SI_MasterialType', 'input', 'json', NULL, NULL, NULL, 'T_DATA', '[

    {

        "MTART" : "", 

        "MTBEZ" : "",

        "NUMKI" : "",

        "PSTAT" : "",

        "KKRE" : "",

        "VPRSV" : ""

    }

]');
INSERT INTO public.sap_sync_params VALUES (6, 'SI_MasterialType', 'output', 'table', 'object', 'MaterialType-Code', '%', 'T_DATA', '${MTART}');


--
-- TOC entry 3758 (class 2606 OID 24753)
-- Name: sap_sync_menus sap_sync_menus_pkey; Type: CONSTRAINT; Schema: public; Owner: postgres
--

ALTER TABLE ONLY public.sap_sync_menus
    ADD CONSTRAINT sap_sync_menus_pkey PRIMARY KEY (id);


--
-- TOC entry 3756 (class 2606 OID 24744)
-- Name: sap_sync_param_mapping sap_sync_param_mapping_pkey; Type: CONSTRAINT; Schema: public; Owner: postgres
--

ALTER TABLE ONLY public.sap_sync_param_mapping
    ADD CONSTRAINT sap_sync_param_mapping_pkey PRIMARY KEY (id);


--
-- TOC entry 3754 (class 2606 OID 24738)
-- Name: sap_sync_params sap_sync_params_pkey; Type: CONSTRAINT; Schema: public; Owner: postgres
--

ALTER TABLE ONLY public.sap_sync_params
    ADD CONSTRAINT sap_sync_params_pkey PRIMARY KEY (id);


--
-- TOC entry 3750 (class 2606 OID 24714)
-- Name: sap_sync sap_sync_pkey; Type: CONSTRAINT; Schema: public; Owner: postgres
--

ALTER TABLE ONLY public.sap_sync
    ADD CONSTRAINT sap_sync_pkey PRIMARY KEY (id);


--
-- TOC entry 3760 (class 2606 OID 24771)
-- Name: sap_sync_tasks sap_sync_tasks_pkey; Type: CONSTRAINT; Schema: public; Owner: postgres
--

ALTER TABLE ONLY public.sap_sync_tasks
    ADD CONSTRAINT sap_sync_tasks_pkey PRIMARY KEY (id);


-- Completed on 2020-10-25 14:44:37

--
--

