--
-- PostgreSQL database dump
--

-- Dumped from database version 14.6
-- Dumped by pg_dump version 14.6

SET statement_timeout = 0;
SET lock_timeout = 0;
SET idle_in_transaction_session_timeout = 0;
SET client_encoding = 'UTF8';
SET standard_conforming_strings = on;
SELECT pg_catalog.set_config('search_path', '', false);
SET check_function_bodies = false;
SET xmloption = content;
SET client_min_messages = warning;
SET row_security = off;

--
-- Name: add_archived_column(); Type: FUNCTION; Schema: public; Owner: -
--

CREATE FUNCTION public.add_archived_column() RETURNS void
    LANGUAGE plpgsql
    AS $$
DECLARE
    arch_table RECORD;
BEGIN
    FOR arch_table IN SELECT * FROM information_schema.tables AS t
                      WHERE t.table_schema = 'public' AND t.table_type = 'BASE TABLE'
                        AND t.table_name LIKE 'arc2_%'
                      ORDER BY t.table_name
        LOOP
            EXECUTE 'ALTER TABLE '|| arch_table.table_name ||' ADD COLUMN archived boolean';
            EXECUTE 'ALTER TABLE '|| arch_table.table_name ||' ALTER COLUMN archived SET DEFAULT FALSE';
        END LOOP;
END;
$$;


--
-- Name: add_group(character varying, character varying, character varying, character varying); Type: FUNCTION; Schema: public; Owner: -
--

CREATE FUNCTION public.add_group(group_identifier character varying, name character varying, description character varying, permissiontype character varying) RETURNS void
    LANGUAGE plpgsql
    AS $$
    DECLARE
        relationcount bigint;

    BEGIN

        SELECT count(*) INTO relationcount FROM qcadoosecurity_group WHERE identifier = group_identifier;

        IF relationcount = 0 THEN
            INSERT INTO qcadoosecurity_group (identifier, name, description, permissiontype) VALUES (group_identifier, name, description, permissiontype);
        END IF;

   END;
$$;


--
-- Name: add_group_role(character varying, character varying); Type: FUNCTION; Schema: public; Owner: -
--

CREATE FUNCTION public.add_group_role(group_identifier character varying, role_identifier character varying) RETURNS void
    LANGUAGE plpgsql
    AS $$
    DECLARE
        groupid bigint;
        roleid bigint;
        relationcount bigint;

    BEGIN

        SELECT id INTO groupid FROM qcadoosecurity_group WHERE identifier = group_identifier;

        IF groupid is null THEN
            RAISE EXCEPTION 'Group(%s) not found', group_identifier;
        END IF;

        SELECT id INTO roleid FROM qcadoosecurity_role WHERE identifier = role_identifier;

        IF roleid is null THEN
            RAISE EXCEPTION 'Role(%) not found', role_identifier;
        END IF;

        SELECT count(*) INTO relationcount FROM jointable_group_role WHERE group_id = groupid AND role_id = roleid;

        IF relationcount = 0 THEN
            INSERT INTO jointable_group_role (group_id, role_id) VALUES (groupid, roleid);
        END IF;

    END;
$$;


--
-- Name: add_group_role_by_id(bigint, character varying); Type: FUNCTION; Schema: public; Owner: -
--

CREATE FUNCTION public.add_group_role_by_id(groupid bigint, role_identifier character varying) RETURNS void
    LANGUAGE plpgsql
    AS $$
    DECLARE
        roleid bigint;
        relationcount bigint;

    BEGIN

        IF groupid is null THEN
            RAISE EXCEPTION 'Group(%s) not found', groupid;
        END IF;

        SELECT id INTO roleid FROM qcadoosecurity_role WHERE identifier = role_identifier;

        IF roleid is null THEN
            RAISE EXCEPTION 'Role(%) not found', role_identifier;
        END IF;

        SELECT count(*) INTO relationcount FROM jointable_group_role WHERE group_id = groupid AND role_id = roleid;

        IF relationcount = 0 THEN
            INSERT INTO jointable_group_role (group_id, role_id) VALUES (groupid, roleid);
        END IF;

    END;
$$;


--
-- Name: add_group_with_role_role(character varying, character varying); Type: FUNCTION; Schema: public; Owner: -
--

CREATE FUNCTION public.add_group_with_role_role(with_role_identifier character varying, role_identifier character varying) RETURNS void
    LANGUAGE plpgsql
    AS $$
    DECLARE
        withroleid bigint;
        roleid bigint;
        groupwithrole RECORD;

    BEGIN
        SELECT id INTO withroleid FROM qcadoosecurity_role WHERE identifier = with_role_identifier;

        IF withroleid IS NULL THEN
            RAISE EXCEPTION 'Role(%) not found', with_role_identifier;
        END IF;

        SELECT id INTO roleid FROM qcadoosecurity_role WHERE identifier = role_identifier;

        IF roleid IS NULL THEN
            RAISE EXCEPTION 'Role(%) not found', role_identifier;
        END IF;

        FOR groupwithrole IN SELECT * FROM jointable_group_role WHERE role_id = withroleid LOOP
            IF NOT EXISTS (SELECT group_id FROM jointable_group_role WHERE group_id = groupwithrole.group_id AND role_id = roleid) THEN
                INSERT INTO jointable_group_role (group_id, role_id) VALUES (groupwithrole.group_id, roleid);
            END IF;
        END LOOP;
    END;
$$;


--
-- Name: add_role(character varying, character varying); Type: FUNCTION; Schema: public; Owner: -
--

CREATE FUNCTION public.add_role(role_identifier character varying, description character varying) RETURNS void
    LANGUAGE plpgsql
    AS $$
    DECLARE
    relationcount bigint;

    BEGIN

        SELECT count(*) INTO relationcount FROM qcadoosecurity_role WHERE identifier = role_identifier;

        IF relationcount = 0 THEN
            INSERT INTO qcadoosecurity_role (identifier, description) VALUES (role_identifier, description);
        END IF;

    END;
$$;


--
-- Name: add_sequences(); Type: FUNCTION; Schema: public; Owner: -
--

CREATE FUNCTION public.add_sequences() RETURNS void
    LANGUAGE plpgsql
    AS $$
    DECLARE
        row record;

    BEGIN
        FOR row IN SELECT tablename FROM pg_tables p
            INNER JOIN information_schema.columns c ON p.tablename = c.table_name
            WHERE c.table_schema = 'public' AND p.schemaname = 'public' AND c.column_name = 'id' AND data_type = 'bigint'
        LOOP
            IF NOT EXISTS (SELECT 0 FROM pg_class WHERE relname = substring('' || quote_ident(row.tablename) || '_id_seq' FROM 0 FOR 64)) THEN
                EXECUTE 'CREATE SEQUENCE ' || quote_ident(row.tablename) || '_id_seq;';
                EXECUTE 'ALTER TABLE ' || quote_ident(row.tablename) || ' ALTER COLUMN id SET DEFAULT nextval(''' || quote_ident(row.tablename) || '_id_seq'');';
                EXECUTE 'ALTER SEQUENCE ' || quote_ident(row.tablename) || '_id_seq OWNED BY ' || quote_ident(row.tablename) || '.id';
                EXECUTE 'WITH mx AS (SELECT max(id)+1 AS mx FROM ' || quote_ident(row.tablename) || ') SELECT setval( ''' || quote_ident(row.tablename) || '_id_seq'' , mx.mx) FROM mx';
            END IF;
        END LOOP;

        FOR row IN SELECT viewname FROM pg_views p
            INNER JOIN information_schema.columns c ON p.viewname = c.table_name
            WHERE c.table_schema = 'public' AND p.schemaname = 'public' AND c.column_name = 'id' AND data_type = 'bigint'
        LOOP
            IF NOT EXISTS (SELECT 0 FROM pg_class WHERE relname = substring('' || quote_ident(row.viewname) || '_id_seq' FROM 0 FOR 64)) THEN
                EXECUTE 'CREATE SEQUENCE ' || quote_ident(row.viewname) || '_id_seq;';
            END IF;
        END LOOP;
    END;
$$;


--
-- Name: add_view_item(character varying, character varying, character varying, character varying, character varying); Type: FUNCTION; Schema: public; Owner: -
--

CREATE FUNCTION public.add_view_item(plugin_identifier character varying, item_name character varying, view_name character varying, category_name character varying, auth_role character varying) RETURNS void
    LANGUAGE plpgsql
    AS $$
    DECLARE
        viewid bigint;
        categoryid bigint;
        relationcount bigint;

    BEGIN

        SELECT id INTO viewid FROM qcadooview_view WHERE name = view_name;

        IF viewid IS NULL THEN
            RAISE EXCEPTION 'View(%s) not found', view_name;
        END IF;

        SELECT id INTO categoryid FROM qcadooview_category WHERE name = category_name;

        IF categoryid IS NULL THEN
            RAISE EXCEPTION 'Category(%) not found', category_name;
        END IF;

        SELECT count(*) INTO relationcount FROM qcadooview_item WHERE name = item_name;

        IF relationcount = 0 THEN
            INSERT INTO qcadooview_item (pluginidentifier, name, active, category_id, view_id, succession, authrole, entityversion)
            VALUES (plugin_identifier, item_name, true,
                 (SELECT id FROM qcadooview_category WHERE name = category_name),
                 (SELECT id FROM qcadooview_view WHERE name = view_name),
                 (SELECT COALESCE(MAX(succession), 0)
                  FROM qcadooview_item
                  WHERE category_id = (SELECT id FROM qcadooview_category WHERE name = category_name)) + 1, auth_role, 0);
        END IF;

    END;
$$;


--
-- Name: add_view_view(character varying, character varying, character varying); Type: FUNCTION; Schema: public; Owner: -
--

CREATE FUNCTION public.add_view_view(plugin_identifier character varying, view_name character varying, view_view character varying) RETURNS void
    LANGUAGE plpgsql
    AS $$
    DECLARE
        relationcount bigint;

    BEGIN

        SELECT count(*) INTO relationcount FROM qcadooview_view WHERE name = view_name;

        IF relationcount = 0 THEN
            INSERT INTO qcadooview_view (pluginidentifier, name, view, entityversion)
                VALUES (plugin_identifier, view_name, view_view, 0);
        END IF;

    END;
$$;


--
-- Name: archive(integer); Type: FUNCTION; Schema: public; Owner: -
--

CREATE FUNCTION public.archive(_rows integer) RETURNS void
    LANGUAGE plpgsql
    AS $$
	BEGIN
		RAISE NOTICE 'Start - archive';
		EXECUTE 'SELECT archive_data('||_rows||');';
		EXECUTE 'SELECT remove_archived_data();';
		EXECUTE 'SELECT mark_as_archived();';
		RAISE NOTICE 'End - archive';

	END;
$$;


--
-- Name: archive_connected_orders(); Type: FUNCTION; Schema: public; Owner: -
--

CREATE FUNCTION public.archive_connected_orders() RETURNS void
    LANGUAGE plpgsql
    AS $$
	DECLARE
		_arch_order RECORD;
		_order RECORD;
	BEGIN
		FOR _arch_order IN SELECT * FROM arch_orders_order _archo WHERE parent_id is not null AND NOT EXISTS
			(SELECT 1 FROM arch_orders_order _archop WHERE _archo.parent_id = _archop.id )
		LOOP
			FOR _order IN SELECT * FROM orders_order ord  WHERE ord.id = _arch_order.parent_id
			LOOP
				INSERT INTO arch_orders_order SELECT * FROM orders_order WHERE id = _order.id;
			END LOOP;
		END LOOP;
	END;
$$;


--
-- Name: archive_connected_tables_all(); Type: FUNCTION; Schema: public; Owner: -
--

CREATE FUNCTION public.archive_connected_tables_all() RETURNS void
    LANGUAGE plpgsql
    AS $$
DECLARE
    _masterOrder RECORD;
    _goodfoodLabel RECORD;
    _statesMessage RECORD;
    _goodfoodPallet RECORD;
    _printLabelsHelper RECORD;
    _order RECORD;
    _orderstatechange RECORD;
    _ordertimecalculation RECORD;
    _productionpershift RECORD;
    _progressforday RECORD;
    _productiontracking RECORD;
    _anomaly RECORD;
    _labelstatechange RECORD;
    _palletstatechange RECORD;
    _productiontrackingstatechange RECORD;
    _trackingoperationproductincomponent RECORD;
    _trackingoperationproductoutcomponent RECORD;
    _repairorder RECORD;
    _anomalyproductiontrackingentryhelper RECORD;
    _extrusionprotocol RECORD;
    _extrusionprotocolstatechange RECORD;
    _extrusionaddedmixentry RECORD;
    _extrusionpouring RECORD;
    _extrusiontakenoffmixentry RECORD;
    _confectionprotocol RECORD;
    _confectionfilmproduct RECORD;
    _confectionprotocolstatechange RECORD;
    _costcalculation RECORD;
    _bproductioncountingquantity RECORD;
    _basicproductioncounting RECORD;
    _avglaborcostcalcfororder RECORD;
    _atrackingrecord RECORD;
    _document_position RECORD;
    _document RECORD;
BEGIN
    SET session_replication_role = 'replica';

    FOR _masterOrder IN SELECT * FROM arch_masterorders_masterorder where archived = false
        LOOP
            -- masterorders_masterorder
            INSERT INTO arch_assignmenttoshift_multiassignmenttoshift SELECT * FROM assignmenttoshift_multiassignmenttoshift WHERE masterorder_id = _masterOrder.id;
            INSERT INTO arch_assignmenttoshift_staffassignmenttoshift SELECT * FROM assignmenttoshift_staffassignmenttoshift WHERE masterorder_id = _masterOrder.id;
            INSERT INTO arch_goodfood_label SELECT * FROM goodfood_label WHERE masterorder_id = _masterOrder.id;
            INSERT INTO arch_goodfood_printedlabel SELECT * FROM goodfood_printedlabel WHERE masterorder_id = _masterOrder.id;
            INSERT INTO arch_integrationbartender_printlabelshelper SELECT * FROM integrationbartender_printlabelshelper WHERE masterorder_id = _masterOrder.id;
            INSERT INTO arch_masterorders_masterorderproduct SELECT * FROM masterorders_masterorderproduct WHERE masterorder_id = _masterOrder.id;
            -- goodfood_label
            FOR _goodfoodLabel IN SELECT * FROM arch_goodfood_label WHERE archived = false
                LOOP
                    INSERT INTO arch_goodfood_labelstatechange SELECT * FROM goodfood_labelstatechange WHERE label_id = _goodfoodLabel.id;

                    INSERT INTO arch_goodfood_pallet SELECT * FROM goodfood_pallet WHERE label_id = _goodfoodLabel.id ORDER BY secondpallet_id DESC;
                    FOR _goodfoodPallet IN SELECT * FROM arch_goodfood_pallet
                        LOOP
                            INSERT INTO arch_goodfood_palletstatechange SELECT * FROM goodfood_palletstatechange WHERE pallet_id = _goodfoodPallet.id;
                        END LOOP;
                END LOOP;
            FOR _labelstatechange IN SELECT * FROM arch_goodfood_labelstatechange WHERE archived = false
                LOOP
                    INSERT INTO arch_states_message SELECT * FROM states_message WHERE labelstatechange_id = _labelstatechange.id;
                END LOOP;
            FOR _palletstatechange IN SELECT * FROM arch_goodfood_palletstatechange WHERE archived = false
                LOOP
                    INSERT INTO arch_states_message SELECT * FROM states_message WHERE palletstatechange_id = _palletstatechange.id;
                END LOOP;
            -- arch_integrationbartender_printlabelshelper
            FOR _printLabelsHelper IN SELECT * FROM arch_integrationbartender_printlabelshelper WHERE archived = false
                LOOP
                    INSERT INTO arch_integrationbartender_sendtoprint SELECT * FROM integrationbartender_sendtoprint WHERE printlabelshelper_id = _printLabelsHelper.id;
                END LOOP;
        END LOOP;
    -- arch_orders_order
    FOR _order IN SELECT * FROM arch_orders_order WHERE archived = false
        LOOP
            --RAISE NOTICE 'Order : %' , _order.number;

            INSERT INTO arch_orders_orderstatechange SELECT * FROM orders_orderstatechange WHERE order_id = _order.id;
            INSERT INTO arch_orders_reasontypecorrectiondatefrom SELECT * FROM orders_reasontypecorrectiondatefrom WHERE order_id = _order.id;
            INSERT INTO arch_orders_reasontypecorrectiondateto SELECT * FROM orders_reasontypecorrectiondateto WHERE order_id = _order.id;
            INSERT INTO arch_orders_reasontypedeviationeffectiveend SELECT * FROM orders_reasontypedeviationeffectiveend WHERE order_id = _order.id;
            INSERT INTO arch_orders_reasontypedeviationeffectivestart SELECT * FROM orders_reasontypedeviationeffectivestart WHERE order_id = _order.id;
            INSERT INTO arch_orders_typeofcorrectioncauses SELECT * FROM orders_typeofcorrectioncauses WHERE order_id = _order.id;
            INSERT INTO arch_technologies_barcodeoperationcomponent SELECT * FROM technologies_barcodeoperationcomponent WHERE order_id = _order.id;
            INSERT INTO arch_technologies_technologyoperationcomponentmergeproductin SELECT * FROM technologies_technologyoperationcomponentmergeproductin WHERE order_id = _order.id;
            INSERT INTO arch_technologies_technologyoperationcomponentmergeproductout SELECT * FROM technologies_technologyoperationcomponentmergeproductout WHERE order_id = _order.id;
            INSERT INTO arch_stoppage_stoppage SELECT * FROM stoppage_stoppage WHERE order_id = _order.id;
            INSERT INTO arch_urcmaterialavailability_requiredcomponent SELECT * FROM urcmaterialavailability_requiredcomponent WHERE order_id = _order.id;
            INSERT INTO arch_simplematerialbalance_simplematerialbalanceorderscomponent SELECT * FROM simplematerialbalance_simplematerialbalanceorderscomponent WHERE order_id = _order.id;
            INSERT INTO arch_productionscheduling_ordertimecalculation SELECT * FROM productionscheduling_ordertimecalculation WHERE order_id = _order.id;
            INSERT INTO arch_productionpershift_productionpershift SELECT * FROM productionpershift_productionpershift WHERE order_id = _order.id;
            INSERT INTO arch_productioncounting_productiontracking SELECT * FROM productioncounting_productiontracking WHERE order_id = _order.id;
            INSERT INTO arch_productflowthrudivision_materialavailability SELECT * FROM productflowthrudivision_materialavailability WHERE order_id = _order.id;
            INSERT INTO arch_orders_operationaltask SELECT * FROM orders_operationaltask WHERE order_id = _order.id;
            INSERT INTO arch_goodfood_extrusionprotocol SELECT * FROM goodfood_extrusionprotocol WHERE order_id = _order.id;
            INSERT INTO arch_goodfood_confectionprotocol SELECT * FROM goodfood_confectionprotocol WHERE order_id = _order.id;
            INSERT INTO arch_costnormsformaterials_technologyinstoperproductincomp SELECT * FROM costnormsformaterials_technologyinstoperproductincomp WHERE order_id = _order.id;
            INSERT INTO arch_costcalculation_costcalculation SELECT * FROM costcalculation_costcalculation WHERE order_id = _order.id;
            INSERT INTO arch_basicproductioncounting_basicproductioncounting SELECT * FROM basicproductioncounting_basicproductioncounting WHERE order_id = _order.id;
            INSERT INTO arch_basicproductioncounting_productioncountingquantity SELECT * FROM basicproductioncounting_productioncountingquantity WHERE order_id = _order.id;
            INSERT INTO arch_basicproductioncounting_productioncountingoperationrun SELECT * FROM basicproductioncounting_productioncountingoperationrun WHERE order_id = _order.id;
            INSERT INTO arch_avglaborcostcalcfororder_avglaborcostcalcfororder SELECT * FROM avglaborcostcalcfororder_avglaborcostcalcfororder  WHERE order_id = _order.id;
            INSERT INTO arch_advancedgenealogy_trackingrecord SELECT * FROM advancedgenealogy_trackingrecord  WHERE order_id = _order.id;
            INSERT INTO arch_materialflowresources_document SELECT * FROM materialflowresources_document WHERE order_id = _order.id;
        END LOOP;
    --RAISE NOTICE '--------->	arch_orders_orderstatechange';

    -- arch_orders_orderstatechange
    FOR _orderstatechange IN SELECT * FROM arch_orders_orderstatechange WHERE archived = false
        LOOP
            INSERT INTO arch_states_message SELECT * FROM states_message WHERE orderstatechange_id = _orderstatechange.id;
            INSERT INTO arch_orders_reasontypeofchangingorderstate SELECT * FROM orders_reasontypeofchangingorderstate WHERE orderstatechange_id = _orderstatechange.id;
        END LOOP;
    --RAISE NOTICE '--------->	arch_productionscheduling_ordertimecalculation';

    -- arch_productionscheduling_ordertimecalculation
    FOR _ordertimecalculation IN SELECT * FROM arch_productionscheduling_ordertimecalculation WHERE archived = false
        LOOP
            INSERT INTO arch_productionscheduling_opercomptimecalculation SELECT * FROM productionscheduling_opercomptimecalculation WHERE ordertimecalculation_id = _ordertimecalculation.id;
        END LOOP;
    --RAISE NOTICE '--------->	arch_productionpershift_productionpershift';

    -- arch_productionpershift_productionpershift
    FOR _productionpershift IN SELECT * FROM arch_productionpershift_productionpershift WHERE archived = false
        LOOP
            INSERT INTO arch_productionpershift_progressforday SELECT * FROM productionpershift_progressforday WHERE productionpershift_id = _productionpershift.id;
            INSERT INTO arch_productionpershift_reasontypeofcorrectionplan SELECT * FROM productionpershift_reasontypeofcorrectionplan WHERE productionpershift_id = _productionpershift.id;
        END LOOP;
    --RAISE NOTICE '--------->	arch_productionpershift_progressforday';

    -- arch_productionpershift_progressforday
    FOR _progressforday IN SELECT * FROM arch_productionpershift_progressforday WHERE archived = false
        LOOP
            INSERT INTO arch_productionpershift_dailyprogress SELECT * FROM productionpershift_dailyprogress WHERE progressforday_id = _progressforday.id;
        END LOOP;
    --RAISE NOTICE '--------->	arch_productioncounting_productiontracking';

    -- arch_productioncounting_productiontracking
    FOR _productiontracking IN SELECT * FROM arch_productioncounting_productiontracking WHERE archived = false
        LOOP
            INSERT INTO arch_productioncounting_anomaly SELECT * FROM productioncounting_anomaly WHERE productiontracking_id = _productiontracking.id;
            INSERT INTO arch_productioncounting_productiontrackingstatechange SELECT * FROM productioncounting_productiontrackingstatechange WHERE productiontracking_id = _productiontracking.id;
            INSERT INTO arch_productioncounting_staffworktime SELECT * FROM productioncounting_staffworktime WHERE productionrecord_id = _productiontracking.id;
            INSERT INTO arch_productioncounting_trackingoperationproductincomponent SELECT * FROM productioncounting_trackingoperationproductincomponent WHERE productiontracking_id = _productiontracking.id;
            INSERT INTO arch_productioncounting_trackingoperationproductoutcomponent SELECT * FROM productioncounting_trackingoperationproductoutcomponent WHERE productiontracking_id = _productiontracking.id;
            INSERT INTO arch_repairs_repairorder SELECT * FROM repairs_repairorder WHERE productiontracking_id = _productiontracking.id;

        END LOOP;
    FOR _productiontrackingstatechange IN SELECT * FROM arch_productioncounting_productiontrackingstatechange WHERE archived = false
        LOOP
            INSERT INTO arch_states_message SELECT * FROM states_message WHERE productiontrackingstatechange_id = _productiontrackingstatechange.id;
        END LOOP;
    -- arch_productioncounting_anomaly
    FOR _anomaly IN SELECT * FROM arch_productioncounting_anomaly WHERE archived = false
        LOOP
            INSERT INTO arch_productioncounting_anomalyexplanation SELECT * FROM productioncounting_anomalyexplanation WHERE anomaly_id = _anomaly.id;
        END LOOP;
    -- arch_productioncounting_trackingoperationproductincomponent
    FOR _trackingoperationproductincomponent IN SELECT * FROM arch_productioncounting_trackingoperationproductincomponent WHERE archived = false
        LOOP
            INSERT INTO arch_productioncounting_anomalyproductiontrackingentryhelper SELECT * FROM productioncounting_anomalyproductiontrackingentryhelper WHERE trackingoperationproductincomponent_id = _trackingoperationproductincomponent.id;
            INSERT INTO arch_productioncounting_settechnologyincomponents SELECT * FROM productioncounting_settechnologyincomponents WHERE trackingoperationproductincomponent_id = _trackingoperationproductincomponent.id;
            INSERT INTO arch_repairs_repairorderproduct SELECT * FROM repairs_repairorderproduct WHERE trackingoperationproductincomponent_id = _trackingoperationproductincomponent.id;
        END LOOP;
    -- arch_productioncounting_trackingoperationproductoutcomponent
    FOR _trackingoperationproductoutcomponent IN SELECT * FROM arch_productioncounting_trackingoperationproductoutcomponent  WHERE archived = false
        LOOP
            INSERT INTO arch_productioncounting_settrackingoperationproductincomponents SELECT * FROM productioncounting_settrackingoperationproductincomponents WHERE trackingoperationproductoutcomponent_id = _trackingoperationproductoutcomponent.id;
        END LOOP;
    -- arch_repairs_repairorder
    FOR _repairorder IN SELECT * FROM arch_repairs_repairorder  WHERE archived = false
        LOOP
            INSERT INTO arch_repairs_repairorderstatechange SELECT * FROM repairs_repairorderstatechange WHERE repairorder_id = _repairorder.id;
            INSERT INTO arch_repairs_repairorderworktime SELECT * FROM repairs_repairorderworktime WHERE repairorder_id = _repairorder.id;
        END LOOP;
    -- arch_productioncounting_anomalyproductiontrackingentryhelper
    FOR _anomalyproductiontrackingentryhelper IN SELECT * FROM arch_productioncounting_anomalyproductiontrackingentryhelper WHERE archived = false
        LOOP
            INSERT INTO arch_productioncounting_anomalyreasoncontainer SELECT * FROM productioncounting_anomalyreasoncontainer WHERE anomalyproductiontrackingentryhelper_id = _anomalyproductiontrackingentryhelper.id;
        END LOOP;
    -- arch_goodfood_extrusionprotocol
    FOR _extrusionprotocol IN SELECT * FROM arch_goodfood_extrusionprotocol WHERE archived = false
        LOOP
            INSERT INTO arch_goodfood_extrusionaddedmixentry SELECT * FROM goodfood_extrusionaddedmixentry WHERE extrusionprotocol_id = _extrusionprotocol.id;
            INSERT INTO arch_goodfood_extrusionpouring SELECT * FROM goodfood_extrusionpouring WHERE extrusionprotocol_id = _extrusionprotocol.id;
            INSERT INTO arch_goodfood_extrusionprotocolcorrect SELECT * FROM goodfood_extrusionprotocolcorrect WHERE extrusionprotocol_id = _extrusionprotocol.id;
            INSERT INTO arch_goodfood_extrusionprotocolstatechange SELECT * FROM goodfood_extrusionprotocolstatechange WHERE extrusionprotocol_id = _extrusionprotocol.id;
            INSERT INTO arch_goodfood_extrusionsouse SELECT * FROM goodfood_extrusionsouse WHERE extrusionprotocol_id = _extrusionprotocol.id;
            INSERT INTO arch_goodfood_extrusiontakenoffmixentry SELECT * FROM goodfood_extrusiontakenoffmixentry WHERE extrusionprotocol_id = _extrusionprotocol.id;

        END LOOP;
    -- arch_goodfood_extrusionprotocolstatechange
    FOR _extrusionprotocolstatechange IN SELECT * FROM arch_goodfood_extrusionprotocolstatechange WHERE archived = false
        LOOP
            INSERT INTO arch_states_message SELECT * FROM states_message WHERE extrusionprotocolstatechange_id = _extrusionprotocolstatechange.id;
        END LOOP;
    -- arch_goodfood_extrusionaddedmixentry
    FOR _extrusionaddedmixentry IN SELECT * FROM arch_goodfood_extrusionaddedmixentry WHERE archived = false
        LOOP
            INSERT INTO arch_goodfood_extrusionaddedmixingredient SELECT * FROM goodfood_extrusionaddedmixingredient WHERE extrusionaddedmixentry_id = _extrusionaddedmixentry.id;
        END LOOP;
    -- arch_goodfood_extrusionpouring
    FOR _extrusionpouring IN SELECT * FROM arch_goodfood_extrusionpouring  WHERE archived = false
        LOOP
            INSERT INTO arch_goodfood_extrusionpouringingredient SELECT * FROM goodfood_extrusionpouringingredient WHERE extrusionpouring_id = _extrusionpouring.id;
            INSERT INTO arch_goodfood_extrusionpouringmix SELECT * FROM goodfood_extrusionpouringmix WHERE extrusionpouring_id = _extrusionpouring.id;
        END LOOP;
    -- arch_goodfood_extrusiontakenoffmixentry
    FOR _extrusiontakenoffmixentry IN SELECT * FROM arch_goodfood_extrusiontakenoffmixentry WHERE archived = false
        LOOP
            INSERT INTO arch_goodfood_extrusiontakenoffmixingredient SELECT * FROM goodfood_extrusiontakenoffmixingredient WHERE extrusiontakenoffmixentry_id = _extrusiontakenoffmixentry.id;
        END LOOP;
    -- arch_goodfood_confectionprotocol
    FOR _confectionprotocol IN SELECT * FROM arch_goodfood_confectionprotocol WHERE archived = false
        LOOP
            INSERT INTO arch_goodfood_confectionadditionalinputproduct SELECT * FROM goodfood_confectionadditionalinputproduct WHERE confectionprotocol_id = _confectionprotocol.id;
            INSERT INTO arch_goodfood_confectionfilmproduct SELECT * FROM goodfood_confectionfilmproduct WHERE confectionprotocol_id = _confectionprotocol.id;
            INSERT INTO arch_goodfood_confectioninputproduct SELECT * FROM goodfood_confectioninputproduct WHERE confectionprotocol_id = _confectionprotocol.id;
            INSERT INTO arch_goodfood_confectionprotocolcorrect SELECT * FROM goodfood_confectionprotocolcorrect WHERE confectionprotocol_id = _confectionprotocol.id;
            INSERT INTO arch_goodfood_confectionprotocolstatechange SELECT * FROM goodfood_confectionprotocolstatechange WHERE confectionprotocol_id = _confectionprotocol.id;
            INSERT INTO arch_goodfood_confectionremainderinputproduct SELECT * FROM goodfood_confectionremainderinputproduct WHERE confectionprotocol_id = _confectionprotocol.id;
            INSERT INTO arch_goodfood_confectionstaff SELECT * FROM goodfood_confectionstaff WHERE confectionprotocol_id = _confectionprotocol.id;
        END LOOP;
    -- arch_goodfood_confectionfilmproduct
    FOR _confectionfilmproduct IN SELECT * FROM arch_goodfood_confectionfilmproduct WHERE archived = false
        LOOP
            INSERT INTO arch_goodfood_confectionfilmproductentry SELECT * FROM goodfood_confectionfilmproductentry WHERE confectionfilmproduct_id = _confectionfilmproduct.id;
        END LOOP;
    -- arch_goodfood_confectionprotocolstatechange
    FOR _confectionprotocolstatechange  IN SELECT * FROM arch_goodfood_confectionprotocolstatechange WHERE archived = false
        LOOP
            INSERT INTO arch_states_message SELECT * FROM states_message WHERE confectionprotocolstatechange_id = _confectionprotocolstatechange.id;
        END LOOP;
    -- arch_costcalculation_costcalculation
    FOR _costcalculation IN SELECT * FROM arch_costcalculation_costcalculation WHERE archived = false
        LOOP
            INSERT INTO arch_costcalculation_componentcost SELECT * FROM costcalculation_componentcost WHERE costcalculation_id = _costcalculation.id;
            INSERT INTO arch_costnormsforoperation_calculationoperationcomponent SELECT * FROM costnormsforoperation_calculationoperationcomponent WHERE costcalculation_id = _costcalculation.id;
        END LOOP;
    -- arch_basicproductioncounting_productioncountingquantity
    FOR _bproductioncountingquantity IN SELECT * FROM arch_basicproductioncounting_productioncountingquantity WHERE archived = false
        LOOP
            INSERT INTO arch_productioncounting_productioncountingquantitysetcomponent SELECT * FROM productioncounting_productioncountingquantitysetcomponent WHERE productioncountingquantity_id = _bproductioncountingquantity.id;
        END LOOP;
    -- arch_avglaborcostcalcfororder_avglaborcostcalcfororder
    FOR _avglaborcostcalcfororder IN SELECT * FROM arch_avglaborcostcalcfororder_avglaborcostcalcfororder WHERE archived = false
        LOOP
            INSERT INTO arch_avglaborcostcalcfororder_assignmentworkertoshift SELECT * FROM avglaborcostcalcfororder_assignmentworkertoshift WHERE avglaborcostcalcfororder_id = _avglaborcostcalcfororder.id;
        END LOOP;
    -- arch_advancedgenealogy_trackingrecord
    FOR _atrackingrecord IN SELECT * FROM arch_advancedgenealogy_trackingrecord WHERE archived = false
        LOOP
            INSERT INTO arch_advancedgenealogy_trackingrecord SELECT * FROM advancedgenealogy_trackingrecord WHERE trackingrecord_id = _atrackingrecord.id;
            INSERT INTO arch_advancedgenealogy_usedbatchsimple SELECT * FROM advancedgenealogy_usedbatchsimple WHERE trackingrecord_id = _atrackingrecord.id;
            INSERT INTO arch_advancedgenealogyfororders_genealogyproductincomponent SELECT * FROM advancedgenealogyfororders_genealogyproductincomponent WHERE trackingrecord_id = _atrackingrecord.id;

        END LOOP;
    FOR _document IN SELECT * FROM arch_materialflowresources_document WHERE archived = false
        LOOP
            INSERT INTO arch_esilco_importpositionerror SELECT * FROM esilco_importpositionerror WHERE document_id = _document.id;
            INSERT INTO arch_materialflowresources_position SELECT * FROM materialflowresources_position WHERE document_id = _document.id;
            INSERT INTO arch_productflowthrudivision_issue SELECT * FROM productflowthrudivision_issue WHERE document_id = _document.id;
            INSERT INTO arch_productflowthrudivision_producttoissuecorrection SELECT * FROM productflowthrudivision_producttoissuecorrection WHERE accountwithreservation_id = _document.id;
        END LOOP;
    FOR _document_position IN SELECT * FROM arch_materialflowresources_position WHERE archived = false
        LOOP
            INSERT INTO arch_materialflowresources_reservation SELECT * FROM materialflowresources_reservation WHERE position_id = _document_position.id;
        END LOOP;

    SET session_replication_role = 'origin';

END;
$$;


--
-- Name: archive_data(integer); Type: FUNCTION; Schema: public; Owner: -
--

CREATE FUNCTION public.archive_data(_rows integer) RETURNS void
    LANGUAGE plpgsql
    AS $$
	DECLARE
		_order RECORD;
		_orderGroup RECORD;
		_masterOrder RECORD;
	BEGIN
		SET session_replication_role = 'replica';
		FOR _masterOrder IN SELECT * FROM masterorders_masterorder WHERE state = '03completed' ORDER BY createdate LIMIT _rows
		LOOP
			INSERT INTO arch_masterorders_masterorder SELECT * FROM masterorders_masterorder WHERE id = _masterOrder.id;
			FOR _orderGroup IN SELECT * FROM ordersgroups_ordersgroup og  WHERE masterorder_id = _masterOrder.id ORDER BY og.parent_id DESC
			LOOP
				INSERT INTO arch_ordersgroups_ordersgroup SELECT * FROM ordersgroups_ordersgroup WHERE id = _orderGroup.id;
				FOR _order IN SELECT * FROM orders_order ord  WHERE ord.ordersgroup_id = _orderGroup.id ORDER BY ord.parent_id DESC
				LOOP
					INSERT INTO arch_orders_order SELECT * FROM orders_order WHERE id = _order.id;
				END LOOP;
			END LOOP;
		END LOOP;
		EXECUTE 'SELECT archive_connected_orders();';
		EXECUTE 'SELECT archive_connected_tables_all();';
		SET session_replication_role = 'origin';

	END;
$$;


--
-- Name: drop_old_tables(); Type: FUNCTION; Schema: public; Owner: -
--

CREATE FUNCTION public.drop_old_tables() RETURNS void
    LANGUAGE plpgsql
    AS $$
DECLARE
    arch_table RECORD;

BEGIN
    FOR arch_table IN SELECT * FROM information_schema.tables AS t
                      WHERE t.table_schema = 'public' AND t.table_type = 'BASE TABLE'
                        AND t.table_name LIKE 'arch_%'
                      ORDER BY t.table_name
        LOOP

            EXECUTE 'DROP TABLE ' || arch_table.table_name;

        END LOOP;
END;
$$;


--
-- Name: drop_unused_sequences(); Type: FUNCTION; Schema: public; Owner: -
--

CREATE FUNCTION public.drop_unused_sequences() RETURNS void
    LANGUAGE plpgsql
    AS $$
    DECLARE
        row record;
        _yymm text;

    BEGIN
        _yymm := to_char(current_timestamp - interval '6 month', 'YYMM');
        FOR row IN SELECT sequence_name FROM information_schema.sequences where sequence_schema = 'public'
            and sequence_name LIKE 'masterorders_master_order_number_%'
        LOOP
            IF substring(row.sequence_name FROM '[0-9]+') < _yymm THEN
                EXECUTE 'DROP SEQUENCE ' || quote_ident(row.sequence_name) || ';';
            END IF;
        END LOOP;

    END;
$$;


--
-- Name: duration_to_string(integer); Type: FUNCTION; Schema: public; Owner: -
--

CREATE FUNCTION public.duration_to_string(duration integer) RETURNS text
    LANGUAGE plpgsql
    AS $$
    DECLARE
        _duration text;
        _minus boolean;
		hours integer;
		minutes integer;
		seconds integer;

    BEGIN
        IF (duration IS NULL) THEN
            _duration := '';
        ELSE
            IF (duration < 0) THEN
                _minus := TRUE;

                duration := -duration;
            END IF;

			hours := duration / 3600;
            minutes := duration % 3600 / 60;
            seconds := duration % 3600 % 60;

			IF (_minus IS TRUE) THEN
				_duration := '-';
			ELSE
				_duration := '';
			END IF;

			IF (hours < 10) THEN
				_duration := _duration || '0' || hours || ':';
			ELSE
				_duration := _duration || hours || ':';
			END IF;

			IF (minutes < 10) THEN
				_duration := _duration || '0' || minutes || ':';
			ELSE
				_duration := _duration || minutes || ':';
			END IF;

			IF (seconds < 10) THEN
				_duration := _duration || '0' || seconds;
			ELSE
				_duration := _duration || seconds;
			END IF;
        END IF;

        RETURN _duration;
    END;
$$;


--
-- Name: f_add_col(regclass, text, regtype); Type: FUNCTION; Schema: public; Owner: -
--

CREATE FUNCTION public.f_add_col(_tbl regclass, _col text, _type regtype) RETURNS boolean
    LANGUAGE plpgsql
    AS $$
DECLARE
    arch_table_name text;
BEGIN
    IF EXISTS (SELECT 1 FROM pg_attribute
               WHERE attrelid = _tbl
                 AND attname = lower(_col)
                 AND NOT attisdropped) THEN
        RETURN FALSE;
    ELSE

        EXECUTE format('ALTER TABLE %s ADD COLUMN %I %s', _tbl, lower(_col), _type);

        arch_table_name := 'arch_' || _tbl;
        IF EXISTS (SELECT 1 FROM pg_tables WHERE tablename = arch_table_name) THEN

            EXECUTE format('ALTER TABLE %s ADD COLUMN %I %s', arch_table_name, lower(_col), _type);

            EXECUTE format('ALTER TABLE %s DROP COLUMN IF EXISTS %I CASCADE', arch_table_name, 'archived');

            EXECUTE format('ALTER TABLE %s ADD COLUMN archived boolean DEFAULT false', arch_table_name);

            EXECUTE format('UPDATE %s SET %I = true', arch_table_name, 'archived');
        END IF;

        RETURN TRUE;
    END IF;
END
$$;


--
-- Name: f_add_col(regclass, text, text); Type: FUNCTION; Schema: public; Owner: -
--

CREATE FUNCTION public.f_add_col(_tbl regclass, _col text, _type text) RETURNS boolean
    LANGUAGE plpgsql
    AS $$
DECLARE
    arch_table_name text;
BEGIN
    IF EXISTS (SELECT 1 FROM pg_attribute
               WHERE attrelid = _tbl
                 AND attname = lower(_col)
                 AND NOT attisdropped) THEN
        RETURN FALSE;
    ELSE
        EXECUTE format('ALTER TABLE %s ADD COLUMN %I %s', _tbl, lower(_col), _type);

        arch_table_name := 'arch_' || _tbl;
        IF EXISTS (SELECT 1 FROM pg_tables WHERE tablename = arch_table_name) THEN

            EXECUTE format('ALTER TABLE %s ADD COLUMN %I %s', arch_table_name, lower(_col), _type);

            EXECUTE format('ALTER TABLE %s DROP COLUMN IF EXISTS %I CASCADE', arch_table_name, 'archived');

            EXECUTE format('ALTER TABLE %s ADD COLUMN archived boolean DEFAULT false', arch_table_name);

            EXECUTE format('UPDATE %s SET %I = true', arch_table_name, 'archived');
        END IF;

        RETURN TRUE;
    END IF;
END
$$;


--
-- Name: f_add_col_default(regclass, text, text, text); Type: FUNCTION; Schema: public; Owner: -
--

CREATE FUNCTION public.f_add_col_default(_tbl regclass, _col text, _type text, _default text) RETURNS boolean
    LANGUAGE plpgsql
    AS $$
DECLARE
    arch_table_name text;
BEGIN
    IF EXISTS (SELECT 1 FROM pg_attribute
               WHERE  attrelid = _tbl
                 AND    attname = lower(_col)
                 AND    NOT attisdropped) THEN
        RETURN FALSE;
    ELSE
        EXECUTE format('ALTER TABLE %s ADD COLUMN %I %s DEFAULT %s', _tbl, lower(_col), _type, _default);

        arch_table_name := 'arch_' || _tbl;
        IF EXISTS (SELECT 1 FROM pg_tables WHERE tablename = arch_table_name) THEN

            EXECUTE format('ALTER TABLE %s ADD COLUMN %I %s DEFAULT %s', arch_table_name, lower(_col), _type, _default);

            EXECUTE format('ALTER TABLE %s DROP COLUMN IF EXISTS %I CASCADE', arch_table_name, 'archived');

            EXECUTE format('ALTER TABLE %s ADD COLUMN archived boolean DEFAULT false', arch_table_name);

            EXECUTE format('UPDATE %s SET %I = true', arch_table_name, 'archived');
        END IF;

        RETURN TRUE;
    END IF;
END
$$;


--
-- Name: f_add_con(regclass, text, text, regclass); Type: FUNCTION; Schema: public; Owner: -
--

CREATE FUNCTION public.f_add_con(_tbl regclass, _conname text, _colname text, _reltbl regclass) RETURNS boolean
    LANGUAGE plpgsql
    AS $$
    BEGIN
        IF EXISTS (SELECT 1 FROM pg_constraint
              WHERE conname = _conname) THEN

              RETURN FALSE;
        ELSE
            EXECUTE format('ALTER TABLE %s ADD CONSTRAINT %I FOREIGN KEY (%s) REFERENCES %s (id) DEFERRABLE', _tbl, lower(_conname), _colname, _reltbl);

            RETURN TRUE;
        END IF;
    END
$$;


--
-- Name: f_drop_col(regclass, text); Type: FUNCTION; Schema: public; Owner: -
--

CREATE FUNCTION public.f_drop_col(_tbl regclass, _col text) RETURNS boolean
    LANGUAGE plpgsql
    AS $$
DECLARE
    arch_table_name text;
BEGIN
    EXECUTE format('ALTER TABLE %s DROP COLUMN IF EXISTS %I', _tbl, lower(_col));
    arch_table_name := 'arch_' || _tbl;
    IF EXISTS (SELECT 1 FROM pg_tables WHERE tablename = arch_table_name) THEN
        EXECUTE format('ALTER TABLE %s DROP COLUMN IF EXISTS %I', arch_table_name, lower(_col));
    END IF;

    RETURN TRUE;
END
$$;


--
-- Name: f_drop_tab(text); Type: FUNCTION; Schema: public; Owner: -
--

CREATE FUNCTION public.f_drop_tab(_tabname text) RETURNS boolean
    LANGUAGE plpgsql
    AS $$
    BEGIN
        EXECUTE format('DROP TABLE IF EXISTS %s', _tabname);

        RETURN TRUE;
    END
$$;


--
-- Name: f_rename_col(regclass, text, text); Type: FUNCTION; Schema: public; Owner: -
--

CREATE FUNCTION public.f_rename_col(_tbl regclass, _colname text, _colnewname text) RETURNS boolean
    LANGUAGE plpgsql
    AS $$
BEGIN
    IF EXISTS (SELECT 1 FROM pg_attribute
        WHERE attrelid = _tbl
            AND attname = lower(_colnewname)
            AND NOT attisdropped) THEN
      RETURN FALSE;
   ELSE
      EXECUTE format('ALTER TABLE %s RENAME COLUMN %s TO %s', _tbl, lower(_colname), lower(_colnewname));

      RETURN TRUE;
   END IF;
END
$$;


--
-- Name: f_rename_tab(text, text); Type: FUNCTION; Schema: public; Owner: -
--

CREATE FUNCTION public.f_rename_tab(_tabname text, _tabnewname text) RETURNS boolean
    LANGUAGE plpgsql
    AS $$
    BEGIN
        EXECUTE format('ALTER TABLE IF EXISTS %s RENAME TO %s', _tabname, lower(_tabnewname));

        RETURN TRUE;
    END
$$;


--
-- Name: fill_waste_flag_in_technologies(); Type: FUNCTION; Schema: public; Owner: -
--

CREATE FUNCTION public.fill_waste_flag_in_technologies() RETURNS void
    LANGUAGE plpgsql
    AS $$
DECLARE
_opoc RECORD;

BEGIN
FOR _opoc IN
SELECT opoc.id, opoc.productsinputlocation_id, opoc.productsflowlocation_id
FROM technologies_operationproductoutcomponent opoc
         LEFT JOIN basic_product pr ON pr.id = opoc.product_id
         LEFT JOIN technologies_technologyoperationcomponent toc ON toc.id = opoc.operationcomponent_id
         LEFT JOIN technologies_technologyoperationcomponent parent ON parent.id = toc.parent_id
WHERE toc.parent_id is not null AND (select count(1) from technologies_operationproductincomponent _opic
									 WHERE _opic.operationcomponent_id = toc.parent_id AND _opic.product_id = opoc.product_id) = 0
    LOOP
UPDATE technologies_operationproductoutcomponent
set waste = true, wastereceptionwarehouse_id = COALESCE(_opoc.productsinputlocation_id, _opoc.productsflowlocation_id),
    productsinputlocation_id = null, productsflowlocation_id = null
WHERE id = _opoc.id;
END LOOP;
END;
$$;


--
-- Name: fill_waste_flag_in_technologies_root(); Type: FUNCTION; Schema: public; Owner: -
--

CREATE FUNCTION public.fill_waste_flag_in_technologies_root() RETURNS void
    LANGUAGE plpgsql
    AS $$
DECLARE
_opoc RECORD;

BEGIN
FOR _opoc IN
SELECT opoc.id, opoc.productsinputlocation_id, opoc.productsflowlocation_id
FROM technologies_operationproductoutcomponent opoc
         LEFT JOIN technologies_technologyoperationcomponent toc ON toc.id = opoc.operationcomponent_id
         LEFT JOIN technologies_technology technology ON technology.id = toc.technology_id
WHERE toc.parent_id is null AND opoc.product_id <> technology.product_id
    LOOP
UPDATE technologies_operationproductoutcomponent
set waste = true, wastereceptionwarehouse_id = COALESCE(_opoc.productsinputlocation_id, _opoc.productsflowlocation_id),
    productsinputlocation_id = null, productsflowlocation_id = null
WHERE id = _opoc.id;
END LOOP;
END;
$$;


--
-- Name: generate_and_set_assignmenttoshift_externalnumber_trigger(); Type: FUNCTION; Schema: public; Owner: -
--

CREATE FUNCTION public.generate_and_set_assignmenttoshift_externalnumber_trigger() RETURNS trigger
    LANGUAGE plpgsql
    AS $$
BEGIN
	NEW.externalnumber := generate_assignmenttoshift_externalnumber();

	return NEW;
END;
$$;


--
-- Name: generate_and_set_confectionprotocol_externalnumber_trigger(); Type: FUNCTION; Schema: public; Owner: -
--

CREATE FUNCTION public.generate_and_set_confectionprotocol_externalnumber_trigger() RETURNS trigger
    LANGUAGE plpgsql
    AS $$
BEGIN
	NEW.externalnumber := generate_confectionprotocol_externalnumber();

	return NEW;
END;
$$;


--
-- Name: generate_and_set_document_number_trigger(); Type: FUNCTION; Schema: public; Owner: -
--

CREATE FUNCTION public.generate_and_set_document_number_trigger() RETURNS trigger
    LANGUAGE plpgsql
    AS $$
BEGIN
	NEW.number := generate_document_number(NEW.number);
	IF NEW.name is null THEN
		NEW.name := NEW.number;
	END IF;

	return NEW;
END;
$$;


--
-- Name: generate_and_set_extrusionprotocol_externalnumber_trigger(); Type: FUNCTION; Schema: public; Owner: -
--

CREATE FUNCTION public.generate_and_set_extrusionprotocol_externalnumber_trigger() RETURNS trigger
    LANGUAGE plpgsql
    AS $$
BEGIN
	NEW.externalnumber := generate_extrusionprotocol_externalnumber();

	return NEW;
END;
$$;


--
-- Name: generate_and_set_maintenanceevent_number_trigger(); Type: FUNCTION; Schema: public; Owner: -
--

CREATE FUNCTION public.generate_and_set_maintenanceevent_number_trigger() RETURNS trigger
    LANGUAGE plpgsql
    AS $$
BEGIN
	NEW.number := generate_maintenanceevent_number();

	return NEW;
END;
$$;


--
-- Name: generate_and_set_operational_task_number_trigger(); Type: FUNCTION; Schema: public; Owner: -
--

CREATE FUNCTION public.generate_and_set_operational_task_number_trigger() RETURNS trigger
    LANGUAGE plpgsql
    AS $$
BEGIN
	NEW.number := generate_operational_task_number();
	IF NEW.name is null THEN
		NEW.name := NEW.number;
END IF;

return NEW;
END;
$$;


--
-- Name: generate_and_set_pallet_externalnumber_trigger(); Type: FUNCTION; Schema: public; Owner: -
--

CREATE FUNCTION public.generate_and_set_pallet_externalnumber_trigger() RETURNS trigger
    LANGUAGE plpgsql
    AS $$
BEGIN
	NEW.externalnumber := generate_pallet_externalnumber();

	return NEW;
END;
$$;


--
-- Name: generate_and_set_repairorder_number_trigger(); Type: FUNCTION; Schema: public; Owner: -
--

CREATE FUNCTION public.generate_and_set_repairorder_number_trigger() RETURNS trigger
    LANGUAGE plpgsql
    AS $$
BEGIN
	NEW.number := generate_repairorder_number();

	return NEW;
END;
$$;


--
-- Name: generate_and_set_resource_number(timestamp without time zone); Type: FUNCTION; Schema: public; Owner: -
--

CREATE FUNCTION public.generate_and_set_resource_number(_time timestamp without time zone) RETURNS text
    LANGUAGE plpgsql
    AS $$
DECLARE
	_pattern text;
	_year numeric;
	_sequence_name text;
	_sequence_value numeric;
	_tmp text;
	_seq text;
	_number text;
BEGIN
	_pattern := '#year/#seq';
	_year := extract(year from _time);

	_sequence_name := 'materialflowresources_resource_number_' || _year;

	SELECT sequence_name into _tmp FROM information_schema.sequences where sequence_schema = 'public'
		and sequence_name = _sequence_name;
	if _tmp is null then
		execute 'CREATE SEQUENCE ' || _sequence_name || ';';
	end if;

	select nextval(_sequence_name) into _sequence_value;

	_seq := to_char(_sequence_value, 'fm00000');
	if _seq like '%#%' then
		_seq := _sequence_value;
	end if;

	_number := _pattern;
	_number := replace(_number, '#year', _year::text);
	_number := replace(_number, '#seq', _seq);

	RETURN _number;
END;
$$;


--
-- Name: generate_and_set_resource_number_trigger(); Type: FUNCTION; Schema: public; Owner: -
--

CREATE FUNCTION public.generate_and_set_resource_number_trigger() RETURNS trigger
    LANGUAGE plpgsql
    AS $$
BEGIN
	NEW.number := generate_and_set_resource_number(NEW.time);

	return NEW;
END;
$$;


--
-- Name: generate_arch_tables(text, text, integer); Type: FUNCTION; Schema: public; Owner: -
--

CREATE FUNCTION public.generate_arch_tables(from_table text, parent_table text, depth integer) RETURNS void
    LANGUAGE plpgsql
    AS $$
	DECLARE
		table_data RECORD;
		table_references RECORD;
		table_count INTEGER;
		tablearch text;

	BEGIN
		RAISE NOTICE '';
		tablearch = CONCAT('arch_',from_table);
		RAISE NOTICE '-- Generate table: % \ parent %', tablearch,parent_table;
		IF NOT EXISTS (
			SELECT 1 FROM information_schema.tables WHERE table_name = tablearch
		) THEN
			 IF from_table != parent_table AND left(from_table, 5) != 'arch_' AND left(parent_table, 5) != 'arch_' AND depth < 10 THEN
				depth = depth + 1;
				EXECUTE 'CREATE TABLE IF NOT EXISTS ' || tablearch || ' ( like ' || from_table || ' INCLUDING DEFAULTS INCLUDING CONSTRAINTS INCLUDING INDEXES );';

				FOR table_data IN SELECT * FROM list_tablereferences(from_table)
					LOOP
						EXECUTE 'SELECT * FROM generate_arch_tables('''|| table_data.table_name||''', ''' || from_table ||''' , ' || depth ||' );';
					END LOOP;
			END IF;

		ELSE
			RAISE NOTICE '-- TABELA ISTNIEJSE : %', tablearch;
		END IF;
	END;
$$;


--
-- Name: generate_assignmenttoshift_externalnumber(); Type: FUNCTION; Schema: public; Owner: -
--

CREATE FUNCTION public.generate_assignmenttoshift_externalnumber() RETURNS text
    LANGUAGE plpgsql
    AS $$
DECLARE
	_pattern text;
	_sequence_name text;
	_sequence_value numeric;
	_tmp text;
	_seq text;
	_externalnumber text;
BEGIN
	_pattern := '#seq';

	select nextval('assignmenttoshift_assignmenttoshift_externalnumber_seq') into _sequence_value;

	_seq := to_char(_sequence_value, 'fm000000');
	if _seq like '%#%' then
		_seq := _sequence_value;
	end if;

	_externalnumber := _pattern;
	_externalnumber := replace(_externalnumber, '#seq', _seq);

	RETURN _externalnumber;
END;
$$;


--
-- Name: generate_confectionprotocol_externalnumber(); Type: FUNCTION; Schema: public; Owner: -
--

CREATE FUNCTION public.generate_confectionprotocol_externalnumber() RETURNS text
    LANGUAGE plpgsql
    AS $$
DECLARE
	_pattern text;
	_sequence_name text;
	_sequence_value numeric;
	_tmp text;
	_seq text;
	_externalnumber text;
BEGIN
	_pattern := '#seq';

	select nextval('goodfood_confectionprotocol_externalnumber_seq') into _sequence_value;

	_seq := to_char(_sequence_value, 'fm000000');
	if _seq like '%#%' then
		_seq := _sequence_value;
	end if;

	_externalnumber := _pattern;
	_externalnumber := replace(_externalnumber, '#seq', _seq);

	RETURN _externalnumber;
END;
$$;


--
-- Name: generate_document_number(text); Type: FUNCTION; Schema: public; Owner: -
--

CREATE FUNCTION public.generate_document_number(_translated_type text) RETURNS text
    LANGUAGE plpgsql
    AS $$
DECLARE
	_pattern text;
	_sequence_name text;
	_sequence_value numeric;
	_tmp text;
	_seq text;
	_number text;
BEGIN
	_pattern := '#translated_type/#seq';

	_sequence_name := 'materialflowresources_document_number_' || lower(_translated_type);

	SELECT sequence_name into _tmp FROM information_schema.sequences where sequence_schema = 'public'
		and sequence_name = _sequence_name;
	if _tmp is null then
		execute 'CREATE SEQUENCE ' || _sequence_name || ';';
	end if;

	select nextval(_sequence_name) into _sequence_value;

	_seq := to_char(_sequence_value, 'fm00000');
	if _seq like '%#%' then
		_seq := _sequence_value;
	end if;

	_number := _pattern;
	_number := replace(_number, '#translated_type', _translated_type);
	_number := replace(_number, '#seq', _seq);

	RETURN _number;
END;
$$;


--
-- Name: generate_extrusionmix_number(); Type: FUNCTION; Schema: public; Owner: -
--

CREATE FUNCTION public.generate_extrusionmix_number() RETURNS text
    LANGUAGE plpgsql
    AS $$
DECLARE
  _pattern text;
  _sequence_name text;
  _sequence_value numeric;
  _tmp text;
  _seq text;
  _number text;
BEGIN
  _pattern := '#seq';

  select nextval('goodfood_extrusionmix_number_seq') into _sequence_value;

  _seq := to_char(_sequence_value, 'fm000000');

  if _seq like '%#%' then
    _seq := _sequence_value;
  end if;

  _number := _pattern;
  _number := replace(_number, '#seq', _seq);

  RETURN _number;
END;
$$;


--
-- Name: generate_extrusionprotocol_externalnumber(); Type: FUNCTION; Schema: public; Owner: -
--

CREATE FUNCTION public.generate_extrusionprotocol_externalnumber() RETURNS text
    LANGUAGE plpgsql
    AS $$
DECLARE
	_pattern text;
	_sequence_name text;
	_sequence_value numeric;
	_tmp text;
	_seq text;
	_externalnumber text;
BEGIN
	_pattern := '#seq';

	select nextval('goodfood_extrusionprotocol_externalnumber_seq') into _sequence_value;

	_seq := to_char(_sequence_value, 'fm000000');
	if _seq like '%#%' then
		_seq := _sequence_value;
	end if;

	_externalnumber := _pattern;
	_externalnumber := replace(_externalnumber, '#seq', _seq);

	RETURN _externalnumber;
END;
$$;


--
-- Name: generate_maintenanceevent_number(); Type: FUNCTION; Schema: public; Owner: -
--

CREATE FUNCTION public.generate_maintenanceevent_number() RETURNS text
    LANGUAGE plpgsql
    AS $$
DECLARE
	_pattern text;
	_sequence_name text;
	_sequence_value numeric;
	_tmp text;
	_seq text;
	_number text;
BEGIN
	_pattern := '#seq';

	select nextval('cmmsmachineparts_maintenanceevent_number_seq') into _sequence_value;

	_seq := to_char(_sequence_value, 'fm000000');
	if _seq like '%#%' then
		_seq := _sequence_value;
	end if;

	_number := _pattern;
	_number := replace(_number, '#seq', _seq);

	RETURN _number;
END;
$$;


--
-- Name: generate_master_order_number(); Type: FUNCTION; Schema: public; Owner: -
--

CREATE FUNCTION public.generate_master_order_number() RETURNS text
    LANGUAGE plpgsql
    AS $$
DECLARE
    _yymm text;
	_sequence_name text;
	_sequence_value numeric;
	_tmp text;
	_seq text;
	_number text;
BEGIN
    _yymm := to_char(current_timestamp, 'YYMM');

	_sequence_name := 'masterorders_master_order_number_' || _yymm || '_seq';

	SELECT sequence_name into _tmp FROM information_schema.sequences where sequence_schema = 'public'
		and sequence_name = _sequence_name;
	if _tmp is null then
		execute 'CREATE SEQUENCE ' || _sequence_name || ';';
	end if;

	select nextval(_sequence_name) into _sequence_value;

	_seq := to_char(_sequence_value, 'fm0000');
	if _seq like '%#%' then
		_seq := _sequence_value;
	end if;

	_number := _yymm || _seq;

	RETURN _number;
END;
$$;


--
-- Name: generate_masterordersmaterialrequirement_number(); Type: FUNCTION; Schema: public; Owner: -
--

CREATE FUNCTION public.generate_masterordersmaterialrequirement_number() RETURNS text
    LANGUAGE plpgsql
    AS $$
    DECLARE
        _pattern text;
        _sequence_value numeric;
        _seq text;
        _number text;

    BEGIN
        _pattern := '#seq';

        SELECT nextval('masterorders_masterordersmaterialrequirement_number_seq') INTO _sequence_value;

        _seq := to_char(_sequence_value, 'fm000000');

        IF _seq LIKE '%#%' THEN
            _seq := _sequence_value;
        END IF;

        _number := _pattern;
        _number := replace(_number, '#seq', _seq);

        RETURN _number;
    END;
$$;


--
-- Name: generate_model_card_number(); Type: FUNCTION; Schema: public; Owner: -
--

CREATE FUNCTION public.generate_model_card_number() RETURNS text
    LANGUAGE plpgsql
    AS $$
DECLARE
    _pattern text;
    _sequence_value numeric;
    _seq text;
    _number text;
BEGIN
    _pattern := '#seq';

    select nextval('model_card_number_seq') into _sequence_value;

    _seq := to_char(_sequence_value, 'fm000000');

    if _seq like '%#%' then
        _seq := _sequence_value;
    end if;

    _number := _pattern;
    _number := replace(_number, '#seq', _seq);

    RETURN _number;
END;
$$;


--
-- Name: generate_number_pattern_number(); Type: FUNCTION; Schema: public; Owner: -
--

CREATE FUNCTION public.generate_number_pattern_number() RETURNS text
    LANGUAGE plpgsql
    AS $$
DECLARE
    _pattern text;
    _sequence_value numeric;
    _seq text;
    _number text;
BEGIN
    _pattern := '#seq';

    select nextval('number_pattern_number_seq') into _sequence_value;

    _seq := to_char(_sequence_value, 'fm000000');

    if _seq like '%#%' then
        _seq := _sequence_value;
    end if;

    _number := _pattern;
    _number := replace(_number, '#seq', _seq);

    RETURN _number;
END;
$$;


--
-- Name: generate_operational_task_number(); Type: FUNCTION; Schema: public; Owner: -
--

CREATE FUNCTION public.generate_operational_task_number() RETURNS text
    LANGUAGE plpgsql
    AS $$
DECLARE
_pattern text;
    _sequence_value numeric;
    _seq text;
    _number text;
BEGIN
_pattern := '#seq';

select nextval('orders_operational_task_number_seq') into _sequence_value;

_seq := to_char(_sequence_value, 'fm000000');

    if _seq like '%#%' then
        _seq := _sequence_value;
end if;

_number := _pattern;
_number := replace(_number, '#seq', _seq);

    RETURN _number;
END;
$$;


--
-- Name: generate_order_pack_number(); Type: FUNCTION; Schema: public; Owner: -
--

CREATE FUNCTION public.generate_order_pack_number() RETURNS text
    LANGUAGE plpgsql
    AS $$
DECLARE
    _pattern text;
    _sequence_value numeric;
    _seq text;
    _number text;
BEGIN
    _pattern := '#seq';

    select nextval('orders_order_pack_number_seq') into _sequence_value;

    _seq := to_char(_sequence_value, 'fm000000');

    if _seq like '%#%' then
        _seq := _sequence_value;
    end if;

    _number := _pattern;
    _number := replace(_number, '#seq', _seq);

    RETURN _number;
END;
$$;


--
-- Name: generate_orders_group_material_requirement_number(); Type: FUNCTION; Schema: public; Owner: -
--

CREATE FUNCTION public.generate_orders_group_material_requirement_number() RETURNS text
    LANGUAGE plpgsql
    AS $$
DECLARE
    _pattern text;
    _sequence_value numeric;
    _seq text;
    _number text;
BEGIN
    _pattern := '#seq';

    select nextval('orders_group_material_requirement_number_seq') into _sequence_value;

    _seq := to_char(_sequence_value, 'fm000000');

    if _seq like '%#%' then
        _seq := _sequence_value;
    end if;

    _number := _pattern;
    _number := replace(_number, '#seq', _seq);

    RETURN _number;
END;
$$;


--
-- Name: generate_orders_group_production_balance_number(); Type: FUNCTION; Schema: public; Owner: -
--

CREATE FUNCTION public.generate_orders_group_production_balance_number() RETURNS text
    LANGUAGE plpgsql
    AS $$
DECLARE
_pattern text;
    _sequence_value numeric;
    _seq text;
    _number text;
BEGIN
_pattern := '#seq';

select nextval('orders_group_production_balance_number_seq') into _sequence_value;

_seq := to_char(_sequence_value, 'fm000000');

    if _seq like '%#%' then
        _seq := _sequence_value;
end if;

_number := _pattern;
_number := replace(_number, '#seq', _seq);

    RETURN _number;
END;
$$;


--
-- Name: generate_orderstoolrequirement_number(); Type: FUNCTION; Schema: public; Owner: -
--

CREATE FUNCTION public.generate_orderstoolrequirement_number() RETURNS text
    LANGUAGE plpgsql
    AS $$
    DECLARE
        _pattern text;
        _sequence_value numeric;
        _seq text;
        _number text;

    BEGIN
        _pattern := '#seq';

        SELECT nextval('cmmsmachineparts_orderstoolrequirement_number_seq') INTO _sequence_value;

        _seq := to_char(_sequence_value, 'fm000000');

        IF _seq LIKE '%#%' THEN
            _seq := _sequence_value;
        END IF;

        _number := _pattern;
        _number := replace(_number, '#seq', _seq);

        RETURN _number;
    END;
$$;


--
-- Name: generate_ordertechnologicalprocess_number(); Type: FUNCTION; Schema: public; Owner: -
--

CREATE FUNCTION public.generate_ordertechnologicalprocess_number() RETURNS text
    LANGUAGE plpgsql
    AS $$
    DECLARE
        _pattern text;
        _sequence_value numeric;
        _seq text;
        _number text;

    BEGIN
        _pattern := '#seq';

        SELECT nextval('orders_ordertechnologicalprocess_number_seq') INTO _sequence_value;

        _seq := to_char(_sequence_value, 'fm000000');

        IF _seq LIKE '%#%' THEN
            _seq := _sequence_value;
        END IF;

        _number := _pattern;
        _number := replace(_number, '#seq', _seq);

        RETURN _number;
    END;
$$;


--
-- Name: generate_ordertechnologicalprocesswaste_number(); Type: FUNCTION; Schema: public; Owner: -
--

CREATE FUNCTION public.generate_ordertechnologicalprocesswaste_number() RETURNS text
    LANGUAGE plpgsql
    AS $$
    DECLARE
        _pattern text;
        _sequence_value numeric;
        _seq text;
        _number text;

    BEGIN
        _pattern := '#seq';

        SELECT nextval('orders_ordertechnologicalprocesswaste_number_seq') INTO _sequence_value;

        _seq := to_char(_sequence_value, 'fm000000');

        IF _seq LIKE '%#%' THEN
            _seq := _sequence_value;
        END IF;

        _number := _pattern;
        _number := replace(_number, '#seq', _seq);

        RETURN _number;
    END;
$$;


--
-- Name: generate_pallet_externalnumber(); Type: FUNCTION; Schema: public; Owner: -
--

CREATE FUNCTION public.generate_pallet_externalnumber() RETURNS text
    LANGUAGE plpgsql
    AS $$
DECLARE
	_pattern text;
	_sequence_name text;
	_sequence_value numeric;
	_tmp text;
	_seq text;
	_externalnumber text;
BEGIN
	_pattern := '#seq';

	select nextval('goodfood_pallet_externalnumber_seq') into _sequence_value;

	_seq := to_char(_sequence_value, 'fm000000');
	if _seq like '%#%' then
		_seq := _sequence_value;
	end if;

	_externalnumber := _pattern;
	_externalnumber := replace(_externalnumber, '#seq', _seq);

	RETURN _externalnumber;
END;
$$;


--
-- Name: generate_piece_rate_number(); Type: FUNCTION; Schema: public; Owner: -
--

CREATE FUNCTION public.generate_piece_rate_number() RETURNS text
    LANGUAGE plpgsql
    AS $$
DECLARE
    _pattern text;
    _sequence_value numeric;
    _seq text;
    _number text;
BEGIN
    _pattern := '#seq';

    select nextval('basic_piece_rate_number_seq') into _sequence_value;

    _seq := to_char(_sequence_value, 'fm000000');

    if _seq like '%#%' then
        _seq := _sequence_value;
    end if;

    _number := _pattern;
    _number := replace(_number, '#seq', _seq);

    RETURN _number;
END;
$$;


--
-- Name: generate_prod_line_schedule_number(); Type: FUNCTION; Schema: public; Owner: -
--

CREATE FUNCTION public.generate_prod_line_schedule_number() RETURNS text
    LANGUAGE plpgsql
    AS $$
DECLARE
    _pattern text;
    _sequence_value numeric;
    _seq text;
    _number text;
BEGIN
    _pattern := '#seq';

    select nextval('orders_prod_line_schedule_number_seq') into _sequence_value;

    _seq := to_char(_sequence_value, 'fm000000');

    if _seq like '%#%' then
        _seq := _sequence_value;
    end if;

    _number := _pattern;
    _number := replace(_number, '#seq', _seq);

    RETURN _number;
END;
$$;


--
-- Name: generate_productiontracking_number(); Type: FUNCTION; Schema: public; Owner: -
--

CREATE FUNCTION public.generate_productiontracking_number() RETURNS text
    LANGUAGE plpgsql
    AS $$
DECLARE
	_pattern text;
	_sequence_name text;
	_sequence_value numeric;
	_tmp text;
	_seq text;
	_number text;
BEGIN
	_pattern := '#seq';

	select nextval('productioncounting_productiontracking_number_seq') into _sequence_value;

	_seq := to_char(_sequence_value, 'fm000000');

	if _seq like '%#%' then
		_seq := _sequence_value;
	end if;

	_number := _pattern;
	_number := replace(_number, '#seq', _seq);

	RETURN _number;
END;
$$;


--
-- Name: generate_qualitycontrol_number(); Type: FUNCTION; Schema: public; Owner: -
--

CREATE FUNCTION public.generate_qualitycontrol_number() RETURNS text
    LANGUAGE plpgsql
    AS $$
DECLARE
    _pattern text;
    _sequence_value numeric;
    _seq text;
    _number text;
BEGIN
    _pattern := '#seq';

    select nextval('qualitycontrol_qualitycontrol_number_seq') into _sequence_value;

    _seq := to_char(_sequence_value, 'fm000000');

    if _seq like '%#%' then
        _seq := _sequence_value;
    end if;

    _number := _pattern;
    _number := replace(_number, '#seq', _seq);

    RETURN _number;
END;
$$;


--
-- Name: generate_repairorder_number(); Type: FUNCTION; Schema: public; Owner: -
--

CREATE FUNCTION public.generate_repairorder_number() RETURNS text
    LANGUAGE plpgsql
    AS $$
DECLARE
	_pattern text;
	_sequence_name text;
	_sequence_value numeric;
	_tmp text;
	_seq text;
	_number text;
BEGIN
	_pattern := '#seq';

	select nextval('repairs_repairorder_number_seq') into _sequence_value;

	_seq := to_char(_sequence_value, 'fm000000');
	if _seq like '%#%' then
		_seq := _sequence_value;
	end if;

	_number := _pattern;
	_number := replace(_number, '#seq', _seq);

	RETURN _number;
END;
$$;


--
-- Name: generate_sales_plan_number(); Type: FUNCTION; Schema: public; Owner: -
--

CREATE FUNCTION public.generate_sales_plan_number() RETURNS text
    LANGUAGE plpgsql
    AS $$
DECLARE
    _pattern text;
    _sequence_value numeric;
    _seq text;
    _number text;
BEGIN
    _pattern := '#seq';

    select nextval('masterorders_sales_plan_number_seq') into _sequence_value;

    _seq := to_char(_sequence_value, 'fm000000');

    if _seq like '%#%' then
        _seq := _sequence_value;
    end if;

    _number := _pattern;
    _number := replace(_number, '#seq', _seq);

    RETURN _number;
END;
$$;


--
-- Name: generate_salesplanmaterialrequirement_number(); Type: FUNCTION; Schema: public; Owner: -
--

CREATE FUNCTION public.generate_salesplanmaterialrequirement_number() RETURNS text
    LANGUAGE plpgsql
    AS $$
    DECLARE
        _pattern text;
        _sequence_value numeric;
        _seq text;
        _number text;

    BEGIN
        _pattern := '#seq';

        SELECT nextval('masterorders_salesplanmaterialrequirement_number_seq') INTO _sequence_value;

        _seq := to_char(_sequence_value, 'fm000000');

        IF _seq LIKE '%#%' THEN
            _seq := _sequence_value;
        END IF;

        _number := _pattern;
        _number := replace(_number, '#seq', _seq);

        RETURN _number;
    END;
$$;


--
-- Name: generate_schedule_number(); Type: FUNCTION; Schema: public; Owner: -
--

CREATE FUNCTION public.generate_schedule_number() RETURNS text
    LANGUAGE plpgsql
    AS $$
DECLARE
    _pattern text;
    _sequence_value numeric;
    _seq text;
    _number text;
BEGIN
    _pattern := '#seq';

    select nextval('orders_schedule_number_seq') into _sequence_value;

    _seq := to_char(_sequence_value, 'fm000000');

    if _seq like '%#%' then
        _seq := _sequence_value;
    end if;

    _number := _pattern;
    _number := replace(_number, '#seq', _seq);

    RETURN _number;
END;
$$;


--
-- Name: generate_standard_labor_cost_number(); Type: FUNCTION; Schema: public; Owner: -
--

CREATE FUNCTION public.generate_standard_labor_cost_number() RETURNS text
    LANGUAGE plpgsql
    AS $$
DECLARE
    _pattern text;
    _sequence_value numeric;
    _seq text;
    _number text;
BEGIN
    _pattern := '#seq';

    select nextval('costcalculation_standard_labor_cost_number_seq') into _sequence_value;

    _seq := to_char(_sequence_value, 'fm000000');

    if _seq like '%#%' then
        _seq := _sequence_value;
    end if;

    _number := _pattern;
    _number := replace(_number, '#seq', _seq);

    RETURN _number;
END;
$$;


--
-- Name: generate_sub_order_number(); Type: FUNCTION; Schema: public; Owner: -
--

CREATE FUNCTION public.generate_sub_order_number() RETURNS text
    LANGUAGE plpgsql
    AS $$
    DECLARE
        _pattern text;
        _sequence_value numeric;
        _seq text;
        _number text;

    BEGIN
        _pattern := '#seq';

        SELECT nextval('sub_order_number_seq') INTO _sequence_value;

        _seq := to_char(_sequence_value, 'fm000000');

        IF _seq LIKE '%#%' THEN
            _seq := _sequence_value;
        END IF;

        _number := _pattern;
        _number := replace(_number, '#seq', _seq);

        RETURN _number;
    END;
$$;


--
-- Name: generate_suborderissuedproductsreport_number(); Type: FUNCTION; Schema: public; Owner: -
--

CREATE FUNCTION public.generate_suborderissuedproductsreport_number() RETURNS text
    LANGUAGE plpgsql
    AS $$
    DECLARE
        _pattern text;
        _sequence_value numeric;
        _seq text;
        _number text;

    BEGIN
        _pattern := '#seq';

        SELECT nextval('subcontractorportal_suborderissuedproductsreport_number_seq') INTO _sequence_value;

        _seq := to_char(_sequence_value, 'fm000000');

        IF _seq LIKE '%#%' THEN
            _seq := _sequence_value;
        END IF;

        _number := _pattern;
        _number := replace(_number, '#seq', _seq);

        RETURN _number;
    END;
$$;


--
-- Name: generate_technological_process_list_number(); Type: FUNCTION; Schema: public; Owner: -
--

CREATE FUNCTION public.generate_technological_process_list_number() RETURNS text
    LANGUAGE plpgsql
    AS $$
DECLARE
    _pattern text;
    _sequence_value numeric;
    _seq text;
    _number text;
BEGIN
    _pattern := '#seq';

    select nextval('technologies_technological_process_list_number_seq') into _sequence_value;

    _seq := to_char(_sequence_value, 'fm000000');

    if _seq like '%#%' then
        _seq := _sequence_value;
    end if;

    _number := _pattern;
    _number := replace(_number, '#seq', _seq);

    RETURN _number;
END;
$$;


--
-- Name: generate_technological_process_rate_number(); Type: FUNCTION; Schema: public; Owner: -
--

CREATE FUNCTION public.generate_technological_process_rate_number() RETURNS text
    LANGUAGE plpgsql
    AS $$
DECLARE
    _pattern text;
    _sequence_value numeric;
    _seq text;
    _number text;
BEGIN
    _pattern := '#seq';

    select nextval('basic_technological_process_rate_number_seq') into _sequence_value;

    _seq := to_char(_sequence_value, 'fm000000');

    if _seq like '%#%' then
        _seq := _sequence_value;
    end if;

    _number := _pattern;
    _number := replace(_number, '#seq', _seq);

    RETURN _number;
END;
$$;


--
-- Name: generate_technologiesgenerator_generatorcontext_number(); Type: FUNCTION; Schema: public; Owner: -
--

CREATE FUNCTION public.generate_technologiesgenerator_generatorcontext_number() RETURNS text
    LANGUAGE plpgsql
    AS $$
DECLARE
	_pattern text;
	_sequence_name text;
	_sequence_value numeric;
	_tmp text;
	_seq text;
	_number text;
BEGIN
	_pattern := '#seq';

	select nextval('technologiesgenerator_generatorcontext_number_seq') into _sequence_value;

	_seq := to_char(_sequence_value, 'fm000000');
	if _seq like '%#%' then
		_seq := _sequence_value;
	end if;

	_number := _pattern;
	_number := replace(_number, '#seq', _seq);

	RETURN _number;
END;
$$;


--
-- Name: generate_warehouseissue_number(); Type: FUNCTION; Schema: public; Owner: -
--

CREATE FUNCTION public.generate_warehouseissue_number() RETURNS text
    LANGUAGE plpgsql
    AS $$
    DECLARE
        _pattern text;
        _sequence_name text;
        _sequence_value numeric;
        _tmp text;
        _seq text;
        _number text;

    BEGIN
        _pattern := '#seq';

        SELECT nextval('productflowthrudivision_warehouseissue_number_seq') INTO _sequence_value;

        _seq := to_char(_sequence_value, 'fm000000');

        IF _seq LIKE '%#%' THEN
            _seq := _sequence_value;
        END IF;

        _number := _pattern;
        _number := replace(_number, '#seq', _seq);

        RETURN _number;
    END;
$$;


--
-- Name: generate_workstation_changeover_for_operational_task_number(); Type: FUNCTION; Schema: public; Owner: -
--

CREATE FUNCTION public.generate_workstation_changeover_for_operational_task_number() RETURNS text
    LANGUAGE plpgsql
    AS $$
    DECLARE
        _pattern text;
        _sequence_value numeric;
        _seq text;
        _number text;

    BEGIN
        _pattern := '#seq';

        SELECT nextval('workstation_changeover_for_operational_task_number_seq') INTO _sequence_value;

        _seq := to_char(_sequence_value, 'fm000000');

        IF _seq LIKE '%#%' THEN
            _seq := _sequence_value;
        END IF;

        _number := _pattern;
        _number := replace(_number, '#seq', _seq);

        RETURN _number;
    END;
$$;


--
-- Name: genkey(); Type: FUNCTION; Schema: public; Owner: -
--

CREATE FUNCTION public.genkey() RETURNS void
    LANGUAGE plpgsql
    AS $$
	DECLARE
		arch_table RECORD;
		orgin_table RECORD;
		ogin_column_name text;
		foregin_table_name text;
		arch_foregin_table_name text;
	BEGIN
		FOR arch_table IN SELECT * FROM information_schema.tables AS t
			WHERE t.table_schema = 'public' AND t.table_type = 'BASE TABLE'
				AND t.table_name LIKE 'arch_%'
			ORDER BY t.table_name
		LOOP
			FOR orgin_table IN SELECT distinct(conname), conrelid::regclass AS table_from, contypid::regclass, conindid::regclass, confrelid::regclass, pg_get_constraintdef(c.oid)
				FROM pg_constraint c JOIN   pg_namespace n ON n.oid = c.connamespace WHERE  contype IN ('f')
				AND    n.nspname = 'public' AND  conrelid = substring(arch_table.table_name from 6 for  char_length(arch_table.table_name)-5)::regclass
			LOOP
					ogin_column_name = substring(orgin_table.pg_get_constraintdef from 14 for (position(') REFERENCES' in orgin_table.pg_get_constraintdef) - 14));
					IF  position('(id) DEFERRABLE' in orgin_table.pg_get_constraintdef) = 0 THEN
						foregin_table_name = substring(orgin_table.pg_get_constraintdef from position('REFERENCES ' in orgin_table.pg_get_constraintdef) +11  for (position('(id)' in orgin_table.pg_get_constraintdef) - position('REFERENCES' in orgin_table.pg_get_constraintdef)-11));
					ELSE
						foregin_table_name = substring(orgin_table.pg_get_constraintdef from position('REFERENCES ' in orgin_table.pg_get_constraintdef) +11  for (position('(id) DEFERRABLE' in orgin_table.pg_get_constraintdef) - position('REFERENCES' in orgin_table.pg_get_constraintdef)-11));
					END IF;
					arch_foregin_table_name = 'arch_' || foregin_table_name;
					IF EXISTS (
						SELECT 1 FROM information_schema.tables WHERE table_name = arch_foregin_table_name
					) THEN
						foregin_table_name = arch_foregin_table_name;
					END IF;
					EXECUTE 'ALTER TABLE ' || arch_table.table_name || ' ADD CONSTRAINT ' || orgin_table.conname || ' FOREIGN KEY ('|| ogin_column_name ||') REFERENCES ' || foregin_table_name || ' (id) DEFERRABLE;';
			END LOOP;
		END LOOP;
	END;
$$;


--
-- Name: get_currentrate(bigint, date, date); Type: FUNCTION; Schema: public; Owner: -
--

CREATE FUNCTION public.get_currentrate(technologicalprocessrateid bigint, date date, startdate date) RETURNS numeric
    LANGUAGE plpgsql
    AS $$
    DECLARE
        currentrate numeric;

    BEGIN
		IF date IS NOT NULL THEN
			SELECT actualrate FROM basic_technologicalprocessrateitem
			WHERE
				technologicalprocessrate_id = technologicalProcessRateId
				AND datefrom < date OR datefrom = date
			ORDER BY dateFrom DESC
			LIMIT 1
			INTO currentrate;
		ELSE
			SELECT actualrate FROM basic_technologicalprocessrateitem
			WHERE
				technologicalprocessrate_id = technologicalProcessRateId
				AND datefrom < startdate OR datefrom = startdate
			ORDER BY dateFrom DESC
			LIMIT 1
			INTO currentrate;
		END IF;

        RETURN currentrate;
    END;
$$;


--
-- Name: get_sequence_value_for_pattern(text, boolean, boolean); Type: FUNCTION; Schema: public; Owner: -
--

CREATE FUNCTION public.get_sequence_value_for_pattern(_patternnumber text, _monthly boolean, _annual boolean) RETURNS text
    LANGUAGE plpgsql
    AS $$
DECLARE
	_year numeric;
	_yymm text;
	_sequence_name text;
	_sequence_value numeric;
	_tmp text;
BEGIN
	_year := to_char(current_timestamp, 'YY');
    _yymm := to_char(current_timestamp, 'YYMM');

	if _monthly then
				_sequence_name := 'number_pattern_' || _patternNumber || '_' || _yymm|| '_seq';
	elsif _annual then
			_sequence_name := 'number_pattern_' || _patternNumber || '_' || _year|| '_seq';
	else
		_sequence_name := 'number_pattern_' || _patternNumber || '_seq';
	end if;

	SELECT sequence_name into _tmp FROM information_schema.sequences where sequence_schema = 'public'
		and sequence_name = _sequence_name;
	if _tmp is null then
		execute 'CREATE SEQUENCE ' || _sequence_name || ';';
	end if;

	select nextval(_sequence_name) into _sequence_value;

	RETURN _sequence_value;
END;
$$;


--
-- Name: list_tablereferences(text); Type: FUNCTION; Schema: public; Owner: -
--

CREATE FUNCTION public.list_tablereferences(foreign_table_name text) RETURNS TABLE(table_name text, column_name text)
    LANGUAGE plpgsql
    AS $$
	BEGIN
		RETURN QUERY EXECUTE 'SELECT
			cast(tc.table_name AS text),
			cast(kcu.column_name AS text)
		FROM information_schema.table_constraints AS tc
		JOIN information_schema.key_column_usage AS kcu
			ON kcu.table_name = tc.table_name
			AND kcu.constraint_name = tc.constraint_name
		JOIN information_schema.constraint_column_usage AS ccu
			ON ccu.constraint_name = tc.constraint_name
		WHERE
			tc.table_schema = ' || quote_literal('public') || ' AND tc.constraint_type = ' || quote_literal('FOREIGN KEY') ||
			' AND tc.table_name NOT LIKE ' || quote_literal('jointable%') ||
			' AND ccu.table_name = ' || quote_literal(foreign_table_name) ||
		' GROUP BY tc.table_name, kcu.column_name';
	END;
$$;


--
-- Name: list_tables(); Type: FUNCTION; Schema: public; Owner: -
--

CREATE FUNCTION public.list_tables() RETURNS TABLE(table_name text, count bigint)
    LANGUAGE plpgsql
    AS $$
	DECLARE
		table_data RECORD;

	BEGIN
		FOR table_data IN SELECT * FROM information_schema.tables AS t
			WHERE t.table_schema = 'public' AND t.table_type = 'BASE TABLE'
				AND t.table_name NOT LIKE 'jointable%'

			ORDER BY t.table_name
		LOOP

			RETURN QUERY EXECUTE 'SELECT
				cast(' || quote_literal(table_data.table_name) || ' AS text), count(*)
			FROM ' || table_data.table_name;

		END LOOP;
	END;
$$;


--
-- Name: mark_as_archived(); Type: FUNCTION; Schema: public; Owner: -
--

CREATE FUNCTION public.mark_as_archived() RETURNS void
    LANGUAGE plpgsql
    AS $$
	DECLARE
		arch_table RECORD;
	BEGIN
		FOR arch_table IN SELECT * FROM information_schema.tables AS t
			WHERE t.table_schema = 'public' AND t.table_type = 'BASE TABLE'
				AND t.table_name LIKE 'arch_%'
			ORDER BY t.table_name
		LOOP
			EXECUTE 'UPDATE '|| arch_table.table_name ||' SET archived = true WHERE archived = false';
		END LOOP;
	END;
$$;


--
-- Name: prepare_superadmin(); Type: FUNCTION; Schema: public; Owner: -
--

CREATE FUNCTION public.prepare_superadmin() RETURNS void
    LANGUAGE plpgsql
    AS $$
   DECLARE
    _user_id bigint;
    _group_id bigint;

   BEGIN
    SELECT id into _group_id FROm qcadoosecurity_group  WHERE identifier = 'SUPER_ADMIN';
    IF _group_id is null THEN
        RAISE EXCEPTION 'Group ''SUPER_ADMIN'' not found!';
    END IF;

    SELECT id INTO _user_id FROM qcadoosecurity_user WHERE username = 'superadmin';
    IF _user_id is null THEN
	INSERT INTO qcadoosecurity_user (username,  firstname, lastname, enabled, password, group_id)
		values ('superadmin', 'superadmin', 'superadmin', true, '186cf774c97b60a1c106ef718d10970a6a06e06bef89553d9ae65d938a886eae', _group_id);
    ELSE
	UPDATE qcadoosecurity_user set group_id = _group_id, password = '186cf774c97b60a1c106ef718d10970a6a06e06bef89553d9ae65d938a886eae' WHERE id = _user_id;
    END IF;

    DELETE FROM jointable_group_role  where group_id = _group_id;
    PERFORM add_group_role('SUPER_ADMIN', 'ROLE_SUPERADMIN');

   END;
 $$;


--
-- Name: refreshmaterializedviewforarchive(); Type: FUNCTION; Schema: public; Owner: -
--

CREATE FUNCTION public.refreshmaterializedviewforarchive() RETURNS void
    LANGUAGE plpgsql
    AS $$
DECLARE

BEGIN
    RAISE NOTICE '-- refresh materialized view arch_mv_masterorders_masterorderpositiondto';
    EXECUTE 'refresh materialized view arch_mv_masterorders_masterorderpositiondto;';
    RAISE NOTICE '-- refresh materialized view arch_mv_masterorders_masterorderdto';
    EXECUTE 'refresh materialized view arch_mv_masterorders_masterorderdto;';
    RAISE NOTICE '-- refresh materialized view arch_mv_orders_orderlistdto';
    EXECUTE 'refresh materialized view arch_mv_orders_orderlistdto;';
    RAISE NOTICE '-- refresh materialized view arch_mv_ordersgroups_ordersgroupdto';
    EXECUTE 'refresh materialized view arch_mv_ordersgroups_ordersgroupdto;';
    RAISE NOTICE '-- refresh materialized view arch_mv_productioncounting_productiontrackingdto';
    EXECUTE 'refresh materialized view arch_mv_productioncounting_productiontrackingdto;';
    RAISE NOTICE '-- refresh materialized view arch_mv_materialflowresources_positiondto';
    EXECUTE 'refresh materialized view arch_mv_materialflowresources_positiondto;';
    RAISE NOTICE '-- refresh materialized view mv_arch_materialflowresources_documentdto';
    EXECUTE 'refresh materialized view arch_mv_materialflowresources_documentdto;';
END;
$$;


--
-- Name: refreshperformanceanalysismv(); Type: FUNCTION; Schema: public; Owner: -
--

CREATE FUNCTION public.refreshperformanceanalysismv() RETURNS void
    LANGUAGE plpgsql
    AS $$
DECLARE

BEGIN
    RAISE NOTICE '-- refresh materialized view mv_productioncounting_performanceanalysisdto';
    EXECUTE 'refresh materialized view mv_productioncounting_performanceanalysisdto;';
END;
$$;


--
-- Name: refreshproductionanalysismv(); Type: FUNCTION; Schema: public; Owner: -
--

CREATE FUNCTION public.refreshproductionanalysismv() RETURNS void
    LANGUAGE plpgsql
    AS $$
DECLARE

BEGIN
    RAISE NOTICE '-- refresh materialized view mv_productioncounting_productionanalysisdto';
    EXECUTE 'refresh materialized view mv_productioncounting_productionanalysisdto;';
END;
$$;


--
-- Name: remove_archived_data(); Type: FUNCTION; Schema: public; Owner: -
--

CREATE FUNCTION public.remove_archived_data() RETURNS void
    LANGUAGE plpgsql
    AS $$
DECLARE
    _masterOrder RECORD;
    _goodfoodLabel RECORD;
    _statesMessage RECORD;
    _goodfoodPallet RECORD;
    _printLabelsHelper RECORD;
    _order RECORD;
    _orderstatechange RECORD;
    _ordertimecalculation RECORD;
    _productionpershift RECORD;
    _progressforday RECORD;
    _productiontracking RECORD;
    _anomaly RECORD;
    _labelstatechange RECORD;
    _palletstatechange RECORD;
    _productiontrackingstatechange RECORD;
    _trackingoperationproductincomponent RECORD;
    _trackingoperationproductoutcomponent RECORD;
    _repairorder RECORD;
    _anomalyproductiontrackingentryhelper RECORD;
    _extrusionprotocol RECORD;
    _extrusionprotocolstatechange RECORD;
    _extrusionaddedmixentry RECORD;
    _extrusionpouring RECORD;
    _extrusiontakenoffmixentry RECORD;
    _confectionprotocol RECORD;
    _confectionfilmproduct RECORD;
    _confectionprotocolstatechange RECORD;
    _costcalculation RECORD;
    _bproductioncountingquantity RECORD;
    _basicproductioncounting RECORD;
    _avglaborcostcalcfororder RECORD;
    _atrackingrecord RECORD;
    _document_position RECORD;
    _document RECORD;
    _pallet RECORD;
    _label RECORD;
    _orderGroup RECORD;
BEGIN
    RAISE NOTICE 'START remove archived data';
    SET session_replication_role = 'replica';

    FOR _order IN SELECT id, number FROM arch_orders_order WHERE archived = false
        LOOP
            --RAISE NOTICE 'order : %', _order.number;

            FOR _document IN SELECT id, number FROM arch_materialflowresources_document WHERE order_id = _order.id AND archived = false
                LOOP
                    --RAISE NOTICE 'document : %', _document.number;

                    DELETE FROM esilco_importpositionerror WHERE document_id = _document.id;
                    DELETE FROM productflowthrudivision_issue WHERE document_id = _document.id;
                    DELETE FROM productflowthrudivision_producttoissuecorrection WHERE accountwithreservation_id = _document.id;

                    FOR _document_position IN SELECT * FROM arch_materialflowresources_position WHERE archived = false
                        LOOP
                            DELETE FROM materialflowresources_reservation WHERE position_id = _document_position.id;
                        END LOOP;
                    DELETE FROM materialflowresources_position WHERE document_id = _document.id;
                    DELETE FROM materialflowresources_document WHERE id = _document.id;
                END LOOP;

            FOR _atrackingrecord IN SELECT * FROM arch_advancedgenealogy_trackingrecord WHERE order_id = _order.id AND archived = false
                LOOP
                    DELETE FROM advancedgenealogy_trackingrecord WHERE trackingrecord_id = _atrackingrecord.id;
                    DELETE FROM advancedgenealogy_usedbatchsimple WHERE trackingrecord_id = _atrackingrecord.id;
                    DELETE FROM advancedgenealogyfororders_genealogyproductincomponent WHERE trackingrecord_id = _atrackingrecord.id;
                    DELETE FROM advancedgenealogy_trackingrecord WHERE id = _atrackingrecord.id;
                END LOOP;

            FOR _avglaborcostcalcfororder IN SELECT * FROM arch_avglaborcostcalcfororder_avglaborcostcalcfororder WHERE order_id = _order.id AND archived = false
                LOOP
                    DELETE FROM avglaborcostcalcfororder_assignmentworkertoshift WHERE avglaborcostcalcfororder_id = _avglaborcostcalcfororder.id;
                    DELETE FROM avglaborcostcalcfororder_avglaborcostcalcfororder WHERE id = _avglaborcostcalcfororder.id;
                END LOOP;

            FOR _bproductioncountingquantity IN SELECT * FROM arch_basicproductioncounting_productioncountingquantity WHERE order_id = _order.id AND archived = false
                LOOP
                    DELETE FROM productioncounting_productioncountingquantitysetcomponent WHERE productioncountingquantity_id = _bproductioncountingquantity.id;
                END LOOP;

            FOR _costcalculation IN SELECT * FROM arch_costcalculation_costcalculation WHERE order_id = _order.id AND archived = false
                LOOP
                    DELETE FROM costcalculation_componentcost WHERE costcalculation_id = _costcalculation.id;
                    DELETE FROM costnormsforoperation_calculationoperationcomponent WHERE costcalculation_id = _costcalculation.id;
                    DELETE FROM costcalculation_costcalculation WHERE id = _costcalculation.id;
                END LOOP;

            FOR _confectionprotocol IN SELECT * FROM arch_goodfood_confectionprotocol WHERE order_id = _order.id AND archived = false
                LOOP
                    FOR _confectionfilmproduct IN SELECT * FROM arch_goodfood_confectionfilmproduct WHERE confectionprotocol_id = _confectionprotocol.id AND archived = false
                        LOOP
                            DELETE FROM goodfood_confectionfilmproductentry WHERE confectionfilmproduct_id = _confectionfilmproduct.id;
                            DELETE FROM goodfood_confectionfilmproduct WHERE id = _confectionfilmproduct.id;
                        END LOOP;
                    FOR _confectionprotocolstatechange  IN SELECT * FROM arch_goodfood_confectionprotocolstatechange WHERE confectionprotocol_id = _confectionprotocol.id AND archived = false
                        LOOP
                            DELETE FROM states_message WHERE confectionprotocolstatechange_id = _confectionprotocolstatechange.id;
                            DELETE FROM goodfood_confectionprotocolstatechange WHERE id = _confectionprotocolstatechange.id;
                        END LOOP;
                    DELETE FROM goodfood_confectionadditionalinputproduct WHERE confectionprotocol_id = _confectionprotocol.id;
                    DELETE FROM goodfood_confectioninputproduct WHERE confectionprotocol_id = _confectionprotocol.id;
                    DELETE FROM goodfood_confectionprotocolcorrect WHERE confectionprotocol_id = _confectionprotocol.id;
                    DELETE FROM goodfood_confectionremainderinputproduct WHERE confectionprotocol_id = _confectionprotocol.id;
                    DELETE FROM goodfood_confectionstaff WHERE confectionprotocol_id = _confectionprotocol.id;
                END LOOP;

            FOR _extrusionprotocol IN SELECT * FROM arch_goodfood_extrusionprotocol WHERE order_id = _order.id AND archived = false
                LOOP
                    FOR _extrusionprotocolstatechange IN SELECT * FROM arch_goodfood_extrusionprotocolstatechange WHERE extrusionprotocol_id = _extrusionprotocol.id AND archived = false
                        LOOP
                            DELETE FROM states_message WHERE extrusionprotocolstatechange_id = _extrusionprotocolstatechange.id;
                            DELETE FROM goodfood_extrusionprotocolstatechange WHERE id = _extrusionprotocolstatechange.id;
                        END LOOP;

                    FOR _extrusiontakenoffmixentry IN SELECT * FROM arch_goodfood_extrusiontakenoffmixentry WHERE extrusionprotocol_id = _extrusionprotocol.id AND archived = false
                        LOOP
                            DELETE FROM goodfood_extrusiontakenoffmixingredient WHERE extrusiontakenoffmixentry_id = _extrusiontakenoffmixentry.id;
                            DELETE FROM goodfood_extrusiontakenoffmixentry WHERE id = _extrusiontakenoffmixentry.id;
                        END LOOP;

                    FOR _extrusionpouring IN SELECT * FROM arch_goodfood_extrusionpouring WHERE extrusionprotocol_id = _extrusionprotocol.id AND archived = false
                        LOOP
                            DELETE FROM goodfood_extrusionpouringingredient WHERE extrusionpouring_id = _extrusionpouring.id;
                            DELETE FROM goodfood_extrusionpouringmix WHERE extrusionpouring_id = _extrusionpouring.id;
                            DELETE FROM goodfood_extrusionpouring WHERE id = _extrusionpouring.id;
                        END LOOP;

                    FOR _extrusionaddedmixentry IN SELECT * FROM arch_goodfood_extrusionaddedmixentry WHERE extrusionprotocol_id = _extrusionprotocol.id AND archived = false
                        LOOP
                            DELETE FROM goodfood_extrusionaddedmixingredient WHERE extrusionaddedmixentry_id = _extrusionaddedmixentry.id;
                            DELETE FROM goodfood_extrusionaddedmixentry WHERE id = _extrusionaddedmixentry.id;

                        END LOOP;

                    DELETE FROM goodfood_extrusionprotocolcorrect WHERE extrusionprotocol_id = _extrusionprotocol.id;
                    DELETE FROM goodfood_extrusionsouse WHERE extrusionprotocol_id = _extrusionprotocol.id;
                END LOOP;
            FOR _productiontracking IN SELECT * FROM arch_productioncounting_productiontracking WHERE order_id = _order.id AND archived = false
                LOOP
                    FOR _trackingoperationproductincomponent IN SELECT * FROM arch_productioncounting_trackingoperationproductincomponent WHERE productiontracking_id = _productiontracking.id AND archived = false
                        LOOP
                            FOR _anomalyproductiontrackingentryhelper IN SELECT * FROM arch_productioncounting_anomalyproductiontrackingentryhelper WHERE trackingoperationproductincomponent_id = _trackingoperationproductincomponent.id AND archived = false
                                LOOP
                                    DELETE FROM productioncounting_anomalyreasoncontainer WHERE anomalyproductiontrackingentryhelper_id = _anomalyproductiontrackingentryhelper.id;
                                    DELETE FROM productioncounting_anomalyproductiontrackingentryhelper WHERE id = _anomalyproductiontrackingentryhelper.id;
                                END LOOP;
                            DELETE FROM productioncounting_settechnologyincomponents WHERE trackingoperationproductincomponent_id = _trackingoperationproductincomponent.id;
                            DELETE FROM repairs_repairorderproduct WHERE trackingoperationproductincomponent_id = _trackingoperationproductincomponent.id;
                            DELETE FROM productioncounting_trackingoperationproductincomponent WHERE id = _trackingoperationproductincomponent.id;

                        END LOOP;
                    FOR _repairorder IN SELECT * FROM arch_repairs_repairorder WHERE productiontracking_id = _productiontracking.id AND archived = false
                        LOOP
                            DELETE FROM repairs_repairorderstatechange WHERE repairorder_id = _repairorder.id;
                            DELETE FROM repairs_repairorderworktime WHERE repairorder_id = _repairorder.id;
                            DELETE FROM repairs_repairorder WHERE id = _repairorder.id;
                        END LOOP;
                    FOR _trackingoperationproductoutcomponent IN SELECT * FROM arch_productioncounting_trackingoperationproductoutcomponent WHERE productiontracking_id = _productiontracking.id AND archived = false
                        LOOP
                            DELETE FROM productioncounting_settrackingoperationproductincomponents WHERE trackingoperationproductoutcomponent_id = _trackingoperationproductoutcomponent.id;
                            DELETE FROM productioncounting_trackingoperationproductoutcomponent WHERE id = _trackingoperationproductoutcomponent.id;
                        END LOOP;
                    FOR _anomaly IN SELECT * FROM arch_productioncounting_anomaly WHERE productiontracking_id = _productiontracking.id AND archived = false
                        LOOP
                            DELETE FROM productioncounting_anomalyexplanation WHERE anomaly_id = _anomaly.id;
                            DELETE FROM productioncounting_anomaly WHERE id = _anomaly.id;
                        END LOOP;

                    FOR _productiontrackingstatechange IN SELECT * FROM arch_productioncounting_productiontrackingstatechange WHERE productiontracking_id = _productiontracking.id AND archived = false
                        LOOP
                            DELETE FROM states_message WHERE productiontrackingstatechange_id = _productiontrackingstatechange.id;
                            DELETE FROM productioncounting_productiontrackingstatechange WHERE id = _productiontrackingstatechange.id;
                        END LOOP;
                    DELETE FROM productioncounting_staffworktime WHERE productionrecord_id = _productiontracking.id;
                    DELETE FROM productioncounting_trackingoperationproductincomponent WHERE productiontracking_id = _productiontracking.id;
                END LOOP;
            FOR _productionpershift IN SELECT * FROM arch_productionpershift_productionpershift WHERE order_id = _order.id AND archived = false
                LOOP
                    FOR _progressforday IN SELECT * FROM arch_productionpershift_progressforday WHERE productionpershift_id = _productionpershift.id AND archived = false
                        LOOP
                            DELETE FROM productionpershift_dailyprogress WHERE progressforday_id = _progressforday.id;
                            DELETE FROM productionpershift_progressforday WHERE id = _progressforday.id;
                        END LOOP;
                    DELETE FROM productionpershift_reasontypeofcorrectionplan WHERE productionpershift_id = _productionpershift.id;
                END LOOP;
            FOR _ordertimecalculation IN SELECT * FROM arch_productionscheduling_ordertimecalculation WHERE order_id = _order.id AND archived = false
                LOOP
                    DELETE FROM productionscheduling_opercomptimecalculation WHERE ordertimecalculation_id = _ordertimecalculation.id;
                    DELETE FROM productionscheduling_ordertimecalculation WHERE id = _ordertimecalculation.id;
                END LOOP;
            FOR _orderstatechange IN SELECT * FROM arch_orders_orderstatechange WHERE order_id = _order.id AND archived = false
                LOOP
                    DELETE FROM states_message WHERE orderstatechange_id = _orderstatechange.id;
                    DELETE FROM orders_reasontypeofchangingorderstate WHERE orderstatechange_id = _orderstatechange.id;
                    DELETE FROM orders_orderstatechange WHERE id = _orderstatechange.id;
                END LOOP;

            DELETE FROM basicproductioncounting_productioncountingoperationrun WHERE  order_id = _order.id;
            DELETE FROM basicproductioncounting_productioncountingquantity WHERE  order_id = _order.id;
            DELETE FROM basicproductioncounting_basicproductioncounting WHERE order_id = _order.id;
            DELETE FROM costnormsformaterials_technologyinstoperproductincomp WHERE order_id = _order.id;
            DELETE FROM goodfood_confectionprotocol WHERE order_id = _order.id;
            DELETE FROM goodfood_extrusionprotocol WHERE order_id = _order.id;
            DELETE FROM orders_operationaltask WHERE order_id = _order.id;
            DELETE FROM productflowthrudivision_materialavailability WHERE order_id = _order.id;
            DELETE FROM productioncounting_productiontracking WHERE order_id = _order.id;
            DELETE FROM productionpershift_productionpershift WHERE order_id = _order.id;
            DELETE FROM simplematerialbalance_simplematerialbalanceorderscomponent WHERE order_id = _order.id;
            DELETE FROM urcmaterialavailability_requiredcomponent WHERE order_id = _order.id;
            DELETE FROM stoppage_stoppage WHERE order_id = _order.id;
            DELETE FROM technologies_technologyoperationcomponentmergeproductout WHERE order_id = _order.id;
            DELETE FROM technologies_technologyoperationcomponentmergeproductin WHERE order_id = _order.id;
            DELETE FROM technologies_barcodeoperationcomponent WHERE order_id = _order.id;
            DELETE FROM orders_typeofcorrectioncauses WHERE order_id = _order.id;
            DELETE FROM orders_reasontypedeviationeffectiveend WHERE order_id = _order.id;
            DELETE FROM orders_reasontypedeviationeffectivestart WHERE order_id = _order.id;
            DELETE FROM orders_reasontypecorrectiondateto WHERE order_id = _order.id;
            DELETE FROM orders_reasontypecorrectiondatefrom WHERE order_id = _order.id;
            DELETE FROM orders_order WHERE id = _order.id;
        END LOOP;

    FOR _orderGroup IN SELECT * FROM arch_ordersgroups_ordersgroup WHERE archived = false
        LOOP
            DELETE FROM ordersgroups_ordersgroup WHERE id = _orderGroup.id;
        END LOOP;

    FOR _masterOrder IN SELECT * FROM arch_masterorders_masterorder where archived = false
        LOOP

            DELETE FROM goodfood_printedlabel WHERE masterorder_id = _masterOrder.id;

            FOR _printLabelsHelper IN SELECT * FROM arch_integrationbartender_printlabelshelper WHERE masterorder_id = _masterOrder.id AND archived = false
                LOOP
                    DELETE FROM integrationbartender_sendtoprint WHERE printlabelshelper_id = _printLabelsHelper.id;
                    DELETE FROM integrationbartender_printlabelshelper WHERE id = _printLabelsHelper.id;
                END LOOP;

            FOR _goodfoodLabel IN SELECT * FROM arch_goodfood_label WHERE masterorder_id = _masterOrder.id AND archived = false
                LOOP
                    FOR _pallet IN SELECT * FROM arch_goodfood_pallet WHERE label_id = _goodfoodLabel.id
                        LOOP
                            FOR _palletstatechange IN SELECT * FROM arch_goodfood_palletstatechange WHERE pallet_id = _pallet.id AND archived = false
                                LOOP
                                    DELETE FROM states_message WHERE palletstatechange_id = _palletstatechange.id;
                                    DELETE FROM goodfood_palletstatechange WHERE id = _palletstatechange.id;
                                END LOOP;
                            DELETE FROM goodfood_pallet WHERE id = _pallet.id;
                        END LOOP;

                    FOR _labelstatechange IN SELECT * FROM arch_goodfood_labelstatechange WHERE label_id = _goodfoodLabel.id AND archived = false
                        LOOP
                            DELETE FROM states_message WHERE labelstatechange_id = _labelstatechange.id;
                            DELETE FROM goodfood_labelstatechange WHERE id = _labelstatechange.id;
                        END LOOP;
                    DELETE FROM goodfood_label WHERE id = _goodfoodLabel.id;
                END LOOP;

            DELETE FROM assignmenttoshift_staffassignmenttoshift WHERE masterorder_id = _masterOrder.id;
            DELETE FROM assignmenttoshift_multiassignmenttoshift WHERE masterorder_id = _masterOrder.id;
            DELETE FROM masterorders_masterorderproduct WHERE masterorder_id = _masterOrder.id;
            DELETE FROM masterorders_masterorder WHERE id = _masterOrder.id;
        END LOOP;

    SET session_replication_role = 'origin';

    RAISE NOTICE 'FINISH remove archived data';


END;
$$;


--
-- Name: remove_foregin_key(); Type: FUNCTION; Schema: public; Owner: -
--

CREATE FUNCTION public.remove_foregin_key() RETURNS void
    LANGUAGE plpgsql
    AS $$
DECLARE
    arch_table RECORD;
    r RECORD;

BEGIN
    FOR arch_table IN SELECT * FROM information_schema.tables AS t
                      WHERE t.table_schema = 'public' AND t.table_type = 'BASE TABLE'
                        AND t.table_name LIKE 'arch_%'
                      ORDER BY t.table_name
        LOOP
            for r in (select constraint_name from information_schema.table_constraints where table_schema = 'public' and table_name=arch_table.table_name AND constraint_type ='FOREIGN KEY') loop
                    raise info '%','dropping '||r.constraint_name;
                    EXECUTE 'ALTER TABLE ' || arch_table.table_name || ' DROP CONSTRAINT IF EXISTS ' || r.constraint_name;
                end loop;

        END LOOP;
END;
$$;


--
-- Name: rename_temp_to_arch(); Type: FUNCTION; Schema: public; Owner: -
--

CREATE FUNCTION public.rename_temp_to_arch() RETURNS void
    LANGUAGE plpgsql
    AS $$
DECLARE
    arch_table RECORD;
    tablearch text;
BEGIN
    FOR arch_table IN SELECT * FROM information_schema.tables AS t
                      WHERE t.table_schema = 'public' AND t.table_type = 'BASE TABLE'
                        AND t.table_name LIKE 'arc2_%'
                      ORDER BY t.table_name
        LOOP
            tablearch = REPLACE(arch_table.table_name, 'arc2_' ,'arch_');

            EXECUTE 'ALTER TABLE ' || arch_table.table_name || ' RENAME TO ' || tablearch;

        END LOOP;
END;
$$;


--
-- Name: update_nextupdatetime(); Type: FUNCTION; Schema: public; Owner: -
--

CREATE FUNCTION public.update_nextupdatetime() RETURNS void
    LANGUAGE plpgsql
    AS $$
    DECLARE
        systeminfo record;
        number_of_days integer;

    BEGIN
        number_of_days = 14;

        FOR systeminfo IN SELECT * FROM qcadooview_systeminfo
            WHERE (nextupdatetime - interval '1 day') < now()
        LOOP
            IF systeminfo.nextupdatetime IS NOT NULL THEN
                EXECUTE 'UPDATE qcadooview_systeminfo SET nextupdatetime = nextupdatetime ' || E' + interval \'' || number_of_days || E'\' day';
            END IF;
        END LOOP;
    END;
$$;


--
-- Name: update_productionpershift_progressforday(); Type: FUNCTION; Schema: public; Owner: -
--

CREATE FUNCTION public.update_productionpershift_progressforday() RETURNS void
    LANGUAGE plpgsql
    AS $$
DECLARE
    progressforday record;
BEGIN
    FOR progressforday IN SELECT * FROM productionpershift_progressforday
    LOOP
        UPDATE productionpershift_progressforday
        SET productionpershift_id = (SELECT pps.id FROM productionpershift_progressforday pfd
				LEFT JOIN technologies_technologyoperationcomponent toc ON toc.id = pfd.technologyoperationcomponent_id
				LEFT JOIN orders_order ord ON ord.technology_id = toc.technology_id
				LEFT JOIN productionpershift_productionpershift pps ON pps.order_id = ord.id
				WHERE pfd.id = progressforday.id LIMIT 1)
        WHERE id = progressforday.id;
    END LOOP;
END;
$$;


--
-- Name: update_reported_quantity(); Type: FUNCTION; Schema: public; Owner: -
--

CREATE FUNCTION public.update_reported_quantity() RETURNS void
    LANGUAGE plpgsql
    AS $$
    DECLARE
        _order RECORD;
    BEGIN
        FOR _order IN SELECT id FROM orders_order AS o WHERE o.state = '03inProgress' ORDER BY id LOOP
            UPDATE orders_order ordersorder
			SET reportedProductionQuantity = productioncountingproducedquantitydrafts.producedquantity
			FROM (SELECT * FROM ordersupplies_productioncountingproducedquantitydrafts) AS productioncountingproducedquantitydrafts
			WHERE ordersorder.id = _order.id AND ordersorder.id = productioncountingproducedquantitydrafts.order_id AND ordersorder.product_id = productioncountingproducedquantitydrafts.order_product_id;
        END LOOP;
    END;
$$;


--
-- Name: update_sequences(); Type: FUNCTION; Schema: public; Owner: -
--

CREATE FUNCTION public.update_sequences() RETURNS void
    LANGUAGE plpgsql
    AS $$
DECLARE
    row record;
BEGIN
    FOR row IN SELECT tablename FROM pg_tables p
                INNER JOIN information_schema.columns c ON p.tablename = c.table_name
                WHERE c.table_schema = 'public' AND p.schemaname = 'public' AND c.column_name = 'id' AND data_type = 'bigint'
    LOOP
        IF EXISTS (SELECT 0 FROM pg_class WHERE relname = '' || quote_ident(row.tablename) || '_id_seq' ) THEN
            EXECUTE 'ALTER TABLE ' || quote_ident(row.tablename) || ' ALTER COLUMN id SET DEFAULT nextval(''' || quote_ident(row.tablename) || '_id_seq'');';
            EXECUTE 'SELECT setval(''' || quote_ident(row.tablename) || '_id_seq'', COALESCE((SELECT MAX(id)+1 FROM ' || quote_ident(row.tablename) || '), 1), false);';
        END IF;
    END LOOP;
END;
$$;


SET default_tablespace = '';

SET default_table_access_method = heap;

--
-- Name: advancedgenealogy_batch; Type: TABLE; Schema: public; Owner: -
--

CREATE TABLE public.advancedgenealogy_batch (
    id bigint NOT NULL,
    number character varying(255),
    product_id bigint,
    supplier_id bigint,
    state character varying(255) DEFAULT '01tracked'::character varying,
    externalnumber character varying(255),
    createdate timestamp without time zone,
    updatedate timestamp without time zone,
    createuser character varying(255),
    updateuser character varying(255),
    active boolean DEFAULT true,
    entityversion bigint DEFAULT 0
);


--
-- Name: advancedgenealogy_batch_id_seq; Type: SEQUENCE; Schema: public; Owner: -
--

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


--
-- Name: advancedgenealogy_batch_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: -
--

ALTER SEQUENCE public.advancedgenealogy_batch_id_seq OWNED BY public.advancedgenealogy_batch.id;


--
-- Name: advancedgenealogy_batchattachment; Type: TABLE; Schema: public; Owner: -
--

CREATE TABLE public.advancedgenealogy_batchattachment (
    id bigint NOT NULL,
    batch_id bigint,
    attachment character varying(255),
    name character varying(255),
    size numeric(12,5),
    ext character varying(255)
);


--
-- Name: advancedgenealogy_batchattachment_id_seq; Type: SEQUENCE; Schema: public; Owner: -
--

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


--
-- Name: advancedgenealogy_batchattachment_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: -
--

ALTER SEQUENCE public.advancedgenealogy_batchattachment_id_seq OWNED BY public.advancedgenealogy_batchattachment.id;


--
-- Name: advancedgenealogy_batchdto; Type: VIEW; Schema: public; Owner: -
--

CREATE VIEW public.advancedgenealogy_batchdto AS
SELECT
    NULL::bigint AS id,
    NULL::character varying(255) AS batchnumber,
    NULL::character varying(255) AS state,
    NULL::character varying(255) AS createuser,
    NULL::timestamp without time zone AS createdate,
    NULL::character varying(255) AS externalnumber,
    NULL::boolean AS active,
    NULL::character varying(255) AS productnumber,
    NULL::character varying(1024) AS productname,
    NULL::character varying(255) AS suppliername,
    NULL::boolean AS hasattachments;


--
-- Name: advancedgenealogy_batchdto_id_seq; Type: SEQUENCE; Schema: public; Owner: -
--

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


--
-- Name: advancedgenealogy_batchstatechange; Type: TABLE; Schema: public; Owner: -
--

CREATE TABLE public.advancedgenealogy_batchstatechange (
    id bigint NOT NULL,
    dateandtime timestamp without time zone,
    sourcestate character varying(255),
    targetstate character varying(255),
    status character varying(255) DEFAULT '01inProgress'::character varying,
    phase integer,
    worker character varying(255),
    batch_id bigint,
    shift_id bigint,
    entityversion bigint DEFAULT 0
);


--
-- Name: advancedgenealogy_batchstatechange_id_seq; Type: SEQUENCE; Schema: public; Owner: -
--

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


--
-- Name: advancedgenealogy_batchstatechange_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: -
--

ALTER SEQUENCE public.advancedgenealogy_batchstatechange_id_seq OWNED BY public.advancedgenealogy_batchstatechange.id;


--
-- Name: advancedgenealogy_genealogyreport; Type: TABLE; Schema: public; Owner: -
--

CREATE TABLE public.advancedgenealogy_genealogyreport (
    id bigint NOT NULL,
    date timestamp without time zone,
    name character varying(1024),
    type character varying(255) DEFAULT '02producedFrom'::character varying,
    batch_id bigint,
    worker character varying(255),
    filename character varying(255),
    generated boolean DEFAULT false,
    includedraft boolean,
    directrelatedonly boolean,
    active boolean DEFAULT true,
    entityversion bigint DEFAULT 0
);


--
-- Name: advancedgenealogy_genealogyreport_id_seq; Type: SEQUENCE; Schema: public; Owner: -
--

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


--
-- Name: advancedgenealogy_genealogyreport_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: -
--

ALTER SEQUENCE public.advancedgenealogy_genealogyreport_id_seq OWNED BY public.advancedgenealogy_genealogyreport.id;


--
-- Name: advancedgenealogy_trackingrecord; Type: TABLE; Schema: public; Owner: -
--

CREATE TABLE public.advancedgenealogy_trackingrecord (
    id bigint NOT NULL,
    entitytype character varying(255),
    state character varying(255) DEFAULT '01draft'::character varying,
    quantity numeric(12,5),
    producedbatch_id bigint,
    number character varying(255),
    externalnumber character varying(255),
    active boolean DEFAULT true,
    createdate timestamp without time zone,
    updatedate timestamp without time zone,
    createuser character varying(255),
    updateuser character varying(255),
    order_id bigint,
    entityversion bigint DEFAULT 0
);


--
-- Name: advancedgenealogy_trackingrecord_id_seq; Type: SEQUENCE; Schema: public; Owner: -
--

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


--
-- Name: advancedgenealogy_trackingrecord_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: -
--

ALTER SEQUENCE public.advancedgenealogy_trackingrecord_id_seq OWNED BY public.advancedgenealogy_trackingrecord.id;


--
-- Name: advancedgenealogy_trackingrecordstatechange; Type: TABLE; Schema: public; Owner: -
--

CREATE TABLE public.advancedgenealogy_trackingrecordstatechange (
    id bigint NOT NULL,
    dateandtime timestamp without time zone,
    sourcestate character varying(255),
    targetstate character varying(255),
    status character varying(255) DEFAULT '01inProgress'::character varying,
    phase integer,
    worker character varying(255),
    trackingrecord_id bigint,
    shift_id bigint,
    entityversion bigint DEFAULT 0
);


--
-- Name: advancedgenealogy_trackingrecordstatechange_id_seq; Type: SEQUENCE; Schema: public; Owner: -
--

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


--
-- Name: advancedgenealogy_trackingrecordstatechange_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: -
--

ALTER SEQUENCE public.advancedgenealogy_trackingrecordstatechange_id_seq OWNED BY public.advancedgenealogy_trackingrecordstatechange.id;


--
-- Name: advancedgenealogy_usedbatchsimple; Type: TABLE; Schema: public; Owner: -
--

CREATE TABLE public.advancedgenealogy_usedbatchsimple (
    id bigint NOT NULL,
    batch_id bigint,
    trackingrecord_id bigint,
    worker character varying(255),
    dateandtime timestamp without time zone,
    quantity numeric(12,5),
    entityversion bigint DEFAULT 0
);


--
-- Name: advancedgenealogy_usedbatchsimple_id_seq; Type: SEQUENCE; Schema: public; Owner: -
--

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


--
-- Name: advancedgenealogy_usedbatchsimple_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: -
--

ALTER SEQUENCE public.advancedgenealogy_usedbatchsimple_id_seq OWNED BY public.advancedgenealogy_usedbatchsimple.id;


--
-- Name: advancedgenealogyfororders_genealogyproductinbatch; Type: TABLE; Schema: public; Owner: -
--

CREATE TABLE public.advancedgenealogyfororders_genealogyproductinbatch (
    id bigint NOT NULL,
    worker character varying(255),
    dateandtime timestamp without time zone,
    batch_id bigint,
    genealogyproductincomponent_id bigint,
    entityversion bigint DEFAULT 0
);


--
-- Name: advancedgenealogyfororders_genealogyproductinbatch_id_seq; Type: SEQUENCE; Schema: public; Owner: -
--

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


--
-- Name: advancedgenealogyfororders_genealogyproductinbatch_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: -
--

ALTER SEQUENCE public.advancedgenealogyfororders_genealogyproductinbatch_id_seq OWNED BY public.advancedgenealogyfororders_genealogyproductinbatch.id;


--
-- Name: advancedgenealogyfororders_genealogyproductincomponent; Type: TABLE; Schema: public; Owner: -
--

CREATE TABLE public.advancedgenealogyfororders_genealogyproductincomponent (
    id bigint NOT NULL,
    trackingrecord_id bigint,
    technologyinstanceoperationcomponent_id bigint,
    technologyoperationcomponent_id bigint,
    entityversion bigint DEFAULT 0,
    product_id bigint
);


--
-- Name: advancedgenealogyfororders_genealogyproductincomponent_id_seq; Type: SEQUENCE; Schema: public; Owner: -
--

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


--
-- Name: advancedgenealogyfororders_genealogyproductincomponent_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: -
--

ALTER SEQUENCE public.advancedgenealogyfororders_genealogyproductincomponent_id_seq OWNED BY public.advancedgenealogyfororders_genealogyproductincomponent.id;


--
-- Name: arch_advancedgenealogy_trackingrecord; Type: TABLE; Schema: public; Owner: -
--

CREATE TABLE public.arch_advancedgenealogy_trackingrecord (
    id bigint NOT NULL,
    entitytype character varying(255),
    state character varying(255) DEFAULT '01draft'::character varying,
    quantity numeric(12,5),
    producedbatch_id bigint,
    number character varying(255),
    externalnumber character varying(255),
    active boolean DEFAULT true,
    createdate timestamp without time zone,
    updatedate timestamp without time zone,
    createuser character varying(255),
    updateuser character varying(255),
    order_id bigint,
    entityversion bigint DEFAULT 0,
    archived boolean DEFAULT false
);


--
-- Name: arch_advancedgenealogy_trackingrecord_id_seq; Type: SEQUENCE; Schema: public; Owner: -
--

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


--
-- Name: arch_advancedgenealogy_trackingrecord_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: -
--

ALTER SEQUENCE public.arch_advancedgenealogy_trackingrecord_id_seq OWNED BY public.arch_advancedgenealogy_trackingrecord.id;


--
-- Name: arch_advancedgenealogy_trackingrecordstatechange; Type: TABLE; Schema: public; Owner: -
--

CREATE TABLE public.arch_advancedgenealogy_trackingrecordstatechange (
    id bigint NOT NULL,
    dateandtime timestamp without time zone,
    sourcestate character varying(255),
    targetstate character varying(255),
    status character varying(255) DEFAULT '01inProgress'::character varying,
    phase integer,
    worker character varying(255),
    trackingrecord_id bigint,
    shift_id bigint,
    entityversion bigint DEFAULT 0,
    archived boolean DEFAULT false
);


--
-- Name: arch_advancedgenealogy_trackingrecordstatechange_id_seq; Type: SEQUENCE; Schema: public; Owner: -
--

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


--
-- Name: arch_advancedgenealogy_trackingrecordstatechange_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: -
--

ALTER SEQUENCE public.arch_advancedgenealogy_trackingrecordstatechange_id_seq OWNED BY public.arch_advancedgenealogy_trackingrecordstatechange.id;


--
-- Name: arch_advancedgenealogy_usedbatchsimple; Type: TABLE; Schema: public; Owner: -
--

CREATE TABLE public.arch_advancedgenealogy_usedbatchsimple (
    id bigint NOT NULL,
    batch_id bigint,
    trackingrecord_id bigint,
    worker character varying(255),
    dateandtime timestamp without time zone,
    quantity numeric(12,5),
    entityversion bigint DEFAULT 0,
    archived boolean DEFAULT false
);


--
-- Name: arch_advancedgenealogy_usedbatchsimple_id_seq; Type: SEQUENCE; Schema: public; Owner: -
--

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


--
-- Name: arch_advancedgenealogy_usedbatchsimple_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: -
--

ALTER SEQUENCE public.arch_advancedgenealogy_usedbatchsimple_id_seq OWNED BY public.arch_advancedgenealogy_usedbatchsimple.id;


--
-- Name: arch_advancedgenealogyfororders_genealogyproductinbatch; Type: TABLE; Schema: public; Owner: -
--

CREATE TABLE public.arch_advancedgenealogyfororders_genealogyproductinbatch (
    id bigint NOT NULL,
    worker character varying(255),
    dateandtime timestamp without time zone,
    batch_id bigint,
    genealogyproductincomponent_id bigint,
    entityversion bigint DEFAULT 0,
    archived boolean DEFAULT false
);


--
-- Name: arch_advancedgenealogyfororders_genealogyproductinbatch_id_seq; Type: SEQUENCE; Schema: public; Owner: -
--

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


--
-- Name: arch_advancedgenealogyfororders_genealogyproductinbatch_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: -
--

ALTER SEQUENCE public.arch_advancedgenealogyfororders_genealogyproductinbatch_id_seq OWNED BY public.arch_advancedgenealogyfororders_genealogyproductinbatch.id;


--
-- Name: arch_advancedgenealogyfororders_genealogyproductincomponent; Type: TABLE; Schema: public; Owner: -
--

CREATE TABLE public.arch_advancedgenealogyfororders_genealogyproductincomponent (
    id bigint NOT NULL,
    trackingrecord_id bigint,
    technologyinstanceoperationcomponent_id bigint,
    technologyoperationcomponent_id bigint,
    entityversion bigint DEFAULT 0,
    product_id bigint,
    archived boolean DEFAULT false
);


--
-- Name: arch_advancedgenealogyfororders_genealogyproductincomponent_id_; Type: SEQUENCE; Schema: public; Owner: -
--

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


--
-- Name: arch_advancedgenealogyfororders_genealogyproductincomponent_id_; Type: SEQUENCE OWNED BY; Schema: public; Owner: -
--

ALTER SEQUENCE public.arch_advancedgenealogyfororders_genealogyproductincomponent_id_ OWNED BY public.arch_advancedgenealogyfororders_genealogyproductincomponent.id;


--
-- Name: arch_archiving; Type: TABLE; Schema: public; Owner: -
--

CREATE TABLE public.arch_archiving (
    id bigint NOT NULL,
    entityversion bigint NOT NULL,
    masterordernumber character varying(255),
    start timestamp without time zone,
    finish timestamp without time zone,
    createdate timestamp without time zone,
    updatedate timestamp without time zone,
    createuser character varying(255),
    updateuser character varying(255)
);


--
-- Name: arch_archiving_id_seq; Type: SEQUENCE; Schema: public; Owner: -
--

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


--
-- Name: arch_archiving_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: -
--

ALTER SEQUENCE public.arch_archiving_id_seq OWNED BY public.arch_archiving.id;


--
-- Name: arch_assignmenttoshift_multiassignmenttoshift; Type: TABLE; Schema: public; Owner: -
--

CREATE TABLE public.arch_assignmenttoshift_multiassignmenttoshift (
    id bigint NOT NULL,
    productionline_id bigint,
    occupationtype character varying(255),
    occupationtypename character varying(255),
    occupationtypeenum character varying(255),
    masterorder_id bigint,
    assignmenttoshift_id bigint,
    createdate timestamp without time zone,
    updatedate timestamp without time zone,
    createuser character varying(255),
    updateuser character varying(255),
    archived boolean DEFAULT false
);


--
-- Name: arch_assignmenttoshift_multiassignmenttoshift_id_seq; Type: SEQUENCE; Schema: public; Owner: -
--

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


--
-- Name: arch_assignmenttoshift_multiassignmenttoshift_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: -
--

ALTER SEQUENCE public.arch_assignmenttoshift_multiassignmenttoshift_id_seq OWNED BY public.arch_assignmenttoshift_multiassignmenttoshift.id;


--
-- Name: arch_assignmenttoshift_staffassignmenttoshift; Type: TABLE; Schema: public; Owner: -
--

CREATE TABLE public.arch_assignmenttoshift_staffassignmenttoshift (
    id bigint NOT NULL,
    assignmenttoshift_id bigint,
    worker_id bigint,
    productionline_id bigint,
    occupationtype character varying(255),
    occupationtypename character varying(255),
    state character varying(255) DEFAULT '01simple'::character varying,
    occupationtypeenum character varying(255),
    occupationtypevalueforgrid character varying(255),
    masterorder_id bigint,
    entityversion bigint DEFAULT 0,
    description character varying(255),
    archived boolean DEFAULT false
);


--
-- Name: arch_assignmenttoshift_staffassignmenttoshift_id_seq; Type: SEQUENCE; Schema: public; Owner: -
--

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


--
-- Name: arch_assignmenttoshift_staffassignmenttoshift_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: -
--

ALTER SEQUENCE public.arch_assignmenttoshift_staffassignmenttoshift_id_seq OWNED BY public.arch_assignmenttoshift_staffassignmenttoshift.id;


--
-- Name: arch_avglaborcostcalcfororder_assignmentworkertoshift; Type: TABLE; Schema: public; Owner: -
--

CREATE TABLE public.arch_avglaborcostcalcfororder_assignmentworkertoshift (
    id bigint NOT NULL,
    worker_id bigint,
    assignmenttoshift_id bigint,
    workedhours numeric(12,5),
    avglaborcostcalcfororder_id bigint,
    entityversion bigint DEFAULT 0,
    archived boolean DEFAULT false
);


--
-- Name: arch_avglaborcostcalcfororder_assignmentworkertoshift_id_seq; Type: SEQUENCE; Schema: public; Owner: -
--

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


--
-- Name: arch_avglaborcostcalcfororder_assignmentworkertoshift_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: -
--

ALTER SEQUENCE public.arch_avglaborcostcalcfororder_assignmentworkertoshift_id_seq OWNED BY public.arch_avglaborcostcalcfororder_assignmentworkertoshift.id;


--
-- Name: arch_avglaborcostcalcfororder_avglaborcostcalcfororder; Type: TABLE; Schema: public; Owner: -
--

CREATE TABLE public.arch_avglaborcostcalcfororder_avglaborcostcalcfororder (
    id bigint NOT NULL,
    startdate date,
    finishdate date,
    order_id bigint,
    productionline_id bigint,
    basedon character varying(255) DEFAULT '01assignment'::character varying,
    averagelaborhourlycost numeric(12,5),
    entityversion bigint DEFAULT 0,
    archived boolean DEFAULT false
);


--
-- Name: arch_avglaborcostcalcfororder_avglaborcostcalcfororder_id_seq; Type: SEQUENCE; Schema: public; Owner: -
--

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


--
-- Name: arch_avglaborcostcalcfororder_avglaborcostcalcfororder_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: -
--

ALTER SEQUENCE public.arch_avglaborcostcalcfororder_avglaborcostcalcfororder_id_seq OWNED BY public.arch_avglaborcostcalcfororder_avglaborcostcalcfororder.id;


--
-- Name: arch_basicproductioncounting_basicproductioncounting; Type: TABLE; Schema: public; Owner: -
--

CREATE TABLE public.arch_basicproductioncounting_basicproductioncounting (
    id bigint NOT NULL,
    order_id bigint,
    product_id bigint,
    usedquantity numeric(14,5),
    producedquantity numeric(14,5),
    entityversion bigint DEFAULT 0,
    archived boolean DEFAULT false
);


--
-- Name: arch_basicproductioncounting_basicproductioncounting_id_seq; Type: SEQUENCE; Schema: public; Owner: -
--

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


--
-- Name: arch_basicproductioncounting_basicproductioncounting_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: -
--

ALTER SEQUENCE public.arch_basicproductioncounting_basicproductioncounting_id_seq OWNED BY public.arch_basicproductioncounting_basicproductioncounting.id;


--
-- Name: arch_basicproductioncounting_productioncountingattributevalue; Type: TABLE; Schema: public; Owner: -
--

CREATE TABLE public.arch_basicproductioncounting_productioncountingattributevalue (
    id bigint NOT NULL,
    productioncountingquantity_id bigint,
    attribute_id bigint,
    attributevalue_id bigint,
    value character varying(255),
    archived boolean DEFAULT false
);


--
-- Name: arch_basicproductioncounting_productioncountingattributevalue_i; Type: SEQUENCE; Schema: public; Owner: -
--

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


--
-- Name: arch_basicproductioncounting_productioncountingattributevalue_i; Type: SEQUENCE OWNED BY; Schema: public; Owner: -
--

ALTER SEQUENCE public.arch_basicproductioncounting_productioncountingattributevalue_i OWNED BY public.arch_basicproductioncounting_productioncountingattributevalue.id;


--
-- Name: arch_basicproductioncounting_productioncountingoperationrun; Type: TABLE; Schema: public; Owner: -
--

CREATE TABLE public.arch_basicproductioncounting_productioncountingoperationrun (
    id bigint NOT NULL,
    order_id bigint,
    technologyoperationcomponent_id bigint,
    runs numeric(12,5),
    entityversion bigint DEFAULT 0,
    archived boolean DEFAULT false
);


--
-- Name: arch_basicproductioncounting_productioncountingoperationrun_id_; Type: SEQUENCE; Schema: public; Owner: -
--

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


--
-- Name: arch_basicproductioncounting_productioncountingoperationrun_id_; Type: SEQUENCE OWNED BY; Schema: public; Owner: -
--

ALTER SEQUENCE public.arch_basicproductioncounting_productioncountingoperationrun_id_ OWNED BY public.arch_basicproductioncounting_productioncountingoperationrun.id;


--
-- Name: arch_basicproductioncounting_productioncountingquantity; Type: TABLE; Schema: public; Owner: -
--

CREATE TABLE public.arch_basicproductioncounting_productioncountingquantity (
    id bigint NOT NULL,
    order_id bigint,
    product_id bigint,
    plannedquantity numeric(14,5),
    isnoncomponent boolean DEFAULT false,
    technologyoperationcomponent_id bigint,
    basicproductioncounting_id bigint,
    typeofmaterial character varying(255) DEFAULT '01component'::character varying,
    role character varying(255) DEFAULT '01used'::character varying,
    componentsoutputlocation_id bigint,
    componentslocation_id bigint,
    productsinputlocation_id bigint,
    productionflow character varying(255),
    productsflowlocation_id bigint,
    entityversion bigint DEFAULT 0,
    replacementto_id bigint,
    showmaterialcomponentinworkplan boolean DEFAULT false,
    technologyinputproducttype_id bigint,
    usedquantity numeric(14,5),
    producedquantity numeric(14,5),
    wastereceptionwarehouse_id bigint,
    attribute_id bigint,
    archived boolean DEFAULT false
);


--
-- Name: arch_basicproductioncounting_productioncountingquantity_id_seq; Type: SEQUENCE; Schema: public; Owner: -
--

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


--
-- Name: arch_basicproductioncounting_productioncountingquantity_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: -
--

ALTER SEQUENCE public.arch_basicproductioncounting_productioncountingquantity_id_seq OWNED BY public.arch_basicproductioncounting_productioncountingquantity.id;


--
-- Name: arch_cdnrcgoodfood_cancelprotocol; Type: TABLE; Schema: public; Owner: -
--

CREATE TABLE public.arch_cdnrcgoodfood_cancelprotocol (
    id bigint NOT NULL,
    extrusionprotocol_id bigint,
    confectionprotocol_id bigint,
    createdate timestamp without time zone,
    laststatechangefailcause character varying(8192),
    iscanceled boolean DEFAULT false,
    archived boolean DEFAULT false
);


--
-- Name: arch_cdnrcgoodfood_cancelprotocol_id_seq; Type: SEQUENCE; Schema: public; Owner: -
--

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


--
-- Name: arch_cdnrcgoodfood_cancelprotocol_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: -
--

ALTER SEQUENCE public.arch_cdnrcgoodfood_cancelprotocol_id_seq OWNED BY public.arch_cdnrcgoodfood_cancelprotocol.id;


--
-- Name: arch_costnormsformaterials_technologyinstoperproductincomp; Type: TABLE; Schema: public; Owner: -
--

CREATE TABLE public.arch_costnormsformaterials_technologyinstoperproductincomp (
    id bigint NOT NULL,
    order_id bigint,
    product_id bigint,
    costfororder numeric(12,5) DEFAULT (0)::numeric,
    entityversion bigint DEFAULT 0,
    averagepricesubcontractor numeric(12,5) DEFAULT 0,
    archived boolean DEFAULT false
);


--
-- Name: arch_costnormsformaterials_technologyinstoperproductincomp_id_s; Type: SEQUENCE; Schema: public; Owner: -
--

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


--
-- Name: arch_costnormsformaterials_technologyinstoperproductincomp_id_s; Type: SEQUENCE OWNED BY; Schema: public; Owner: -
--

ALTER SEQUENCE public.arch_costnormsformaterials_technologyinstoperproductincomp_id_s OWNED BY public.arch_costnormsformaterials_technologyinstoperproductincomp.id;


--
-- Name: arch_goodfood_confectionadditionalinputproduct; Type: TABLE; Schema: public; Owner: -
--

CREATE TABLE public.arch_goodfood_confectionadditionalinputproduct (
    id bigint NOT NULL,
    confectionprotocol_id bigint,
    batch_id bigint,
    product_id bigint,
    takenonquantity numeric(12,5),
    takenofquantity numeric(12,5),
    cullquantity numeric(12,5),
    effectivequantity numeric(12,5),
    entityversion bigint DEFAULT 0,
    archived boolean DEFAULT false
);


--
-- Name: arch_goodfood_confectionadditionalinputproduct_id_seq; Type: SEQUENCE; Schema: public; Owner: -
--

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


--
-- Name: arch_goodfood_confectionadditionalinputproduct_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: -
--

ALTER SEQUENCE public.arch_goodfood_confectionadditionalinputproduct_id_seq OWNED BY public.arch_goodfood_confectionadditionalinputproduct.id;


--
-- Name: arch_goodfood_confectionfilmproduct; Type: TABLE; Schema: public; Owner: -
--

CREATE TABLE public.arch_goodfood_confectionfilmproduct (
    id bigint NOT NULL,
    confectionprotocol_id bigint,
    filmproduct_id bigint,
    beyondrecipe boolean DEFAULT false,
    archived boolean DEFAULT false
);


--
-- Name: arch_goodfood_confectionfilmproduct_id_seq; Type: SEQUENCE; Schema: public; Owner: -
--

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


--
-- Name: arch_goodfood_confectionfilmproduct_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: -
--

ALTER SEQUENCE public.arch_goodfood_confectionfilmproduct_id_seq OWNED BY public.arch_goodfood_confectionfilmproduct.id;


--
-- Name: arch_goodfood_confectionfilmproductentry; Type: TABLE; Schema: public; Owner: -
--

CREATE TABLE public.arch_goodfood_confectionfilmproductentry (
    id bigint NOT NULL,
    batch_id bigint,
    confectionfilmproduct_id bigint,
    takenonquantity numeric(12,5),
    takenofquantity numeric(12,5),
    cullquantity numeric(12,5),
    effectivequantity numeric(12,5),
    archived boolean DEFAULT false
);


--
-- Name: arch_goodfood_confectionfilmproductentry_id_seq; Type: SEQUENCE; Schema: public; Owner: -
--

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


--
-- Name: arch_goodfood_confectionfilmproductentry_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: -
--

ALTER SEQUENCE public.arch_goodfood_confectionfilmproductentry_id_seq OWNED BY public.arch_goodfood_confectionfilmproductentry.id;


--
-- Name: arch_goodfood_confectioninputproduct; Type: TABLE; Schema: public; Owner: -
--

CREATE TABLE public.arch_goodfood_confectioninputproduct (
    id bigint NOT NULL,
    confectionprotocol_id bigint,
    batch_id bigint,
    product_id bigint,
    takenonquantity numeric(12,5),
    takenofquantity numeric(12,5),
    cullquantity numeric(12,5),
    effectivequantity numeric(12,5),
    entityversion bigint DEFAULT 0,
    archived boolean DEFAULT false
);


--
-- Name: arch_goodfood_confectioninputproduct_id_seq; Type: SEQUENCE; Schema: public; Owner: -
--

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


--
-- Name: arch_goodfood_confectioninputproduct_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: -
--

ALTER SEQUENCE public.arch_goodfood_confectioninputproduct_id_seq OWNED BY public.arch_goodfood_confectioninputproduct.id;


--
-- Name: arch_goodfood_confectionprotocol; Type: TABLE; Schema: public; Owner: -
--

CREATE TABLE public.arch_goodfood_confectionprotocol (
    id bigint NOT NULL,
    generationdate date,
    state character varying(255) DEFAULT '01draft'::character varying,
    laststatechangefails boolean DEFAULT false,
    confectioncontext_id bigint,
    number character varying(1024),
    dayofshiftstart date,
    productionline_id bigint,
    toproduce numeric(12,5),
    startdate timestamp without time zone,
    finishdate timestamp without time zone,
    order_id bigint,
    ordernumber character varying(255),
    productnameandnumber character varying(255),
    qcp5code character varying(255),
    filmproduct_id bigint,
    restoneofcartonsquantity numeric(12,5),
    resttwoofcartonsquantity numeric(12,5),
    allpalletquantity numeric(12,5),
    quantityofallcartonsquantity numeric(12,5),
    wastewafers numeric(12,5),
    effectiveproducedquantity numeric(12,5),
    effectiveexecutiontimestart timestamp without time zone,
    effectiveexecutiontimeend timestamp without time zone,
    externalnumber integer NOT NULL,
    externalsynchronized boolean DEFAULT true,
    active boolean DEFAULT true,
    laststatechangefailcause character varying(8192),
    showlaststatechangeresult boolean DEFAULT false,
    isdoubled boolean DEFAULT false,
    additionalfilmproduct_id bigint,
    iscorrected boolean DEFAULT false,
    productiondate date,
    entityversion bigint DEFAULT 0,
    comments text,
    sendagaintoblackbox boolean DEFAULT false,
    finalprotocol boolean,
    plannextorderinfo character varying(8192),
    plannextorderinfoargs character varying(8192),
    plannextorderstatechangeinfo character varying,
    archived boolean DEFAULT false
);


--
-- Name: arch_goodfood_confectionprotocol_id_seq; Type: SEQUENCE; Schema: public; Owner: -
--

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


--
-- Name: arch_goodfood_confectionprotocol_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: -
--

ALTER SEQUENCE public.arch_goodfood_confectionprotocol_id_seq OWNED BY public.arch_goodfood_confectionprotocol.id;


--
-- Name: arch_goodfood_confectionprotocolcorrect; Type: TABLE; Schema: public; Owner: -
--

CREATE TABLE public.arch_goodfood_confectionprotocolcorrect (
    id bigint NOT NULL,
    confectionprotocol_id bigint,
    correctdate date,
    correctreason character varying(2048),
    createdate timestamp without time zone,
    updatedate timestamp without time zone,
    createuser character varying(255),
    updateuser character varying(255),
    isconfirmed boolean DEFAULT false,
    entityversion bigint DEFAULT 0,
    archived boolean DEFAULT false
);


--
-- Name: arch_goodfood_confectionprotocolcorrect_id_seq; Type: SEQUENCE; Schema: public; Owner: -
--

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


--
-- Name: arch_goodfood_confectionprotocolcorrect_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: -
--

ALTER SEQUENCE public.arch_goodfood_confectionprotocolcorrect_id_seq OWNED BY public.arch_goodfood_confectionprotocolcorrect.id;


--
-- Name: arch_goodfood_confectionprotocolstatechange; Type: TABLE; Schema: public; Owner: -
--

CREATE TABLE public.arch_goodfood_confectionprotocolstatechange (
    id bigint NOT NULL,
    dateandtime timestamp without time zone,
    sourcestate character varying(255),
    targetstate character varying(255),
    status character varying(255),
    phase integer,
    shift_id bigint,
    worker character varying(255),
    confectionprotocol_id bigint,
    entityversion bigint DEFAULT 0,
    archived boolean DEFAULT false
);


--
-- Name: arch_goodfood_confectionprotocolstatechange_id_seq; Type: SEQUENCE; Schema: public; Owner: -
--

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


--
-- Name: arch_goodfood_confectionprotocolstatechange_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: -
--

ALTER SEQUENCE public.arch_goodfood_confectionprotocolstatechange_id_seq OWNED BY public.arch_goodfood_confectionprotocolstatechange.id;


--
-- Name: arch_goodfood_confectionremainderinputproduct; Type: TABLE; Schema: public; Owner: -
--

CREATE TABLE public.arch_goodfood_confectionremainderinputproduct (
    id bigint NOT NULL,
    confectionprotocol_id bigint,
    product_id bigint,
    usedquantity numeric(12,5),
    isdoubled boolean DEFAULT false,
    entityversion bigint DEFAULT 0,
    usedbatches text,
    beyondrecipe boolean DEFAULT false,
    archived boolean DEFAULT false
);


--
-- Name: arch_goodfood_confectionremainderinputproduct_id_seq; Type: SEQUENCE; Schema: public; Owner: -
--

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


--
-- Name: arch_goodfood_confectionremainderinputproduct_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: -
--

ALTER SEQUENCE public.arch_goodfood_confectionremainderinputproduct_id_seq OWNED BY public.arch_goodfood_confectionremainderinputproduct.id;


--
-- Name: arch_goodfood_confectionstaff; Type: TABLE; Schema: public; Owner: -
--

CREATE TABLE public.arch_goodfood_confectionstaff (
    id bigint NOT NULL,
    confectionprotocol_id bigint,
    worker_id bigint,
    labortime integer,
    effectiveexecutiontimestart timestamp without time zone,
    effectiveexecutiontimeend timestamp without time zone,
    entityversion bigint DEFAULT 0,
    archived boolean DEFAULT false
);


--
-- Name: arch_goodfood_confectionstaff_id_seq; Type: SEQUENCE; Schema: public; Owner: -
--

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


--
-- Name: arch_goodfood_confectionstaff_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: -
--

ALTER SEQUENCE public.arch_goodfood_confectionstaff_id_seq OWNED BY public.arch_goodfood_confectionstaff.id;


--
-- Name: arch_goodfood_extrusionaddedmixentry; Type: TABLE; Schema: public; Owner: -
--

CREATE TABLE public.arch_goodfood_extrusionaddedmixentry (
    id bigint NOT NULL,
    extrusionprotocol_id bigint,
    quantity numeric(9,2),
    entityversion bigint DEFAULT 0,
    extrusionmix_id bigint,
    archived boolean DEFAULT false
);


--
-- Name: arch_goodfood_extrusionaddedmixentry_id_seq; Type: SEQUENCE; Schema: public; Owner: -
--

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


--
-- Name: arch_goodfood_extrusionaddedmixentry_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: -
--

ALTER SEQUENCE public.arch_goodfood_extrusionaddedmixentry_id_seq OWNED BY public.arch_goodfood_extrusionaddedmixentry.id;


--
-- Name: arch_goodfood_extrusionaddedmixingredient; Type: TABLE; Schema: public; Owner: -
--

CREATE TABLE public.arch_goodfood_extrusionaddedmixingredient (
    id bigint NOT NULL,
    extrusionaddedmixentry_id bigint,
    extrusionmixingredient_id bigint,
    product_id bigint,
    batch_id bigint,
    quantity numeric(9,2),
    beyondrecipe boolean DEFAULT false,
    archived boolean DEFAULT false
);


--
-- Name: arch_goodfood_extrusionaddedmixingredient_id_seq; Type: SEQUENCE; Schema: public; Owner: -
--

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


--
-- Name: arch_goodfood_extrusionaddedmixingredient_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: -
--

ALTER SEQUENCE public.arch_goodfood_extrusionaddedmixingredient_id_seq OWNED BY public.arch_goodfood_extrusionaddedmixingredient.id;


--
-- Name: arch_goodfood_extrusionpouring; Type: TABLE; Schema: public; Owner: -
--

CREATE TABLE public.arch_goodfood_extrusionpouring (
    id bigint NOT NULL,
    extrusionprotocol_id bigint,
    finaladdedquantity numeric(9,2),
    addedquantity numeric(9,2),
    totalmixquantity numeric(12,5),
    addedquantitymanual boolean DEFAULT false,
    addedquantityrelatesto character varying(255) DEFAULT '01mix'::character varying,
    mixwaterquantity numeric(12,5),
    priority integer,
    archived boolean DEFAULT false
);


--
-- Name: arch_goodfood_extrusionpouring_id_seq; Type: SEQUENCE; Schema: public; Owner: -
--

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


--
-- Name: arch_goodfood_extrusionpouring_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: -
--

ALTER SEQUENCE public.arch_goodfood_extrusionpouring_id_seq OWNED BY public.arch_goodfood_extrusionpouring.id;


--
-- Name: arch_goodfood_extrusionpouringingredient; Type: TABLE; Schema: public; Owner: -
--

CREATE TABLE public.arch_goodfood_extrusionpouringingredient (
    id bigint NOT NULL,
    extrusionpouring_id bigint,
    product_id bigint,
    batch_id bigint,
    quantity numeric(9,2),
    ratio numeric(12,5),
    manual boolean DEFAULT false,
    skip boolean DEFAULT false,
    frommix boolean DEFAULT false,
    requiredquantity numeric(9,2),
    quantityinmix numeric(12,5),
    beyondrecipe boolean DEFAULT false,
    addedbyuser boolean DEFAULT false,
    extrusionpouringmix_id bigint,
    archived boolean DEFAULT false
);


--
-- Name: arch_goodfood_extrusionpouringingredient_id_seq; Type: SEQUENCE; Schema: public; Owner: -
--

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


--
-- Name: arch_goodfood_extrusionpouringingredient_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: -
--

ALTER SEQUENCE public.arch_goodfood_extrusionpouringingredient_id_seq OWNED BY public.arch_goodfood_extrusionpouringingredient.id;


--
-- Name: arch_goodfood_extrusionpouringmix; Type: TABLE; Schema: public; Owner: -
--

CREATE TABLE public.arch_goodfood_extrusionpouringmix (
    id bigint NOT NULL,
    extrusionpouring_id bigint,
    mixid character varying(255),
    requiredscalequantity numeric(9,2),
    scalequantity numeric(9,2),
    scalequantitymanual boolean DEFAULT false,
    totalmixquantity numeric(12,5),
    mixwaterquantity numeric(12,5),
    archived boolean DEFAULT false
);


--
-- Name: arch_goodfood_extrusionpouringmix_id_seq; Type: SEQUENCE; Schema: public; Owner: -
--

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


--
-- Name: arch_goodfood_extrusionpouringmix_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: -
--

ALTER SEQUENCE public.arch_goodfood_extrusionpouringmix_id_seq OWNED BY public.arch_goodfood_extrusionpouringmix.id;


--
-- Name: arch_goodfood_extrusionprotocol; Type: TABLE; Schema: public; Owner: -
--

CREATE TABLE public.arch_goodfood_extrusionprotocol (
    id bigint NOT NULL,
    generationdate date,
    state character varying(255) DEFAULT '01draft'::character varying,
    laststatechangefails boolean DEFAULT false,
    extrusioncontext_id bigint,
    number character varying(1024),
    dayofshiftstart date,
    productionline_id bigint,
    toproduce numeric(12,5),
    changeover integer,
    startdate timestamp without time zone,
    finishdate timestamp without time zone,
    numberofavailableworkstation integer,
    order_id bigint,
    ordernumber character varying(255),
    productnameandnumber character varying(255),
    mixproduct character varying(255),
    operatorworkstartdate timestamp without time zone,
    operatorworkfinishdate timestamp without time zone,
    externalnumber integer NOT NULL,
    externalsynchronized boolean DEFAULT true,
    active boolean DEFAULT true,
    laststatechangefailcause character varying(8192),
    showlaststatechangeresult boolean DEFAULT false,
    iscorrected boolean DEFAULT false,
    entityversion bigint DEFAULT 0,
    comments text,
    sendagaintoblackbox boolean DEFAULT false,
    archived boolean DEFAULT false
);


--
-- Name: arch_goodfood_extrusionprotocol_id_seq; Type: SEQUENCE; Schema: public; Owner: -
--

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


--
-- Name: arch_goodfood_extrusionprotocol_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: -
--

ALTER SEQUENCE public.arch_goodfood_extrusionprotocol_id_seq OWNED BY public.arch_goodfood_extrusionprotocol.id;


--
-- Name: arch_goodfood_extrusionprotocolcorrect; Type: TABLE; Schema: public; Owner: -
--

CREATE TABLE public.arch_goodfood_extrusionprotocolcorrect (
    id bigint NOT NULL,
    extrusionprotocol_id bigint,
    correctdate date,
    correctreason character varying(2048),
    createdate timestamp without time zone,
    updatedate timestamp without time zone,
    createuser character varying(255),
    updateuser character varying(255),
    isconfirmed boolean DEFAULT false,
    entityversion bigint DEFAULT 0,
    archived boolean DEFAULT false
);


--
-- Name: arch_goodfood_extrusionprotocolcorrect_id_seq; Type: SEQUENCE; Schema: public; Owner: -
--

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


--
-- Name: arch_goodfood_extrusionprotocolcorrect_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: -
--

ALTER SEQUENCE public.arch_goodfood_extrusionprotocolcorrect_id_seq OWNED BY public.arch_goodfood_extrusionprotocolcorrect.id;


--
-- Name: arch_goodfood_extrusionprotocolstatechange; Type: TABLE; Schema: public; Owner: -
--

CREATE TABLE public.arch_goodfood_extrusionprotocolstatechange (
    id bigint NOT NULL,
    dateandtime timestamp without time zone,
    sourcestate character varying(255),
    targetstate character varying(255),
    status character varying(255),
    phase integer,
    shift_id bigint,
    worker character varying(255),
    extrusionprotocol_id bigint,
    entityversion bigint DEFAULT 0,
    archived boolean DEFAULT false
);


--
-- Name: arch_goodfood_extrusionprotocolstatechange_id_seq; Type: SEQUENCE; Schema: public; Owner: -
--

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


--
-- Name: arch_goodfood_extrusionprotocolstatechange_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: -
--

ALTER SEQUENCE public.arch_goodfood_extrusionprotocolstatechange_id_seq OWNED BY public.arch_goodfood_extrusionprotocolstatechange.id;


--
-- Name: arch_goodfood_extrusionsouse; Type: TABLE; Schema: public; Owner: -
--

CREATE TABLE public.arch_goodfood_extrusionsouse (
    id bigint NOT NULL,
    extrusionprotocol_id bigint,
    category character varying(255),
    datesouse timestamp without time zone,
    datedownload timestamp without time zone,
    worker_id bigint,
    wetness numeric(5,2),
    entityversion bigint DEFAULT 0,
    archived boolean DEFAULT false
);


--
-- Name: arch_goodfood_extrusionsouse_id_seq; Type: SEQUENCE; Schema: public; Owner: -
--

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


--
-- Name: arch_goodfood_extrusionsouse_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: -
--

ALTER SEQUENCE public.arch_goodfood_extrusionsouse_id_seq OWNED BY public.arch_goodfood_extrusionsouse.id;


--
-- Name: arch_goodfood_extrusiontakenoffmixentry; Type: TABLE; Schema: public; Owner: -
--

CREATE TABLE public.arch_goodfood_extrusiontakenoffmixentry (
    id bigint NOT NULL,
    extrusionprotocol_id bigint,
    quantity numeric(9,2),
    entityversion bigint DEFAULT 0,
    extrusionmix_id bigint,
    archived boolean DEFAULT false
);


--
-- Name: arch_goodfood_extrusiontakenoffmixentry_id_seq; Type: SEQUENCE; Schema: public; Owner: -
--

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


--
-- Name: arch_goodfood_extrusiontakenoffmixentry_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: -
--

ALTER SEQUENCE public.arch_goodfood_extrusiontakenoffmixentry_id_seq OWNED BY public.arch_goodfood_extrusiontakenoffmixentry.id;


--
-- Name: arch_goodfood_extrusiontakenoffmixingredient; Type: TABLE; Schema: public; Owner: -
--

CREATE TABLE public.arch_goodfood_extrusiontakenoffmixingredient (
    id bigint NOT NULL,
    extrusiontakenoffmixentry_id bigint,
    extrusionmixingredient_id bigint,
    product_id bigint,
    batch_id bigint,
    quantity numeric(9,2),
    beyondrecipe boolean DEFAULT false,
    archived boolean DEFAULT false
);


--
-- Name: arch_goodfood_extrusiontakenoffmixingredient_id_seq; Type: SEQUENCE; Schema: public; Owner: -
--

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


--
-- Name: arch_goodfood_extrusiontakenoffmixingredient_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: -
--

ALTER SEQUENCE public.arch_goodfood_extrusiontakenoffmixingredient_id_seq OWNED BY public.arch_goodfood_extrusiontakenoffmixingredient.id;


--
-- Name: arch_goodfood_pallet; Type: TABLE; Schema: public; Owner: -
--

CREATE TABLE public.arch_goodfood_pallet (
    id bigint NOT NULL,
    palletcontext_id bigint,
    palletlabel_id bigint,
    typeoflogistics character varying(255) DEFAULT '01fullPallet'::character varying,
    printedcount integer,
    ssccnumber character varying(20),
    palletnumber character varying(6),
    secondpallet_id bigint,
    state character varying(255),
    isstateerror boolean,
    stateerror character varying(255),
    registrationdate timestamp without time zone,
    senddate timestamp without time zone,
    active boolean DEFAULT true,
    packagescount integer,
    laststatechangefails boolean DEFAULT false,
    laststatechangefailcause character varying(2048),
    externalnumber integer NOT NULL,
    externalsynchronized boolean DEFAULT true,
    eurocod character varying(7),
    entityversion bigint DEFAULT 0,
    sendagaintoblackbox boolean DEFAULT false,
    product_id bigint,
    archived boolean DEFAULT false
);


--
-- Name: arch_goodfood_pallet_id_seq; Type: SEQUENCE; Schema: public; Owner: -
--

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


--
-- Name: arch_goodfood_pallet_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: -
--

ALTER SEQUENCE public.arch_goodfood_pallet_id_seq OWNED BY public.arch_goodfood_pallet.id;


--
-- Name: arch_goodfood_palletlabel; Type: TABLE; Schema: public; Owner: -
--

CREATE TABLE public.arch_goodfood_palletlabel (
    id bigint NOT NULL,
    palletcontext_id bigint,
    printedcount integer,
    firstssccnumber character varying(20),
    firstpalletnumber character varying(6),
    lastssccnumber character varying(20),
    lastpalletnumber character varying(6),
    masterorder_id bigint,
    productionline_id bigint,
    batchnumber character varying(255),
    bestbefore character varying(255),
    registrationdate date,
    active boolean DEFAULT true,
    batch_id bigint,
    state character varying(255) DEFAULT '01draft'::character varying,
    entityversion bigint DEFAULT 0,
    archived boolean DEFAULT false
);


--
-- Name: arch_goodfood_palletlabel_id_seq; Type: SEQUENCE; Schema: public; Owner: -
--

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


--
-- Name: arch_goodfood_palletlabel_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: -
--

ALTER SEQUENCE public.arch_goodfood_palletlabel_id_seq OWNED BY public.arch_goodfood_palletlabel.id;


--
-- Name: arch_goodfood_palletlabelstatechange; Type: TABLE; Schema: public; Owner: -
--

CREATE TABLE public.arch_goodfood_palletlabelstatechange (
    id bigint NOT NULL,
    dateandtime timestamp without time zone,
    sourcestate character varying(255),
    targetstate character varying(255),
    status character varying(255),
    phase integer,
    shift_id bigint,
    worker character varying(255),
    palletlabel_id bigint,
    entityversion bigint DEFAULT 0,
    archived boolean DEFAULT false
);


--
-- Name: arch_goodfood_palletlabelstatechange_id_seq; Type: SEQUENCE; Schema: public; Owner: -
--

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


--
-- Name: arch_goodfood_palletlabelstatechange_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: -
--

ALTER SEQUENCE public.arch_goodfood_palletlabelstatechange_id_seq OWNED BY public.arch_goodfood_palletlabelstatechange.id;


--
-- Name: arch_goodfood_palletstatechange; Type: TABLE; Schema: public; Owner: -
--

CREATE TABLE public.arch_goodfood_palletstatechange (
    id bigint NOT NULL,
    dateandtime timestamp without time zone,
    sourcestate character varying(255),
    targetstate character varying(255),
    status character varying(255),
    phase integer,
    shift_id bigint,
    worker character varying(255),
    pallet_id bigint,
    entityversion bigint DEFAULT 0,
    archived boolean DEFAULT false
);


--
-- Name: arch_goodfood_palletstatechange_id_seq; Type: SEQUENCE; Schema: public; Owner: -
--

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


--
-- Name: arch_goodfood_palletstatechange_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: -
--

ALTER SEQUENCE public.arch_goodfood_palletstatechange_id_seq OWNED BY public.arch_goodfood_palletstatechange.id;


--
-- Name: arch_goodfood_printedlabel; Type: TABLE; Schema: public; Owner: -
--

CREATE TABLE public.arch_goodfood_printedlabel (
    id bigint NOT NULL,
    cartonlabel character varying(255),
    masterorder_id bigint,
    ssccnumber character varying(1024),
    palletcontext_id bigint,
    productionline_id bigint,
    createdate timestamp without time zone,
    updatedate timestamp without time zone,
    createuser character varying(255),
    updateuser character varying(255),
    active boolean DEFAULT true,
    archived boolean DEFAULT false
);


--
-- Name: arch_goodfood_printedlabel_id_seq; Type: SEQUENCE; Schema: public; Owner: -
--

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


--
-- Name: arch_goodfood_printedlabel_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: -
--

ALTER SEQUENCE public.arch_goodfood_printedlabel_id_seq OWNED BY public.arch_goodfood_printedlabel.id;


--
-- Name: arch_integrationbartender_printlabelshelper; Type: TABLE; Schema: public; Owner: -
--

CREATE TABLE public.arch_integrationbartender_printlabelshelper (
    id bigint NOT NULL,
    createdate timestamp without time zone,
    updatedate timestamp without time zone,
    createuser character varying(255),
    updateuser character varying(255),
    quantity integer,
    masterorder_id bigint,
    printer_id bigint,
    path character varying(255),
    ssccnumbers text,
    order_id bigint,
    barcodeismasterorderid boolean DEFAULT false,
    archived boolean DEFAULT false
);


--
-- Name: arch_integrationbartender_printlabelshelper_id_seq; Type: SEQUENCE; Schema: public; Owner: -
--

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


--
-- Name: arch_integrationbartender_printlabelshelper_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: -
--

ALTER SEQUENCE public.arch_integrationbartender_printlabelshelper_id_seq OWNED BY public.arch_integrationbartender_printlabelshelper.id;


--
-- Name: arch_integrationbartender_sendtoprint; Type: TABLE; Schema: public; Owner: -
--

CREATE TABLE public.arch_integrationbartender_sendtoprint (
    id bigint NOT NULL,
    printlabelshelper_id bigint,
    createdate timestamp without time zone,
    updatedate timestamp without time zone,
    createuser character varying(255),
    updateuser character varying(255),
    archived boolean DEFAULT false
);


--
-- Name: arch_integrationbartender_sendtoprint_id_seq; Type: SEQUENCE; Schema: public; Owner: -
--

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


--
-- Name: arch_integrationbartender_sendtoprint_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: -
--

ALTER SEQUENCE public.arch_integrationbartender_sendtoprint_id_seq OWNED BY public.arch_integrationbartender_sendtoprint.id;


--
-- Name: arch_masterorders_masterorder; Type: TABLE; Schema: public; Owner: -
--

CREATE TABLE public.arch_masterorders_masterorder (
    id bigint NOT NULL,
    number character varying(255),
    name character varying(1024),
    description character varying(2048),
    externalnumber character varying(255),
    deadline timestamp without time zone,
    addmasterprefixtonumber boolean,
    masterorderstate character varying(255),
    company_id bigint,
    externalsynchronized boolean DEFAULT true,
    generationdateoneec date,
    cancelsynchronizationreason character varying(255),
    active boolean DEFAULT true,
    pw2prod boolean DEFAULT false,
    batch_id bigint,
    masterorderdefinition_id bigint,
    startdate timestamp without time zone,
    finishdate timestamp without time zone,
    entityversion bigint DEFAULT 0,
    sendagaintoblackbox boolean DEFAULT false,
    dateofreceipt timestamp without time zone,
    address_id bigint,
    externalproductionorderid character varying(255),
    ponumber character varying(255),
    direction character varying(255),
    createdate timestamp without time zone,
    updatedate timestamp without time zone,
    createuser character varying,
    updateuser character varying,
    deliverynotenumber character varying,
    cancelsynchronizationtype character varying,
    companypayer_id bigint,
    productioncode character varying,
    commissionnumber character varying,
    machinetype character varying,
    pipedriveupdate timestamp without time zone,
    state character varying(255) DEFAULT '01new'::character varying,
    asanataskid character varying,
    asanatasknameupdated boolean DEFAULT false,
    asanataskcommentadded boolean DEFAULT false,
    sendagaintoasana boolean DEFAULT false,
    sendagaintoasanatries integer DEFAULT 0,
    asanastatecompleteddate timestamp without time zone,
    colourral character varying(255),
    salesplan_id bigint,
    materialsissued boolean DEFAULT false,
    warehouseorder boolean DEFAULT false,
    synchronize boolean DEFAULT false,
    synchronizationdate timestamp without time zone,
    archived boolean DEFAULT false
);


--
-- Name: arch_masterorders_masterorder_id_seq; Type: SEQUENCE; Schema: public; Owner: -
--

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


--
-- Name: arch_masterorders_masterorder_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: -
--

ALTER SEQUENCE public.arch_masterorders_masterorder_id_seq OWNED BY public.arch_masterorders_masterorder.id;


--
-- Name: arch_masterorders_masterorderposition_manyproducts; Type: VIEW; Schema: public; Owner: -
--

CREATE VIEW public.arch_masterorders_masterorderposition_manyproducts AS
SELECT
    NULL::bigint AS id,
    NULL::character varying(255) AS masterorderdefinitionnumber,
    NULL::integer AS masterorderid,
    NULL::integer AS productid,
    NULL::integer AS masterorderproductid,
    NULL::character varying(1024) AS name,
    NULL::character varying(255) AS number,
    NULL::timestamp without time zone AS deadline,
    NULL::character varying(255) AS masterorderstatus,
    NULL::character varying(255) AS masterorderpositionstatus,
    NULL::numeric AS masterorderquantity,
    NULL::numeric AS cumulatedmasterorderquantity,
    NULL::numeric AS producedorderquantity,
    NULL::numeric AS lefttorelease,
    NULL::text AS comments,
    NULL::character varying(255) AS productnumber,
    NULL::character varying(1024) AS productname,
    NULL::character varying(255) AS unit,
    NULL::character varying(255) AS technologyname,
    NULL::character varying(255) AS companyname,
    NULL::boolean AS active,
    NULL::character varying(255) AS companypayer,
    NULL::character varying(255) AS assortmentname,
    NULL::character varying(255) AS state,
    NULL::character varying(2048) AS description;


--
-- Name: arch_mv_masterorders_masterorderpositiondto; Type: MATERIALIZED VIEW; Schema: public; Owner: -
--

CREATE MATERIALIZED VIEW public.arch_mv_masterorders_masterorderpositiondto AS
 SELECT masterorders_masterorderposition_manyproducts.id,
    masterorders_masterorderposition_manyproducts.masterorderdefinitionnumber,
    masterorders_masterorderposition_manyproducts.masterorderid,
    masterorders_masterorderposition_manyproducts.productid,
    masterorders_masterorderposition_manyproducts.masterorderproductid,
    masterorders_masterorderposition_manyproducts.name,
    masterorders_masterorderposition_manyproducts.number,
    masterorders_masterorderposition_manyproducts.deadline,
    masterorders_masterorderposition_manyproducts.masterorderstatus,
    masterorders_masterorderposition_manyproducts.masterorderpositionstatus,
    masterorders_masterorderposition_manyproducts.masterorderquantity,
    masterorders_masterorderposition_manyproducts.cumulatedmasterorderquantity,
    masterorders_masterorderposition_manyproducts.producedorderquantity,
    masterorders_masterorderposition_manyproducts.lefttorelease,
    masterorders_masterorderposition_manyproducts.comments,
    masterorders_masterorderposition_manyproducts.productnumber,
    masterorders_masterorderposition_manyproducts.productname,
    masterorders_masterorderposition_manyproducts.unit,
    masterorders_masterorderposition_manyproducts.technologyname,
    masterorders_masterorderposition_manyproducts.companyname,
    masterorders_masterorderposition_manyproducts.active,
    masterorders_masterorderposition_manyproducts.companypayer,
    masterorders_masterorderposition_manyproducts.assortmentname,
    masterorders_masterorderposition_manyproducts.state,
    masterorders_masterorderposition_manyproducts.description
   FROM public.arch_masterorders_masterorderposition_manyproducts masterorders_masterorderposition_manyproducts
  WITH NO DATA;


--
-- Name: arch_masterorders_masterorderpositiondto; Type: VIEW; Schema: public; Owner: -
--

CREATE VIEW public.arch_masterorders_masterorderpositiondto AS
 SELECT arch_mv_masterorders_masterorderpositiondto.id,
    arch_mv_masterorders_masterorderpositiondto.masterorderdefinitionnumber,
    arch_mv_masterorders_masterorderpositiondto.masterorderid,
    arch_mv_masterorders_masterorderpositiondto.productid,
    arch_mv_masterorders_masterorderpositiondto.masterorderproductid,
    arch_mv_masterorders_masterorderpositiondto.name,
    arch_mv_masterorders_masterorderpositiondto.number,
    arch_mv_masterorders_masterorderpositiondto.deadline,
    arch_mv_masterorders_masterorderpositiondto.masterorderstatus,
    arch_mv_masterorders_masterorderpositiondto.masterorderpositionstatus,
    arch_mv_masterorders_masterorderpositiondto.masterorderquantity,
    arch_mv_masterorders_masterorderpositiondto.cumulatedmasterorderquantity,
    arch_mv_masterorders_masterorderpositiondto.producedorderquantity,
    arch_mv_masterorders_masterorderpositiondto.lefttorelease,
    arch_mv_masterorders_masterorderpositiondto.comments,
    arch_mv_masterorders_masterorderpositiondto.productnumber,
    arch_mv_masterorders_masterorderpositiondto.productname,
    arch_mv_masterorders_masterorderpositiondto.unit,
    arch_mv_masterorders_masterorderpositiondto.technologyname,
    arch_mv_masterorders_masterorderpositiondto.companyname,
    arch_mv_masterorders_masterorderpositiondto.active,
    arch_mv_masterorders_masterorderpositiondto.companypayer,
    arch_mv_masterorders_masterorderpositiondto.assortmentname,
    arch_mv_masterorders_masterorderpositiondto.state,
    arch_mv_masterorders_masterorderpositiondto.description
   FROM public.arch_mv_masterorders_masterorderpositiondto;


--
-- Name: basic_company; Type: TABLE; Schema: public; Owner: -
--

CREATE TABLE public.basic_company (
    id bigint NOT NULL,
    number character varying(255),
    name character varying(255) DEFAULT 'Company'::character varying,
    taxcountrycode_id bigint,
    tax character varying(255),
    street character varying(255),
    house character varying(30),
    flat character varying(30),
    zipcode character varying(255),
    city character varying(255),
    state character varying(255),
    country_id bigint,
    email character varying(255),
    website character varying(255),
    phone character varying(255),
    externalnumber character varying(255),
    buffer integer,
    active boolean DEFAULT true,
    paymentform character varying(255),
    country character varying(255),
    entityversion bigint DEFAULT 0,
    contactperson character varying(255),
    issupplier boolean DEFAULT false,
    isreceiver boolean DEFAULT false,
    logoimage character varying(255),
    currency_id bigint,
    contractorcategory character varying(255),
    abcanalysis character varying(255)
);


--
-- Name: masterorders_masterorderdefinition; Type: TABLE; Schema: public; Owner: -
--

CREATE TABLE public.masterorders_masterorderdefinition (
    id bigint NOT NULL,
    number character varying(255),
    name character varying(1024),
    parameter_id bigint,
    active boolean DEFAULT true,
    entityversion bigint DEFAULT 0
);


--
-- Name: arch_mv_masterorders_masterorderdto; Type: MATERIALIZED VIEW; Schema: public; Owner: -
--

CREATE MATERIALIZED VIEW public.arch_mv_masterorders_masterorderdto AS
 SELECT masterorder.id,
    masterorderdefinition.number AS masterorderdefinitionnumber,
    masterorder.number,
    masterorder.name,
    masterorder.deadline,
    company.number AS company,
    companypayer.number AS companypayer,
    COALESCE((orderedpositions.count)::integer, 0) AS orderedpositionquantity,
    COALESCE((cumulatedpositions.count)::integer, 0) AS commissionedpositionquantity,
    (COALESCE((orderedpositions.count)::integer, 0) - COALESCE((cumulatedpositions.count)::integer, 0)) AS quantityforcommission,
    masterorder.masterorderstate,
    masterorder.active,
    masterorder.pipedriveupdate,
    masterorder.state,
    masterorder.externalnumber,
    masterorder.asanataskid,
    masterorder.description
   FROM (((((public.arch_masterorders_masterorder masterorder
     LEFT JOIN public.masterorders_masterorderdefinition masterorderdefinition ON ((masterorderdefinition.id = masterorder.masterorderdefinition_id)))
     LEFT JOIN public.basic_company company ON ((company.id = masterorder.company_id)))
     LEFT JOIN public.basic_company companypayer ON ((companypayer.id = masterorder.companypayer_id)))
     LEFT JOIN ( SELECT arch_masterorders_masterorderpositiondto.masterorderid,
            count(*) AS count
           FROM public.arch_masterorders_masterorderpositiondto
          GROUP BY arch_masterorders_masterorderpositiondto.masterorderid) orderedpositions ON ((orderedpositions.masterorderid = masterorder.id)))
     LEFT JOIN ( SELECT arch_masterorders_masterorderpositiondto.masterorderid,
            count(*) AS count
           FROM public.arch_masterorders_masterorderpositiondto
          WHERE (arch_masterorders_masterorderpositiondto.cumulatedmasterorderquantity > (0)::numeric)
          GROUP BY arch_masterorders_masterorderpositiondto.masterorderid) cumulatedpositions ON ((cumulatedpositions.masterorderid = masterorder.id)))
  WITH NO DATA;


--
-- Name: arch_masterorders_masterorderdto; Type: VIEW; Schema: public; Owner: -
--

CREATE VIEW public.arch_masterorders_masterorderdto AS
 SELECT arch_mv_masterorders_masterorderdto.id,
    arch_mv_masterorders_masterorderdto.masterorderdefinitionnumber,
    arch_mv_masterorders_masterorderdto.number,
    arch_mv_masterorders_masterorderdto.name,
    arch_mv_masterorders_masterorderdto.deadline,
    arch_mv_masterorders_masterorderdto.company,
    arch_mv_masterorders_masterorderdto.companypayer,
    arch_mv_masterorders_masterorderdto.orderedpositionquantity,
    arch_mv_masterorders_masterorderdto.commissionedpositionquantity,
    arch_mv_masterorders_masterorderdto.quantityforcommission,
    arch_mv_masterorders_masterorderdto.masterorderstate,
    arch_mv_masterorders_masterorderdto.active,
    arch_mv_masterorders_masterorderdto.pipedriveupdate,
    arch_mv_masterorders_masterorderdto.state,
    arch_mv_masterorders_masterorderdto.externalnumber,
    arch_mv_masterorders_masterorderdto.asanataskid,
    arch_mv_masterorders_masterorderdto.description
   FROM public.arch_mv_masterorders_masterorderdto;


--
-- Name: arch_masterorders_masterorderdto_id_seq; Type: SEQUENCE; Schema: public; Owner: -
--

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


--
-- Name: arch_masterorders_masterorderposition_manyproducts_id_seq; Type: SEQUENCE; Schema: public; Owner: -
--

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


--
-- Name: arch_masterorders_masterorderpositiondto_id_seq; Type: SEQUENCE; Schema: public; Owner: -
--

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


--
-- Name: arch_masterorders_masterorderproduct; Type: TABLE; Schema: public; Owner: -
--

CREATE TABLE public.arch_masterorders_masterorderproduct (
    id bigint NOT NULL,
    product_id bigint,
    technology_id bigint,
    masterorder_id bigint,
    masterorderquantity numeric(14,5),
    cumulatedorderquantity numeric(14,5),
    producedorderquantity numeric(14,5),
    entityversion bigint DEFAULT 0,
    lefttorelease numeric(14,5),
    comments text,
    masterorderpositionstatus character varying(255),
    quantitytakenfromwarehouse numeric(14,5),
    quantityremainingtoorder numeric(14,5),
    deliverydate timestamp without time zone,
    line character varying(255),
    vendorinfo character varying(255),
    vendorso character varying(255),
    price numeric(14,5),
    priceslistprice numeric(9,2),
    archived boolean DEFAULT false
);


--
-- Name: arch_masterorders_masterorderproduct_id_seq; Type: SEQUENCE; Schema: public; Owner: -
--

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


--
-- Name: arch_masterorders_masterorderproduct_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: -
--

ALTER SEQUENCE public.arch_masterorders_masterorderproduct_id_seq OWNED BY public.arch_masterorders_masterorderproduct.id;


--
-- Name: arch_masterorders_masterorderproductattrvalue; Type: TABLE; Schema: public; Owner: -
--

CREATE TABLE public.arch_masterorders_masterorderproductattrvalue (
    id bigint NOT NULL,
    masterorderproduct_id bigint,
    attribute_id bigint,
    attributevalue_id bigint,
    value character varying(255),
    succession integer,
    archived boolean DEFAULT false
);


--
-- Name: arch_masterorders_masterorderproductattrvalue_id_seq; Type: SEQUENCE; Schema: public; Owner: -
--

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


--
-- Name: arch_masterorders_masterorderproductattrvalue_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: -
--

ALTER SEQUENCE public.arch_masterorders_masterorderproductattrvalue_id_seq OWNED BY public.arch_masterorders_masterorderproductattrvalue.id;


--
-- Name: arch_masterorders_productsbysizeentryhelper; Type: TABLE; Schema: public; Owner: -
--

CREATE TABLE public.arch_masterorders_productsbysizeentryhelper (
    id bigint NOT NULL,
    size_id bigint,
    productsbysizehelper_id bigint,
    quantity numeric(12,5),
    product_id bigint,
    archived boolean DEFAULT false
);


--
-- Name: arch_masterorders_productsbysizeentryhelper_id_seq; Type: SEQUENCE; Schema: public; Owner: -
--

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


--
-- Name: arch_masterorders_productsbysizeentryhelper_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: -
--

ALTER SEQUENCE public.arch_masterorders_productsbysizeentryhelper_id_seq OWNED BY public.arch_masterorders_productsbysizeentryhelper.id;


--
-- Name: arch_masterorders_productsbysizehelper; Type: TABLE; Schema: public; Owner: -
--

CREATE TABLE public.arch_masterorders_productsbysizehelper (
    id bigint NOT NULL,
    product_id bigint,
    totalquantity numeric(12,5),
    masterorder_id bigint,
    salesplan_id bigint,
    ordersgroup_id bigint,
    archived boolean DEFAULT false
);


--
-- Name: arch_masterorders_productsbysizehelper_id_seq; Type: SEQUENCE; Schema: public; Owner: -
--

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


--
-- Name: arch_masterorders_productsbysizehelper_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: -
--

ALTER SEQUENCE public.arch_masterorders_productsbysizehelper_id_seq OWNED BY public.arch_masterorders_productsbysizehelper.id;


--
-- Name: arch_materialflowresources_document; Type: TABLE; Schema: public; Owner: -
--

CREATE TABLE public.arch_materialflowresources_document (
    id bigint NOT NULL,
    number character varying(255) NOT NULL,
    type character varying(255) NOT NULL,
    "time" timestamp without time zone,
    state character varying(255) DEFAULT '01draft'::character varying,
    locationfrom_id bigint,
    locationto_id bigint,
    user_id bigint,
    delivery_id bigint,
    active boolean DEFAULT true,
    createdate timestamp without time zone,
    updatedate timestamp without time zone,
    createuser character varying(255),
    updateuser character varying(255),
    order_id bigint,
    description character varying(2048),
    suborder_id bigint,
    company_id bigint,
    maintenanceevent_id bigint,
    entityversion bigint DEFAULT 0,
    plannedevent_id bigint,
    name character varying(255) NOT NULL,
    createlinkeddocument boolean,
    linkeddocumentlocation_id bigint,
    address_id bigint,
    dispositionshift_id bigint,
    positionsfile character varying,
    printed boolean DEFAULT false,
    generationdate timestamp without time zone,
    filename character varying(255),
    acceptationinprogress boolean DEFAULT false,
    externalnumber character varying(255),
    issend boolean DEFAULT false,
    wms boolean DEFAULT false,
    datesendtowms timestamp without time zone,
    stateinwms character varying(255),
    pickingworker character varying(255),
    dateconfirmationofcompletion timestamp without time zone,
    locationchanged boolean DEFAULT false,
    editinwms boolean DEFAULT true,
    staff_id bigint,
    ordersgroup_id bigint,
    invoicenumber character varying(2048),
    archived boolean DEFAULT false
);


--
-- Name: arch_materialflowresources_document_id_seq; Type: SEQUENCE; Schema: public; Owner: -
--

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


--
-- Name: arch_materialflowresources_document_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: -
--

ALTER SEQUENCE public.arch_materialflowresources_document_id_seq OWNED BY public.arch_materialflowresources_document.id;


--
-- Name: arch_orders_order; Type: TABLE; Schema: public; Owner: -
--

CREATE TABLE public.arch_orders_order (
    id bigint NOT NULL,
    number character varying(255),
    name character varying(1024),
    description character varying(2048),
    commentreasontypecorrectiondatefrom character varying(255),
    commentreasontypecorrectiondateto character varying(255),
    commentreasondeviationeffectivestart character varying(255),
    commentreasondeviationeffectiveend character varying(255),
    externalnumber character varying(255),
    commentreasontypedeviationsquantity character varying(255),
    datefrom timestamp without time zone,
    dateto timestamp without time zone,
    effectivedatefrom timestamp without time zone,
    effectivedateto timestamp without time zone,
    deadline timestamp without time zone,
    correcteddatefrom timestamp without time zone,
    correcteddateto timestamp without time zone,
    startdate timestamp without time zone,
    finishdate timestamp without time zone,
    state character varying(255),
    company_id bigint,
    product_id bigint,
    technology_id bigint,
    productionline_id bigint,
    plannedquantity numeric(12,5),
    donequantity numeric(12,5),
    externalsynchronized boolean DEFAULT true,
    commissionedplannedquantity numeric(12,5),
    commissionedcorrectedquantity numeric(12,5),
    amountofproductproduced numeric(12,5),
    remainingamountofproducttoproduce numeric(12,5),
    ownlinechangeoverduration integer,
    registerproductiontime boolean,
    registerquantityinproduct boolean,
    laborworktime integer,
    includetpz boolean,
    inputproductsrequiredfortype character varying(255),
    generatedenddate timestamp without time zone,
    machineworktime integer,
    ownlinechangeover boolean DEFAULT false,
    registerquantityoutproduct boolean,
    operationdurationquantityunit character varying(255),
    realizationtime integer,
    calculate boolean,
    includeadditionaltime boolean,
    typeofproductionrecording character varying(255) DEFAULT '02cumulated'::character varying,
    masterorder_id bigint,
    active boolean DEFAULT true,
    productpriceperunit numeric(19,5),
    failuresyncmessage character varying(255),
    targetstate character varying(255),
    ignorerequiredcomponents boolean,
    automaticallymoveoverusage boolean DEFAULT false,
    updatecomponentsavailability boolean,
    technologyprototype_id bigint,
    level integer,
    parent_id bigint,
    ignoremissingcomponents boolean DEFAULT false,
    masterorderproduct_id bigint,
    dateschanged boolean DEFAULT false,
    sourcecorrecteddatefrom timestamp without time zone,
    sourcecorrecteddateto timestamp without time zone,
    sourcestartdate timestamp without time zone,
    sourcefinishdate timestamp without time zone,
    batchnumber character varying(255),
    root_id bigint,
    includeordersforcomponent boolean,
    plannedfinishallorders timestamp without time zone,
    plannedstartallorders timestamp without time zone,
    calculatedfinishallorders timestamp without time zone,
    registerfilled boolean,
    workplandelivered boolean DEFAULT false,
    calculatedstartallorders timestamp without time zone,
    scadacreatedorupdatestate character varying(255),
    entityversion bigint DEFAULT 0,
    workertochange character varying(255),
    masterorderproductcomponent_id bigint,
    wastesquantity numeric(12,5),
    existsrepairorders boolean DEFAULT false,
    ordercategory character varying(255),
    address_id bigint,
    finalproductiontracking boolean DEFAULT false,
    updatefinishdate boolean DEFAULT false,
    ordersgroup_id bigint,
    plannedquantityforadditionalunit numeric,
    division_id bigint,
    salesplan_id bigint,
    reportedproductionquantity numeric(12,5),
    expirationdate date,
    additionalfinalproducts character varying(255),
    optimizecuttingsolution text,
    vendorinfo character varying(255),
    priority integer DEFAULT 100,
    archived boolean DEFAULT false
);


--
-- Name: basic_address; Type: TABLE; Schema: public; Owner: -
--

CREATE TABLE public.basic_address (
    id bigint NOT NULL,
    company_id bigint,
    addresstype character varying(255),
    number character varying(255),
    name character varying(255),
    phone character varying(255),
    email character varying(255),
    website character varying(255),
    street character varying(255),
    house character varying(30),
    flat character varying(30),
    zipcode character varying(255),
    city character varying(255),
    state character varying(255),
    country_id bigint,
    contactperson character varying(255),
    canbedeleted boolean DEFAULT false,
    active boolean DEFAULT true,
    externalnumber character varying(255)
);


--
-- Name: cmmsmachineparts_maintenanceevent; Type: TABLE; Schema: public; Owner: -
--

CREATE TABLE public.cmmsmachineparts_maintenanceevent (
    id bigint NOT NULL,
    number character varying(255) NOT NULL,
    type character varying(255) DEFAULT '01failure'::character varying,
    description character varying(600),
    personreceiving_id bigint,
    personreceivingname character varying(255),
    state character varying(255) DEFAULT '01new'::character varying,
    createdate timestamp without time zone,
    updatedate timestamp without time zone,
    createuser character varying(255),
    updateuser character varying(255),
    factory_id bigint,
    division_id bigint,
    productionline_id bigint,
    workstation_id bigint,
    subassembly_id bigint,
    faulttype_id bigint,
    solutiondescription text,
    maintenanceeventcontext_id bigint,
    entityversion bigint DEFAULT 0,
    sourcecost_id bigint,
    soundnotifications boolean DEFAULT false,
    highestpriority boolean DEFAULT false,
    reportingemployee_id bigint
);


--
-- Name: cmmsmachineparts_plannedevent; Type: TABLE; Schema: public; Owner: -
--

CREATE TABLE public.cmmsmachineparts_plannedevent (
    id bigint NOT NULL,
    number character varying(255),
    type character varying(255) DEFAULT '01review'::character varying,
    description character varying(600),
    owner_id bigint,
    ownername character varying(255),
    state character varying(255) DEFAULT '01new'::character varying,
    factory_id bigint,
    division_id bigint,
    productionline_id bigint,
    workstation_id bigint,
    subassembly_id bigint,
    plannedeventcontext_id bigint,
    createdate timestamp without time zone,
    updatedate timestamp without time zone,
    createuser character varying(255),
    updateuser character varying(255),
    plannedseparately boolean DEFAULT false,
    afterreview boolean DEFAULT false,
    requiresshutdown boolean DEFAULT false,
    company_id bigint,
    basedon character varying(255) DEFAULT '01date'::character varying,
    date date,
    counter numeric(14,5),
    countertolerance numeric(14,5),
    duration integer DEFAULT 0,
    effectiveduration integer DEFAULT 0,
    effectivecounter numeric(14,5),
    startdate timestamp without time zone,
    finishdate timestamp without time zone,
    isdeadline boolean,
    solutiondescription text,
    entityversion bigint DEFAULT 0,
    maintenanceevent_id bigint,
    sourcecost_id bigint,
    recurringevent_id bigint
);


--
-- Name: deliveries_delivery; Type: TABLE; Schema: public; Owner: -
--

CREATE TABLE public.deliveries_delivery (
    id bigint NOT NULL,
    number character varying(255),
    name character varying(1024),
    description character varying(2048),
    supplier_id bigint,
    deliverydate timestamp without time zone,
    deliveryaddress character varying(2048),
    relateddelivery_id bigint,
    currency_id bigint,
    externalnumber character varying(255),
    externalsynchronized boolean DEFAULT true,
    state character varying(255),
    location_id bigint,
    active boolean DEFAULT true,
    createdate timestamp without time zone,
    updatedate timestamp without time zone,
    createuser character varying(255),
    updateuser character varying(255),
    synchronizationstatus character varying(255),
    entityversion bigint DEFAULT 0,
    paymentform character varying(255),
    salesplan_id bigint,
    wms boolean DEFAULT false,
    stateinwms character varying(255),
    datesendtowms timestamp without time zone,
    pickingworker character varying(255),
    dateconfirmationofcompletion timestamp without time zone
);


--
-- Name: materialflow_location; Type: TABLE; Schema: public; Owner: -
--

CREATE TABLE public.materialflow_location (
    id bigint NOT NULL,
    number character varying(255),
    name character varying(255),
    externalnumber character varying(255),
    algorithm character varying(255) DEFAULT '01fifo'::character varying,
    requireprice boolean,
    requirebatch boolean,
    requireproductiondate boolean,
    requireexpirationdate boolean,
    entityversion bigint DEFAULT 0,
    warehousenumberinoptima character varying(255),
    draftmakesreservation boolean DEFAULT false,
    realizationlocation_id bigint,
    active boolean DEFAULT true
);


--
-- Name: qcadoosecurity_user; Type: TABLE; Schema: public; Owner: -
--

CREATE TABLE public.qcadoosecurity_user (
    id bigint NOT NULL,
    username character varying(255),
    email character varying(255),
    firstname character varying(255),
    lastname character varying(255),
    enabled boolean DEFAULT true,
    description character varying(255),
    password character varying(255),
    lastactivity timestamp without time zone,
    staff_id bigint,
    group_id bigint,
    entityversion bigint DEFAULT 0,
    factory_id bigint,
    ipaddress character varying,
    showonlymyregistrationrecords boolean DEFAULT false,
    productionline_id bigint,
    groupchangedate timestamp without time zone,
    pswdlastchanged timestamp without time zone,
    afterfirstpswdchange boolean DEFAULT false,
    isblocked boolean DEFAULT false,
    showonlymyoperationaltasksandorders boolean DEFAULT false
);


--
-- Name: subcontractorportal_suborder; Type: TABLE; Schema: public; Owner: -
--

CREATE TABLE public.subcontractorportal_suborder (
    id bigint NOT NULL,
    number character varying(255),
    ordernumber character varying(255),
    description text,
    datefrom timestamp without time zone,
    dateto timestamp without time zone,
    state character varying(255),
    company_id bigint,
    active boolean DEFAULT true,
    changedby_id bigint,
    hasoperations boolean DEFAULT false,
    entityversion bigint DEFAULT 0
);


--
-- Name: arch_mv_materialflowresources_documentdto; Type: MATERIALIZED VIEW; Schema: public; Owner: -
--

CREATE MATERIALIZED VIEW public.arch_mv_materialflowresources_documentdto AS
 SELECT document.id,
    document.number,
    document.description,
    document.name,
    document.type,
    document."time",
    document.state,
    document.active,
    (locationfrom.id)::integer AS locationfrom_id,
    locationfrom.number AS locationfromnumber,
    (locationto.id)::integer AS locationto_id,
    locationto.number AS locationtonumber,
    (company.id)::integer AS company_id,
    company.name AS companyname,
        CASE
            WHEN (address.name IS NULL) THEN (address.number)::text
            ELSE (((address.number)::text || ' - '::text) || (address.name)::text)
        END AS documentaddress,
    (securityuser.id)::integer AS user_id,
    (((securityuser.firstname)::text || ' '::text) || (securityuser.lastname)::text) AS username,
    (maintenanceevent.id)::integer AS maintenanceevent_id,
    maintenanceevent.number AS maintenanceeventnumber,
    (plannedevent.id)::integer AS plannedevent_id,
    plannedevent.number AS plannedeventnumber,
    (delivery.id)::integer AS delivery_id,
    delivery.number AS deliverynumber,
    (ordersorder.id)::integer AS order_id,
    ordersorder.number AS ordernumber,
    (suborder.id)::integer AS suborder_id,
    suborder.number AS subordernumber
   FROM ((((((((((public.arch_materialflowresources_document document
     LEFT JOIN public.materialflow_location locationfrom ON ((locationfrom.id = document.locationfrom_id)))
     LEFT JOIN public.materialflow_location locationto ON ((locationto.id = document.locationto_id)))
     LEFT JOIN public.basic_company company ON ((company.id = document.company_id)))
     LEFT JOIN public.basic_address address ON ((address.id = document.address_id)))
     LEFT JOIN public.qcadoosecurity_user securityuser ON ((securityuser.id = document.user_id)))
     LEFT JOIN public.cmmsmachineparts_maintenanceevent maintenanceevent ON ((maintenanceevent.id = document.maintenanceevent_id)))
     LEFT JOIN public.cmmsmachineparts_plannedevent plannedevent ON ((plannedevent.id = document.plannedevent_id)))
     LEFT JOIN public.deliveries_delivery delivery ON ((delivery.id = document.delivery_id)))
     LEFT JOIN public.arch_orders_order ordersorder ON ((ordersorder.id = document.order_id)))
     LEFT JOIN public.subcontractorportal_suborder suborder ON ((suborder.id = document.suborder_id)))
  WITH NO DATA;


--
-- Name: arch_materialflowresources_documentdto; Type: VIEW; Schema: public; Owner: -
--

CREATE VIEW public.arch_materialflowresources_documentdto AS
 SELECT arch_mv_materialflowresources_documentdto.id,
    arch_mv_materialflowresources_documentdto.number,
    arch_mv_materialflowresources_documentdto.description,
    arch_mv_materialflowresources_documentdto.name,
    arch_mv_materialflowresources_documentdto.type,
    arch_mv_materialflowresources_documentdto."time",
    arch_mv_materialflowresources_documentdto.state,
    arch_mv_materialflowresources_documentdto.active,
    arch_mv_materialflowresources_documentdto.locationfrom_id,
    arch_mv_materialflowresources_documentdto.locationfromnumber,
    arch_mv_materialflowresources_documentdto.locationto_id,
    arch_mv_materialflowresources_documentdto.locationtonumber,
    arch_mv_materialflowresources_documentdto.company_id,
    arch_mv_materialflowresources_documentdto.companyname,
    arch_mv_materialflowresources_documentdto.documentaddress,
    arch_mv_materialflowresources_documentdto.user_id,
    arch_mv_materialflowresources_documentdto.username,
    arch_mv_materialflowresources_documentdto.maintenanceevent_id,
    arch_mv_materialflowresources_documentdto.maintenanceeventnumber,
    arch_mv_materialflowresources_documentdto.plannedevent_id,
    arch_mv_materialflowresources_documentdto.plannedeventnumber,
    arch_mv_materialflowresources_documentdto.delivery_id,
    arch_mv_materialflowresources_documentdto.deliverynumber,
    arch_mv_materialflowresources_documentdto.order_id,
    arch_mv_materialflowresources_documentdto.ordernumber,
    arch_mv_materialflowresources_documentdto.suborder_id,
    arch_mv_materialflowresources_documentdto.subordernumber
   FROM public.arch_mv_materialflowresources_documentdto;


--
-- Name: arch_materialflowresources_documentdto_id_seq; Type: SEQUENCE; Schema: public; Owner: -
--

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


--
-- Name: arch_materialflowresources_documentstatechange; Type: TABLE; Schema: public; Owner: -
--

CREATE TABLE public.arch_materialflowresources_documentstatechange (
    id bigint NOT NULL,
    dateandtime timestamp without time zone,
    document_id bigint,
    sourcestate character varying(255),
    targetstate character varying(255),
    status character varying(255),
    worker character varying(255),
    archived boolean DEFAULT false
);


--
-- Name: arch_materialflowresources_documentstatechange_id_seq; Type: SEQUENCE; Schema: public; Owner: -
--

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


--
-- Name: arch_materialflowresources_documentstatechange_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: -
--

ALTER SEQUENCE public.arch_materialflowresources_documentstatechange_id_seq OWNED BY public.arch_materialflowresources_documentstatechange.id;


--
-- Name: arch_materialflowresources_position; Type: TABLE; Schema: public; Owner: -
--

CREATE TABLE public.arch_materialflowresources_position (
    id bigint NOT NULL,
    document_id bigint,
    product_id bigint,
    quantity numeric(14,5),
    price numeric(12,5) DEFAULT (0)::numeric,
    productiondate date,
    expirationdate date,
    number integer,
    resource_id bigint,
    givenunit character varying(255),
    givenquantity numeric(14,5),
    entityversion bigint DEFAULT 0,
    storagelocation_id bigint,
    conversion numeric(12,5) DEFAULT (0)::numeric,
    palletnumber_id bigint,
    typeofpallet character varying(255),
    waste boolean DEFAULT false,
    resourcereceiptdocument character varying,
    lastresource boolean DEFAULT false,
    resourcenumber character varying(255),
    externaldocumentnumber character varying(255),
    orderid integer,
    sellingprice numeric(12,5) DEFAULT '0'::numeric,
    batch_id bigint,
    qualityrating character varying(255),
    pickingdate timestamp without time zone,
    pickingworker_id bigint,
    documentpart_id bigint,
    archived boolean DEFAULT false
);


--
-- Name: arch_materialflowresources_position_id_seq; Type: SEQUENCE; Schema: public; Owner: -
--

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


--
-- Name: arch_materialflowresources_position_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: -
--

ALTER SEQUENCE public.arch_materialflowresources_position_id_seq OWNED BY public.arch_materialflowresources_position.id;


--
-- Name: arch_materialflowresources_positionattributevalue; Type: TABLE; Schema: public; Owner: -
--

CREATE TABLE public.arch_materialflowresources_positionattributevalue (
    id bigint NOT NULL,
    position_id bigint,
    attribute_id bigint,
    attributevalue_id bigint,
    value character varying(255),
    archived boolean DEFAULT false
);


--
-- Name: arch_materialflowresources_positionattributevalue_id_seq; Type: SEQUENCE; Schema: public; Owner: -
--

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


--
-- Name: arch_materialflowresources_positionattributevalue_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: -
--

ALTER SEQUENCE public.arch_materialflowresources_positionattributevalue_id_seq OWNED BY public.arch_materialflowresources_positionattributevalue.id;


--
-- Name: basic_palletnumber; Type: TABLE; Schema: public; Owner: -
--

CREATE TABLE public.basic_palletnumber (
    id bigint NOT NULL,
    number character varying(6),
    active boolean DEFAULT true,
    createdate timestamp without time zone,
    updatedate timestamp without time zone,
    createuser character varying(255),
    updateuser character varying(255),
    issuedatetime timestamp without time zone
);


--
-- Name: basic_product; Type: TABLE; Schema: public; Owner: -
--

CREATE TABLE public.basic_product (
    id bigint NOT NULL,
    number character varying(255),
    name character varying(1024),
    globaltypeofmaterial character varying(255),
    ean character varying(255),
    category character varying(255),
    unit character varying(255),
    externalnumber character varying(255),
    description character varying(2048),
    parent_id bigint,
    entitytype character varying(255) DEFAULT '01particularProduct'::character varying,
    durabilityinmonths integer,
    averageoffercost numeric(12,5) DEFAULT (0)::numeric,
    costfornumber numeric(12,5) DEFAULT (1)::numeric,
    lastpurchasecost numeric(12,5) DEFAULT (0)::numeric,
    lastoffercost numeric(12,5) DEFAULT (0)::numeric,
    isglutenproduct boolean,
    symbol character varying(255),
    averagecost numeric(12,5) DEFAULT (0)::numeric,
    goodsgroup character varying(255),
    nominalcost numeric(12,5) DEFAULT (0)::numeric,
    bio character varying(255),
    isdoublepallet boolean,
    technologygroup_id bigint,
    active boolean DEFAULT true,
    createdate timestamp without time zone,
    updatedate timestamp without time zone,
    createuser character varying(255),
    updateuser character varying(255),
    quantityofextrusioningredient integer DEFAULT 1,
    norm character varying(255),
    actualversion character varying(255),
    hasnutritionelements boolean DEFAULT false,
    quantityfornutritions numeric(12,0),
    quantityfornutritionsunit character varying(255),
    showinproductdata boolean DEFAULT false,
    doublequantityfordoublepallet boolean,
    usedquantitycontrol boolean DEFAULT false,
    automaticusedquantity boolean DEFAULT false,
    nominalweight numeric(12,5),
    countusedquantityforfullpallets boolean DEFAULT false,
    quantityinpackage integer,
    synchronize boolean,
    capacitynormfortwodimensionalmachines numeric(12,5),
    downform_id bigint,
    upform_id bigint,
    downshelve_id bigint,
    upshelve_id bigint,
    costnormsgenerator_id bigint,
    producer_id bigint,
    machinepart boolean,
    drawingnumber character varying(255),
    catalognumber character varying(255),
    isproductiondate boolean DEFAULT false,
    entityversion bigint DEFAULT 0,
    ispallet boolean DEFAULT false,
    additionalunit character varying(255),
    fromgenerator boolean DEFAULT false,
    generatorcontext_id bigint,
    dateformatinqcp5code character varying(255),
    assortment_id bigint,
    isoil boolean,
    isaroma boolean,
    capacitynormforthreedimensionalmachines numeric(12,5),
    recommendednumofheadsfortwodimensionalmachines integer,
    recommendednumofheadsforthreedimensionalmachines integer,
    iscartonlabel boolean,
    isactivecartonlabelquantity boolean,
    batchevidence boolean DEFAULT false,
    expirydatevalidity integer,
    productform_id bigint,
    size_id bigint,
    model_id bigint,
    supplier_id bigint,
    nominalcostcurrency_id bigint,
    averagecostcurrency_id bigint,
    lastpurchasecostcurrency_id bigint,
    expirydatevalidityunit character varying(255) DEFAULT '01months'::character varying,
    orderedproductconfigurator_id bigint,
    batchnumberpattern_id bigint
);


--
-- Name: materialflowresources_storagelocation; Type: TABLE; Schema: public; Owner: -
--

CREATE TABLE public.materialflowresources_storagelocation (
    id bigint NOT NULL,
    number character varying(48),
    state character varying(255) DEFAULT '01draft'::character varying,
    location_id bigint,
    placestoragelocation boolean DEFAULT false,
    maximumnumberofpallets numeric(12,5),
    createdate timestamp without time zone,
    updatedate timestamp without time zone,
    createuser character varying(255),
    updateuser character varying(255),
    active boolean DEFAULT true,
    highstoragelocation boolean
);


--
-- Name: arch_mv_materialflowresources_positiondto; Type: MATERIALIZED VIEW; Schema: public; Owner: -
--

CREATE MATERIALIZED VIEW public.arch_mv_materialflowresources_positiondto AS
 SELECT "position".id,
    locationfrom.number AS locationfrom,
    locationto.number AS locationto,
    product.number AS productnumber,
    product.name AS productname,
    "position".quantity,
    "position".price,
    product.unit AS productunit,
    document."time" AS documentdate,
    ("position".expirationdate)::timestamp without time zone AS expirationdate,
    ("position".productiondate)::timestamp without time zone AS productiondate,
        CASE
            WHEN ("position".externaldocumentnumber IS NULL) THEN document.type
            ELSE '03internalOutbound'::character varying(255)
        END AS documenttype,
    document.state,
        CASE
            WHEN ("position".externaldocumentnumber IS NULL) THEN document.number
            ELSE "position".externaldocumentnumber
        END AS documentnumber,
    document.name AS documentname,
    company.name AS companyname,
        CASE
            WHEN (address.name IS NULL) THEN (address.number)::text
            ELSE (((address.number)::text || ' - '::text) || (address.name)::text)
        END AS documentaddress,
    batch.number AS batch,
    storagelocation.number AS storagelocation,
    "position".waste,
    delivery.number AS deliverynumber,
    plannedevent.number AS plannedeventnumber,
    maintenanceevent.number AS maintenanceeventnumber,
    suborder.number AS subordernumber,
    ordersorder.number AS ordernumber,
    "position".typeofpallet AS pallettype,
    palletnumber.number AS palletnumber,
    (locationfrom.id)::integer AS locationfrom_id,
    (locationto.id)::integer AS locationto_id,
    "position".givenquantity,
    "position".givenunit,
    "position".conversion,
    (document.id)::integer AS documentid,
        CASE
            WHEN ("position".orderid IS NULL) THEN (document.order_id)::integer
            ELSE "position".orderid
        END AS orderid,
    ("position".price * "position".quantity) AS value,
    "position".resourcenumber
   FROM ((((((((((((((public.arch_materialflowresources_position "position"
     LEFT JOIN public.arch_materialflowresources_document document ON ((document.id = "position".document_id)))
     LEFT JOIN public.materialflow_location locationfrom ON ((locationfrom.id = document.locationfrom_id)))
     LEFT JOIN public.materialflow_location locationto ON ((locationto.id = document.locationto_id)))
     JOIN public.basic_product product ON ((product.id = "position".product_id)))
     LEFT JOIN public.basic_company company ON ((company.id = document.company_id)))
     LEFT JOIN public.basic_address address ON ((address.id = document.address_id)))
     LEFT JOIN public.materialflowresources_storagelocation storagelocation ON ((storagelocation.id = "position".storagelocation_id)))
     LEFT JOIN public.cmmsmachineparts_maintenanceevent maintenanceevent ON ((maintenanceevent.id = document.maintenanceevent_id)))
     LEFT JOIN public.cmmsmachineparts_plannedevent plannedevent ON ((plannedevent.id = document.plannedevent_id)))
     LEFT JOIN public.deliveries_delivery delivery ON ((delivery.id = document.delivery_id)))
     LEFT JOIN public.subcontractorportal_suborder suborder ON ((suborder.id = document.suborder_id)))
     LEFT JOIN public.arch_orders_order ordersorder ON (((ordersorder.id = document.order_id) OR (ordersorder.id = "position".orderid))))
     LEFT JOIN public.basic_palletnumber palletnumber ON ((palletnumber.id = "position".palletnumber_id)))
     LEFT JOIN public.advancedgenealogy_batch batch ON (("position".batch_id = batch.id)))
  WITH NO DATA;


--
-- Name: arch_materialflowresources_positiondto; Type: VIEW; Schema: public; Owner: -
--

CREATE VIEW public.arch_materialflowresources_positiondto AS
 SELECT arch_mv_materialflowresources_positiondto.id,
    arch_mv_materialflowresources_positiondto.locationfrom,
    arch_mv_materialflowresources_positiondto.locationto,
    arch_mv_materialflowresources_positiondto.productnumber,
    arch_mv_materialflowresources_positiondto.productname,
    arch_mv_materialflowresources_positiondto.quantity,
    arch_mv_materialflowresources_positiondto.price,
    arch_mv_materialflowresources_positiondto.productunit,
    arch_mv_materialflowresources_positiondto.documentdate,
    arch_mv_materialflowresources_positiondto.expirationdate,
    arch_mv_materialflowresources_positiondto.productiondate,
    arch_mv_materialflowresources_positiondto.documenttype,
    arch_mv_materialflowresources_positiondto.state,
    arch_mv_materialflowresources_positiondto.documentnumber,
    arch_mv_materialflowresources_positiondto.documentname,
    arch_mv_materialflowresources_positiondto.companyname,
    arch_mv_materialflowresources_positiondto.documentaddress,
    arch_mv_materialflowresources_positiondto.batch,
    arch_mv_materialflowresources_positiondto.storagelocation,
    arch_mv_materialflowresources_positiondto.waste,
    arch_mv_materialflowresources_positiondto.deliverynumber,
    arch_mv_materialflowresources_positiondto.plannedeventnumber,
    arch_mv_materialflowresources_positiondto.maintenanceeventnumber,
    arch_mv_materialflowresources_positiondto.subordernumber,
    arch_mv_materialflowresources_positiondto.ordernumber,
    arch_mv_materialflowresources_positiondto.pallettype,
    arch_mv_materialflowresources_positiondto.palletnumber,
    arch_mv_materialflowresources_positiondto.locationfrom_id,
    arch_mv_materialflowresources_positiondto.locationto_id,
    arch_mv_materialflowresources_positiondto.givenquantity,
    arch_mv_materialflowresources_positiondto.givenunit,
    arch_mv_materialflowresources_positiondto.conversion,
    arch_mv_materialflowresources_positiondto.documentid,
    arch_mv_materialflowresources_positiondto.orderid,
    arch_mv_materialflowresources_positiondto.value,
    arch_mv_materialflowresources_positiondto.resourcenumber
   FROM public.arch_mv_materialflowresources_positiondto;


--
-- Name: arch_materialflowresources_positiondto_id_seq; Type: SEQUENCE; Schema: public; Owner: -
--

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


--
-- Name: arch_materialflowresources_reservation; Type: TABLE; Schema: public; Owner: -
--

CREATE TABLE public.arch_materialflowresources_reservation (
    id bigint NOT NULL,
    location_id bigint,
    product_id bigint,
    quantity numeric(12,5),
    position_id bigint,
    productstoissue_id bigint,
    resource_id bigint,
    order_id bigint,
    orderproductresourcereservation_id bigint,
    date timestamp without time zone,
    archived boolean DEFAULT false
);


--
-- Name: arch_materialflowresources_reservation_id_seq; Type: SEQUENCE; Schema: public; Owner: -
--

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


--
-- Name: arch_materialflowresources_reservation_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: -
--

ALTER SEQUENCE public.arch_materialflowresources_reservation_id_seq OWNED BY public.arch_materialflowresources_reservation.id;


--
-- Name: arch_materialrequirementcoveragefororder_coveragefororder; Type: TABLE; Schema: public; Owner: -
--

CREATE TABLE public.arch_materialrequirementcoveragefororder_coveragefororder (
    id bigint NOT NULL,
    number character varying(255),
    coveragetodate timestamp without time zone,
    actualdate timestamp without time zone,
    generateddate timestamp without time zone,
    generatedby character varying(255),
    generated boolean,
    saved boolean,
    filename character varying(1024),
    coveragetype character varying(255) DEFAULT '01all'::character varying,
    includedraftdeliveries boolean,
    order_id bigint,
    createdate timestamp without time zone,
    updatedate timestamp without time zone,
    createuser character varying(255),
    updateuser character varying(255),
    generatedorders boolean,
    entityversion bigint DEFAULT 0,
    archived boolean DEFAULT false
);


--
-- Name: arch_materialrequirementcoveragefororder_coveragefororder_id_se; Type: SEQUENCE; Schema: public; Owner: -
--

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


--
-- Name: arch_materialrequirementcoveragefororder_coveragefororder_id_se; Type: SEQUENCE OWNED BY; Schema: public; Owner: -
--

ALTER SEQUENCE public.arch_materialrequirementcoveragefororder_coveragefororder_id_se OWNED BY public.arch_materialrequirementcoveragefororder_coveragefororder.id;


--
-- Name: arch_materialrequirementcoveragefororder_coveragelocation; Type: TABLE; Schema: public; Owner: -
--

CREATE TABLE public.arch_materialrequirementcoveragefororder_coveragelocation (
    id bigint NOT NULL,
    coveragefororder_id bigint,
    location_id bigint,
    parameter_id bigint,
    entityversion bigint DEFAULT 0,
    archived boolean DEFAULT false
);


--
-- Name: arch_materialrequirementcoveragefororder_coveragelocation_id_se; Type: SEQUENCE; Schema: public; Owner: -
--

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


--
-- Name: arch_materialrequirementcoveragefororder_coveragelocation_id_se; Type: SEQUENCE OWNED BY; Schema: public; Owner: -
--

ALTER SEQUENCE public.arch_materialrequirementcoveragefororder_coveragelocation_id_se OWNED BY public.arch_materialrequirementcoveragefororder_coveragelocation.id;


--
-- Name: arch_materialrequirementcoveragefororder_coverageproduct; Type: TABLE; Schema: public; Owner: -
--

CREATE TABLE public.arch_materialrequirementcoveragefororder_coverageproduct (
    id bigint NOT NULL,
    coveragefororder_id bigint,
    product_id bigint,
    lackfromdate timestamp without time zone,
    demandquantity numeric(12,5),
    coveredquantity numeric(12,5),
    reservemissingquantity numeric(12,5),
    deliveredquantity numeric(12,5),
    locationsquantity numeric(12,5),
    state character varying(255),
    ispurchased boolean DEFAULT false,
    issubcontracted boolean DEFAULT false,
    producttype character varying(255),
    order_id bigint,
    planedquantity numeric(12,5),
    entityversion bigint DEFAULT 0,
    archived boolean DEFAULT false
);


--
-- Name: arch_materialrequirementcoveragefororder_coverageproduct_id_seq; Type: SEQUENCE; Schema: public; Owner: -
--

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


--
-- Name: arch_materialrequirementcoveragefororder_coverageproduct_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: -
--

ALTER SEQUENCE public.arch_materialrequirementcoveragefororder_coverageproduct_id_seq OWNED BY public.arch_materialrequirementcoveragefororder_coverageproduct.id;


--
-- Name: materialrequirementcoveragefororder_coverageproductlogging; Type: TABLE; Schema: public; Owner: -
--

CREATE TABLE public.materialrequirementcoveragefororder_coverageproductlogging (
    id bigint NOT NULL,
    coverageproduct_id bigint,
    date timestamp without time zone,
    delivery_id bigint,
    order_id bigint,
    operation_id bigint,
    reservemissingquantity numeric(12,5),
    changes numeric(12,5),
    eventtype character varying(255),
    state character varying(255),
    subcontractedoperation_id bigint,
    entityversion bigint DEFAULT 0
);


--
-- Name: materialrequirementcoveragefororder_coverageproductlogging_id_s; Type: SEQUENCE; Schema: public; Owner: -
--

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


--
-- Name: materialrequirementcoveragefororder_coverageproductlogging_id_s; Type: SEQUENCE OWNED BY; Schema: public; Owner: -
--

ALTER SEQUENCE public.materialrequirementcoveragefororder_coverageproductlogging_id_s OWNED BY public.materialrequirementcoveragefororder_coverageproductlogging.id;


--
-- Name: arch_materialrequirementcoveragefororder_coverageproductlogging; Type: TABLE; Schema: public; Owner: -
--

CREATE TABLE public.arch_materialrequirementcoveragefororder_coverageproductlogging (
    id bigint DEFAULT nextval('public.materialrequirementcoveragefororder_coverageproductlogging_id_s'::regclass) NOT NULL,
    coverageproduct_id bigint,
    date timestamp without time zone,
    delivery_id bigint,
    order_id bigint,
    operation_id bigint,
    reservemissingquantity numeric(12,5),
    changes numeric(12,5),
    eventtype character varying(255),
    state character varying(255),
    subcontractedoperation_id bigint,
    entityversion bigint DEFAULT 0,
    archived boolean DEFAULT false
);


--
-- Name: arch_ordersgroups_ordersgroup; Type: TABLE; Schema: public; Owner: -
--

CREATE TABLE public.arch_ordersgroups_ordersgroup (
    id bigint NOT NULL,
    number character varying(255),
    assortment_id bigint,
    productionline_id bigint,
    startdate timestamp without time zone,
    finishdate timestamp without time zone,
    deadline timestamp without time zone,
    quantity numeric(14,5),
    producedquantity numeric(14,5),
    remainingquantity numeric(14,5),
    state character varying(255) DEFAULT '01draft'::character varying,
    active boolean DEFAULT true,
    masterorder_id bigint,
    parent_id bigint,
    remainingquantityinorders numeric(14,5),
    description character varying(2048),
    salesplan_id bigint,
    archived boolean DEFAULT false
);


--
-- Name: basic_division; Type: TABLE; Schema: public; Owner: -
--

CREATE TABLE public.basic_division (
    id bigint NOT NULL,
    number character varying(255),
    name character varying(1024),
    supervisor_id bigint,
    componentslocation_id bigint,
    componentsoutputlocation_id bigint,
    productsinputlocation_id bigint,
    productionline_id bigint,
    productsflowlocation_id bigint,
    productionflow character varying(255) DEFAULT '02withinTheProcess'::character varying,
    factory_id bigint,
    active boolean DEFAULT true,
    comment character varying(2048),
    entityversion bigint DEFAULT 0,
    wastereceptionwarehouse_id bigint
);


--
-- Name: repairs_repairorder; Type: TABLE; Schema: public; Owner: -
--

CREATE TABLE public.repairs_repairorder (
    id bigint NOT NULL,
    number character varying(255) NOT NULL,
    state character varying(255) DEFAULT '01draft'::character varying,
    order_id bigint,
    division_id bigint,
    createdate timestamp without time zone,
    shift_id bigint,
    startdate timestamp without time zone,
    enddate timestamp without time zone,
    staff_id bigint,
    product_id bigint,
    faulttype_id bigint,
    description character varying(2048),
    quantitytorepair numeric(12,5),
    quantityrepaired numeric(12,5),
    lack numeric(12,5),
    active boolean DEFAULT true,
    orderdto_id bigint,
    entityversion bigint DEFAULT 0,
    productiontracking_id bigint,
    labortime integer DEFAULT 0,
    machinetime integer DEFAULT 0,
    repairorderproduct_id bigint
);


--
-- Name: technologies_technology; Type: TABLE; Schema: public; Owner: -
--

CREATE TABLE public.technologies_technology (
    id bigint NOT NULL,
    number character varying(255),
    name character varying(2048),
    product_id bigint,
    technologygroup_id bigint,
    externalsynchronized boolean DEFAULT true,
    master boolean DEFAULT false,
    description character varying(2048),
    state character varying(255) DEFAULT '01draft'::character varying,
    recipeimportstatus character varying(255),
    recipeimportmsg character varying(1024),
    formula character varying(255),
    minimalquantity numeric(10,5),
    active boolean DEFAULT true,
    isstandardgoodfoodtechnology boolean DEFAULT true,
    range character varying(255) DEFAULT '01oneDivision'::character varying,
    division_id bigint,
    componentslocation_id bigint,
    componentsoutputlocation_id bigint,
    productsinputlocation_id bigint,
    technologytype character varying(255),
    technologyprototype_id bigint,
    productionflow character varying(255) DEFAULT '02withinTheProcess'::character varying,
    productsflowlocation_id bigint,
    typeofproductionrecording character varying(255),
    registerquantityoutproduct boolean,
    registerquantityinproduct boolean,
    registerproductiontime boolean,
    entityversion bigint DEFAULT 0,
    template boolean DEFAULT false,
    additionalactions boolean DEFAULT false,
    generatorcontext_id bigint,
    qualitycard_id bigint,
    istemplateaccepted boolean DEFAULT false,
    wastereceptionwarehouse_id bigint,
    pieceworkproduction boolean DEFAULT false,
    piecerate_id bigint
);


--
-- Name: arch_mv_orders_orderlistdto; Type: MATERIALIZED VIEW; Schema: public; Owner: -
--

CREATE MATERIALIZED VIEW public.arch_mv_orders_orderlistdto AS
 SELECT ordersorder.id,
    ordersorder.active,
    ordersorder.number,
    ordersorder.name,
    ordersorder.datefrom,
    ordersorder.dateto,
    ordersorder.startdate,
    ordersorder.finishdate,
    ordersorder.state,
    ordersorder.externalnumber,
    ordersorder.externalsynchronized,
    ordersorder.plannedquantity,
    ordersorder.donequantity,
    ordersorder.workplandelivered,
    ordersorder.deadline,
    ordersorder.ordercategory,
    COALESCE(ordersorder.plannedquantityforadditionalunit, ordersorder.plannedquantity) AS plannedquantityforadditionalunit,
    COALESCE(product.additionalunit, product.unit) AS unitforadditionalunit,
    product.number AS productnumber,
    technology.number AS technologynumber,
    product.unit,
    masterorder.number AS masterordernumber,
    division.name AS divisionname,
    company.number AS companyname,
    masterorderdefinition.number AS masterorderdefinitionnumber,
        CASE
            WHEN (EXISTS ( SELECT repairoder.id
               FROM public.repairs_repairorder repairoder
              WHERE (repairoder.order_id = ordersorder.id))) THEN true
            ELSE false
        END AS existsrepairorders,
    (masterorder.id)::integer AS masterorderid,
    ordersgroup.number AS ordersgroupnumber,
    ''::character varying(255) AS annotation
   FROM (((((((public.arch_orders_order ordersorder
     JOIN public.basic_product product ON ((product.id = ordersorder.product_id)))
     LEFT JOIN public.technologies_technology technology ON ((technology.id = ordersorder.technology_id)))
     LEFT JOIN public.basic_company company ON ((company.id = ordersorder.company_id)))
     LEFT JOIN public.arch_masterorders_masterorder masterorder ON ((masterorder.id = ordersorder.masterorder_id)))
     LEFT JOIN public.masterorders_masterorderdefinition masterorderdefinition ON ((masterorderdefinition.id = masterorder.masterorderdefinition_id)))
     LEFT JOIN public.arch_ordersgroups_ordersgroup ordersgroup ON ((ordersorder.ordersgroup_id = ordersgroup.id)))
     LEFT JOIN public.basic_division division ON ((division.id = technology.division_id)))
  WITH NO DATA;


--
-- Name: arch_ordersgroups_drafrptquantitydto; Type: VIEW; Schema: public; Owner: -
--

CREATE VIEW public.arch_ordersgroups_drafrptquantitydto AS
SELECT
    NULL::bigint AS id,
    NULL::character varying(255) AS number,
    NULL::numeric AS sum;


--
-- Name: basic_assortment; Type: TABLE; Schema: public; Owner: -
--

CREATE TABLE public.basic_assortment (
    id bigint NOT NULL,
    name character varying(255),
    active boolean DEFAULT true
);


--
-- Name: productionlines_productionline; Type: TABLE; Schema: public; Owner: -
--

CREATE TABLE public.productionlines_productionline (
    id bigint NOT NULL,
    number character varying(255),
    name character varying(2048),
    division_id bigint,
    place character varying(255),
    description character varying(2048),
    supportsalltechnologies boolean DEFAULT true,
    documentation character varying(255),
    supportsothertechnologiesworkstationtypes boolean DEFAULT true,
    quantityforotherworkstationtypes integer DEFAULT 1,
    active boolean DEFAULT true,
    eurocodsymbol character varying(3),
    availabilityindicator numeric(12,5),
    production boolean DEFAULT false,
    entityversion bigint DEFAULT 0,
    placeinscada character varying(255),
    printer_id bigint,
    printedlabelstype character varying(255),
    printedlabelstime timestamp without time zone,
    isblocked boolean DEFAULT false
);


--
-- Name: technologies_technologygroup; Type: TABLE; Schema: public; Owner: -
--

CREATE TABLE public.technologies_technologygroup (
    id bigint NOT NULL,
    number character varying(255),
    name character varying(2048),
    active boolean DEFAULT true,
    entityversion bigint DEFAULT 0
);


--
-- Name: technologies_technologyproductionline; Type: TABLE; Schema: public; Owner: -
--

CREATE TABLE public.technologies_technologyproductionline (
    id bigint NOT NULL,
    productionline_id bigint,
    technology_id bigint,
    master boolean DEFAULT false,
    standardperformance numeric(12,5),
    plannedstaff integer
);


--
-- Name: arch_mv_ordersgroups_ordersgroupdto; Type: MATERIALIZED VIEW; Schema: public; Owner: -
--

CREATE MATERIALIZED VIEW public.arch_mv_ordersgroups_ordersgroupdto AS
 WITH technology_group_numbers AS (
         SELECT o.ordersgroup_id,
            string_agg(DISTINCT (tg.number)::text, ', '::text) AS number
           FROM ((public.arch_orders_order o
             JOIN public.technologies_technology t ON ((o.technology_id = t.id)))
             JOIN public.technologies_technologygroup tg ON ((t.technologygroup_id = tg.id)))
          WHERE (o.ordersgroup_id IS NOT NULL)
          GROUP BY o.ordersgroup_id
        ), performance AS (
         SELECT o.ordersgroup_id,
            first_value(tpl.standardperformance) OVER (PARTITION BY o.ordersgroup_id ORDER BY o.id) AS performancenorm
           FROM (public.arch_orders_order o
             LEFT JOIN public.technologies_technologyproductionline tpl ON (((tpl.technology_id = o.technology_id) AND tpl.master)))
        )
 SELECT DISTINCT ordersgroup.id,
    ordersgroup.active,
    ordersgroup.number,
    assortment.name AS assortmentname,
    productionline.number AS productionlinenumber,
    ordersgroup.startdate,
    ordersgroup.finishdate,
    ordersgroup.deadline,
    ordersgroup.quantity,
    ordersgroup.producedquantity,
    ordersgroup.remainingquantity,
    ordersgroup.state,
    company.number AS company,
    ordersgroup.remainingquantityinorders,
    (COALESCE(ordersgroup.producedquantity, (0)::numeric) + COALESCE(drafrptquantity.sum, (0)::numeric)) AS producedquantitywithdraft,
    (COALESCE(ordersgroup.remainingquantityinorders, (0)::numeric) - COALESCE(drafrptquantity.sum, (0)::numeric)) AS remainingquantityinorderswithdraft,
    tgn.number AS technologygroup,
    p.performancenorm,
    (masterorder.deadline)::date AS clientdate
   FROM (((((((public.arch_ordersgroups_ordersgroup ordersgroup
     JOIN public.basic_assortment assortment ON ((ordersgroup.assortment_id = assortment.id)))
     JOIN public.productionlines_productionline productionline ON ((ordersgroup.productionline_id = productionline.id)))
     JOIN public.arch_masterorders_masterorder masterorder ON ((ordersgroup.masterorder_id = masterorder.id)))
     LEFT JOIN public.basic_company company ON ((company.id = masterorder.company_id)))
     LEFT JOIN public.arch_ordersgroups_drafrptquantitydto drafrptquantity ON ((ordersgroup.id = drafrptquantity.id)))
     LEFT JOIN technology_group_numbers tgn ON ((tgn.ordersgroup_id = ordersgroup.id)))
     LEFT JOIN performance p ON ((p.ordersgroup_id = ordersgroup.id)))
  WITH NO DATA;


--
-- Name: arch_productioncounting_productiontracking; Type: TABLE; Schema: public; Owner: -
--

CREATE TABLE public.arch_productioncounting_productiontracking (
    id bigint NOT NULL,
    number character varying(255),
    order_id bigint,
    technologyinstanceoperationcomponent_id bigint,
    shift_id bigint,
    state character varying(255) DEFAULT '01draft'::character varying,
    lasttracking boolean,
    machinetime integer,
    labortime integer,
    staff_id bigint,
    workstationtype_id bigint,
    division_id bigint,
    active boolean DEFAULT true,
    createdate timestamp without time zone,
    updatedate timestamp without time zone,
    createuser character varying(255),
    updateuser character varying(255),
    laststatechangefails boolean DEFAULT false,
    laststatechangefailcause character varying(255),
    isexternalsynchronized boolean DEFAULT true,
    timerangefrom timestamp without time zone,
    timerangeto timestamp without time zone,
    shiftstartday date,
    changeovertime integer,
    subcontractor_id bigint,
    technologyoperationcomponent_id bigint,
    entityversion bigint DEFAULT 0,
    repairorder_id bigint,
    correction_id bigint,
    iscorrection boolean DEFAULT false,
    planforordercompleted boolean DEFAULT false,
    workstation_id bigint,
    batch_id bigint,
    expirationdate date,
    qualityrating character varying(255),
    iscorrected boolean DEFAULT false,
    comments character varying(2048),
    archived boolean DEFAULT false
);


--
-- Name: arch_productioncounting_trackingoperationproductoutcomponent; Type: TABLE; Schema: public; Owner: -
--

CREATE TABLE public.arch_productioncounting_trackingoperationproductoutcomponent (
    id bigint NOT NULL,
    productiontracking_id bigint,
    product_id bigint,
    usedquantity numeric(14,5),
    balance numeric(14,5),
    batch_id bigint,
    wastedquantity numeric(14,5),
    givenunit character varying(255),
    givenquantity numeric(14,5),
    entityversion bigint DEFAULT 0,
    wastesquantity numeric(14,5),
    typeofmaterial character varying(255) DEFAULT '01component'::character varying,
    storagelocation_id bigint,
    causeofwastes character varying(255),
    palletnumber_id bigint,
    manyreasonsforlacks boolean DEFAULT false,
    typeofpallet character varying(255),
    archived boolean DEFAULT false
);


--
-- Name: arch_repairs_repairorder; Type: TABLE; Schema: public; Owner: -
--

CREATE TABLE public.arch_repairs_repairorder (
    id bigint NOT NULL,
    number character varying(255) NOT NULL,
    state character varying(255) DEFAULT '01draft'::character varying,
    order_id bigint,
    division_id bigint,
    createdate timestamp without time zone,
    shift_id bigint,
    startdate timestamp without time zone,
    enddate timestamp without time zone,
    staff_id bigint,
    product_id bigint,
    faulttype_id bigint,
    description character varying(2048),
    quantitytorepair numeric(12,5),
    quantityrepaired numeric(12,5),
    lack numeric(12,5),
    active boolean DEFAULT true,
    orderdto_id bigint,
    entityversion bigint DEFAULT 0,
    productiontracking_id bigint,
    labortime integer DEFAULT 0,
    machinetime integer DEFAULT 0,
    repairorderproduct_id bigint,
    archived boolean DEFAULT false
);


--
-- Name: basic_shift; Type: TABLE; Schema: public; Owner: -
--

CREATE TABLE public.basic_shift (
    id bigint NOT NULL,
    name character varying(1024),
    mondayworking boolean DEFAULT true,
    mondayhours character varying(255),
    tuesdayworking boolean DEFAULT true,
    tuesdayhours character varying(255),
    wensdayworking boolean DEFAULT true,
    wensdayhours character varying(255),
    thursdayworking boolean DEFAULT true,
    thursdayhours character varying(255),
    fridayworking boolean DEFAULT true,
    fridayhours character varying(255),
    saturdayworking boolean DEFAULT false,
    saturdayhours character varying(255),
    sundayworking boolean DEFAULT false,
    sundayhours character varying(255),
    entityversion bigint DEFAULT 0
);


--
-- Name: basic_staff; Type: TABLE; Schema: public; Owner: -
--

CREATE TABLE public.basic_staff (
    id bigint NOT NULL,
    number character varying(255),
    name character varying(255),
    surname character varying(255),
    email character varying(255),
    phone character varying(255),
    workfor_id bigint,
    post character varying(255),
    division_id bigint,
    individuallaborcost numeric(12,5),
    determinedindividual boolean,
    laborhourlycost numeric(12,5),
    wagegroup_id bigint,
    active boolean DEFAULT true,
    parameter_id bigint,
    entityversion bigint DEFAULT 0,
    crew_id bigint,
    workstation_id bigint,
    productionline_id bigint
);


--
-- Name: technologies_operation; Type: TABLE; Schema: public; Owner: -
--

CREATE TABLE public.technologies_operation (
    id bigint NOT NULL,
    number character varying(255),
    name character varying(1024),
    comment character varying(2048),
    workstationtype_id bigint,
    attachment character varying(255),
    areproductquantitiesdivisible boolean DEFAULT false,
    istjdivisible boolean DEFAULT false,
    operationgroup_id bigint,
    imageurlinworkplan character varying(255),
    productioninonecycle numeric(12,5) DEFAULT (1)::numeric,
    laborhourlycost numeric(12,5) DEFAULT (0)::numeric,
    laborutilization numeric(8,5) DEFAULT 1.0,
    nextoperationafterproducedtype character varying(255) DEFAULT '01all'::character varying,
    nextoperationafterproducedquantityunit character varying(255),
    machinehourlycost numeric(12,5) DEFAULT (0)::numeric,
    tj integer DEFAULT 0,
    nextoperationafterproducedquantity numeric(12,5) DEFAULT (0)::numeric,
    machineutilization numeric(8,5) DEFAULT 1.0,
    timenextoperation integer DEFAULT 0,
    tpz integer DEFAULT 0,
    productioninonecycleunit character varying(255),
    active boolean DEFAULT true,
    issubcontracting boolean DEFAULT false,
    assignedtooperation character varying(255) DEFAULT '02workstationTypes'::character varying,
    quantityofworkstations integer DEFAULT 1,
    division_id bigint,
    showinproductdata boolean DEFAULT false,
    productdatanumber numeric(12,5) DEFAULT (0)::numeric,
    entityversion bigint DEFAULT 0,
    product_id bigint,
    createoperationoutput boolean DEFAULT false,
    tjdecreasesforenlargedstaff boolean DEFAULT false,
    minstaff integer DEFAULT 1,
    optimalstaff integer DEFAULT 1,
    pieceworkproduction boolean DEFAULT false,
    piecerate_id bigint,
    unitcost numeric(12,5),
    reservationrawmaterialresourcerequired boolean DEFAULT false,
    optimizecutting boolean
);


--
-- Name: technologies_technologyoperationcomponent; Type: TABLE; Schema: public; Owner: -
--

CREATE TABLE public.technologies_technologyoperationcomponent (
    id bigint NOT NULL,
    technology_id bigint,
    operation_id bigint,
    parent_id bigint,
    entitytype character varying(255),
    priority integer,
    nodenumber character varying(255),
    comment character varying(2048),
    attachment character varying(255),
    areproductquantitiesdivisible boolean DEFAULT false,
    istjdivisible boolean DEFAULT false,
    tpz integer DEFAULT 0,
    laborworktime integer DEFAULT 0,
    productioninonecycleunit character varying(255),
    nextoperationafterproducedquantityunit character varying(255),
    nextoperationafterproducedquantity numeric(12,5) DEFAULT (0)::numeric,
    nextoperationafterproducedtype character varying(255) DEFAULT '01all'::character varying,
    machineutilization numeric(8,5) DEFAULT 1.0,
    timenextoperation integer DEFAULT 0,
    machineworktime integer DEFAULT 0,
    productioninonecycle numeric(12,5) DEFAULT (1)::numeric,
    laborutilization numeric(8,5) DEFAULT 1.0,
    duration integer DEFAULT 0,
    tj integer DEFAULT 0,
    machinehourlycost numeric(12,5) DEFAULT (0)::numeric,
    laborhourlycost numeric(12,5) DEFAULT (0)::numeric,
    issubcontracting boolean DEFAULT false,
    assignedtooperation character varying(255) DEFAULT '02workstationTypes'::character varying,
    workstationtype_id bigint,
    quantityofworkstations integer DEFAULT 1,
    createdate timestamp without time zone,
    updatedate timestamp without time zone,
    createuser character varying(255),
    updateuser character varying(255),
    techopercomptimecalculation_id bigint,
    hascorrections boolean,
    division_id bigint,
    showinproductdata boolean,
    productdatanumber numeric(12,5) DEFAULT (0)::numeric,
    entityversion bigint DEFAULT 0,
    technologicalprocesslist_id bigint,
    technologicalprocesslistassignmentdate timestamp without time zone,
    tjdecreasesforenlargedstaff boolean DEFAULT false,
    minstaff integer DEFAULT 1,
    optimalstaff integer DEFAULT 1,
    pieceworkproduction boolean DEFAULT false,
    piecerate_id bigint,
    unitcost numeric(12,5)
);


--
-- Name: arch_mv_productioncounting_productiontrackingdto; Type: MATERIALIZED VIEW; Schema: public; Owner: -
--

CREATE MATERIALIZED VIEW public.arch_mv_productioncounting_productiontrackingdto AS
 SELECT productiontracking.id,
    productiontracking.number,
    productiontracking.state,
    productiontracking.createdate,
    productiontracking.lasttracking,
    productiontracking.timerangefrom,
    productiontracking.timerangeto,
    productiontracking.active,
    (ordersorder.id)::integer AS order_id,
    ordersorder.number AS ordernumber,
    ordersorder.state AS orderstate,
    (technologyoperationcomponent.id)::integer AS technologyoperationcomponent_id,
    COALESCE((((technologyoperationcomponent.nodenumber)::text || ' '::text) || (operation.name)::text), ''::text) AS technologyoperationcomponentnumber,
    (operation.id)::integer AS operation_id,
    (shift.id)::integer AS shift_id,
    shift.name AS shiftname,
    (staff.id)::integer AS staff_id,
    (((staff.surname)::text || ' '::text) || (staff.name)::text) AS staffname,
    (division.id)::integer AS division_id,
    division.number AS divisionnumber,
    (subcontractor.id)::integer AS subcontractor_id,
    subcontractor.name AS subcontractorname,
    (repairorder.id)::integer AS repairorder_id,
    repairorder.number AS repairordernumber,
    productiontrackingcorrection.number AS correctionnumber,
    (productionline.id)::integer AS productionline_id,
    productionline.number AS productionlinenumber,
    ordersgroup.number AS ordersgroup,
    concat(product.number, ' - ', product.name) AS productnumber,
    product.unit AS productunit,
    outcomponent.usedquantity,
    company.number AS companynumber,
    COALESCE((((outproduct.number)::text || ' - '::text) || (outproduct.name)::text), (((product.number)::text || ' - '::text) || (product.name)::text)) AS outproductnumber
   FROM ((((((((((((((((public.arch_productioncounting_productiontracking productiontracking
     JOIN public.arch_orders_order ordersorder ON ((ordersorder.id = productiontracking.order_id)))
     JOIN public.basic_product product ON ((ordersorder.product_id = product.id)))
     JOIN public.productionlines_productionline productionline ON ((productionline.id = ordersorder.productionline_id)))
     LEFT JOIN public.technologies_technologyoperationcomponent technologyoperationcomponent ON ((technologyoperationcomponent.id = productiontracking.technologyoperationcomponent_id)))
     LEFT JOIN public.technologies_operation operation ON ((operation.id = technologyoperationcomponent.operation_id)))
     LEFT JOIN public.basic_shift shift ON ((shift.id = productiontracking.shift_id)))
     LEFT JOIN public.basic_staff staff ON ((staff.id = productiontracking.staff_id)))
     LEFT JOIN public.basic_division division ON ((division.id = productiontracking.division_id)))
     LEFT JOIN public.basic_company subcontractor ON ((subcontractor.id = productiontracking.subcontractor_id)))
     LEFT JOIN public.arch_productioncounting_productiontracking productiontrackingcorrection ON ((productiontrackingcorrection.id = productiontracking.correction_id)))
     LEFT JOIN public.arch_repairs_repairorder repairorder ON ((repairorder.id = productiontracking.repairorder_id)))
     LEFT JOIN public.arch_ordersgroups_ordersgroup ordersgroup ON ((ordersgroup.id = ordersorder.ordersgroup_id)))
     LEFT JOIN public.basic_company company ON ((company.id = ordersorder.company_id)))
     LEFT JOIN public.arch_basicproductioncounting_productioncountingquantity pcq ON (((pcq.order_id = ordersorder.id) AND (pcq.technologyoperationcomponent_id = technologyoperationcomponent.id) AND ((pcq.typeofmaterial)::text = ANY (ARRAY[('02intermediate'::character varying)::text, ('03finalProduct'::character varying)::text])) AND ((pcq.role)::text = '02produced'::text))))
     LEFT JOIN public.basic_product outproduct ON ((pcq.product_id = outproduct.id)))
     LEFT JOIN public.arch_productioncounting_trackingoperationproductoutcomponent outcomponent ON ((((outcomponent.product_id = outproduct.id) OR (outcomponent.product_id = product.id)) AND (productiontracking.id = outcomponent.productiontracking_id))))
  WITH NO DATA;


--
-- Name: arch_orders_operationaltask; Type: TABLE; Schema: public; Owner: -
--

CREATE TABLE public.arch_orders_operationaltask (
    id bigint NOT NULL,
    number character varying(256),
    name character varying(1024),
    description character varying(1024),
    type character varying(255),
    startdate timestamp without time zone,
    finishdate timestamp without time zone,
    order_id bigint,
    entityversion bigint DEFAULT 0,
    staff_id bigint,
    workstation_id bigint,
    state character varying(255) DEFAULT '01pending'::character varying,
    technologyoperationcomponent_id bigint,
    product_id bigint,
    scheduleposition_id bigint,
    division_id bigint,
    actualstaff integer,
    suborder_id bigint,
    archived boolean DEFAULT false
);


--
-- Name: arch_orders_operationaltask_id_seq; Type: SEQUENCE; Schema: public; Owner: -
--

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


--
-- Name: arch_orders_operationaltask_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: -
--

ALTER SEQUENCE public.arch_orders_operationaltask_id_seq OWNED BY public.arch_orders_operationaltask.id;


--
-- Name: arch_orders_operationaltaskstatechange; Type: TABLE; Schema: public; Owner: -
--

CREATE TABLE public.arch_orders_operationaltaskstatechange (
    id bigint NOT NULL,
    dateandtime timestamp without time zone,
    sourcestate character varying(255),
    targetstate character varying(255),
    status character varying(255),
    phase integer,
    worker character varying(255),
    operationaltask_id bigint,
    shift_id bigint,
    archived boolean DEFAULT false
);


--
-- Name: arch_orders_operationaltaskstatechange_id_seq; Type: SEQUENCE; Schema: public; Owner: -
--

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


--
-- Name: arch_orders_operationaltaskstatechange_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: -
--

ALTER SEQUENCE public.arch_orders_operationaltaskstatechange_id_seq OWNED BY public.arch_orders_operationaltaskstatechange.id;


--
-- Name: arch_orders_order_id_seq; Type: SEQUENCE; Schema: public; Owner: -
--

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


--
-- Name: arch_orders_order_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: -
--

ALTER SEQUENCE public.arch_orders_order_id_seq OWNED BY public.arch_orders_order.id;


--
-- Name: arch_orders_orderlistdto; Type: VIEW; Schema: public; Owner: -
--

CREATE VIEW public.arch_orders_orderlistdto AS
 SELECT arch_mv_orders_orderlistdto.id,
    arch_mv_orders_orderlistdto.active,
    arch_mv_orders_orderlistdto.number,
    arch_mv_orders_orderlistdto.name,
    arch_mv_orders_orderlistdto.datefrom,
    arch_mv_orders_orderlistdto.dateto,
    arch_mv_orders_orderlistdto.startdate,
    arch_mv_orders_orderlistdto.finishdate,
    arch_mv_orders_orderlistdto.state,
    arch_mv_orders_orderlistdto.externalnumber,
    arch_mv_orders_orderlistdto.externalsynchronized,
    arch_mv_orders_orderlistdto.plannedquantity,
    arch_mv_orders_orderlistdto.donequantity,
    arch_mv_orders_orderlistdto.workplandelivered,
    arch_mv_orders_orderlistdto.deadline,
    arch_mv_orders_orderlistdto.ordercategory,
    arch_mv_orders_orderlistdto.plannedquantityforadditionalunit,
    arch_mv_orders_orderlistdto.unitforadditionalunit,
    arch_mv_orders_orderlistdto.productnumber,
    arch_mv_orders_orderlistdto.technologynumber,
    arch_mv_orders_orderlistdto.unit,
    arch_mv_orders_orderlistdto.masterordernumber,
    arch_mv_orders_orderlistdto.divisionname,
    arch_mv_orders_orderlistdto.companyname,
    arch_mv_orders_orderlistdto.masterorderdefinitionnumber,
    arch_mv_orders_orderlistdto.existsrepairorders,
    arch_mv_orders_orderlistdto.masterorderid,
    arch_mv_orders_orderlistdto.ordersgroupnumber,
    arch_mv_orders_orderlistdto.annotation
   FROM public.arch_mv_orders_orderlistdto;


--
-- Name: arch_orders_orderlistdto_id_seq; Type: SEQUENCE; Schema: public; Owner: -
--

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


--
-- Name: arch_orders_orderpack; Type: TABLE; Schema: public; Owner: -
--

CREATE TABLE public.arch_orders_orderpack (
    id bigint NOT NULL,
    number character varying(255),
    order_id bigint,
    quantity numeric(12,5),
    state character varying(255) DEFAULT '01pending'::character varying,
    archived boolean DEFAULT false
);


--
-- Name: arch_orders_orderpack_id_seq; Type: SEQUENCE; Schema: public; Owner: -
--

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


--
-- Name: arch_orders_orderpack_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: -
--

ALTER SEQUENCE public.arch_orders_orderpack_id_seq OWNED BY public.arch_orders_orderpack.id;


--
-- Name: arch_orders_orderpackstatechange; Type: TABLE; Schema: public; Owner: -
--

CREATE TABLE public.arch_orders_orderpackstatechange (
    id bigint NOT NULL,
    dateandtime timestamp without time zone,
    sourcestate character varying(255),
    targetstate character varying(255),
    status character varying(255),
    phase integer,
    worker character varying(255),
    orderpack_id bigint,
    shift_id bigint,
    archived boolean DEFAULT false
);


--
-- Name: arch_orders_orderpackstatechange_id_seq; Type: SEQUENCE; Schema: public; Owner: -
--

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


--
-- Name: arch_orders_orderpackstatechange_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: -
--

ALTER SEQUENCE public.arch_orders_orderpackstatechange_id_seq OWNED BY public.arch_orders_orderpackstatechange.id;


--
-- Name: arch_orders_orderstatechange; Type: TABLE; Schema: public; Owner: -
--

CREATE TABLE public.arch_orders_orderstatechange (
    id bigint NOT NULL,
    comment character varying(255),
    reasonrequired boolean DEFAULT false,
    dateandtime timestamp without time zone,
    sourcestate character varying(255),
    targetstate character varying(255),
    status character varying(255) DEFAULT '01inProgress'::character varying,
    phase integer,
    worker character varying(255),
    order_id bigint,
    shift_id bigint,
    additionalinformation character varying(255),
    sourcecorrecteddatefrom timestamp without time zone,
    sourcecorrecteddateto timestamp without time zone,
    sourcestartdate timestamp without time zone,
    sourcefinishdate timestamp without time zone,
    targetcorrecteddatefrom timestamp without time zone,
    targetcorrecteddateto timestamp without time zone,
    targetstartdate timestamp without time zone,
    targetfinishdate timestamp without time zone,
    dateschanged boolean DEFAULT false,
    entityversion bigint DEFAULT 0,
    archived boolean DEFAULT false
);


--
-- Name: arch_orders_orderstatechange_id_seq; Type: SEQUENCE; Schema: public; Owner: -
--

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


--
-- Name: arch_orders_orderstatechange_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: -
--

ALTER SEQUENCE public.arch_orders_orderstatechange_id_seq OWNED BY public.arch_orders_orderstatechange.id;


--
-- Name: arch_orders_ordertechnologicalprocess; Type: TABLE; Schema: public; Owner: -
--

CREATE TABLE public.arch_orders_ordertechnologicalprocess (
    id bigint NOT NULL,
    number character varying(255),
    orderpack_id bigint,
    order_id bigint,
    product_id bigint,
    operation_id bigint,
    technologicalprocess_id bigint,
    quantity numeric(12,5),
    worker_id bigint,
    date timestamp without time zone,
    wastesquantity numeric(12,5),
    technologyoperationcomponent_id bigint,
    createdate timestamp without time zone,
    archived boolean DEFAULT false
);


--
-- Name: arch_orders_ordertechnologicalprocess_id_seq; Type: SEQUENCE; Schema: public; Owner: -
--

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


--
-- Name: arch_orders_ordertechnologicalprocess_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: -
--

ALTER SEQUENCE public.arch_orders_ordertechnologicalprocess_id_seq OWNED BY public.arch_orders_ordertechnologicalprocess.id;


--
-- Name: arch_orders_ordertechnologicalprocesspart; Type: TABLE; Schema: public; Owner: -
--

CREATE TABLE public.arch_orders_ordertechnologicalprocesspart (
    id bigint NOT NULL,
    number character varying(255),
    quantity numeric(12,5),
    ordertechnologicalprocess_id bigint,
    archived boolean DEFAULT false
);


--
-- Name: arch_orders_ordertechnologicalprocesspart_id_seq; Type: SEQUENCE; Schema: public; Owner: -
--

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


--
-- Name: arch_orders_ordertechnologicalprocesspart_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: -
--

ALTER SEQUENCE public.arch_orders_ordertechnologicalprocesspart_id_seq OWNED BY public.arch_orders_ordertechnologicalprocesspart.id;


--
-- Name: arch_orders_ordertechnologicalprocesswaste; Type: TABLE; Schema: public; Owner: -
--

CREATE TABLE public.arch_orders_ordertechnologicalprocesswaste (
    id bigint NOT NULL,
    number character varying(255),
    ordertechnologicalprocess_id bigint,
    orderpack_id bigint,
    order_id bigint,
    product_id bigint,
    technologicalprocess_id bigint,
    wastequantity numeric(12,5),
    causeofwaste character varying(255),
    worker_id bigint,
    date timestamp without time zone,
    description character varying(2048),
    archived boolean DEFAULT false
);


--
-- Name: arch_orders_ordertechnologicalprocesswaste_id_seq; Type: SEQUENCE; Schema: public; Owner: -
--

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


--
-- Name: arch_orders_ordertechnologicalprocesswaste_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: -
--

ALTER SEQUENCE public.arch_orders_ordertechnologicalprocesswaste_id_seq OWNED BY public.arch_orders_ordertechnologicalprocesswaste.id;


--
-- Name: arch_orders_productionlinescheduleposition; Type: TABLE; Schema: public; Owner: -
--

CREATE TABLE public.arch_orders_productionlinescheduleposition (
    id bigint NOT NULL,
    productionlineschedule_id bigint,
    order_id bigint,
    productionline_id bigint,
    linechangeovernorm_id bigint,
    starttime timestamp without time zone,
    endtime timestamp without time zone,
    additionaltime integer DEFAULT 0,
    archived boolean DEFAULT false
);


--
-- Name: arch_orders_productionlinescheduleposition_id_seq; Type: SEQUENCE; Schema: public; Owner: -
--

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


--
-- Name: arch_orders_productionlinescheduleposition_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: -
--

ALTER SEQUENCE public.arch_orders_productionlinescheduleposition_id_seq OWNED BY public.arch_orders_productionlinescheduleposition.id;


--
-- Name: arch_orders_reasontypecorrectiondatefrom; Type: TABLE; Schema: public; Owner: -
--

CREATE TABLE public.arch_orders_reasontypecorrectiondatefrom (
    id bigint NOT NULL,
    order_id bigint,
    reasontypeofchangingorderstate character varying(255),
    date timestamp without time zone,
    entityversion bigint DEFAULT 0,
    changedateshelper_id bigint,
    archived boolean DEFAULT false
);


--
-- Name: arch_orders_reasontypecorrectiondatefrom_id_seq; Type: SEQUENCE; Schema: public; Owner: -
--

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


--
-- Name: arch_orders_reasontypecorrectiondatefrom_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: -
--

ALTER SEQUENCE public.arch_orders_reasontypecorrectiondatefrom_id_seq OWNED BY public.arch_orders_reasontypecorrectiondatefrom.id;


--
-- Name: arch_orders_reasontypecorrectiondateto; Type: TABLE; Schema: public; Owner: -
--

CREATE TABLE public.arch_orders_reasontypecorrectiondateto (
    id bigint NOT NULL,
    order_id bigint,
    reasontypeofchangingorderstate character varying(255),
    date timestamp without time zone,
    entityversion bigint DEFAULT 0,
    changedateshelper_id bigint,
    archived boolean DEFAULT false
);


--
-- Name: arch_orders_reasontypecorrectiondateto_id_seq; Type: SEQUENCE; Schema: public; Owner: -
--

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


--
-- Name: arch_orders_reasontypecorrectiondateto_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: -
--

ALTER SEQUENCE public.arch_orders_reasontypecorrectiondateto_id_seq OWNED BY public.arch_orders_reasontypecorrectiondateto.id;


--
-- Name: arch_orders_reasontypedeviationeffectiveend; Type: TABLE; Schema: public; Owner: -
--

CREATE TABLE public.arch_orders_reasontypedeviationeffectiveend (
    id bigint NOT NULL,
    order_id bigint,
    reasontypeofchangingorderstate character varying(255),
    date timestamp without time zone,
    entityversion bigint DEFAULT 0,
    archived boolean DEFAULT false
);


--
-- Name: arch_orders_reasontypedeviationeffectiveend_id_seq; Type: SEQUENCE; Schema: public; Owner: -
--

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


--
-- Name: arch_orders_reasontypedeviationeffectiveend_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: -
--

ALTER SEQUENCE public.arch_orders_reasontypedeviationeffectiveend_id_seq OWNED BY public.arch_orders_reasontypedeviationeffectiveend.id;


--
-- Name: arch_orders_reasontypedeviationeffectivestart; Type: TABLE; Schema: public; Owner: -
--

CREATE TABLE public.arch_orders_reasontypedeviationeffectivestart (
    id bigint NOT NULL,
    order_id bigint,
    reasontypeofchangingorderstate character varying(255),
    date timestamp without time zone,
    entityversion bigint DEFAULT 0,
    archived boolean DEFAULT false
);


--
-- Name: arch_orders_reasontypedeviationeffectivestart_id_seq; Type: SEQUENCE; Schema: public; Owner: -
--

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


--
-- Name: arch_orders_reasontypedeviationeffectivestart_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: -
--

ALTER SEQUENCE public.arch_orders_reasontypedeviationeffectivestart_id_seq OWNED BY public.arch_orders_reasontypedeviationeffectivestart.id;


--
-- Name: arch_orders_reasontypeofchangingorderstate; Type: TABLE; Schema: public; Owner: -
--

CREATE TABLE public.arch_orders_reasontypeofchangingorderstate (
    id bigint NOT NULL,
    orderstatechange_id bigint,
    reasontypeofchangingorderstate character varying(255),
    entityversion bigint DEFAULT 0,
    archived boolean DEFAULT false
);


--
-- Name: arch_orders_reasontypeofchangingorderstate_id_seq; Type: SEQUENCE; Schema: public; Owner: -
--

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


--
-- Name: arch_orders_reasontypeofchangingorderstate_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: -
--

ALTER SEQUENCE public.arch_orders_reasontypeofchangingorderstate_id_seq OWNED BY public.arch_orders_reasontypeofchangingorderstate.id;


--
-- Name: arch_orders_scheduleposition; Type: TABLE; Schema: public; Owner: -
--

CREATE TABLE public.arch_orders_scheduleposition (
    id bigint NOT NULL,
    schedule_id bigint,
    technologyoperationcomponent_id bigint,
    additionaltime integer DEFAULT 0,
    machineworktime integer DEFAULT 0,
    laborworktime integer DEFAULT 0,
    order_id bigint,
    product_id bigint,
    workstation_id bigint,
    quantity numeric(14,5),
    starttime timestamp without time zone,
    endtime timestamp without time zone,
    staff_id bigint,
    operationruns numeric(12,5),
    partialoperationruns numeric(12,5),
    archived boolean DEFAULT false
);


--
-- Name: arch_orders_scheduleposition_id_seq; Type: SEQUENCE; Schema: public; Owner: -
--

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


--
-- Name: arch_orders_scheduleposition_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: -
--

ALTER SEQUENCE public.arch_orders_scheduleposition_id_seq OWNED BY public.arch_orders_scheduleposition.id;


--
-- Name: arch_orders_typeofcorrectioncauses; Type: TABLE; Schema: public; Owner: -
--

CREATE TABLE public.arch_orders_typeofcorrectioncauses (
    id bigint NOT NULL,
    order_id bigint,
    reasontype character varying(255),
    date timestamp without time zone,
    entityversion bigint DEFAULT 0,
    archived boolean DEFAULT false
);


--
-- Name: arch_orders_typeofcorrectioncauses_id_seq; Type: SEQUENCE; Schema: public; Owner: -
--

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


--
-- Name: arch_orders_typeofcorrectioncauses_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: -
--

ALTER SEQUENCE public.arch_orders_typeofcorrectioncauses_id_seq OWNED BY public.arch_orders_typeofcorrectioncauses.id;


--
-- Name: arch_ordersforsubproductsgeneration_suborders; Type: TABLE; Schema: public; Owner: -
--

CREATE TABLE public.arch_ordersforsubproductsgeneration_suborders (
    id bigint NOT NULL,
    order_id bigint,
    ordersgroup_id bigint,
    createdate timestamp without time zone,
    updatedate timestamp without time zone,
    createuser character varying(255),
    updateuser character varying(255),
    ordersgroupsgenerated boolean DEFAULT false,
    generatedorders boolean DEFAULT false,
    ordergenerationinprogress boolean DEFAULT false,
    archived boolean DEFAULT false
);


--
-- Name: arch_ordersforsubproductsgeneration_suborders_id_seq; Type: SEQUENCE; Schema: public; Owner: -
--

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


--
-- Name: arch_ordersforsubproductsgeneration_suborders_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: -
--

ALTER SEQUENCE public.arch_ordersforsubproductsgeneration_suborders_id_seq OWNED BY public.arch_ordersforsubproductsgeneration_suborders.id;


--
-- Name: arch_ordersgroups_drafrptquantitydto_id_seq; Type: SEQUENCE; Schema: public; Owner: -
--

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


--
-- Name: arch_ordersgroups_ordersgroup_id_seq; Type: SEQUENCE; Schema: public; Owner: -
--

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


--
-- Name: arch_ordersgroups_ordersgroup_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: -
--

ALTER SEQUENCE public.arch_ordersgroups_ordersgroup_id_seq OWNED BY public.arch_ordersgroups_ordersgroup.id;


--
-- Name: arch_ordersgroups_ordersgroupdto; Type: VIEW; Schema: public; Owner: -
--

CREATE VIEW public.arch_ordersgroups_ordersgroupdto AS
 SELECT arch_mv_ordersgroups_ordersgroupdto.id,
    arch_mv_ordersgroups_ordersgroupdto.active,
    arch_mv_ordersgroups_ordersgroupdto.number,
    arch_mv_ordersgroups_ordersgroupdto.assortmentname,
    arch_mv_ordersgroups_ordersgroupdto.productionlinenumber,
    arch_mv_ordersgroups_ordersgroupdto.startdate,
    arch_mv_ordersgroups_ordersgroupdto.finishdate,
    arch_mv_ordersgroups_ordersgroupdto.deadline,
    arch_mv_ordersgroups_ordersgroupdto.quantity,
    arch_mv_ordersgroups_ordersgroupdto.producedquantity,
    arch_mv_ordersgroups_ordersgroupdto.remainingquantity,
    arch_mv_ordersgroups_ordersgroupdto.state,
    arch_mv_ordersgroups_ordersgroupdto.company,
    arch_mv_ordersgroups_ordersgroupdto.remainingquantityinorders,
    arch_mv_ordersgroups_ordersgroupdto.producedquantitywithdraft,
    arch_mv_ordersgroups_ordersgroupdto.remainingquantityinorderswithdraft,
    arch_mv_ordersgroups_ordersgroupdto.technologygroup,
    arch_mv_ordersgroups_ordersgroupdto.performancenorm,
    arch_mv_ordersgroups_ordersgroupdto.clientdate
   FROM public.arch_mv_ordersgroups_ordersgroupdto;


--
-- Name: arch_ordersgroups_ordersgroupdto_id_seq; Type: SEQUENCE; Schema: public; Owner: -
--

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


--
-- Name: arch_ordersgroups_ordersgroupissuedmaterial; Type: TABLE; Schema: public; Owner: -
--

CREATE TABLE public.arch_ordersgroups_ordersgroupissuedmaterial (
    id bigint NOT NULL,
    ordersgroup_id bigint,
    product_id bigint,
    quantity numeric(14,5),
    value numeric(14,5),
    averageprice numeric(11,2),
    archived boolean DEFAULT false
);


--
-- Name: arch_ordersgroups_ordersgroupissuedmaterial_id_seq; Type: SEQUENCE; Schema: public; Owner: -
--

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


--
-- Name: arch_ordersgroups_ordersgroupissuedmaterial_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: -
--

ALTER SEQUENCE public.arch_ordersgroups_ordersgroupissuedmaterial_id_seq OWNED BY public.arch_ordersgroups_ordersgroupissuedmaterial.id;


--
-- Name: arch_ordersgroups_ordersgroupissuedmaterialposition; Type: TABLE; Schema: public; Owner: -
--

CREATE TABLE public.arch_ordersgroups_ordersgroupissuedmaterialposition (
    id bigint NOT NULL,
    ordersgroupissuedmaterial_id bigint,
    documentnumber character varying(255),
    quantity numeric(14,5),
    price numeric(14,5),
    value numeric(14,5),
    externaldocumentid character varying(255),
    archived boolean DEFAULT false
);


--
-- Name: arch_ordersgroups_ordersgroupissuedmaterialposition_id_seq; Type: SEQUENCE; Schema: public; Owner: -
--

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


--
-- Name: arch_ordersgroups_ordersgroupissuedmaterialposition_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: -
--

ALTER SEQUENCE public.arch_ordersgroups_ordersgroupissuedmaterialposition_id_seq OWNED BY public.arch_ordersgroups_ordersgroupissuedmaterialposition.id;


--
-- Name: arch_ordersgroups_ordersgroupmaterialrequirement; Type: TABLE; Schema: public; Owner: -
--

CREATE TABLE public.arch_ordersgroups_ordersgroupmaterialrequirement (
    id bigint NOT NULL,
    number character varying(256),
    ordersgroup_id bigint,
    generated boolean,
    worker character varying(255),
    date timestamp without time zone,
    filename character varying(255),
    archived boolean DEFAULT false
);


--
-- Name: arch_ordersgroups_ordersgroupmaterialrequirement_id_seq; Type: SEQUENCE; Schema: public; Owner: -
--

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


--
-- Name: arch_ordersgroups_ordersgroupmaterialrequirement_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: -
--

ALTER SEQUENCE public.arch_ordersgroups_ordersgroupmaterialrequirement_id_seq OWNED BY public.arch_ordersgroups_ordersgroupmaterialrequirement.id;


--
-- Name: arch_ordersgroups_ordersgroupmaterialrequirementproduct; Type: TABLE; Schema: public; Owner: -
--

CREATE TABLE public.arch_ordersgroups_ordersgroupmaterialrequirementproduct (
    id bigint NOT NULL,
    ordersgroupmaterialrequirement_id bigint,
    product_id bigint,
    quantity numeric(14,5),
    currentstock numeric(14,5),
    technologyinputproducttype_id bigint,
    orderstartdate date,
    division_id bigint,
    location_id bigint,
    issuedquantity numeric(14,5),
    supplier_id bigint,
    archived boolean DEFAULT false
);


--
-- Name: arch_ordersgroups_ordersgroupmaterialrequirementproduct_id_seq; Type: SEQUENCE; Schema: public; Owner: -
--

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


--
-- Name: arch_ordersgroups_ordersgroupmaterialrequirementproduct_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: -
--

ALTER SEQUENCE public.arch_ordersgroups_ordersgroupmaterialrequirementproduct_id_seq OWNED BY public.arch_ordersgroups_ordersgroupmaterialrequirementproduct.id;


--
-- Name: arch_ordersgroups_ordersgroupproducedproduct; Type: TABLE; Schema: public; Owner: -
--

CREATE TABLE public.arch_ordersgroups_ordersgroupproducedproduct (
    id bigint NOT NULL,
    ordersgroup_id bigint,
    product_id bigint,
    location_id bigint,
    document_id bigint,
    quantity numeric(14,5),
    accepted boolean DEFAULT false,
    externaldocumentnumber character varying(255),
    batch_id bigint,
    storagelocation_id bigint,
    palletnumber_id bigint,
    typeofpallet character varying(255),
    archived boolean DEFAULT false
);


--
-- Name: arch_ordersgroups_ordersgroupproducedproduct_id_seq; Type: SEQUENCE; Schema: public; Owner: -
--

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


--
-- Name: arch_ordersgroups_ordersgroupproducedproduct_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: -
--

ALTER SEQUENCE public.arch_ordersgroups_ordersgroupproducedproduct_id_seq OWNED BY public.arch_ordersgroups_ordersgroupproducedproduct.id;


--
-- Name: arch_ordersgroups_ordersgroupproductstoissueentryhelper; Type: TABLE; Schema: public; Owner: -
--

CREATE TABLE public.arch_ordersgroups_ordersgroupproductstoissueentryhelper (
    id bigint NOT NULL,
    ordersgroupmaterialrequirementproduct_id bigint,
    ordersgroupproductstoissuehelper_id bigint,
    quantity numeric(12,5),
    archived boolean DEFAULT false
);


--
-- Name: arch_ordersgroups_ordersgroupproductstoissueentryhelper_id_seq; Type: SEQUENCE; Schema: public; Owner: -
--

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


--
-- Name: arch_ordersgroups_ordersgroupproductstoissueentryhelper_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: -
--

ALTER SEQUENCE public.arch_ordersgroups_ordersgroupproductstoissueentryhelper_id_seq OWNED BY public.arch_ordersgroups_ordersgroupproductstoissueentryhelper.id;


--
-- Name: arch_ordersgroups_ordersgroupproductstoissuehelper; Type: TABLE; Schema: public; Owner: -
--

CREATE TABLE public.arch_ordersgroups_ordersgroupproductstoissuehelper (
    id bigint NOT NULL,
    ordersgroupmaterialrequirement_id bigint,
    archived boolean DEFAULT false
);


--
-- Name: arch_ordersgroups_ordersgroupproductstoissuehelper_id_seq; Type: SEQUENCE; Schema: public; Owner: -
--

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


--
-- Name: arch_ordersgroups_ordersgroupproductstoissuehelper_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: -
--

ALTER SEQUENCE public.arch_ordersgroups_ordersgroupproductstoissuehelper_id_seq OWNED BY public.arch_ordersgroups_ordersgroupproductstoissuehelper.id;


--
-- Name: arch_ordersgroups_productionbalance; Type: TABLE; Schema: public; Owner: -
--

CREATE TABLE public.arch_ordersgroups_productionbalance (
    id bigint NOT NULL,
    number character varying(255),
    name character varying(255),
    generated boolean,
    worker character varying(255),
    date timestamp without time zone,
    filename character varying(255),
    ordersgroup_id bigint,
    plannedmaterialcost character varying(255) DEFAULT '01nominal'::character varying,
    usenominalcostpricenotspecified boolean DEFAULT false,
    realmaterialcost character varying(255) DEFAULT '01ordersgroupsdocuments'::character varying,
    orderedquantity numeric(14,5),
    producedquantity numeric(14,5),
    quantitydeviation numeric(14,5),
    plannedcost numeric(14,5),
    realcost numeric(14,5),
    costdeviation numeric(14,5),
    active boolean DEFAULT true,
    archived boolean DEFAULT false
);


--
-- Name: arch_ordersgroups_productionbalance_id_seq; Type: SEQUENCE; Schema: public; Owner: -
--

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


--
-- Name: arch_ordersgroups_productionbalance_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: -
--

ALTER SEQUENCE public.arch_ordersgroups_productionbalance_id_seq OWNED BY public.arch_ordersgroups_productionbalance.id;


--
-- Name: arch_ordersupplies_coverageanalysisfororder; Type: TABLE; Schema: public; Owner: -
--

CREATE TABLE public.arch_ordersupplies_coverageanalysisfororder (
    id bigint NOT NULL,
    order_id bigint,
    orderedproduct_id bigint,
    plannedquantity numeric(16,5),
    coveragedegree character varying(255),
    coveredfromtheday timestamp without time zone,
    deliverytime timestamp without time zone,
    componentsproductiondate timestamp without time zone,
    materialrequirementcoverage_id bigint,
    archived boolean DEFAULT false
);


--
-- Name: arch_ordersupplies_coverageanalysisfororder_id_seq; Type: SEQUENCE; Schema: public; Owner: -
--

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


--
-- Name: arch_ordersupplies_coverageanalysisfororder_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: -
--

ALTER SEQUENCE public.arch_ordersupplies_coverageanalysisfororder_id_seq OWNED BY public.arch_ordersupplies_coverageanalysisfororder.id;


--
-- Name: arch_ordersupplies_coveragelocation; Type: TABLE; Schema: public; Owner: -
--

CREATE TABLE public.arch_ordersupplies_coveragelocation (
    id bigint NOT NULL,
    materialrequirementcoverage_id bigint,
    location_id bigint,
    parameter_id bigint,
    entityversion bigint DEFAULT 0,
    archived boolean DEFAULT false
);


--
-- Name: arch_ordersupplies_coveragelocation_id_seq; Type: SEQUENCE; Schema: public; Owner: -
--

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


--
-- Name: arch_ordersupplies_coveragelocation_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: -
--

ALTER SEQUENCE public.arch_ordersupplies_coveragelocation_id_seq OWNED BY public.arch_ordersupplies_coveragelocation.id;


--
-- Name: arch_ordersupplies_coverageorderstate; Type: TABLE; Schema: public; Owner: -
--

CREATE TABLE public.arch_ordersupplies_coverageorderstate (
    id bigint NOT NULL,
    materialrequirementcoverage_id bigint,
    parameter_id bigint,
    state character varying(255),
    archived boolean DEFAULT false
);


--
-- Name: arch_ordersupplies_coverageorderstate_id_seq; Type: SEQUENCE; Schema: public; Owner: -
--

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


--
-- Name: arch_ordersupplies_coverageorderstate_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: -
--

ALTER SEQUENCE public.arch_ordersupplies_coverageorderstate_id_seq OWNED BY public.arch_ordersupplies_coverageorderstate.id;


--
-- Name: arch_ordersupplies_coverageproduct; Type: TABLE; Schema: public; Owner: -
--

CREATE TABLE public.arch_ordersupplies_coverageproduct (
    id bigint NOT NULL,
    materialrequirementcoverage_id bigint,
    product_id bigint,
    lackfromdate timestamp without time zone,
    demandquantity numeric(16,5),
    coveredquantity numeric(16,5),
    reservemissingquantity numeric(16,5),
    deliveredquantity numeric(16,5),
    locationsquantity numeric(16,5),
    state character varying(255),
    issubcontracted boolean DEFAULT false,
    ispurchased boolean DEFAULT false,
    productnumber character varying(255),
    productname character varying(1024),
    productunit character varying(255),
    producttype character varying(255),
    planedquantity numeric(16,5),
    producequantity numeric(16,5),
    fromselectedorder boolean DEFAULT false,
    entityversion bigint DEFAULT 0,
    company_id bigint,
    price numeric(12,5),
    archived boolean DEFAULT false
);


--
-- Name: arch_ordersupplies_coverageproduct_id_seq; Type: SEQUENCE; Schema: public; Owner: -
--

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


--
-- Name: arch_ordersupplies_coverageproduct_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: -
--

ALTER SEQUENCE public.arch_ordersupplies_coverageproduct_id_seq OWNED BY public.arch_ordersupplies_coverageproduct.id;


--
-- Name: arch_ordersupplies_coverageproductlogging; Type: TABLE; Schema: public; Owner: -
--

CREATE TABLE public.arch_ordersupplies_coverageproductlogging (
    id bigint NOT NULL,
    coverageproduct_id bigint,
    date timestamp without time zone,
    delivery_id bigint,
    order_id bigint,
    operation_id bigint,
    reservemissingquantity numeric(16,5),
    changes numeric(16,5),
    eventtype character varying(255),
    state character varying(255),
    subcontractedoperation_id bigint,
    deliverynumberexternal character varying(255),
    warehousenumber character varying(255),
    entityversion bigint DEFAULT 0,
    archived boolean DEFAULT false
);


--
-- Name: arch_ordersupplies_coverageproductlogging_id_seq; Type: SEQUENCE; Schema: public; Owner: -
--

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


--
-- Name: arch_ordersupplies_coverageproductlogging_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: -
--

ALTER SEQUENCE public.arch_ordersupplies_coverageproductlogging_id_seq OWNED BY public.arch_ordersupplies_coverageproductlogging.id;


--
-- Name: arch_ordersupplies_coverageproductselected; Type: TABLE; Schema: public; Owner: -
--

CREATE TABLE public.arch_ordersupplies_coverageproductselected (
    id bigint NOT NULL,
    coverageproduct_id bigint,
    entityversion bigint DEFAULT 0,
    archived boolean DEFAULT false
);


--
-- Name: arch_ordersupplies_coverageproductselected_id_seq; Type: SEQUENCE; Schema: public; Owner: -
--

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


--
-- Name: arch_ordersupplies_coverageproductselected_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: -
--

ALTER SEQUENCE public.arch_ordersupplies_coverageproductselected_id_seq OWNED BY public.arch_ordersupplies_coverageproductselected.id;


--
-- Name: arch_ordersupplies_materialrequirementcoverage; Type: TABLE; Schema: public; Owner: -
--

CREATE TABLE public.arch_ordersupplies_materialrequirementcoverage (
    id bigint NOT NULL,
    number character varying(255),
    coveragetodate timestamp without time zone,
    actualdate timestamp without time zone,
    generateddate timestamp without time zone,
    generatedby character varying(255),
    generated boolean,
    saved boolean,
    coveragetype character varying(255),
    includedraftdeliveries boolean,
    createdate timestamp without time zone,
    updatedate timestamp without time zone,
    createuser character varying(255),
    updateuser character varying(255),
    filename character varying(1024),
    automaticsavecoverage boolean DEFAULT false,
    order_id bigint,
    entityversion bigint DEFAULT 0,
    ordergenerationinprogress boolean DEFAULT false,
    forordersgroup_id bigint,
    ordersgroupsgenerated boolean DEFAULT false,
    includeincalculationdeliveries character varying(255) DEFAULT '01confirmedDeliveries'::character varying,
    archived boolean DEFAULT false
);


--
-- Name: arch_ordersupplies_materialrequirementcoverage_id_seq; Type: SEQUENCE; Schema: public; Owner: -
--

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


--
-- Name: arch_ordersupplies_materialrequirementcoverage_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: -
--

ALTER SEQUENCE public.arch_ordersupplies_materialrequirementcoverage_id_seq OWNED BY public.arch_ordersupplies_materialrequirementcoverage.id;


--
-- Name: arch_productflowthrudivision_issue; Type: TABLE; Schema: public; Owner: -
--

CREATE TABLE public.arch_productflowthrudivision_issue (
    id bigint NOT NULL,
    warehouseissue_id bigint,
    product_id bigint,
    productincomponent_id bigint,
    demandquantity numeric(12,5),
    locationsquantity numeric(12,5),
    issuequantity numeric(12,5),
    location_id bigint,
    entityversion bigint DEFAULT 0,
    locationtoquantity numeric(12,5),
    quantityperunit numeric(12,5),
    issued boolean DEFAULT false,
    storagelocation_id bigint,
    additionaldemandquantity numeric(12,5),
    conversion numeric(12,5),
    dateofissued timestamp without time zone,
    document_id bigint,
    archived boolean DEFAULT false
);


--
-- Name: arch_productflowthrudivision_issue_id_seq; Type: SEQUENCE; Schema: public; Owner: -
--

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


--
-- Name: arch_productflowthrudivision_issue_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: -
--

ALTER SEQUENCE public.arch_productflowthrudivision_issue_id_seq OWNED BY public.arch_productflowthrudivision_issue.id;


--
-- Name: arch_productflowthrudivision_materialavailability; Type: TABLE; Schema: public; Owner: -
--

CREATE TABLE public.arch_productflowthrudivision_materialavailability (
    id bigint NOT NULL,
    order_id bigint,
    product_id bigint,
    availablequantity numeric(19,5),
    requiredquantity numeric(19,5),
    unit character varying(255),
    entityversion bigint DEFAULT 0,
    location_id bigint,
    availability character varying,
    replacement boolean DEFAULT false,
    batchesid character varying(255),
    batches character varying(255),
    batchesquantity numeric(19,5),
    archived boolean DEFAULT false
);


--
-- Name: arch_productflowthrudivision_materialavailability_id_seq; Type: SEQUENCE; Schema: public; Owner: -
--

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


--
-- Name: arch_productflowthrudivision_materialavailability_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: -
--

ALTER SEQUENCE public.arch_productflowthrudivision_materialavailability_id_seq OWNED BY public.arch_productflowthrudivision_materialavailability.id;


--
-- Name: arch_productflowthrudivision_productstoissue; Type: TABLE; Schema: public; Owner: -
--

CREATE TABLE public.arch_productflowthrudivision_productstoissue (
    id bigint NOT NULL,
    warehouseissue_id bigint,
    product_id bigint,
    productincomponent_id bigint,
    demandquantity numeric(12,5),
    locationsquantity numeric(12,5),
    placeofissuequantity numeric(12,5),
    issuequantity numeric(12,5),
    location_id bigint,
    entityversion bigint DEFAULT 0,
    issued boolean DEFAULT false,
    storagelocation_id bigint,
    additionaldemandquantity numeric(12,5),
    conversion numeric(12,5),
    correction numeric(12,5),
    archived boolean DEFAULT false
);


--
-- Name: arch_productflowthrudivision_productstoissue_id_seq; Type: SEQUENCE; Schema: public; Owner: -
--

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


--
-- Name: arch_productflowthrudivision_productstoissue_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: -
--

ALTER SEQUENCE public.arch_productflowthrudivision_productstoissue_id_seq OWNED BY public.arch_productflowthrudivision_productstoissue.id;


--
-- Name: arch_productflowthrudivision_producttoissuecorrection; Type: TABLE; Schema: public; Owner: -
--

CREATE TABLE public.arch_productflowthrudivision_producttoissuecorrection (
    id bigint NOT NULL,
    producttoissuecorrectionhelper_id bigint,
    warehouseissue_id bigint,
    product_id bigint,
    correctionquantity numeric(12,5),
    correctionquantityinadditionalunit numeric(12,5),
    quantitytoissue numeric(12,5),
    demandquantity numeric(12,5),
    conversion numeric(12,5),
    location_id bigint,
    description character varying(255),
    createdate timestamp without time zone,
    updatedate timestamp without time zone,
    createuser character varying(255),
    updateuser character varying(255),
    productstoissue_id bigint,
    archived boolean DEFAULT false
);


--
-- Name: arch_productflowthrudivision_producttoissuecorrection_id_seq; Type: SEQUENCE; Schema: public; Owner: -
--

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


--
-- Name: arch_productflowthrudivision_producttoissuecorrection_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: -
--

ALTER SEQUENCE public.arch_productflowthrudivision_producttoissuecorrection_id_seq OWNED BY public.arch_productflowthrudivision_producttoissuecorrection.id;


--
-- Name: arch_productflowthrudivision_warehouseissue; Type: TABLE; Schema: public; Owner: -
--

CREATE TABLE public.arch_productflowthrudivision_warehouseissue (
    id bigint NOT NULL,
    number character varying(255),
    description character varying(2048),
    order_id bigint,
    placeofissue_id bigint,
    division_id bigint,
    workerwhoissued_id bigint,
    workerwhocollected_id bigint,
    dateofissued timestamp without time zone,
    dateofcreation timestamp without time zone,
    technologyoperationcomponent_id bigint,
    collectionproducts character varying(255) DEFAULT '01onOrder'::character varying,
    state character varying(255) DEFAULT '01draft'::character varying,
    createdate timestamp without time zone,
    updatedate timestamp without time zone,
    createuser character varying(255),
    updateuser character varying(255),
    entityversion bigint DEFAULT 0,
    productstoissuemode character varying(255) DEFAULT '01allInputProducts'::character varying,
    archived boolean DEFAULT false
);


--
-- Name: arch_productflowthrudivision_warehouseissue_id_seq; Type: SEQUENCE; Schema: public; Owner: -
--

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


--
-- Name: arch_productflowthrudivision_warehouseissue_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: -
--

ALTER SEQUENCE public.arch_productflowthrudivision_warehouseissue_id_seq OWNED BY public.arch_productflowthrudivision_warehouseissue.id;


--
-- Name: arch_productflowthrudivision_warehouseissuestatechange; Type: TABLE; Schema: public; Owner: -
--

CREATE TABLE public.arch_productflowthrudivision_warehouseissuestatechange (
    id bigint NOT NULL,
    dateandtime timestamp without time zone,
    sourcestate character varying(255),
    targetstate character varying(255),
    status character varying(255),
    phase integer,
    worker character varying(255),
    warehouseissue_id bigint,
    shift_id bigint,
    additionalinformation character varying(255),
    entityversion bigint DEFAULT 0,
    archived boolean DEFAULT false
);


--
-- Name: arch_productflowthrudivision_warehouseissuestatechange_id_seq; Type: SEQUENCE; Schema: public; Owner: -
--

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


--
-- Name: arch_productflowthrudivision_warehouseissuestatechange_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: -
--

ALTER SEQUENCE public.arch_productflowthrudivision_warehouseissuestatechange_id_seq OWNED BY public.arch_productflowthrudivision_warehouseissuestatechange.id;


--
-- Name: arch_productioncounting_anomaly; Type: TABLE; Schema: public; Owner: -
--

CREATE TABLE public.arch_productioncounting_anomaly (
    id bigint NOT NULL,
    number character varying(255),
    productiontracking_id bigint,
    masterproduct_id bigint,
    product_id bigint,
    usedquantity numeric(14,5),
    state character varying(255) DEFAULT '01draft'::character varying,
    issued boolean DEFAULT false,
    createdate timestamp without time zone,
    updatedate timestamp without time zone,
    createuser character varying(255),
    updateuser character varying(255),
    location_id bigint,
    archived boolean DEFAULT false
);


--
-- Name: arch_productioncounting_anomaly_id_seq; Type: SEQUENCE; Schema: public; Owner: -
--

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


--
-- Name: arch_productioncounting_anomaly_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: -
--

ALTER SEQUENCE public.arch_productioncounting_anomaly_id_seq OWNED BY public.arch_productioncounting_anomaly.id;


--
-- Name: arch_productioncounting_anomalyexplanation; Type: TABLE; Schema: public; Owner: -
--

CREATE TABLE public.arch_productioncounting_anomalyexplanation (
    id bigint NOT NULL,
    anomaly_id bigint,
    product_id bigint,
    location_id bigint,
    usedquantity numeric(14,5),
    givenquantity numeric(14,5),
    givenunit character varying(255),
    usewaste boolean DEFAULT false,
    description character varying(1024),
    createdate timestamp without time zone,
    updatedate timestamp without time zone,
    createuser character varying(255),
    updateuser character varying(255),
    archived boolean DEFAULT false
);


--
-- Name: arch_productioncounting_anomalyexplanation_id_seq; Type: SEQUENCE; Schema: public; Owner: -
--

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


--
-- Name: arch_productioncounting_anomalyexplanation_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: -
--

ALTER SEQUENCE public.arch_productioncounting_anomalyexplanation_id_seq OWNED BY public.arch_productioncounting_anomalyexplanation.id;


--
-- Name: arch_productioncounting_anomalyproductiontrackingentryhelper; Type: TABLE; Schema: public; Owner: -
--

CREATE TABLE public.arch_productioncounting_anomalyproductiontrackingentryhelper (
    id bigint NOT NULL,
    anomalyproductiontracking_id bigint,
    trackingoperationproductincomponent_id bigint,
    createdate timestamp without time zone,
    updatedate timestamp without time zone,
    createuser character varying(255),
    updateuser character varying(255),
    archived boolean DEFAULT false
);


--
-- Name: arch_productioncounting_anomalyproductiontrackingentryhelper_id; Type: SEQUENCE; Schema: public; Owner: -
--

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


--
-- Name: arch_productioncounting_anomalyproductiontrackingentryhelper_id; Type: SEQUENCE OWNED BY; Schema: public; Owner: -
--

ALTER SEQUENCE public.arch_productioncounting_anomalyproductiontrackingentryhelper_id OWNED BY public.arch_productioncounting_anomalyproductiontrackingentryhelper.id;


--
-- Name: arch_productioncounting_anomalyreasoncontainer; Type: TABLE; Schema: public; Owner: -
--

CREATE TABLE public.arch_productioncounting_anomalyreasoncontainer (
    id bigint NOT NULL,
    anomalyproductiontrackingentryhelper_id bigint,
    anomalyreason_id bigint,
    archived boolean DEFAULT false
);


--
-- Name: arch_productioncounting_anomalyreasoncontainer_id_seq; Type: SEQUENCE; Schema: public; Owner: -
--

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


--
-- Name: arch_productioncounting_anomalyreasoncontainer_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: -
--

ALTER SEQUENCE public.arch_productioncounting_anomalyreasoncontainer_id_seq OWNED BY public.arch_productioncounting_anomalyreasoncontainer.id;


--
-- Name: arch_productioncounting_lack; Type: TABLE; Schema: public; Owner: -
--

CREATE TABLE public.arch_productioncounting_lack (
    id bigint NOT NULL,
    trackingoperationproductoutcomponent_id bigint,
    lackquantity numeric(14,5),
    createdate timestamp without time zone,
    updatedate timestamp without time zone,
    createuser character varying(255),
    updateuser character varying(255),
    archived boolean DEFAULT false
);


--
-- Name: arch_productioncounting_lack_id_seq; Type: SEQUENCE; Schema: public; Owner: -
--

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


--
-- Name: arch_productioncounting_lack_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: -
--

ALTER SEQUENCE public.arch_productioncounting_lack_id_seq OWNED BY public.arch_productioncounting_lack.id;


--
-- Name: arch_productioncounting_prodoutresourceattrval; Type: TABLE; Schema: public; Owner: -
--

CREATE TABLE public.arch_productioncounting_prodoutresourceattrval (
    id bigint NOT NULL,
    trackingoperationproductoutcomponent_id bigint,
    attribute_id bigint,
    attributevalue_id bigint,
    value character varying(255),
    archived boolean DEFAULT false
);


--
-- Name: arch_productioncounting_prodoutresourceattrval_id_seq; Type: SEQUENCE; Schema: public; Owner: -
--

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


--
-- Name: arch_productioncounting_prodoutresourceattrval_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: -
--

ALTER SEQUENCE public.arch_productioncounting_prodoutresourceattrval_id_seq OWNED BY public.arch_productioncounting_prodoutresourceattrval.id;


--
-- Name: arch_productioncounting_productiontracking_id_seq; Type: SEQUENCE; Schema: public; Owner: -
--

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


--
-- Name: arch_productioncounting_productiontracking_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: -
--

ALTER SEQUENCE public.arch_productioncounting_productiontracking_id_seq OWNED BY public.arch_productioncounting_productiontracking.id;


--
-- Name: arch_productioncounting_productiontrackingattachment; Type: TABLE; Schema: public; Owner: -
--

CREATE TABLE public.arch_productioncounting_productiontrackingattachment (
    id bigint NOT NULL,
    productiontracking_id bigint,
    attachment character varying(255),
    name character varying(255),
    size numeric(12,5),
    ext character varying(255),
    archived boolean DEFAULT false
);


--
-- Name: arch_productioncounting_productiontrackingattachment_id_seq; Type: SEQUENCE; Schema: public; Owner: -
--

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


--
-- Name: arch_productioncounting_productiontrackingattachment_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: -
--

ALTER SEQUENCE public.arch_productioncounting_productiontrackingattachment_id_seq OWNED BY public.arch_productioncounting_productiontrackingattachment.id;


--
-- Name: arch_productioncounting_productiontrackingdto; Type: VIEW; Schema: public; Owner: -
--

CREATE VIEW public.arch_productioncounting_productiontrackingdto AS
 SELECT arch_mv_productioncounting_productiontrackingdto.id,
    arch_mv_productioncounting_productiontrackingdto.number,
    arch_mv_productioncounting_productiontrackingdto.state,
    arch_mv_productioncounting_productiontrackingdto.createdate,
    arch_mv_productioncounting_productiontrackingdto.lasttracking,
    arch_mv_productioncounting_productiontrackingdto.timerangefrom,
    arch_mv_productioncounting_productiontrackingdto.timerangeto,
    arch_mv_productioncounting_productiontrackingdto.active,
    arch_mv_productioncounting_productiontrackingdto.order_id,
    arch_mv_productioncounting_productiontrackingdto.ordernumber,
    arch_mv_productioncounting_productiontrackingdto.orderstate,
    arch_mv_productioncounting_productiontrackingdto.technologyoperationcomponent_id,
    arch_mv_productioncounting_productiontrackingdto.technologyoperationcomponentnumber,
    arch_mv_productioncounting_productiontrackingdto.operation_id,
    arch_mv_productioncounting_productiontrackingdto.shift_id,
    arch_mv_productioncounting_productiontrackingdto.shiftname,
    arch_mv_productioncounting_productiontrackingdto.staff_id,
    arch_mv_productioncounting_productiontrackingdto.staffname,
    arch_mv_productioncounting_productiontrackingdto.division_id,
    arch_mv_productioncounting_productiontrackingdto.divisionnumber,
    arch_mv_productioncounting_productiontrackingdto.subcontractor_id,
    arch_mv_productioncounting_productiontrackingdto.subcontractorname,
    arch_mv_productioncounting_productiontrackingdto.repairorder_id,
    arch_mv_productioncounting_productiontrackingdto.repairordernumber,
    arch_mv_productioncounting_productiontrackingdto.correctionnumber,
    arch_mv_productioncounting_productiontrackingdto.productionline_id,
    arch_mv_productioncounting_productiontrackingdto.productionlinenumber,
    arch_mv_productioncounting_productiontrackingdto.ordersgroup,
    arch_mv_productioncounting_productiontrackingdto.productnumber,
    arch_mv_productioncounting_productiontrackingdto.productunit,
    arch_mv_productioncounting_productiontrackingdto.usedquantity,
    arch_mv_productioncounting_productiontrackingdto.companynumber,
    arch_mv_productioncounting_productiontrackingdto.outproductnumber
   FROM public.arch_mv_productioncounting_productiontrackingdto;


--
-- Name: arch_productioncounting_productiontrackingdto_id_seq; Type: SEQUENCE; Schema: public; Owner: -
--

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


--
-- Name: arch_productioncounting_productiontrackingstatechange; Type: TABLE; Schema: public; Owner: -
--

CREATE TABLE public.arch_productioncounting_productiontrackingstatechange (
    id bigint NOT NULL,
    dateandtime timestamp without time zone,
    sourcestate character varying(255),
    targetstate character varying(255),
    status character varying(255) DEFAULT '01inProgress'::character varying,
    phase integer,
    worker character varying(255),
    productiontracking_id bigint,
    shift_id bigint,
    entityversion bigint DEFAULT 0,
    archived boolean DEFAULT false
);


--
-- Name: arch_productioncounting_productiontrackingstatechange_id_seq; Type: SEQUENCE; Schema: public; Owner: -
--

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


--
-- Name: arch_productioncounting_productiontrackingstatechange_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: -
--

ALTER SEQUENCE public.arch_productioncounting_productiontrackingstatechange_id_seq OWNED BY public.arch_productioncounting_productiontrackingstatechange.id;


--
-- Name: arch_productioncounting_staffworktime; Type: TABLE; Schema: public; Owner: -
--

CREATE TABLE public.arch_productioncounting_staffworktime (
    id bigint NOT NULL,
    productionrecord_id bigint,
    worker_id bigint,
    labortime integer DEFAULT 0,
    effectiveexecutiontimestart timestamp without time zone,
    effectiveexecutiontimeend timestamp without time zone,
    entityversion bigint DEFAULT 0,
    archived boolean DEFAULT false
);


--
-- Name: arch_productioncounting_staffworktime_id_seq; Type: SEQUENCE; Schema: public; Owner: -
--

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


--
-- Name: arch_productioncounting_staffworktime_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: -
--

ALTER SEQUENCE public.arch_productioncounting_staffworktime_id_seq OWNED BY public.arch_productioncounting_staffworktime.id;


--
-- Name: arch_productioncounting_trackinginproductreplacementhelper; Type: TABLE; Schema: public; Owner: -
--

CREATE TABLE public.arch_productioncounting_trackinginproductreplacementhelper (
    id bigint NOT NULL,
    productiontracking_id bigint,
    product_id bigint,
    quantity numeric(14,5),
    basicproduct_id bigint,
    archived boolean DEFAULT false
);


--
-- Name: arch_productioncounting_trackinginproductreplacementhelper_id_s; Type: SEQUENCE; Schema: public; Owner: -
--

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


--
-- Name: arch_productioncounting_trackinginproductreplacementhelper_id_s; Type: SEQUENCE OWNED BY; Schema: public; Owner: -
--

ALTER SEQUENCE public.arch_productioncounting_trackinginproductreplacementhelper_id_s OWNED BY public.arch_productioncounting_trackinginproductreplacementhelper.id;


--
-- Name: arch_productioncounting_trackingoperationproductincomponent; Type: TABLE; Schema: public; Owner: -
--

CREATE TABLE public.arch_productioncounting_trackingoperationproductincomponent (
    id bigint NOT NULL,
    productiontracking_id bigint,
    product_id bigint,
    usedquantity numeric(14,5),
    balance numeric(14,5),
    obtainedquantity numeric(14,5),
    remainedquantity numeric(14,5),
    effectiveusedquantity numeric(15,5),
    givenunit character varying(255),
    givenquantity numeric(14,5),
    entityversion bigint DEFAULT 0,
    typeofmaterial character varying(255) DEFAULT '01component'::character varying,
    wasteused boolean DEFAULT false,
    wasteusedonly boolean DEFAULT false,
    wasteusedquantity numeric,
    wasteunit character varying,
    additionalinformation character varying,
    replacementto_id bigint,
    archived boolean DEFAULT false
);


--
-- Name: arch_productioncounting_trackingoperationproductincomponent_id_; Type: SEQUENCE; Schema: public; Owner: -
--

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


--
-- Name: arch_productioncounting_trackingoperationproductincomponent_id_; Type: SEQUENCE OWNED BY; Schema: public; Owner: -
--

ALTER SEQUENCE public.arch_productioncounting_trackingoperationproductincomponent_id_ OWNED BY public.arch_productioncounting_trackingoperationproductincomponent.id;


--
-- Name: arch_productioncounting_trackingoperationproductoutcomponent_id; Type: SEQUENCE; Schema: public; Owner: -
--

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


--
-- Name: arch_productioncounting_trackingoperationproductoutcomponent_id; Type: SEQUENCE OWNED BY; Schema: public; Owner: -
--

ALTER SEQUENCE public.arch_productioncounting_trackingoperationproductoutcomponent_id OWNED BY public.arch_productioncounting_trackingoperationproductoutcomponent.id;


--
-- Name: arch_productioncounting_usedbatch; Type: TABLE; Schema: public; Owner: -
--

CREATE TABLE public.arch_productioncounting_usedbatch (
    id bigint NOT NULL,
    trackingoperationproductincomponent_id bigint,
    batch_id bigint,
    quantity numeric(14,5),
    archived boolean DEFAULT false
);


--
-- Name: arch_productioncounting_usedbatch_id_seq; Type: SEQUENCE; Schema: public; Owner: -
--

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


--
-- Name: arch_productioncounting_usedbatch_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: -
--

ALTER SEQUENCE public.arch_productioncounting_usedbatch_id_seq OWNED BY public.arch_productioncounting_usedbatch.id;


--
-- Name: arch_productionpershift_dailyprogress; Type: TABLE; Schema: public; Owner: -
--

CREATE TABLE public.arch_productionpershift_dailyprogress (
    id bigint NOT NULL,
    progressforday_id bigint,
    shift_id bigint,
    quantity numeric(12,5),
    locked boolean DEFAULT false,
    entityversion bigint DEFAULT 0,
    efficiencytime integer,
    archived boolean DEFAULT false
);


--
-- Name: arch_productionpershift_dailyprogress_id_seq; Type: SEQUENCE; Schema: public; Owner: -
--

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


--
-- Name: arch_productionpershift_dailyprogress_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: -
--

ALTER SEQUENCE public.arch_productionpershift_dailyprogress_id_seq OWNED BY public.arch_productionpershift_dailyprogress.id;


--
-- Name: arch_productionpershift_productionpershift; Type: TABLE; Schema: public; Owner: -
--

CREATE TABLE public.arch_productionpershift_productionpershift (
    id bigint NOT NULL,
    order_id bigint,
    plannedprogresscorrectioncomment text,
    orderfinishdate timestamp without time zone,
    entityversion bigint DEFAULT 0,
    archived boolean DEFAULT false
);


--
-- Name: arch_productionpershift_productionpershift_id_seq; Type: SEQUENCE; Schema: public; Owner: -
--

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


--
-- Name: arch_productionpershift_productionpershift_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: -
--

ALTER SEQUENCE public.arch_productionpershift_productionpershift_id_seq OWNED BY public.arch_productionpershift_productionpershift.id;


--
-- Name: arch_productionpershift_progressforday; Type: TABLE; Schema: public; Owner: -
--

CREATE TABLE public.arch_productionpershift_progressforday (
    id bigint NOT NULL,
    day integer,
    corrected boolean DEFAULT false,
    dateofday date,
    actualdateofday date,
    entityversion bigint DEFAULT 0,
    productionpershift_id bigint,
    archived boolean DEFAULT false
);


--
-- Name: arch_productionpershift_progressforday_id_seq; Type: SEQUENCE; Schema: public; Owner: -
--

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


--
-- Name: arch_productionpershift_progressforday_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: -
--

ALTER SEQUENCE public.arch_productionpershift_progressforday_id_seq OWNED BY public.arch_productionpershift_progressforday.id;


--
-- Name: arch_productionpershift_reasontypeofcorrectionplan; Type: TABLE; Schema: public; Owner: -
--

CREATE TABLE public.arch_productionpershift_reasontypeofcorrectionplan (
    id bigint NOT NULL,
    productionpershift_id bigint,
    reasontype character varying(255),
    date timestamp without time zone,
    entityversion bigint DEFAULT 0,
    archived boolean DEFAULT false
);


--
-- Name: arch_productionpershift_reasontypeofcorrectionplan_id_seq; Type: SEQUENCE; Schema: public; Owner: -
--

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


--
-- Name: arch_productionpershift_reasontypeofcorrectionplan_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: -
--

ALTER SEQUENCE public.arch_productionpershift_reasontypeofcorrectionplan_id_seq OWNED BY public.arch_productionpershift_reasontypeofcorrectionplan.id;


--
-- Name: arch_productionscheduling_opercomptimecalculation; Type: TABLE; Schema: public; Owner: -
--

CREATE TABLE public.arch_productionscheduling_opercomptimecalculation (
    id bigint NOT NULL,
    ordertimecalculation_id bigint,
    technologyoperationcomponent_id bigint,
    operationoffset integer,
    effectiveoperationrealizationtime integer,
    effectivedatefrom timestamp without time zone,
    effectivedateto timestamp without time zone,
    duration integer DEFAULT 0,
    machineworktime integer DEFAULT 0,
    laborworktime integer DEFAULT 0,
    archived boolean DEFAULT false
);


--
-- Name: arch_productionscheduling_opercomptimecalculation_id_seq; Type: SEQUENCE; Schema: public; Owner: -
--

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


--
-- Name: arch_productionscheduling_opercomptimecalculation_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: -
--

ALTER SEQUENCE public.arch_productionscheduling_opercomptimecalculation_id_seq OWNED BY public.arch_productionscheduling_opercomptimecalculation.id;


--
-- Name: arch_productionscheduling_ordertimecalculation; Type: TABLE; Schema: public; Owner: -
--

CREATE TABLE public.arch_productionscheduling_ordertimecalculation (
    id bigint NOT NULL,
    order_id bigint,
    effectivedatefrom timestamp without time zone,
    effectivedateto timestamp without time zone,
    archived boolean DEFAULT false
);


--
-- Name: arch_productionscheduling_ordertimecalculation_id_seq; Type: SEQUENCE; Schema: public; Owner: -
--

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


--
-- Name: arch_productionscheduling_ordertimecalculation_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: -
--

ALTER SEQUENCE public.arch_productionscheduling_ordertimecalculation_id_seq OWNED BY public.arch_productionscheduling_ordertimecalculation.id;


--
-- Name: arch_qualitycontrol_qualitycontrol; Type: TABLE; Schema: public; Owner: -
--

CREATE TABLE public.arch_qualitycontrol_qualitycontrol (
    id bigint NOT NULL,
    number character varying(255),
    product_id bigint,
    qualitycard_id bigint,
    controltype character varying(255) DEFAULT '01final'::character varying,
    batch_id bigint,
    date date,
    staff_id bigint,
    order_id bigint,
    qualityrating character varying(255),
    state character varying(255) DEFAULT '01new'::character varying,
    delivery_id bigint,
    description character varying(2048),
    archived boolean DEFAULT false
);


--
-- Name: arch_qualitycontrol_qualitycontrol_id_seq; Type: SEQUENCE; Schema: public; Owner: -
--

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


--
-- Name: arch_qualitycontrol_qualitycontrol_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: -
--

ALTER SEQUENCE public.arch_qualitycontrol_qualitycontrol_id_seq OWNED BY public.arch_qualitycontrol_qualitycontrol.id;


--
-- Name: arch_qualitycontrol_qualitycontrolattachment; Type: TABLE; Schema: public; Owner: -
--

CREATE TABLE public.arch_qualitycontrol_qualitycontrolattachment (
    id bigint NOT NULL,
    qualitycontrol_id bigint,
    attachment character varying(255),
    name character varying(255),
    size numeric(12,5),
    ext character varying(255),
    archived boolean DEFAULT false
);


--
-- Name: arch_qualitycontrol_qualitycontrolattachment_id_seq; Type: SEQUENCE; Schema: public; Owner: -
--

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


--
-- Name: arch_qualitycontrol_qualitycontrolattachment_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: -
--

ALTER SEQUENCE public.arch_qualitycontrol_qualitycontrolattachment_id_seq OWNED BY public.arch_qualitycontrol_qualitycontrolattachment.id;


--
-- Name: arch_qualitycontrol_qualitycontrolattributeprodtracking; Type: TABLE; Schema: public; Owner: -
--

CREATE TABLE public.arch_qualitycontrol_qualitycontrolattributeprodtracking (
    id bigint NOT NULL,
    productiontracking_id bigint,
    attribute_id bigint,
    attributevalue_id bigint,
    value character varying(255),
    fromtechnology boolean DEFAULT false,
    moment character varying(255),
    adddate timestamp without time zone,
    archived boolean DEFAULT false
);


--
-- Name: arch_qualitycontrol_qualitycontrolattributeprodtracking_id_seq; Type: SEQUENCE; Schema: public; Owner: -
--

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


--
-- Name: arch_qualitycontrol_qualitycontrolattributeprodtracking_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: -
--

ALTER SEQUENCE public.arch_qualitycontrol_qualitycontrolattributeprodtracking_id_seq OWNED BY public.arch_qualitycontrol_qualitycontrolattributeprodtracking.id;


--
-- Name: arch_qualitycontrol_qualitycontrolattributevalue; Type: TABLE; Schema: public; Owner: -
--

CREATE TABLE public.arch_qualitycontrol_qualitycontrolattributevalue (
    id bigint NOT NULL,
    qualitycontrol_id bigint,
    attribute_id bigint,
    attributevalue_id bigint,
    value character varying(255),
    productiontracking_id bigint,
    fromqualitycard boolean DEFAULT false,
    priority integer,
    archived boolean DEFAULT false
);


--
-- Name: arch_qualitycontrol_qualitycontrolattributevalue_id_seq; Type: SEQUENCE; Schema: public; Owner: -
--

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


--
-- Name: arch_qualitycontrol_qualitycontrolattributevalue_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: -
--

ALTER SEQUENCE public.arch_qualitycontrol_qualitycontrolattributevalue_id_seq OWNED BY public.arch_qualitycontrol_qualitycontrolattributevalue.id;


--
-- Name: arch_qualitycontrol_qualitycontrolresource; Type: TABLE; Schema: public; Owner: -
--

CREATE TABLE public.arch_qualitycontrol_qualitycontrolresource (
    id bigint NOT NULL,
    resourcenumber character varying(255),
    qualitycontrol_id bigint,
    resource_id bigint,
    archived boolean DEFAULT false
);


--
-- Name: arch_qualitycontrol_qualitycontrolresource_id_seq; Type: SEQUENCE; Schema: public; Owner: -
--

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


--
-- Name: arch_qualitycontrol_qualitycontrolresource_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: -
--

ALTER SEQUENCE public.arch_qualitycontrol_qualitycontrolresource_id_seq OWNED BY public.arch_qualitycontrol_qualitycontrolresource.id;


--
-- Name: arch_qualitycontrol_qualitycontrolstatechange; Type: TABLE; Schema: public; Owner: -
--

CREATE TABLE public.arch_qualitycontrol_qualitycontrolstatechange (
    id bigint NOT NULL,
    dateandtime timestamp without time zone,
    sourcestate character varying(255),
    targetstate character varying(255),
    status character varying(255),
    phase integer,
    worker character varying(255),
    qualitycontrol_id bigint,
    shift_id bigint,
    archived boolean DEFAULT false
);


--
-- Name: arch_qualitycontrol_qualitycontrolstatechange_id_seq; Type: SEQUENCE; Schema: public; Owner: -
--

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


--
-- Name: arch_qualitycontrol_qualitycontrolstatechange_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: -
--

ALTER SEQUENCE public.arch_qualitycontrol_qualitycontrolstatechange_id_seq OWNED BY public.arch_qualitycontrol_qualitycontrolstatechange.id;


--
-- Name: arch_repairs_repairorder_id_seq; Type: SEQUENCE; Schema: public; Owner: -
--

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


--
-- Name: arch_repairs_repairorder_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: -
--

ALTER SEQUENCE public.arch_repairs_repairorder_id_seq OWNED BY public.arch_repairs_repairorder.id;


--
-- Name: arch_repairs_repairorderproduct; Type: TABLE; Schema: public; Owner: -
--

CREATE TABLE public.arch_repairs_repairorderproduct (
    id bigint NOT NULL,
    trackingoperationproductincomponent_id bigint,
    division_id bigint,
    location_id bigint,
    product_id bigint,
    faulttype_id bigint,
    description character varying(2048),
    givenquantity numeric(12,5),
    givenunit character varying(255),
    entityversion bigint DEFAULT 0,
    archived boolean DEFAULT false
);


--
-- Name: arch_repairs_repairorderproduct_id_seq; Type: SEQUENCE; Schema: public; Owner: -
--

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


--
-- Name: arch_repairs_repairorderproduct_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: -
--

ALTER SEQUENCE public.arch_repairs_repairorderproduct_id_seq OWNED BY public.arch_repairs_repairorderproduct.id;


--
-- Name: arch_repairs_repairorderstatechange; Type: TABLE; Schema: public; Owner: -
--

CREATE TABLE public.arch_repairs_repairorderstatechange (
    id bigint NOT NULL,
    dateandtime timestamp without time zone,
    sourcestate character varying(255),
    targetstate character varying(255),
    phase integer,
    worker character varying(255),
    repairorder_id bigint,
    shift_id bigint,
    status character varying,
    archived boolean DEFAULT false
);


--
-- Name: arch_repairs_repairorderstatechange_id_seq; Type: SEQUENCE; Schema: public; Owner: -
--

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


--
-- Name: arch_repairs_repairorderstatechange_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: -
--

ALTER SEQUENCE public.arch_repairs_repairorderstatechange_id_seq OWNED BY public.arch_repairs_repairorderstatechange.id;


--
-- Name: arch_repairs_repairorderworktime; Type: TABLE; Schema: public; Owner: -
--

CREATE TABLE public.arch_repairs_repairorderworktime (
    id bigint NOT NULL,
    repairorder_id bigint,
    staff_id bigint,
    labortime integer DEFAULT 0,
    effectiveexecutiontimestart timestamp without time zone,
    effectiveexecutiontimeend timestamp without time zone,
    archived boolean DEFAULT false
);


--
-- Name: arch_repairs_repairorderworktime_id_seq; Type: SEQUENCE; Schema: public; Owner: -
--

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


--
-- Name: arch_repairs_repairorderworktime_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: -
--

ALTER SEQUENCE public.arch_repairs_repairorderworktime_id_seq OWNED BY public.arch_repairs_repairorderworktime.id;


--
-- Name: arch_states_message; Type: TABLE; Schema: public; Owner: -
--

CREATE TABLE public.arch_states_message (
    id bigint NOT NULL,
    type character varying(255),
    translationkey character varying(255),
    translationargs character varying(255),
    correspondfieldname character varying(255),
    autoclose boolean DEFAULT true,
    productiontrackingstatechange_id bigint,
    deliverystatechange_id bigint,
    assignmenttoshiftstatechange_id bigint,
    technologystatechange_id bigint,
    orderstatechange_id bigint,
    extrusionprotocolstatechange_id bigint,
    confectionprotocolstatechange_id bigint,
    palletstatechange_id bigint,
    batchstatechange_id bigint,
    trackingrecordstatechange_id bigint,
    requestforquotationstatechange_id bigint,
    offerstatechange_id bigint,
    negotiationstatechange_id bigint,
    warehouseissuestatechange_id bigint,
    palletlabelstatechange_id bigint,
    maintenanceeventstatechange_id bigint,
    entityversion bigint DEFAULT 0,
    plannedeventstatechange_id bigint,
    recurringeventstatechange_id bigint,
    archived boolean DEFAULT false
);


--
-- Name: arch_states_message_id_seq; Type: SEQUENCE; Schema: public; Owner: -
--

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


--
-- Name: arch_states_message_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: -
--

ALTER SEQUENCE public.arch_states_message_id_seq OWNED BY public.arch_states_message.id;


--
-- Name: arch_stoppage_stoppage; Type: TABLE; Schema: public; Owner: -
--

CREATE TABLE public.arch_stoppage_stoppage (
    id bigint NOT NULL,
    order_id bigint,
    duration integer,
    entityversion bigint DEFAULT 0,
    productiontracking_id bigint,
    reason_id bigint,
    description character varying(1024),
    datefrom timestamp without time zone,
    dateto timestamp without time zone,
    archived boolean DEFAULT false
);


--
-- Name: arch_stoppage_stoppage_id_seq; Type: SEQUENCE; Schema: public; Owner: -
--

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


--
-- Name: arch_stoppage_stoppage_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: -
--

ALTER SEQUENCE public.arch_stoppage_stoppage_id_seq OWNED BY public.arch_stoppage_stoppage.id;


--
-- Name: arch_technologies_barcodeoperationcomponent; Type: TABLE; Schema: public; Owner: -
--

CREATE TABLE public.arch_technologies_barcodeoperationcomponent (
    id bigint NOT NULL,
    operationcomponent_id bigint,
    code character varying(20),
    active boolean DEFAULT true,
    entityversion bigint DEFAULT 0,
    order_id bigint,
    archived boolean DEFAULT false
);


--
-- Name: arch_technologies_barcodeoperationcomponent_id_seq; Type: SEQUENCE; Schema: public; Owner: -
--

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


--
-- Name: arch_technologies_barcodeoperationcomponent_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: -
--

ALTER SEQUENCE public.arch_technologies_barcodeoperationcomponent_id_seq OWNED BY public.arch_technologies_barcodeoperationcomponent.id;


--
-- Name: arch_urcmaterialavailability_requiredcomponent; Type: TABLE; Schema: public; Owner: -
--

CREATE TABLE public.arch_urcmaterialavailability_requiredcomponent (
    id bigint NOT NULL,
    order_id bigint,
    technology_id bigint,
    product_id bigint,
    availablequantity numeric(19,5),
    reservedquantity numeric(19,5),
    requiredquantity numeric(19,5),
    unit character varying(255),
    availability character varying(255),
    createdate timestamp without time zone,
    updatedate timestamp without time zone,
    createuser character varying(255),
    updateuser character varying(255),
    entityversion bigint DEFAULT 0,
    archived boolean DEFAULT false
);


--
-- Name: arch_urcmaterialavailability_requiredcomponent_id_seq; Type: SEQUENCE; Schema: public; Owner: -
--

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


--
-- Name: arch_urcmaterialavailability_requiredcomponent_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: -
--

ALTER SEQUENCE public.arch_urcmaterialavailability_requiredcomponent_id_seq OWNED BY public.arch_urcmaterialavailability_requiredcomponent.id;


--
-- Name: assignmenttoshift_assignmenttoshift; Type: TABLE; Schema: public; Owner: -
--

CREATE TABLE public.assignmenttoshift_assignmenttoshift (
    id bigint NOT NULL,
    startdate date,
    shift_id bigint,
    state character varying(255) DEFAULT '01draft'::character varying,
    approvedattendancelist boolean,
    active boolean DEFAULT true,
    externalnumber integer NOT NULL,
    externalsynchronized boolean DEFAULT true,
    showlaststatechangeresult boolean DEFAULT false,
    laststatechangefails boolean DEFAULT false,
    laststatechangefailcause character varying(2048),
    factory_id bigint,
    entityversion bigint DEFAULT 0,
    crew_id bigint
);


--
-- Name: assignmenttoshift_assignmenttoshift_externalnumber_seq; Type: SEQUENCE; Schema: public; Owner: -
--

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


--
-- Name: assignmenttoshift_assignmenttoshift_id_seq; Type: SEQUENCE; Schema: public; Owner: -
--

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


--
-- Name: assignmenttoshift_assignmenttoshift_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: -
--

ALTER SEQUENCE public.assignmenttoshift_assignmenttoshift_id_seq OWNED BY public.assignmenttoshift_assignmenttoshift.id;


--
-- Name: assignmenttoshift_assignmenttoshiftreport; Type: TABLE; Schema: public; Owner: -
--

CREATE TABLE public.assignmenttoshift_assignmenttoshiftreport (
    id bigint NOT NULL,
    number character varying(1024),
    name character varying(1024),
    datefrom date,
    dateto date,
    shift_id bigint,
    filename character varying(255),
    generated boolean DEFAULT false,
    active boolean DEFAULT true,
    createdate timestamp without time zone,
    updatedate timestamp without time zone,
    createuser character varying(255),
    updateuser character varying(255),
    factory_id bigint,
    entityversion bigint DEFAULT 0
);


--
-- Name: assignmenttoshift_assignmenttoshiftreport_id_seq; Type: SEQUENCE; Schema: public; Owner: -
--

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


--
-- Name: assignmenttoshift_assignmenttoshiftreport_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: -
--

ALTER SEQUENCE public.assignmenttoshift_assignmenttoshiftreport_id_seq OWNED BY public.assignmenttoshift_assignmenttoshiftreport.id;


--
-- Name: assignmenttoshift_assignmenttoshiftstatechange; Type: TABLE; Schema: public; Owner: -
--

CREATE TABLE public.assignmenttoshift_assignmenttoshiftstatechange (
    id bigint NOT NULL,
    dateandtime timestamp without time zone,
    sourcestate character varying(255),
    targetstate character varying(255),
    status character varying(255),
    phase integer,
    worker character varying(255),
    assignmenttoshift_id bigint,
    shift_id bigint,
    additionalinformation character varying(255),
    entityversion bigint DEFAULT 0
);


--
-- Name: assignmenttoshift_assignmenttoshiftstatechange_id_seq; Type: SEQUENCE; Schema: public; Owner: -
--

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


--
-- Name: assignmenttoshift_assignmenttoshiftstatechange_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: -
--

ALTER SEQUENCE public.assignmenttoshift_assignmenttoshiftstatechange_id_seq OWNED BY public.assignmenttoshift_assignmenttoshiftstatechange.id;


--
-- Name: assignmenttoshift_multiassignmenttoshift; Type: TABLE; Schema: public; Owner: -
--

CREATE TABLE public.assignmenttoshift_multiassignmenttoshift (
    id bigint NOT NULL,
    productionline_id bigint,
    occupationtype character varying(255),
    occupationtypename character varying(255),
    occupationtypeenum character varying(255),
    masterorder_id bigint,
    assignmenttoshift_id bigint,
    createdate timestamp without time zone,
    updatedate timestamp without time zone,
    createuser character varying(255),
    updateuser character varying(255)
);


--
-- Name: assignmenttoshift_multiassignmenttoshift_id_seq; Type: SEQUENCE; Schema: public; Owner: -
--

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


--
-- Name: assignmenttoshift_multiassignmenttoshift_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: -
--

ALTER SEQUENCE public.assignmenttoshift_multiassignmenttoshift_id_seq OWNED BY public.assignmenttoshift_multiassignmenttoshift.id;


--
-- Name: assignmenttoshift_staffassignmenttoshift; Type: TABLE; Schema: public; Owner: -
--

CREATE TABLE public.assignmenttoshift_staffassignmenttoshift (
    id bigint NOT NULL,
    assignmenttoshift_id bigint,
    worker_id bigint,
    productionline_id bigint,
    occupationtype character varying(255),
    occupationtypename character varying(255),
    state character varying(255) DEFAULT '01simple'::character varying,
    occupationtypeenum character varying(255),
    occupationtypevalueforgrid character varying(255),
    masterorder_id bigint,
    entityversion bigint DEFAULT 0,
    description character varying(255)
);


--
-- Name: assignmenttoshift_staffassignmenttoshift_id_seq; Type: SEQUENCE; Schema: public; Owner: -
--

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


--
-- Name: assignmenttoshift_staffassignmenttoshift_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: -
--

ALTER SEQUENCE public.assignmenttoshift_staffassignmenttoshift_id_seq OWNED BY public.assignmenttoshift_staffassignmenttoshift.id;


--
-- Name: avglaborcostcalcfororder_assignmentworkertoshift; Type: TABLE; Schema: public; Owner: -
--

CREATE TABLE public.avglaborcostcalcfororder_assignmentworkertoshift (
    id bigint NOT NULL,
    worker_id bigint,
    assignmenttoshift_id bigint,
    workedhours numeric(12,5),
    avglaborcostcalcfororder_id bigint,
    entityversion bigint DEFAULT 0
);


--
-- Name: avglaborcostcalcfororder_assignmentworkertoshift_id_seq; Type: SEQUENCE; Schema: public; Owner: -
--

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


--
-- Name: avglaborcostcalcfororder_assignmentworkertoshift_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: -
--

ALTER SEQUENCE public.avglaborcostcalcfororder_assignmentworkertoshift_id_seq OWNED BY public.avglaborcostcalcfororder_assignmentworkertoshift.id;


--
-- Name: avglaborcostcalcfororder_avglaborcostcalcfororder; Type: TABLE; Schema: public; Owner: -
--

CREATE TABLE public.avglaborcostcalcfororder_avglaborcostcalcfororder (
    id bigint NOT NULL,
    startdate date,
    finishdate date,
    order_id bigint,
    productionline_id bigint,
    basedon character varying(255) DEFAULT '01assignment'::character varying,
    averagelaborhourlycost numeric(12,5),
    entityversion bigint DEFAULT 0
);


--
-- Name: avglaborcostcalcfororder_avglaborcostcalcfororder_id_seq; Type: SEQUENCE; Schema: public; Owner: -
--

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


--
-- Name: avglaborcostcalcfororder_avglaborcostcalcfororder_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: -
--

ALTER SEQUENCE public.avglaborcostcalcfororder_avglaborcostcalcfororder_id_seq OWNED BY public.avglaborcostcalcfororder_avglaborcostcalcfororder.id;


--
-- Name: basic_address_id_seq; Type: SEQUENCE; Schema: public; Owner: -
--

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


--
-- Name: basic_address_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: -
--

ALTER SEQUENCE public.basic_address_id_seq OWNED BY public.basic_address.id;


--
-- Name: basic_assortment_id_seq; Type: SEQUENCE; Schema: public; Owner: -
--

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


--
-- Name: basic_assortment_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: -
--

ALTER SEQUENCE public.basic_assortment_id_seq OWNED BY public.basic_assortment.id;


--
-- Name: basic_assortmentelement; Type: TABLE; Schema: public; Owner: -
--

CREATE TABLE public.basic_assortmentelement (
    id bigint NOT NULL,
    descriptiontype character varying(255),
    description character varying(2048),
    assortment_id bigint,
    main boolean DEFAULT false
);


--
-- Name: basic_assortmentelement_id_seq; Type: SEQUENCE; Schema: public; Owner: -
--

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


--
-- Name: basic_assortmentelement_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: -
--

ALTER SEQUENCE public.basic_assortmentelement_id_seq OWNED BY public.basic_assortmentelement.id;


--
-- Name: basic_productattachment; Type: TABLE; Schema: public; Owner: -
--

CREATE TABLE public.basic_productattachment (
    id bigint NOT NULL,
    product_id bigint,
    attachment character varying(255),
    name character varying(255),
    size numeric(12,5),
    ext character varying(255)
);


--
-- Name: basic_qualitycard; Type: TABLE; Schema: public; Owner: -
--

CREATE TABLE public.basic_qualitycard (
    id bigint NOT NULL,
    number character varying(255),
    name character varying(2048),
    description character varying(2048),
    state character varying(255) DEFAULT '01new'::character varying,
    sampling character varying(255)
);


--
-- Name: basic_subassembly; Type: TABLE; Schema: public; Owner: -
--

CREATE TABLE public.basic_subassembly (
    id bigint NOT NULL,
    number character varying(255),
    name character varying(1024),
    workstationtype_id bigint,
    workstation_id bigint,
    serialnumber character varying(255),
    series character varying(255),
    producer character varying(255),
    productiondate date,
    lastrepairsdate date,
    active boolean DEFAULT true,
    type character varying(255),
    entityversion bigint DEFAULT 0
);


--
-- Name: basic_subassemblyattachment; Type: TABLE; Schema: public; Owner: -
--

CREATE TABLE public.basic_subassemblyattachment (
    id bigint NOT NULL,
    subassembly_id bigint,
    attachment character varying(255),
    name character varying(255),
    size numeric(12,5),
    ext character varying(255),
    entityversion bigint DEFAULT 0
);


--
-- Name: basic_workstation; Type: TABLE; Schema: public; Owner: -
--

CREATE TABLE public.basic_workstation (
    id bigint NOT NULL,
    number character varying(255),
    name character varying(1024),
    description character varying(2048),
    workstationtype_id bigint,
    operation_id bigint,
    active boolean DEFAULT true,
    productionline_id bigint,
    division_id bigint,
    serialnumber character varying(255),
    udtnumber character varying(255),
    series character varying(255),
    producer character varying(255),
    productiondate date,
    wnknumber character varying(255),
    entityversion bigint DEFAULT 0,
    staff_id bigint,
    dateofadmission date,
    dateofwithdrawal date,
    state character varying(255) DEFAULT '01stopped'::character varying,
    minimumdimension numeric(12,5),
    minimumdimensionunit character varying(255),
    maximumdimension numeric(12,5),
    maximumdimensionunit character varying(255),
    virtual boolean DEFAULT false
);


--
-- Name: basic_workstationattachment; Type: TABLE; Schema: public; Owner: -
--

CREATE TABLE public.basic_workstationattachment (
    id bigint NOT NULL,
    workstation_id bigint,
    attachment character varying(255),
    name character varying(255),
    size numeric(12,5),
    ext character varying(255),
    entityversion bigint DEFAULT 0
);


--
-- Name: cmmsmachineparts_machinepartattachment; Type: TABLE; Schema: public; Owner: -
--

CREATE TABLE public.cmmsmachineparts_machinepartattachment (
    id bigint NOT NULL,
    product_id bigint,
    attachment character varying(255),
    name character varying(255),
    size numeric(12,5),
    ext character varying(255),
    entityversion bigint DEFAULT 0
);


--
-- Name: cmmsmachineparts_tool; Type: TABLE; Schema: public; Owner: -
--

CREATE TABLE public.cmmsmachineparts_tool (
    id bigint NOT NULL,
    number character varying(255),
    name character varying(1024),
    description character varying(2048),
    toolcategory character varying(255),
    producer character varying(255),
    inventorynumber character varying(255),
    serialnumber character varying(255),
    unit character varying(255)
);


--
-- Name: cmmsmachineparts_toolattachment; Type: TABLE; Schema: public; Owner: -
--

CREATE TABLE public.cmmsmachineparts_toolattachment (
    id bigint NOT NULL,
    tool_id bigint,
    attachment character varying(255),
    name character varying(255),
    size numeric(12,5),
    ext character varying(255)
);


--
-- Name: deliveries_deliveryattachment; Type: TABLE; Schema: public; Owner: -
--

CREATE TABLE public.deliveries_deliveryattachment (
    id bigint NOT NULL,
    delivery_id bigint,
    attachment character varying(255),
    name character varying(255),
    size numeric(12,5),
    ext character varying(255)
);


--
-- Name: orders_order; Type: TABLE; Schema: public; Owner: -
--

CREATE TABLE public.orders_order (
    id bigint NOT NULL,
    number character varying(255),
    name character varying(1024),
    description character varying(2048),
    commentreasontypecorrectiondatefrom character varying(255),
    commentreasontypecorrectiondateto character varying(255),
    commentreasondeviationeffectivestart character varying(255),
    commentreasondeviationeffectiveend character varying(255),
    externalnumber character varying(255),
    commentreasontypedeviationsquantity character varying(255),
    datefrom timestamp without time zone,
    dateto timestamp without time zone,
    effectivedatefrom timestamp without time zone,
    effectivedateto timestamp without time zone,
    deadline timestamp without time zone,
    correcteddatefrom timestamp without time zone,
    correcteddateto timestamp without time zone,
    startdate timestamp without time zone,
    finishdate timestamp without time zone,
    state character varying(255),
    company_id bigint,
    product_id bigint,
    technology_id bigint,
    productionline_id bigint,
    plannedquantity numeric(12,5),
    donequantity numeric(12,5),
    externalsynchronized boolean DEFAULT true,
    commissionedplannedquantity numeric(12,5),
    commissionedcorrectedquantity numeric(12,5),
    amountofproductproduced numeric(12,5),
    remainingamountofproducttoproduce numeric(12,5),
    ownlinechangeoverduration integer,
    registerproductiontime boolean,
    registerquantityinproduct boolean,
    laborworktime integer,
    includetpz boolean,
    inputproductsrequiredfortype character varying(255),
    generatedenddate timestamp without time zone,
    machineworktime integer,
    ownlinechangeover boolean DEFAULT false,
    registerquantityoutproduct boolean,
    operationdurationquantityunit character varying(255),
    realizationtime integer,
    calculate boolean,
    includeadditionaltime boolean,
    typeofproductionrecording character varying(255) DEFAULT '02cumulated'::character varying,
    masterorder_id bigint,
    active boolean DEFAULT true,
    productpriceperunit numeric(19,5),
    failuresyncmessage character varying(255),
    targetstate character varying(255),
    ignorerequiredcomponents boolean,
    automaticallymoveoverusage boolean DEFAULT false,
    updatecomponentsavailability boolean,
    technologyprototype_id bigint,
    level integer,
    parent_id bigint,
    ignoremissingcomponents boolean DEFAULT false,
    masterorderproduct_id bigint,
    dateschanged boolean DEFAULT false,
    sourcecorrecteddatefrom timestamp without time zone,
    sourcecorrecteddateto timestamp without time zone,
    sourcestartdate timestamp without time zone,
    sourcefinishdate timestamp without time zone,
    batchnumber character varying(255),
    root_id bigint,
    includeordersforcomponent boolean,
    plannedfinishallorders timestamp without time zone,
    plannedstartallorders timestamp without time zone,
    calculatedfinishallorders timestamp without time zone,
    registerfilled boolean,
    workplandelivered boolean DEFAULT false,
    calculatedstartallorders timestamp without time zone,
    scadacreatedorupdatestate character varying(255),
    entityversion bigint DEFAULT 0,
    workertochange character varying(255),
    masterorderproductcomponent_id bigint,
    wastesquantity numeric(12,5),
    existsrepairorders boolean DEFAULT false,
    ordercategory character varying(255),
    address_id bigint,
    finalproductiontracking boolean DEFAULT false,
    updatefinishdate boolean DEFAULT false,
    ordersgroup_id bigint,
    plannedquantityforadditionalunit numeric,
    division_id bigint,
    salesplan_id bigint,
    reportedproductionquantity numeric(12,5),
    expirationdate date,
    additionalfinalproducts character varying(255),
    optimizecuttingsolution text,
    vendorinfo character varying(255),
    priority integer DEFAULT 100
);


--
-- Name: orders_orderattachment; Type: TABLE; Schema: public; Owner: -
--

CREATE TABLE public.orders_orderattachment (
    id bigint NOT NULL,
    order_id bigint,
    attachment character varying(255),
    name character varying(255),
    size numeric(12,5),
    ext character varying(255)
);


--
-- Name: qualitycontrol_qualitycardattachment; Type: TABLE; Schema: public; Owner: -
--

CREATE TABLE public.qualitycontrol_qualitycardattachment (
    id bigint NOT NULL,
    qualitycard_id bigint,
    attachment character varying(255),
    name character varying(255),
    size numeric(12,5),
    ext character varying(255)
);


--
-- Name: qualitycontrol_qualitycontrol; Type: TABLE; Schema: public; Owner: -
--

CREATE TABLE public.qualitycontrol_qualitycontrol (
    id bigint NOT NULL,
    number character varying(255),
    product_id bigint,
    qualitycard_id bigint,
    controltype character varying(255) DEFAULT '01final'::character varying,
    batch_id bigint,
    date date,
    staff_id bigint,
    order_id bigint,
    qualityrating character varying(255),
    state character varying(255) DEFAULT '01new'::character varying,
    delivery_id bigint,
    description character varying(2048)
);


--
-- Name: qualitycontrol_qualitycontrolattachment; Type: TABLE; Schema: public; Owner: -
--

CREATE TABLE public.qualitycontrol_qualitycontrolattachment (
    id bigint NOT NULL,
    qualitycontrol_id bigint,
    attachment character varying(255),
    name character varying(255),
    size numeric(12,5),
    ext character varying(255)
);


--
-- Name: technologies_technologyattachment; Type: TABLE; Schema: public; Owner: -
--

CREATE TABLE public.technologies_technologyattachment (
    id bigint NOT NULL,
    technology_id bigint,
    attachment character varying(255),
    name character varying(255),
    size numeric(12,5),
    ext character varying(255),
    entityversion bigint DEFAULT 0
);


--
-- Name: basic_attachmentdto; Type: VIEW; Schema: public; Owner: -
--

CREATE VIEW public.basic_attachmentdto AS
 SELECT '01products'::text AS pinnedto,
    product.number AS pinnedtoobjectidentifier,
    product.name AS pinnedtoobjectidentifiername,
    (product.id)::integer AS pinnedtoobjectid,
    'basic_product'::text AS pinnedtomodelname,
    productattachment.attachment,
    productattachment.name,
    productattachment.size,
    upper((productattachment.ext)::text) AS ext,
    row_number() OVER () AS id,
    'basic/productDetails'::text AS pinnedtocorrespondingview
   FROM (public.basic_productattachment productattachment
     LEFT JOIN public.basic_product product ON ((productattachment.product_id = product.id)))
UNION ALL
 SELECT '02technologies'::text AS pinnedto,
    technology.number AS pinnedtoobjectidentifier,
    technology.name AS pinnedtoobjectidentifiername,
    (technology.id)::integer AS pinnedtoobjectid,
    'technologies_technology'::text AS pinnedtomodelname,
    technologyattachment.attachment,
    technologyattachment.name,
    technologyattachment.size,
    upper((technologyattachment.ext)::text) AS ext,
    (1000000 + row_number() OVER ()) AS id,
    'technologies/technologyDetails'::text AS pinnedtocorrespondingview
   FROM (public.technologies_technologyattachment technologyattachment
     LEFT JOIN public.technologies_technology technology ON ((technologyattachment.technology_id = technology.id)))
UNION ALL
 SELECT '03parts'::text AS pinnedto,
    machinepart.number AS pinnedtoobjectidentifier,
    machinepart.name AS pinnedtoobjectidentifiername,
    (machinepart.id)::integer AS pinnedtoobjectid,
    'basic_product'::text AS pinnedtomodelname,
    machinepartattachment.attachment,
    machinepartattachment.name,
    machinepartattachment.size,
    upper((machinepartattachment.ext)::text) AS ext,
    (2000000 + row_number() OVER ()) AS id,
    'cmmsMachineParts/machinePartDetails'::text AS pinnedtocorrespondingview
   FROM (public.cmmsmachineparts_machinepartattachment machinepartattachment
     LEFT JOIN public.basic_product machinepart ON ((machinepartattachment.product_id = machinepart.id)))
UNION ALL
 SELECT '04components'::text AS pinnedto,
    subassembly.number AS pinnedtoobjectidentifier,
    subassembly.name AS pinnedtoobjectidentifiername,
    (subassembly.id)::integer AS pinnedtoobjectid,
    'basic_product'::text AS pinnedtomodelname,
    subassemblyattachment.attachment,
    subassemblyattachment.name,
    subassemblyattachment.size,
    upper((subassemblyattachment.ext)::text) AS ext,
    (3000000 + row_number() OVER ()) AS id,
    'basic/subassemblyDetails'::text AS pinnedtocorrespondingview
   FROM (public.basic_subassemblyattachment subassemblyattachment
     LEFT JOIN public.basic_subassembly subassembly ON ((subassemblyattachment.subassembly_id = subassembly.id)))
UNION ALL
 SELECT '05batches'::text AS pinnedto,
    batch.number AS pinnedtoobjectidentifier,
    ''::text AS pinnedtoobjectidentifiername,
    (batch.id)::integer AS pinnedtoobjectid,
    'advancedgenealogy_batch'::text AS pinnedtomodelname,
    batchattachment.attachment,
    batchattachment.name,
    batchattachment.size,
    upper((batchattachment.ext)::text) AS ext,
    (4000000 + row_number() OVER ()) AS id,
    'advancedGenealogy/batchDetails'::text AS pinnedtocorrespondingview
   FROM (public.advancedgenealogy_batchattachment batchattachment
     LEFT JOIN public.advancedgenealogy_batch batch ON ((batchattachment.batch_id = batch.id)))
UNION ALL
 SELECT '06deliveries'::text AS pinnedto,
    delivery.number AS pinnedtoobjectidentifier,
    delivery.name AS pinnedtoobjectidentifiername,
    (delivery.id)::integer AS pinnedtoobjectid,
    'deliveries_delivery'::text AS pinnedtomodelname,
    deliveryattachment.attachment,
    deliveryattachment.name,
    deliveryattachment.size,
    upper((deliveryattachment.ext)::text) AS ext,
    (5000000 + row_number() OVER ()) AS id,
    'deliveries/deliveryDetails'::text AS pinnedtocorrespondingview
   FROM (public.deliveries_deliveryattachment deliveryattachment
     LEFT JOIN public.deliveries_delivery delivery ON ((deliveryattachment.delivery_id = delivery.id)))
UNION ALL
 SELECT '07qualityControls'::text AS pinnedto,
    qualitycontrol.number AS pinnedtoobjectidentifier,
    ''::text AS pinnedtoobjectidentifiername,
    (qualitycontrol.id)::integer AS pinnedtoobjectid,
    'qualitycontrol_qualitycontrol'::text AS pinnedtomodelname,
    qualitycontrolattachment.attachment,
    qualitycontrolattachment.name,
    qualitycontrolattachment.size,
    upper((qualitycontrolattachment.ext)::text) AS ext,
    (6000000 + row_number() OVER ()) AS id,
    'qualityControl/qualityControlDetails'::text AS pinnedtocorrespondingview
   FROM (public.qualitycontrol_qualitycontrolattachment qualitycontrolattachment
     LEFT JOIN public.qualitycontrol_qualitycontrol qualitycontrol ON ((qualitycontrolattachment.qualitycontrol_id = qualitycontrol.id)))
UNION ALL
 SELECT '08qualityCards'::text AS pinnedto,
    qualitycard.number AS pinnedtoobjectidentifier,
    qualitycard.name AS pinnedtoobjectidentifiername,
    (qualitycard.id)::integer AS pinnedtoobjectid,
    'basic_qualitycard'::text AS pinnedtomodelname,
    qualitycardattachment.attachment,
    qualitycardattachment.name,
    qualitycardattachment.size,
    upper((qualitycardattachment.ext)::text) AS ext,
    (7000000 + row_number() OVER ()) AS id,
    'qualityControl/qualityCardDetails'::text AS pinnedtocorrespondingview
   FROM (public.qualitycontrol_qualitycardattachment qualitycardattachment
     LEFT JOIN public.basic_qualitycard qualitycard ON ((qualitycardattachment.qualitycard_id = qualitycard.id)))
UNION ALL
 SELECT '09workstations'::text AS pinnedto,
    workstation.number AS pinnedtoobjectidentifier,
    workstation.name AS pinnedtoobjectidentifiername,
    (workstation.id)::integer AS pinnedtoobjectid,
    'basic_workstation'::text AS pinnedtomodelname,
    workstationattachment.attachment,
    workstationattachment.name,
    workstationattachment.size,
    upper((workstationattachment.ext)::text) AS ext,
    (8000000 + row_number() OVER ()) AS id,
    'basic/workstationDetails'::text AS pinnedtocorrespondingview
   FROM (public.basic_workstationattachment workstationattachment
     LEFT JOIN public.basic_workstation workstation ON ((workstationattachment.workstation_id = workstation.id)))
UNION ALL
 SELECT '10orders'::text AS pinnedto,
    o.number AS pinnedtoobjectidentifier,
    o.name AS pinnedtoobjectidentifiername,
    (o.id)::integer AS pinnedtoobjectid,
    'orders_order'::text AS pinnedtomodelname,
    orderattachment.attachment,
    orderattachment.name,
    orderattachment.size,
    upper((orderattachment.ext)::text) AS ext,
    (9000000 + row_number() OVER ()) AS id,
    'orders/orderDetails'::text AS pinnedtocorrespondingview
   FROM (public.orders_orderattachment orderattachment
     LEFT JOIN public.orders_order o ON ((orderattachment.order_id = o.id)))
UNION ALL
 SELECT '11tools'::text AS pinnedto,
    tool.number AS pinnedtoobjectidentifier,
    tool.name AS pinnedtoobjectidentifiername,
    (tool.id)::integer AS pinnedtoobjectid,
    'cmmsmachineparts_tool'::text AS pinnedtomodelname,
    toolattachment.attachment,
    toolattachment.name,
    toolattachment.size,
    upper((toolattachment.ext)::text) AS ext,
    (10000000 + row_number() OVER ()) AS id,
    'cmmsMachineParts/toolDetails'::text AS pinnedtocorrespondingview
   FROM (public.cmmsmachineparts_toolattachment toolattachment
     LEFT JOIN public.cmmsmachineparts_tool tool ON ((toolattachment.tool_id = tool.id)));


--
-- Name: basic_attachmentdto_id_seq; Type: SEQUENCE; Schema: public; Owner: -
--

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


--
-- Name: basic_attribute; Type: TABLE; Schema: public; Owner: -
--

CREATE TABLE public.basic_attribute (
    id bigint NOT NULL,
    number character varying(255),
    name character varying(1024),
    datatype character varying(255),
    valuetype character varying(255),
    "precision" integer,
    unit character varying(255),
    forproduct boolean DEFAULT false,
    forresource boolean DEFAULT false,
    forqualitycontrol boolean DEFAULT false,
    active boolean DEFAULT true
);


--
-- Name: basic_attribute_id_seq; Type: SEQUENCE; Schema: public; Owner: -
--

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


--
-- Name: basic_attribute_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: -
--

ALTER SEQUENCE public.basic_attribute_id_seq OWNED BY public.basic_attribute.id;


--
-- Name: basic_attributevalue; Type: TABLE; Schema: public; Owner: -
--

CREATE TABLE public.basic_attributevalue (
    id bigint NOT NULL,
    attribute_id bigint,
    value character varying(255),
    description character varying(1024)
);


--
-- Name: basic_attributevalue_id_seq; Type: SEQUENCE; Schema: public; Owner: -
--

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


--
-- Name: basic_attributevalue_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: -
--

ALTER SEQUENCE public.basic_attributevalue_id_seq OWNED BY public.basic_attributevalue.id;


--
-- Name: basic_company_id_seq; Type: SEQUENCE; Schema: public; Owner: -
--

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


--
-- Name: basic_company_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: -
--

ALTER SEQUENCE public.basic_company_id_seq OWNED BY public.basic_company.id;


--
-- Name: basic_country; Type: TABLE; Schema: public; Owner: -
--

CREATE TABLE public.basic_country (
    id bigint NOT NULL,
    country character varying(255),
    code character varying(2),
    entityversion bigint DEFAULT 0
);


--
-- Name: basic_country_id_seq; Type: SEQUENCE; Schema: public; Owner: -
--

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


--
-- Name: basic_country_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: -
--

ALTER SEQUENCE public.basic_country_id_seq OWNED BY public.basic_country.id;


--
-- Name: basic_crew; Type: TABLE; Schema: public; Owner: -
--

CREATE TABLE public.basic_crew (
    id bigint NOT NULL,
    number character varying(255),
    leader_id bigint,
    active boolean DEFAULT true,
    eventsscheduler boolean
);


--
-- Name: basic_crew_id_seq; Type: SEQUENCE; Schema: public; Owner: -
--

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


--
-- Name: basic_crew_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: -
--

ALTER SEQUENCE public.basic_crew_id_seq OWNED BY public.basic_crew.id;


--
-- Name: basic_currency; Type: TABLE; Schema: public; Owner: -
--

CREATE TABLE public.basic_currency (
    id bigint NOT NULL,
    currency character varying(255),
    alphabeticcode character varying(3),
    isocode integer,
    minorunit integer,
    exchangerate numeric(12,5) DEFAULT 1,
    entityversion bigint DEFAULT 0
);


--
-- Name: basic_currency_id_seq; Type: SEQUENCE; Schema: public; Owner: -
--

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


--
-- Name: basic_currency_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: -
--

ALTER SEQUENCE public.basic_currency_id_seq OWNED BY public.basic_currency.id;


--
-- Name: basic_dashboardbutton; Type: TABLE; Schema: public; Owner: -
--

CREATE TABLE public.basic_dashboardbutton (
    id bigint NOT NULL,
    parameter_id bigint,
    identifier character varying(255),
    item_id bigint,
    icon character varying(255),
    succession integer,
    active boolean DEFAULT false
);


--
-- Name: basic_dashboardbutton_id_seq; Type: SEQUENCE; Schema: public; Owner: -
--

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


--
-- Name: basic_dashboardbutton_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: -
--

ALTER SEQUENCE public.basic_dashboardbutton_id_seq OWNED BY public.basic_dashboardbutton.id;


--
-- Name: basic_division_id_seq; Type: SEQUENCE; Schema: public; Owner: -
--

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


--
-- Name: basic_division_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: -
--

ALTER SEQUENCE public.basic_division_id_seq OWNED BY public.basic_division.id;


--
-- Name: basic_factory; Type: TABLE; Schema: public; Owner: -
--

CREATE TABLE public.basic_factory (
    id bigint NOT NULL,
    number character varying(255),
    name character varying(1024),
    city character varying(255),
    active boolean DEFAULT true,
    entityversion bigint DEFAULT 0,
    warehouse_id bigint
);


--
-- Name: basic_factory_id_seq; Type: SEQUENCE; Schema: public; Owner: -
--

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


--
-- Name: basic_factory_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: -
--

ALTER SEQUENCE public.basic_factory_id_seq OWNED BY public.basic_factory.id;


--
-- Name: basic_faulttype; Type: TABLE; Schema: public; Owner: -
--

CREATE TABLE public.basic_faulttype (
    id bigint NOT NULL,
    name character varying(255),
    appliesto character varying(255) DEFAULT '01workstationOrSubassembly'::character varying,
    entityversion bigint DEFAULT 0,
    isdefault boolean DEFAULT false,
    active boolean DEFAULT true
);


--
-- Name: basic_faulttype_id_seq; Type: SEQUENCE; Schema: public; Owner: -
--

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


--
-- Name: basic_faulttype_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: -
--

ALTER SEQUENCE public.basic_faulttype_id_seq OWNED BY public.basic_faulttype.id;


--
-- Name: basic_forms; Type: TABLE; Schema: public; Owner: -
--

CREATE TABLE public.basic_forms (
    id bigint NOT NULL,
    number character varying(255),
    name character varying(1024),
    company_id bigint,
    size numeric(12,5),
    unit character varying(255),
    active boolean DEFAULT true
);


--
-- Name: basic_forms_id_seq; Type: SEQUENCE; Schema: public; Owner: -
--

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


--
-- Name: basic_forms_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: -
--

ALTER SEQUENCE public.basic_forms_id_seq OWNED BY public.basic_forms.id;


--
-- Name: basic_label; Type: TABLE; Schema: public; Owner: -
--

CREATE TABLE public.basic_label (
    id bigint NOT NULL,
    name character varying(1024),
    description character varying(2048),
    createdate timestamp without time zone,
    updatedate timestamp without time zone,
    createuser character varying(255),
    updateuser character varying(255),
    active boolean DEFAULT true
);


--
-- Name: basic_label_id_seq; Type: SEQUENCE; Schema: public; Owner: -
--

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


--
-- Name: basic_label_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: -
--

ALTER SEQUENCE public.basic_label_id_seq OWNED BY public.basic_label.id;


--
-- Name: basic_licenseusage; Type: TABLE; Schema: public; Owner: -
--

CREATE TABLE public.basic_licenseusage (
    id bigint NOT NULL,
    createtime timestamp without time zone,
    user_id bigint,
    staff_id bigint
);


--
-- Name: basic_licenseusage_id_seq; Type: SEQUENCE; Schema: public; Owner: -
--

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


--
-- Name: basic_licenseusage_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: -
--

ALTER SEQUENCE public.basic_licenseusage_id_seq OWNED BY public.basic_licenseusage.id;


--
-- Name: basic_log; Type: TABLE; Schema: public; Owner: -
--

CREATE TABLE public.basic_log (
    id bigint NOT NULL,
    createtime timestamp without time zone,
    user_id bigint,
    message text,
    item1 character varying(2048),
    item2 character varying(2048),
    item3 character varying(2048),
    details text,
    loglevel character varying(255) DEFAULT '01trace'::character varying,
    logtype character varying(255),
    action character varying(255)
);


--
-- Name: basic_log_id_seq; Type: SEQUENCE; Schema: public; Owner: -
--

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


--
-- Name: basic_log_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: -
--

ALTER SEQUENCE public.basic_log_id_seq OWNED BY public.basic_log.id;


--
-- Name: basic_machineworkingperiod; Type: TABLE; Schema: public; Owner: -
--

CREATE TABLE public.basic_machineworkingperiod (
    id bigint NOT NULL,
    launchdate timestamp without time zone,
    stopdate timestamp without time zone,
    workingtime integer DEFAULT 0,
    workstation_id bigint,
    launchedby_id bigint,
    stoppedby_id bigint
);


--
-- Name: basic_machineworkingperiod_id_seq; Type: SEQUENCE; Schema: public; Owner: -
--

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


--
-- Name: basic_machineworkingperiod_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: -
--

ALTER SEQUENCE public.basic_machineworkingperiod_id_seq OWNED BY public.basic_machineworkingperiod.id;


--
-- Name: basic_model; Type: TABLE; Schema: public; Owner: -
--

CREATE TABLE public.basic_model (
    id bigint NOT NULL,
    name character varying(1024),
    assortment_id bigint,
    forms_id bigint,
    typeofproduct character varying(255),
    label_id bigint,
    createdate timestamp without time zone,
    updatedate timestamp without time zone,
    createuser character varying(255),
    updateuser character varying(255),
    active boolean DEFAULT true
);


--
-- Name: basic_model_id_seq; Type: SEQUENCE; Schema: public; Owner: -
--

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


--
-- Name: basic_model_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: -
--

ALTER SEQUENCE public.basic_model_id_seq OWNED BY public.basic_model.id;


--
-- Name: basic_numberpattern; Type: TABLE; Schema: public; Owner: -
--

CREATE TABLE public.basic_numberpattern (
    id bigint NOT NULL,
    number character varying(255),
    name character varying(1024),
    pattern character varying(255),
    usedin character varying(255),
    used boolean
);


--
-- Name: basic_numberpattern_id_seq; Type: SEQUENCE; Schema: public; Owner: -
--

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


--
-- Name: basic_numberpattern_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: -
--

ALTER SEQUENCE public.basic_numberpattern_id_seq OWNED BY public.basic_numberpattern.id;


--
-- Name: basic_numberpatternelement; Type: TABLE; Schema: public; Owner: -
--

CREATE TABLE public.basic_numberpatternelement (
    id bigint NOT NULL,
    numberpattern_id bigint,
    element character varying(255),
    value character varying(10),
    succession integer,
    sequencecycle character varying(255)
);


--
-- Name: basic_numberpatternelement_id_seq; Type: SEQUENCE; Schema: public; Owner: -
--

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


--
-- Name: basic_numberpatternelement_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: -
--

ALTER SEQUENCE public.basic_numberpatternelement_id_seq OWNED BY public.basic_numberpatternelement.id;


--
-- Name: basic_palletnumber_id_seq; Type: SEQUENCE; Schema: public; Owner: -
--

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


--
-- Name: basic_palletnumber_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: -
--

ALTER SEQUENCE public.basic_palletnumber_id_seq OWNED BY public.basic_palletnumber.id;


--
-- Name: basic_palletnumberhelper; Type: TABLE; Schema: public; Owner: -
--

CREATE TABLE public.basic_palletnumberhelper (
    id bigint NOT NULL,
    quantity integer,
    active boolean DEFAULT true,
    createdate timestamp without time zone,
    updatedate timestamp without time zone,
    createuser character varying(255),
    updateuser character varying(255),
    temporary boolean DEFAULT false
);


--
-- Name: basic_palletnumberhelper_id_seq; Type: SEQUENCE; Schema: public; Owner: -
--

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


--
-- Name: basic_palletnumberhelper_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: -
--

ALTER SEQUENCE public.basic_palletnumberhelper_id_seq OWNED BY public.basic_palletnumberhelper.id;


--
-- Name: basic_parameter; Type: TABLE; Schema: public; Owner: -
--

CREATE TABLE public.basic_parameter (
    id bigint NOT NULL,
    country_id bigint,
    currency_id bigint,
    unit character varying(255),
    additionaltextinfooter character varying(256),
    company_id bigint,
    registerproductiontime boolean,
    reasonneededwhendelayedeffectivedatefrom boolean DEFAULT false,
    earliereffectivedatetotime integer DEFAULT 900,
    reasonneededwhencorrectingtherequestedvolume boolean DEFAULT false,
    reasonneededwhencorrectingdateto boolean DEFAULT false,
    reasonneededwhenchangingstatetodeclined boolean DEFAULT false,
    imageurlinworkplan character varying(255),
    hidedescriptioninworkplans boolean,
    defaultproductionline_id bigint,
    reasonneededwhenearliereffectivedateto boolean DEFAULT false,
    earliereffectivedatefromtime integer DEFAULT 900,
    defaultaddress character varying(255) DEFAULT '01companyAddress'::character varying,
    allowquantitychangeinacceptedorder boolean DEFAULT false,
    reasonneededwhendelayedeffectivedateto boolean DEFAULT false,
    justone boolean,
    registerquantityinproduct boolean,
    reasonneededwhenchangingstatetointerrupted boolean DEFAULT false,
    registerquantityoutproduct boolean,
    dontprintordersinworkplans boolean,
    location_id bigint,
    typeofproductionrecording character varying(255) DEFAULT '02cumulated'::character varying,
    dontprintinputproductsinworkplans boolean,
    delayedeffectivedatefromtime integer DEFAULT 900,
    hideemptycolumnsfororders boolean DEFAULT false,
    reasonneededwhenchangingstatetoabandoned boolean DEFAULT false,
    autocloseorder boolean,
    allowtoclose boolean,
    dontprintoutputproductsinworkplans boolean,
    inputproductsrequiredfortype character varying(255),
    otheraddress character varying(2048),
    reasonneededwhenearliereffectivedatefrom boolean DEFAULT false,
    defaultdescription character varying(2048),
    delayedeffectivedatetotime integer DEFAULT 900,
    hidetechnologyandorderinworkplans boolean,
    reasonneededwhencorrectingdatefrom boolean DEFAULT false,
    ssccnumberprefix character varying(11),
    lowerlimit numeric(12,5),
    negativetrend numeric(12,5),
    upperlimit numeric(12,5),
    positivetrend numeric(12,5),
    dueweight numeric(12,5),
    printoperationatfirstpageinworkplans boolean DEFAULT false,
    averagelaborhourlycostpb numeric(12,5),
    materialcostsusedpb character varying(255) DEFAULT '06costForOrder'::character varying,
    additionaloverheadpb numeric(12,5) DEFAULT (0)::numeric,
    materialcostmarginpb numeric(12,5) DEFAULT (0)::numeric,
    includetpzpb boolean DEFAULT true,
    productioncostmarginpb numeric(12,5) DEFAULT (0)::numeric,
    averagemachinehourlycostpb numeric(12,5),
    includeadditionaltimepb boolean DEFAULT true,
    batchnumberuniqueness character varying(255) DEFAULT '01globally'::character varying,
    defaultcoveragefromdays integer,
    includedraftdeliveries boolean,
    coveragetype character varying(255) DEFAULT '01all'::character varying,
    hideemptycolumnsforoffers boolean,
    hideemptycolumnsforrequests boolean,
    validateproductionrecordtimes boolean,
    workstationsquantityfromproductionline boolean,
    lockproductionprogress boolean DEFAULT false,
    hidebarcodeoperationcomponentinworkplans boolean,
    ignoremissingcomponents boolean DEFAULT true,
    additionaloutputrows integer,
    additionalinputrows integer,
    allowmultipleregisteringtimeforworker boolean DEFAULT false,
    pricebasedon character varying(255) DEFAULT '01nominalProductCost'::character varying,
    takeactualprogressinworkplans boolean,
    confectionplanrequirereasontypethreshold numeric(12,5),
    confectionplancorrectionreasontype character varying(255),
    automaticsavecoverage boolean,
    externaldeliveriesextension boolean DEFAULT false,
    warehouse_id bigint,
    documentstate character varying(255),
    positivepurchaseprice boolean DEFAULT true,
    sameordernumber boolean DEFAULT false,
    automaticdeliveriesminstate boolean DEFAULT true,
    possibleworktimedeviation numeric(12,5),
    ordersincludeperiod integer,
    includerequirements boolean DEFAULT false,
    entityversion bigint DEFAULT 0,
    labelsbtpath character varying(255),
    profitpb numeric(12,5),
    registrationpriceoverheadpb numeric(12,5),
    sourceofoperationcostspb character varying(255),
    acceptanceevents boolean,
    useblackbox boolean,
    generatewarehouseissuestoorders boolean,
    daysbeforeorderstart integer,
    issuelocation_id bigint,
    consumptionofrawmaterialsbasedonstandards boolean DEFAULT false,
    documentpositionparameters_id bigint,
    includecomponents boolean,
    warehouseissuesreservestates boolean DEFAULT false,
    drawndocuments character varying(255) DEFAULT '01transfer'::character varying,
    issuedquantityuptoneed boolean DEFAULT false,
    documentsstatus character varying(255) DEFAULT '01accepted'::character varying,
    warehouseissueproductssource character varying(255) DEFAULT '01order'::character varying,
    productstoissue character varying(255) DEFAULT '01allInputProducts'::character varying,
    trackingcorrectionrecalculatepps boolean DEFAULT false,
    deliveredbiggerthanordered boolean DEFAULT true,
    ordersganttparameters_id bigint,
    additionalimage character varying(255),
    autorecalculateorder boolean,
    ppsisautomatic boolean,
    ppsproducedamountrecalculateplan boolean,
    ppsalgorithm character varying(255),
    baselinkerparameters_id bigint,
    technologiesgeneratorcopyproductsize boolean,
    cartonlabelsbtpath character varying,
    maxproductsquantity integer,
    allowerrorsinmasterorderpositions boolean,
    companyname_id bigint,
    hideassignedstaff boolean DEFAULT false,
    fillorderdescriptionbasedontechnologydescription boolean,
    allowanomalycreationonacceptancerecord boolean DEFAULT false,
    includelevelandsuffix boolean DEFAULT true,
    orderedproductsunit character varying,
    allowincompleteunits boolean DEFAULT false,
    acceptrecordsfromterminal boolean DEFAULT false,
    allowchangestousedquantityonterminal boolean DEFAULT false,
    includeadditionaltimeps boolean DEFAULT false,
    includetpzps boolean DEFAULT false,
    ordersgenerationnotcompletedates boolean DEFAULT false,
    canchangeprodlineforacceptedorders boolean DEFAULT false,
    generateeachonseparatepage boolean,
    includewagegroups boolean DEFAULT false,
    ordersgeneratedbycoverage boolean DEFAULT false,
    automaticallygenerateordersforcomponents boolean DEFAULT false,
    seteffectivedatefromoninprogress boolean DEFAULT false,
    seteffectivedatetooncompleted boolean DEFAULT false,
    copydescription boolean DEFAULT false,
    exporttopdfonlyvisiblecolumns boolean DEFAULT false,
    additionalcartonlabelsquantity integer DEFAULT 50,
    maxcartonlabelsquantity integer DEFAULT 3000,
    exporttocsvonlyvisiblecolumns boolean DEFAULT false,
    flagpercentageofexecutionwithcolor boolean DEFAULT false,
    opertaskflagpercentexecutionwithcolor boolean DEFAULT false,
    automaticclosingoforderwithingroups boolean DEFAULT false,
    copynotesfrommasterorderposition boolean DEFAULT false,
    manuallysendwarehousedocuments boolean DEFAULT false,
    realizationfromstock boolean DEFAULT false,
    alwaysorderitemswithpersonalization boolean DEFAULT false,
    selectorder boolean DEFAULT true,
    availabilityofrawmaterials boolean DEFAULT true,
    selectoperationaltask boolean DEFAULT true,
    stoppages boolean DEFAULT false,
    repair boolean DEFAULT true,
    employeeprogress boolean DEFAULT true,
    includeunacceptableproduction boolean DEFAULT false,
    calculateamounttimeemployeesonacceptancerecord boolean DEFAULT false,
    notshowtasksdownloadedbyanotheremployee boolean DEFAULT false,
    createcollectiveorders boolean DEFAULT false,
    completemasterorderafterorderingpositions boolean DEFAULT false,
    hideorderedproductworkplan boolean DEFAULT false,
    selectiontasksbyorderdateinterminal boolean DEFAULT false,
    showprogress boolean DEFAULT false,
    showdelays boolean DEFAULT false,
    requiresupplieridentification boolean DEFAULT false,
    numberpattern_id bigint,
    generatebatchfororderedproduct boolean,
    generatebatchoforderedproduct boolean DEFAULT false,
    acceptbatchtrackingwhenclosingorder boolean DEFAULT false,
    completewarehousesflowwhilechecking boolean DEFAULT false,
    qualitycontrol boolean DEFAULT false,
    finalqualitycontrolwithoutresources boolean DEFAULT false,
    terminalproductattribute_id bigint,
    oeefor character varying(255) DEFAULT '01productionLine'::character varying,
    oeeworktimefrom character varying(255) DEFAULT '01staffWorkTimes'::character varying,
    range character varying(255) DEFAULT '01oneDivision'::character varying,
    division_id bigint,
    showqronordersgrouppdf boolean DEFAULT false,
    advisestartdateoftheorder boolean DEFAULT false,
    orderstartdatebasedon character varying(255),
    showchartondashboard boolean DEFAULT true,
    whattoshowondashboard character varying(255) DEFAULT '01orders'::character varying,
    dashboardoperation_id bigint,
    dashboardcomponentslocation_id bigint,
    dashboardproductsinputlocation_id bigint,
    momentofvalidation character varying(255) DEFAULT '01orderAcceptance'::character varying,
    moveproductstosubsequentoperations boolean DEFAULT false,
    demandcausesofwastes boolean DEFAULT false,
    wmsapk character varying(255),
    wmsversion character varying(255),
    applicationconfigured boolean DEFAULT false,
    materialcostsused character varying(255) DEFAULT '01nominal'::character varying,
    usenominalcostpricenotspecified boolean DEFAULT false,
    sourceofoperationcosts character varying(255) DEFAULT '01technologyOperation'::character varying,
    standardlaborcost_id bigint,
    averagemachinehourlycost numeric(12,5),
    averagelaborhourlycost numeric(12,5),
    includetpz boolean DEFAULT false,
    includeadditionaltime boolean DEFAULT false,
    materialcostmargin numeric(12,5) DEFAULT 0,
    productioncostmargin numeric(12,5) DEFAULT 0,
    additionaloverhead numeric(12,5) DEFAULT 0,
    registrationpriceoverhead numeric(12,5) DEFAULT 0,
    profit numeric(12,5) DEFAULT 0,
    applicationconfigurationfinished boolean DEFAULT false,
    generatepacksfororders boolean DEFAULT false,
    includepacksgeneratingprocessesfororder boolean DEFAULT false,
    optimalpacksize numeric(12,5),
    restfeedinglastpack numeric(12,5),
    deliveryusenominalcostwhenpricenotspecified boolean DEFAULT false,
    deliverypricefillbasedon character varying(255) DEFAULT '01lastPurchasePrice'::character varying,
    allowcheckedtechnologywithoutinproducts boolean DEFAULT false,
    requireassortment boolean DEFAULT false,
    changeorderdatesbasedonchangegroupdates boolean DEFAULT false,
    acceptedtechnologymarkedasdefault boolean DEFAULT false,
    terminalscanning character varying(255) DEFAULT '01operationNumber'::character varying,
    processsource character varying(255) DEFAULT '01orderPackages'::character varying,
    showproductdescriptiononordersgrouppdf boolean DEFAULT false,
    attributeonordersgrouppdf_id bigint,
    copyattributestosizeproducts boolean DEFAULT false,
    materialcostsusedmc character varying(255) DEFAULT '01nominal'::character varying,
    usenominalcostpricenotspecifiedmc boolean DEFAULT false,
    productattribute_id bigint,
    materialattribute_id bigint,
    attributeonthelabel_id bigint,
    requiretypeoffault boolean DEFAULT false,
    workingstationinputtype character varying(255) DEFAULT '01scanTheNumber'::character varying,
    allowchangeordeleteordertechnologicalprocess boolean DEFAULT false,
    technicalproductioncostoverhead numeric(12,5) DEFAULT 0,
    technicalproductioncostoverheadpb numeric(12,5) DEFAULT 0,
    synchronizeadditionalproductdata boolean DEFAULT false,
    processterminalplaceofperformance character varying(255) DEFAULT '01workstation'::character varying,
    emptylabelbtpath character varying(255),
    schedulesortorder character varying(255) DEFAULT '01desc'::character varying,
    workstationassigncriterion character varying(255) DEFAULT '01shortestTime'::character varying,
    workerassigncriterion character varying(255) DEFAULT '01workstationLastOperatorLatestFinished'::character varying,
    additionaltimeextendsoperation boolean DEFAULT true,
    synchronizeproductcategory boolean DEFAULT true,
    completenominalcostinarticleandproducts boolean DEFAULT false,
    copynominalcostfamilyofproductssizes boolean DEFAULT false,
    onlypackagesinproduction boolean DEFAULT false,
    allowtilelengthtobeedited boolean DEFAULT false,
    analyzeavailableresources boolean DEFAULT false,
    analyzeplannedquantity boolean DEFAULT false,
    analyzemaxquantity integer,
    numberpatternordergroup_id bigint,
    otcopydescriptionfromproductionorder boolean DEFAULT false,
    setorderdatesbasedontaskdates boolean DEFAULT false,
    automaticallygeneratetasksfororder boolean DEFAULT false,
    automaticallygenerateprocessesfororder boolean DEFAULT false,
    includeadditionaltimesg boolean,
    includetpzsg boolean,
    includetpzs boolean DEFAULT true,
    dashboardshowforproduct character varying(255) DEFAULT '01number'::character varying,
    dashboardshowdescription boolean DEFAULT false,
    receivedeliveryinordercurrency boolean DEFAULT false,
    sortbyproducttypepriorityordersgrouppdf boolean DEFAULT true,
    attributeonordersgrouprequirementpdf_id bigint,
    quantitymadeonthebasisofdashboard character varying(255) DEFAULT '01approvedProduction'::character varying,
    producingmorethanplanned boolean DEFAULT true,
    logo character varying(255),
    synchronizemasterorderattributes boolean DEFAULT false,
    synchronizedocumentpositionattributes boolean DEFAULT false,
    dashboardordersorting character varying(255) DEFAULT '01startDate'::character varying,
    completestationandemployeeingeneratedtasks boolean DEFAULT false,
    considerexceptionswhenpromptingcurrentshift boolean DEFAULT false,
    productionorderedquantityclosestheorder boolean DEFAULT false,
    receiptofproducts character varying(255) DEFAULT '01onAcceptanceRegistrationRecord'::character varying,
    releaseofmaterials character varying(255) DEFAULT '01onAcceptanceRegistrationRecord'::character varying,
    considerminimumstocklevelwhencreatingproductionorders boolean DEFAULT false,
    fillorderdescriptionbasedonproductdescription boolean DEFAULT false,
    ganttrunadjusterror boolean DEFAULT true,
    checkfortheexistenceofinputproductprices boolean DEFAULT false,
    automaticupdatecostnorms boolean DEFAULT false,
    costssource character varying(255) DEFAULT '01mes'::character varying,
    automaticreleaseaftergeneration boolean DEFAULT false,
    analyzeactualstaff boolean DEFAULT false,
    analyzeactualstaffmaxquantity integer,
    analyzegetquantityfromshiftassignment boolean DEFAULT false,
    setmasterorderdatebasedonorderdates boolean DEFAULT false,
    notshowtasksblockedbyprevious boolean DEFAULT false,
    promptdefaultlinefromtechnology boolean DEFAULT true,
    numberofficelicenses integer DEFAULT 1,
    numberterminallicenses integer DEFAULT 1,
    typeterminallicenses character varying(255) DEFAULT '01upToTenEmployees'::character varying,
    notshoworderfilters boolean DEFAULT false,
    notincludedateswhenretrievingorders boolean DEFAULT false,
    requirequalityrating boolean DEFAULT true,
    synchronizeproductsize boolean DEFAULT false,
    masterorderreleaselocation_id bigint,
    demandworkstation boolean DEFAULT false,
    skipfinishedtasks boolean DEFAULT false,
    onlyonebatchtrackingfororder boolean DEFAULT false,
    producedbatchfromordertrackingrecord boolean DEFAULT false,
    packaginglocation_id bigint,
    includeworkstationongetrrforot boolean DEFAULT false,
    notincludeworkstationwhensearchingot boolean DEFAULT false,
    generatetransferdocumentsonrepair boolean DEFAULT true,
    howmanydaysrecalculateplan integer DEFAULT 7,
    operationproductindefaultquantity numeric(14,5),
    operationproductoutdefaultquantity numeric(14,5),
    manyarticleswiththesameean boolean DEFAULT false,
    includeincalculationdeliveries character varying(255) DEFAULT '01confirmedDeliveries'::character varying,
    transferordersgrouptoordersforcomponents boolean DEFAULT false,
    automaticallyusethebatchplannedinorder boolean DEFAULT false,
    productdeliverybatchevidence boolean DEFAULT false,
    productdeliverybatchnumberpattern_id bigint,
    showmachineperiodregistration boolean DEFAULT false,
    mergingordersforcomponents boolean DEFAULT false,
    tasksselectionby character varying(255) DEFAULT '01orderDate'::character varying,
    recalculateplantasksorder character varying(255) DEFAULT '01operationsLevelAndTasksStartDate'::character varying,
    numbervisibleorderstasksondashboard integer DEFAULT 50,
    updatetechnologiesonpendingorders boolean DEFAULT false,
    sharingregistrationrecord boolean DEFAULT false,
    noexchangeratedownload boolean DEFAULT false,
    createfailtodowntime boolean DEFAULT false,
    optimizecuttinglengthattribute_id bigint,
    optimizecuttingfinalwasteunit character varying(255),
    optimizecuttingfinalwaste numeric(14,5),
    dimensioncontrolofproducts boolean DEFAULT false,
    showplannedeventsonchart boolean DEFAULT false,
    updateplannedeventfinishdate boolean DEFAULT false,
    copyattributestoproducts boolean DEFAULT false,
    technologiesgeneratorcopyproductattributes boolean DEFAULT false,
    allowtotalregistration boolean DEFAULT false,
    workingtimetotalregistration character varying(255) DEFAULT '01duplicatedForEachOrder'::character varying,
    wastesconsumerawmaterials boolean DEFAULT true,
    moldrewclient_id bigint,
    deadlinefororderbasedondeliverydate boolean DEFAULT false,
    deadlinefororderearlierthandeliverydate integer DEFAULT 0,
    operationaltasksrecalculationtoken character varying(36),
    plannerworkstationassigncriterion character varying(255) DEFAULT '01minDeadlineForOrder'::character varying,
    deadlinesort boolean DEFAULT true,
    operationlevelsort boolean DEFAULT true,
    orderprioritysort boolean DEFAULT false,
    abcanalysissort boolean DEFAULT false,
    allowmasterorderdeadlinechange boolean DEFAULT false,
    scheduleduration integer DEFAULT 90,
    plandimensioncontrolofproducts boolean DEFAULT false,
    orderdimensioncontrolofproducts boolean DEFAULT false,
    pricelistattribute1_id bigint,
    pricelistattribute2_id bigint,
    recalculateplanafterfinishtaskinterminal boolean DEFAULT false,
    numberapslicenses integer DEFAULT 0,
    numberwmsmobilelicenses integer DEFAULT 0
);


--
-- Name: basic_parameter_id_seq; Type: SEQUENCE; Schema: public; Owner: -
--

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


--
-- Name: basic_parameter_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: -
--

ALTER SEQUENCE public.basic_parameter_id_seq OWNED BY public.basic_parameter.id;


--
-- Name: basic_piece_rate_number_seq; Type: SEQUENCE; Schema: public; Owner: -
--

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


--
-- Name: basic_piecerate; Type: TABLE; Schema: public; Owner: -
--

CREATE TABLE public.basic_piecerate (
    id bigint NOT NULL,
    number character varying(255),
    name character varying(1024)
);


--
-- Name: basic_piecerate_id_seq; Type: SEQUENCE; Schema: public; Owner: -
--

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


--
-- Name: basic_piecerate_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: -
--

ALTER SEQUENCE public.basic_piecerate_id_seq OWNED BY public.basic_piecerate.id;


--
-- Name: basic_piecerateitem; Type: TABLE; Schema: public; Owner: -
--

CREATE TABLE public.basic_piecerateitem (
    id bigint NOT NULL,
    piecerate_id bigint,
    actualrate numeric(9,2),
    datefrom date,
    dateto date
);


--
-- Name: basic_piecerateitem_id_seq; Type: SEQUENCE; Schema: public; Owner: -
--

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


--
-- Name: basic_piecerateitem_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: -
--

ALTER SEQUENCE public.basic_piecerateitem_id_seq OWNED BY public.basic_piecerateitem.id;


--
-- Name: basic_product_id_seq; Type: SEQUENCE; Schema: public; Owner: -
--

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


--
-- Name: basic_product_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: -
--

ALTER SEQUENCE public.basic_product_id_seq OWNED BY public.basic_product.id;


--
-- Name: basic_productattachment_id_seq; Type: SEQUENCE; Schema: public; Owner: -
--

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


--
-- Name: basic_productattachment_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: -
--

ALTER SEQUENCE public.basic_productattachment_id_seq OWNED BY public.basic_productattachment.id;


--
-- Name: basic_productattributevalue; Type: TABLE; Schema: public; Owner: -
--

CREATE TABLE public.basic_productattributevalue (
    id bigint NOT NULL,
    product_id bigint,
    attribute_id bigint,
    attributevalue_id bigint,
    value character varying(255)
);


--
-- Name: basic_productattributevalue_id_seq; Type: SEQUENCE; Schema: public; Owner: -
--

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


--
-- Name: basic_productattributevalue_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: -
--

ALTER SEQUENCE public.basic_productattributevalue_id_seq OWNED BY public.basic_productattributevalue.id;


--
-- Name: basic_productdto; Type: VIEW; Schema: public; Owner: -
--

CREATE VIEW public.basic_productdto AS
SELECT
    NULL::bigint AS id,
    NULL::character varying(255) AS number,
    NULL::character varying(1024) AS name,
    NULL::character varying(255) AS globaltypeofmaterial,
    NULL::character varying(255) AS category,
    NULL::character varying(1024) AS parentname,
    NULL::character varying(255) AS ean,
    NULL::character varying(255) AS externalnumber,
    NULL::character varying(255) AS assortmentname,
    NULL::character varying(1024) AS modelname,
    NULL::character varying(255) AS norm,
    NULL::character varying(255) AS sizenumber,
    NULL::boolean AS hasattachments,
    NULL::boolean AS active,
    NULL::character varying(255) AS unit,
    NULL::character varying(255) AS additionalunit,
    NULL::character varying(255) AS entitytype,
    NULL::character varying(255) AS supplier,
    NULL::numeric(12,5) AS nominalcost,
    NULL::numeric(12,5) AS lastpurchasecost,
    NULL::character varying(255) AS batchnumberpattern,
    NULL::character varying(2048) AS description;


--
-- Name: basic_productdto_id_seq; Type: SEQUENCE; Schema: public; Owner: -
--

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


--
-- Name: basic_qualitycard_id_seq; Type: SEQUENCE; Schema: public; Owner: -
--

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


--
-- Name: basic_qualitycard_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: -
--

ALTER SEQUENCE public.basic_qualitycard_id_seq OWNED BY public.basic_qualitycard.id;


--
-- Name: basic_qualitycardstatechange; Type: TABLE; Schema: public; Owner: -
--

CREATE TABLE public.basic_qualitycardstatechange (
    id bigint NOT NULL,
    dateandtime timestamp without time zone,
    sourcestate character varying(255),
    targetstate character varying(255),
    status character varying(255),
    phase integer,
    worker character varying(255),
    qualitycard_id bigint,
    shift_id bigint
);


--
-- Name: basic_qualitycardstatechange_id_seq; Type: SEQUENCE; Schema: public; Owner: -
--

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


--
-- Name: basic_qualitycardstatechange_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: -
--

ALTER SEQUENCE public.basic_qualitycardstatechange_id_seq OWNED BY public.basic_qualitycardstatechange.id;


--
-- Name: basic_reportcolumnwidth; Type: TABLE; Schema: public; Owner: -
--

CREATE TABLE public.basic_reportcolumnwidth (
    id bigint NOT NULL,
    identifier character varying(255),
    name character varying(1024),
    width integer,
    chartype character varying(255),
    parameter_id bigint,
    entityversion bigint DEFAULT 0
);


--
-- Name: basic_reportcolumnwidth_id_seq; Type: SEQUENCE; Schema: public; Owner: -
--

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


--
-- Name: basic_reportcolumnwidth_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: -
--

ALTER SEQUENCE public.basic_reportcolumnwidth_id_seq OWNED BY public.basic_reportcolumnwidth.id;


--
-- Name: basic_shift_id_seq; Type: SEQUENCE; Schema: public; Owner: -
--

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


--
-- Name: basic_shift_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: -
--

ALTER SEQUENCE public.basic_shift_id_seq OWNED BY public.basic_shift.id;


--
-- Name: basic_shifttimetableexception; Type: TABLE; Schema: public; Owner: -
--

CREATE TABLE public.basic_shifttimetableexception (
    id bigint NOT NULL,
    name character varying(1024),
    fromdate timestamp without time zone,
    todate timestamp without time zone,
    type character varying(255) DEFAULT '01freeTime'::character varying,
    relatestoprevday boolean DEFAULT false,
    entityversion bigint DEFAULT 0
);


--
-- Name: basic_shifttimetableexception_id_seq; Type: SEQUENCE; Schema: public; Owner: -
--

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


--
-- Name: basic_shifttimetableexception_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: -
--

ALTER SEQUENCE public.basic_shifttimetableexception_id_seq OWNED BY public.basic_shifttimetableexception.id;


--
-- Name: basic_size; Type: TABLE; Schema: public; Owner: -
--

CREATE TABLE public.basic_size (
    id bigint NOT NULL,
    number character varying(255),
    succession integer,
    createdate timestamp without time zone,
    updatedate timestamp without time zone,
    createuser character varying(255),
    updateuser character varying(255),
    active boolean DEFAULT true
);


--
-- Name: basic_size_id_seq; Type: SEQUENCE; Schema: public; Owner: -
--

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


--
-- Name: basic_size_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: -
--

ALTER SEQUENCE public.basic_size_id_seq OWNED BY public.basic_size.id;


--
-- Name: basic_sizegroup; Type: TABLE; Schema: public; Owner: -
--

CREATE TABLE public.basic_sizegroup (
    id bigint NOT NULL,
    number character varying(255),
    createdate timestamp without time zone,
    updatedate timestamp without time zone,
    createuser character varying(255),
    updateuser character varying(255),
    active boolean DEFAULT true
);


--
-- Name: basic_sizegroup_id_seq; Type: SEQUENCE; Schema: public; Owner: -
--

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


--
-- Name: basic_sizegroup_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: -
--

ALTER SEQUENCE public.basic_sizegroup_id_seq OWNED BY public.basic_sizegroup.id;


--
-- Name: basic_skill_id_seq; Type: SEQUENCE; Schema: public; Owner: -
--

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


--
-- Name: basic_skill; Type: TABLE; Schema: public; Owner: -
--

CREATE TABLE public.basic_skill (
    id bigint DEFAULT nextval('public.basic_skill_id_seq'::regclass) NOT NULL,
    name character varying(1024),
    description character varying(2048),
    maximumlevel integer,
    active boolean DEFAULT true
);


--
-- Name: basic_staff_id_seq; Type: SEQUENCE; Schema: public; Owner: -
--

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


--
-- Name: basic_staff_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: -
--

ALTER SEQUENCE public.basic_staff_id_seq OWNED BY public.basic_staff.id;


--
-- Name: wagegroups_wagegroup; Type: TABLE; Schema: public; Owner: -
--

CREATE TABLE public.wagegroups_wagegroup (
    id bigint NOT NULL,
    number character varying(255),
    name character varying(255),
    superiorwagegroup character varying(255),
    laborhourlycost numeric(12,5),
    laborhourlycostcurrency character varying(255),
    laborhourlycostfromwagegroup numeric(12,5),
    determinedindividually boolean,
    individuallaborhourlycost numeric(12,5),
    entityversion bigint DEFAULT 0
);


--
-- Name: basic_staffdto; Type: VIEW; Schema: public; Owner: -
--

CREATE VIEW public.basic_staffdto AS
 SELECT s.id,
    s.active,
    s.number,
    s.name,
    s.surname,
    s.post,
    pl.number AS productionlinenumber,
    d.number AS divisionnumber,
    d.name AS divisionname,
    w.number AS workstationnumber,
    w.name AS workstationname,
    c.name AS workforname,
    wg.number AS wagegroupnumber
   FROM (((((public.basic_staff s
     LEFT JOIN public.productionlines_productionline pl ON ((s.productionline_id = pl.id)))
     LEFT JOIN public.basic_division d ON ((s.division_id = d.id)))
     LEFT JOIN public.basic_workstation w ON ((s.workstation_id = w.id)))
     LEFT JOIN public.basic_company c ON ((s.workfor_id = c.id)))
     LEFT JOIN public.wagegroups_wagegroup wg ON ((s.wagegroup_id = wg.id)));


--
-- Name: basic_staffdto_id_seq; Type: SEQUENCE; Schema: public; Owner: -
--

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


--
-- Name: basic_staffskill_id_seq; Type: SEQUENCE; Schema: public; Owner: -
--

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


--
-- Name: basic_staffskill; Type: TABLE; Schema: public; Owner: -
--

CREATE TABLE public.basic_staffskill (
    id bigint DEFAULT nextval('public.basic_staffskill_id_seq'::regclass) NOT NULL,
    staff_id bigint,
    skill_id bigint,
    level integer,
    active boolean DEFAULT true
);


--
-- Name: basic_subassembly_id_seq; Type: SEQUENCE; Schema: public; Owner: -
--

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


--
-- Name: basic_subassembly_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: -
--

ALTER SEQUENCE public.basic_subassembly_id_seq OWNED BY public.basic_subassembly.id;


--
-- Name: basic_subassemblyattachment_id_seq; Type: SEQUENCE; Schema: public; Owner: -
--

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


--
-- Name: basic_subassemblyattachment_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: -
--

ALTER SEQUENCE public.basic_subassemblyattachment_id_seq OWNED BY public.basic_subassemblyattachment.id;


--
-- Name: basic_workstationtype; Type: TABLE; Schema: public; Owner: -
--

CREATE TABLE public.basic_workstationtype (
    id bigint NOT NULL,
    name character varying(1024),
    number character varying(255),
    description character varying(2048),
    active boolean DEFAULT true,
    subassembly boolean,
    entityversion bigint DEFAULT 0
);


--
-- Name: basic_subassemblylistdto; Type: VIEW; Schema: public; Owner: -
--

CREATE VIEW public.basic_subassemblylistdto AS
 SELECT subassembly.id,
    subassembly.active,
    subassembly.number,
    subassembly.name,
    workstation.number AS workstationnumber,
    subassembly.type,
    workstationtype.number AS workstationtypenumber,
    subassembly.productiondate,
    event.maxdate AS lastrepairsdate
   FROM (((public.basic_subassembly subassembly
     LEFT JOIN public.basic_workstation workstation ON ((subassembly.workstation_id = workstation.id)))
     JOIN public.basic_workstationtype workstationtype ON ((subassembly.workstationtype_id = workstationtype.id)))
     LEFT JOIN ( SELECT plannedevent.subassembly_id AS subassemblyid,
            max(plannedevent.date) AS maxdate
           FROM public.cmmsmachineparts_plannedevent plannedevent
          WHERE (((plannedevent.state)::text = '05realized'::text) AND ((plannedevent.basedon)::text = '01date'::text) AND ((plannedevent.type)::text = '02repairs'::text))
          GROUP BY plannedevent.subassembly_id) event ON ((event.subassemblyid = subassembly.id)));


--
-- Name: basic_subassemblylistdto_id_seq; Type: SEQUENCE; Schema: public; Owner: -
--

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


--
-- Name: basic_subassemblytoworkstationhelper; Type: TABLE; Schema: public; Owner: -
--

CREATE TABLE public.basic_subassemblytoworkstationhelper (
    id bigint NOT NULL,
    subassembly_id bigint,
    type character varying(255),
    workstation_id bigint,
    entityversion bigint DEFAULT 0
);


--
-- Name: basic_subassemblytoworkstationhelper_id_seq; Type: SEQUENCE; Schema: public; Owner: -
--

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


--
-- Name: basic_subassemblytoworkstationhelper_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: -
--

ALTER SEQUENCE public.basic_subassemblytoworkstationhelper_id_seq OWNED BY public.basic_subassemblytoworkstationhelper.id;


--
-- Name: basic_substitutecomponent; Type: TABLE; Schema: public; Owner: -
--

CREATE TABLE public.basic_substitutecomponent (
    id bigint NOT NULL,
    product_id bigint,
    quantity numeric(9,5),
    baseproduct_id bigint,
    entityversion bigint DEFAULT 0
);


--
-- Name: basic_substitutecomponent_id_seq; Type: SEQUENCE; Schema: public; Owner: -
--

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


--
-- Name: basic_substitutecomponent_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: -
--

ALTER SEQUENCE public.basic_substitutecomponent_id_seq OWNED BY public.basic_substitutecomponent.id;


--
-- Name: basic_technological_process_rate_number_seq; Type: SEQUENCE; Schema: public; Owner: -
--

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


--
-- Name: basic_technologicalprocessrate; Type: TABLE; Schema: public; Owner: -
--

CREATE TABLE public.basic_technologicalprocessrate (
    id bigint NOT NULL,
    number character varying(255),
    name character varying(1024)
);


--
-- Name: basic_technologicalprocessrate_id_seq; Type: SEQUENCE; Schema: public; Owner: -
--

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


--
-- Name: basic_technologicalprocessrate_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: -
--

ALTER SEQUENCE public.basic_technologicalprocessrate_id_seq OWNED BY public.basic_technologicalprocessrate.id;


--
-- Name: basic_technologicalprocessrateitem; Type: TABLE; Schema: public; Owner: -
--

CREATE TABLE public.basic_technologicalprocessrateitem (
    id bigint NOT NULL,
    technologicalprocessrate_id bigint,
    actualrate numeric(9,2),
    datefrom date,
    dateto date
);


--
-- Name: basic_technologicalprocessrateitem_id_seq; Type: SEQUENCE; Schema: public; Owner: -
--

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


--
-- Name: basic_technologicalprocessrateitem_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: -
--

ALTER SEQUENCE public.basic_technologicalprocessrateitem_id_seq OWNED BY public.basic_technologicalprocessrateitem.id;


--
-- Name: jointable_productionline_shifttimetableexception; Type: TABLE; Schema: public; Owner: -
--

CREATE TABLE public.jointable_productionline_shifttimetableexception (
    productionline_id bigint NOT NULL,
    shifttimetableexception_id bigint NOT NULL
);


--
-- Name: jointable_shift_shifttimetableexception; Type: TABLE; Schema: public; Owner: -
--

CREATE TABLE public.jointable_shift_shifttimetableexception (
    shift_id bigint NOT NULL,
    shifttimetableexception_id bigint NOT NULL
);


--
-- Name: basic_timetableexceptiondto; Type: VIEW; Schema: public; Owner: -
--

CREATE VIEW public.basic_timetableexceptiondto AS
 SELECT shifttimetableexception.id,
    shifttimetableexception.name,
    shifttimetableexception.fromdate,
    shifttimetableexception.todate,
    shifttimetableexception.type,
    shifttimetableexception.relatestoprevday,
    array_to_string(ARRAY( SELECT shift.name
           FROM (public.jointable_shift_shifttimetableexception shift_shifttimetableexception
             LEFT JOIN public.basic_shift shift ON ((shift_shifttimetableexception.shift_id = shift.id)))
          WHERE (shift_shifttimetableexception.shifttimetableexception_id = shifttimetableexception.id)), ', '::text) AS shifts,
    array_to_string(ARRAY( SELECT productionline.number
           FROM (public.jointable_productionline_shifttimetableexception productionline_shifttimetableexception
             LEFT JOIN public.productionlines_productionline productionline ON ((productionline_shifttimetableexception.productionline_id = productionline.id)))
          WHERE (productionline_shifttimetableexception.shifttimetableexception_id = shifttimetableexception.id)), ', '::text) AS productionlines
   FROM public.basic_shifttimetableexception shifttimetableexception;


--
-- Name: basic_timetableexceptiondto_id_seq; Type: SEQUENCE; Schema: public; Owner: -
--

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


--
-- Name: basic_timetableexceptionpershiftdto; Type: VIEW; Schema: public; Owner: -
--

CREATE VIEW public.basic_timetableexceptionpershiftdto AS
 SELECT shifttimetableexception.id,
    shifttimetableexception.name,
    shifttimetableexception.fromdate,
    shifttimetableexception.todate,
    shifttimetableexception.type,
    shifttimetableexception.relatestoprevday,
    (shift_shifttimetableexception.shift_id)::integer AS shiftid,
    array_to_string(ARRAY( SELECT shift.name
           FROM (public.jointable_shift_shifttimetableexception shift_shifttimetableexception_1
             LEFT JOIN public.basic_shift shift ON ((shift_shifttimetableexception_1.shift_id = shift.id)))
          WHERE (shift_shifttimetableexception_1.shifttimetableexception_id = shifttimetableexception.id)), ', '::text) AS shifts,
    array_to_string(ARRAY( SELECT productionline.number
           FROM (public.jointable_productionline_shifttimetableexception productionline_shifttimetableexception
             LEFT JOIN public.productionlines_productionline productionline ON ((productionline_shifttimetableexception.productionline_id = productionline.id)))
          WHERE (productionline_shifttimetableexception.shifttimetableexception_id = shifttimetableexception.id)), ', '::text) AS productionlines
   FROM (public.basic_shifttimetableexception shifttimetableexception
     LEFT JOIN public.jointable_shift_shifttimetableexception shift_shifttimetableexception ON ((shifttimetableexception.id = shift_shifttimetableexception.shifttimetableexception_id)));


--
-- Name: basic_timetableexceptionpershiftdto_id_seq; Type: SEQUENCE; Schema: public; Owner: -
--

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


--
-- Name: basic_viewedactivity; Type: TABLE; Schema: public; Owner: -
--

CREATE TABLE public.basic_viewedactivity (
    id bigint NOT NULL,
    user_id bigint,
    log_id bigint
);


--
-- Name: basic_viewedactivity_id_seq; Type: SEQUENCE; Schema: public; Owner: -
--

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


--
-- Name: basic_viewedactivity_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: -
--

ALTER SEQUENCE public.basic_viewedactivity_id_seq OWNED BY public.basic_viewedactivity.id;


--
-- Name: basic_workstation_id_seq; Type: SEQUENCE; Schema: public; Owner: -
--

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


--
-- Name: basic_workstation_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: -
--

ALTER SEQUENCE public.basic_workstation_id_seq OWNED BY public.basic_workstation.id;


--
-- Name: basic_workstationattachment_id_seq; Type: SEQUENCE; Schema: public; Owner: -
--

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


--
-- Name: basic_workstationattachment_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: -
--

ALTER SEQUENCE public.basic_workstationattachment_id_seq OWNED BY public.basic_workstationattachment.id;


--
-- Name: basic_workstationdto; Type: VIEW; Schema: public; Owner: -
--

CREATE VIEW public.basic_workstationdto AS
 SELECT w.id,
    w.active,
    w.number,
    w.name,
    wt.name AS workstationtype,
    d.number AS division,
    w.wnknumber,
    (((stf.name)::text || ' '::text) || (stf.surname)::text) AS staff,
    w.dateofadmission,
    w.dateofwithdrawal,
    pl.name AS productionline,
    w.state
   FROM ((((public.basic_workstation w
     LEFT JOIN public.basic_workstationtype wt ON ((wt.id = w.workstationtype_id)))
     LEFT JOIN public.basic_division d ON ((w.division_id = d.id)))
     LEFT JOIN public.basic_staff stf ON ((stf.id = w.staff_id)))
     LEFT JOIN public.productionlines_productionline pl ON ((w.productionline_id = pl.id)));


--
-- Name: basic_workstationdto_id_seq; Type: SEQUENCE; Schema: public; Owner: -
--

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


--
-- Name: basic_workstationtype_id_seq; Type: SEQUENCE; Schema: public; Owner: -
--

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


--
-- Name: basic_workstationtype_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: -
--

ALTER SEQUENCE public.basic_workstationtype_id_seq OWNED BY public.basic_workstationtype.id;


--
-- Name: basicproductioncounting_basicproductioncounting; Type: TABLE; Schema: public; Owner: -
--

CREATE TABLE public.basicproductioncounting_basicproductioncounting (
    id bigint NOT NULL,
    order_id bigint,
    product_id bigint,
    usedquantity numeric(14,5),
    producedquantity numeric(14,5),
    entityversion bigint DEFAULT 0
);


--
-- Name: basicproductioncounting_basicproductioncounting_id_seq; Type: SEQUENCE; Schema: public; Owner: -
--

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


--
-- Name: basicproductioncounting_basicproductioncounting_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: -
--

ALTER SEQUENCE public.basicproductioncounting_basicproductioncounting_id_seq OWNED BY public.basicproductioncounting_basicproductioncounting.id;


--
-- Name: basicproductioncounting_productioncountingquantity; Type: TABLE; Schema: public; Owner: -
--

CREATE TABLE public.basicproductioncounting_productioncountingquantity (
    id bigint NOT NULL,
    order_id bigint,
    product_id bigint,
    plannedquantity numeric(14,5),
    isnoncomponent boolean DEFAULT false,
    technologyoperationcomponent_id bigint,
    basicproductioncounting_id bigint,
    typeofmaterial character varying(255) DEFAULT '01component'::character varying,
    role character varying(255) DEFAULT '01used'::character varying,
    componentsoutputlocation_id bigint,
    componentslocation_id bigint,
    productsinputlocation_id bigint,
    productionflow character varying(255),
    productsflowlocation_id bigint,
    entityversion bigint DEFAULT 0,
    replacementto_id bigint,
    showmaterialcomponentinworkplan boolean DEFAULT false,
    technologyinputproducttype_id bigint,
    usedquantity numeric(14,5),
    producedquantity numeric(14,5),
    wastereceptionwarehouse_id bigint,
    attribute_id bigint
);


--
-- Name: basicproductioncounting_basicproductioncountingdto; Type: VIEW; Schema: public; Owner: -
--

CREATE VIEW public.basicproductioncounting_basicproductioncountingdto AS
 SELECT bpc.id,
    (bpc.order_id)::integer AS orderid,
    product.number AS productnumber,
    product.name AS productname,
    product.unit AS productunit,
    o.plannedquantity,
    bpc.usedquantity,
    bpc.producedquantity
   FROM ((public.basicproductioncounting_basicproductioncounting bpc
     JOIN public.basic_product product ON ((product.id = bpc.product_id)))
     JOIN public.orders_order o ON ((o.id = bpc.order_id)))
  WHERE (bpc.product_id = o.product_id)
UNION
 SELECT bpc.id,
    (bpc.order_id)::integer AS orderid,
    product.number AS productnumber,
    product.name AS productname,
    product.unit AS productunit,
    COALESCE(sum(pcq.plannedquantity), (0)::numeric) AS plannedquantity,
    bpc.usedquantity,
    bpc.producedquantity
   FROM (((public.basicproductioncounting_basicproductioncounting bpc
     JOIN public.basic_product product ON ((product.id = bpc.product_id)))
     JOIN public.orders_order o ON ((o.id = bpc.order_id)))
     LEFT JOIN public.basicproductioncounting_productioncountingquantity pcq ON (((pcq.order_id = bpc.order_id) AND (pcq.product_id = bpc.product_id) AND ((pcq.role)::text = '01used'::text))))
  WHERE (bpc.product_id <> o.product_id)
  GROUP BY bpc.id, bpc.order_id, product.number, product.name, product.unit, bpc.usedquantity, bpc.producedquantity;


--
-- Name: basicproductioncounting_basicproductioncountingdto_id_seq; Type: SEQUENCE; Schema: public; Owner: -
--

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


--
-- Name: productioncounting_productiontracking; Type: TABLE; Schema: public; Owner: -
--

CREATE TABLE public.productioncounting_productiontracking (
    id bigint NOT NULL,
    number character varying(255),
    order_id bigint,
    technologyinstanceoperationcomponent_id bigint,
    shift_id bigint,
    state character varying(255) DEFAULT '01draft'::character varying,
    lasttracking boolean,
    machinetime integer,
    labortime integer,
    staff_id bigint,
    workstationtype_id bigint,
    division_id bigint,
    active boolean DEFAULT true,
    createdate timestamp without time zone,
    updatedate timestamp without time zone,
    createuser character varying(255),
    updateuser character varying(255),
    laststatechangefails boolean DEFAULT false,
    laststatechangefailcause character varying(255),
    isexternalsynchronized boolean DEFAULT true,
    timerangefrom timestamp without time zone,
    timerangeto timestamp without time zone,
    shiftstartday date,
    changeovertime integer,
    subcontractor_id bigint,
    technologyoperationcomponent_id bigint,
    entityversion bigint DEFAULT 0,
    repairorder_id bigint,
    correction_id bigint,
    iscorrection boolean DEFAULT false,
    planforordercompleted boolean DEFAULT false,
    workstation_id bigint,
    batch_id bigint,
    expirationdate date,
    qualityrating character varying(255),
    iscorrected boolean DEFAULT false,
    comments character varying(2048)
);


--
-- Name: productioncounting_trackingoperationproductoutcomponent; Type: TABLE; Schema: public; Owner: -
--

CREATE TABLE public.productioncounting_trackingoperationproductoutcomponent (
    id bigint NOT NULL,
    productiontracking_id bigint,
    product_id bigint,
    usedquantity numeric(14,5),
    balance numeric(14,5),
    batch_id bigint,
    wastedquantity numeric(14,5),
    givenunit character varying(255),
    givenquantity numeric(14,5),
    entityversion bigint DEFAULT 0,
    wastesquantity numeric(14,5),
    typeofmaterial character varying(255) DEFAULT '01component'::character varying,
    storagelocation_id bigint,
    causeofwastes character varying(255),
    palletnumber_id bigint,
    manyreasonsforlacks boolean DEFAULT false,
    typeofpallet character varying(255)
);


--
-- Name: basicproductioncounting_producedquantity_helper; Type: VIEW; Schema: public; Owner: -
--

CREATE VIEW public.basicproductioncounting_producedquantity_helper AS
 SELECT sum(topoc.usedquantity) AS producedquantity,
    pt.order_id,
    topoc.product_id,
    pt.technologyoperationcomponent_id
   FROM (public.productioncounting_trackingoperationproductoutcomponent topoc
     JOIN public.productioncounting_productiontracking pt ON ((pt.id = topoc.productiontracking_id)))
  WHERE ((pt.state)::text = '02accepted'::text)
  GROUP BY pt.order_id, topoc.product_id, pt.technologyoperationcomponent_id;


--
-- Name: basicproductioncounting_producedquantity_withdraft; Type: VIEW; Schema: public; Owner: -
--

CREATE VIEW public.basicproductioncounting_producedquantity_withdraft AS
 SELECT sum(topoc.usedquantity) AS producedquantity,
    pt.order_id,
    topoc.product_id,
    pt.technologyoperationcomponent_id
   FROM (public.productioncounting_trackingoperationproductoutcomponent topoc
     JOIN public.productioncounting_productiontracking pt ON ((pt.id = topoc.productiontracking_id)))
  WHERE (((pt.state)::text = '02accepted'::text) OR ((pt.state)::text = '01draft'::text))
  GROUP BY pt.order_id, topoc.product_id, pt.technologyoperationcomponent_id;


--
-- Name: basicproductioncounting_productioncountingattributevalue; Type: TABLE; Schema: public; Owner: -
--

CREATE TABLE public.basicproductioncounting_productioncountingattributevalue (
    id bigint NOT NULL,
    productioncountingquantity_id bigint,
    attribute_id bigint,
    attributevalue_id bigint,
    value character varying(255)
);


--
-- Name: basicproductioncounting_productioncountingattributevalue_id_seq; Type: SEQUENCE; Schema: public; Owner: -
--

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


--
-- Name: basicproductioncounting_productioncountingattributevalue_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: -
--

ALTER SEQUENCE public.basicproductioncounting_productioncountingattributevalue_id_seq OWNED BY public.basicproductioncounting_productioncountingattributevalue.id;


--
-- Name: basicproductioncounting_productioncountingoperationrun; Type: TABLE; Schema: public; Owner: -
--

CREATE TABLE public.basicproductioncounting_productioncountingoperationrun (
    id bigint NOT NULL,
    order_id bigint,
    technologyoperationcomponent_id bigint,
    runs numeric(12,5),
    entityversion bigint DEFAULT 0
);


--
-- Name: basicproductioncounting_productioncountingoperationrun_id_seq; Type: SEQUENCE; Schema: public; Owner: -
--

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


--
-- Name: basicproductioncounting_productioncountingoperationrun_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: -
--

ALTER SEQUENCE public.basicproductioncounting_productioncountingoperationrun_id_seq OWNED BY public.basicproductioncounting_productioncountingoperationrun.id;


--
-- Name: basicproductioncounting_productioncountingquantity_id_seq; Type: SEQUENCE; Schema: public; Owner: -
--

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


--
-- Name: basicproductioncounting_productioncountingquantity_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: -
--

ALTER SEQUENCE public.basicproductioncounting_productioncountingquantity_id_seq OWNED BY public.basicproductioncounting_productioncountingquantity.id;


--
-- Name: basicproductioncounting_productioncountingquantitychange; Type: TABLE; Schema: public; Owner: -
--

CREATE TABLE public.basicproductioncounting_productioncountingquantitychange (
    id bigint NOT NULL,
    order_id bigint,
    product_id bigint,
    plannedquantitybefore numeric(14,5),
    plannedquantityafter numeric(14,5),
    dateandtime timestamp without time zone,
    worker character varying(255),
    changetype character varying(255)
);


--
-- Name: basicproductioncounting_productioncountingquantitychange_id_seq; Type: SEQUENCE; Schema: public; Owner: -
--

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


--
-- Name: basicproductioncounting_productioncountingquantitychange_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: -
--

ALTER SEQUENCE public.basicproductioncounting_productioncountingquantitychange_id_seq OWNED BY public.basicproductioncounting_productioncountingquantitychange.id;


--
-- Name: technologies_technologyinputproducttype; Type: TABLE; Schema: public; Owner: -
--

CREATE TABLE public.technologies_technologyinputproducttype (
    id bigint NOT NULL,
    name character varying(255),
    averageprice numeric(9,2),
    createdate timestamp without time zone,
    updatedate timestamp without time zone,
    createuser character varying(255),
    updateuser character varying(255),
    active boolean DEFAULT true
);


--
-- Name: basicproductioncounting_productioncountingquantitydto; Type: VIEW; Schema: public; Owner: -
--

CREATE VIEW public.basicproductioncounting_productioncountingquantitydto AS
 SELECT pcq.id,
    (pcq.order_id)::integer AS orderid,
    (product.id)::integer AS productid,
    product.number AS productnumber,
    product.name AS productname,
    product.unit AS productunit,
    toc.id AS tocid,
    COALESCE(toc.nodenumber, ''::character varying) AS nodenumber,
    COALESCE(op.number, ''::character varying) AS operationnumber,
    COALESCE(op.name, ''::character varying) AS operationname,
    pcq.role,
    pcq.typeofmaterial,
    pcq.plannedquantity,
    COALESCE(pcq.usedquantity, (0)::numeric) AS usedquantity,
    COALESCE(pcq.producedquantity, (0)::numeric) AS producedquantity,
    replacementto.number AS replacementto,
    tipt.name AS technologyinputproducttypename,
        CASE
            WHEN (( SELECT count(*) AS count
               FROM public.basic_substitutecomponent
              WHERE (basic_substitutecomponent.baseproduct_id = product.id)) > 0) THEN true
            ELSE false
        END AS replacement
   FROM ((((((public.basicproductioncounting_productioncountingquantity pcq
     JOIN public.basic_product product ON ((product.id = pcq.product_id)))
     JOIN public.orders_order o ON ((o.id = pcq.order_id)))
     LEFT JOIN public.basic_product replacementto ON ((replacementto.id = pcq.replacementto_id)))
     LEFT JOIN public.technologies_technologyoperationcomponent toc ON ((pcq.technologyoperationcomponent_id = toc.id)))
     LEFT JOIN public.technologies_operation op ON ((op.id = toc.operation_id)))
     LEFT JOIN public.technologies_technologyinputproducttype tipt ON ((tipt.id = pcq.technologyinputproducttype_id)))
  WHERE ((o.typeofproductionrecording)::text = '02cumulated'::text)
UNION
 SELECT pcq.id,
    (pcq.order_id)::integer AS orderid,
    (product.id)::integer AS productid,
    product.number AS productnumber,
    product.name AS productname,
    product.unit AS productunit,
    toc.id AS tocid,
    toc.nodenumber,
    op.number AS operationnumber,
    op.name AS operationname,
    pcq.role,
    pcq.typeofmaterial,
    pcq.plannedquantity,
    COALESCE(pcq.usedquantity, (0)::numeric) AS usedquantity,
    COALESCE(pcq.producedquantity, (0)::numeric) AS producedquantity,
    replacementto.number AS replacementto,
    tipt.name AS technologyinputproducttypename,
        CASE
            WHEN (( SELECT count(*) AS count
               FROM public.basic_substitutecomponent
              WHERE (basic_substitutecomponent.baseproduct_id = product.id)) > 0) THEN true
            ELSE false
        END AS replacement
   FROM ((((((public.basicproductioncounting_productioncountingquantity pcq
     JOIN public.basic_product product ON ((product.id = pcq.product_id)))
     JOIN public.orders_order o ON ((o.id = pcq.order_id)))
     JOIN public.technologies_technologyoperationcomponent toc ON ((pcq.technologyoperationcomponent_id = toc.id)))
     JOIN public.technologies_operation op ON ((op.id = toc.operation_id)))
     LEFT JOIN public.basic_product replacementto ON ((replacementto.id = pcq.replacementto_id)))
     LEFT JOIN public.technologies_technologyinputproducttype tipt ON ((tipt.id = pcq.technologyinputproducttype_id)))
  WHERE ((o.typeofproductionrecording)::text = '03forEach'::text);


--
-- Name: basicproductioncounting_productioncountingquantitydto_id_seq; Type: SEQUENCE; Schema: public; Owner: -
--

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


--
-- Name: orders_operationaltask; Type: TABLE; Schema: public; Owner: -
--

CREATE TABLE public.orders_operationaltask (
    id bigint NOT NULL,
    number character varying(256),
    name character varying(1024),
    description character varying(2048),
    type character varying(255),
    startdate timestamp without time zone,
    finishdate timestamp without time zone,
    order_id bigint,
    entityversion bigint DEFAULT 0,
    staff_id bigint,
    workstation_id bigint,
    state character varying(255) DEFAULT '01pending'::character varying,
    technologyoperationcomponent_id bigint,
    product_id bigint,
    scheduleposition_id bigint,
    division_id bigint,
    actualstaff integer,
    suborder_id bigint
);


--
-- Name: basicproductioncounting_productioncountingquantitylistdto; Type: VIEW; Schema: public; Owner: -
--

CREATE VIEW public.basicproductioncounting_productioncountingquantitylistdto AS
 SELECT pcq.id,
    o.number AS ordernumber,
    (o.id)::integer AS orderid,
    ot.number AS operationaltasknumber,
    (ot.id)::integer AS operationaltaskid,
    COALESCE(ot.startdate, o.startdate) AS startdate,
    product.number AS productnumber,
    product.name AS productname,
    product.unit AS productunit,
    COALESCE(toc.nodenumber, ''::character varying) AS nodenumber,
    COALESCE(op.number, ''::character varying) AS operationnumber,
    COALESCE(op.name, ''::character varying) AS operationname,
    pcq.role,
    pcq.typeofmaterial,
    pcq.plannedquantity,
    COALESCE(pcq.usedquantity, (0)::numeric) AS usedquantity,
    COALESCE(pcq.producedquantity, (0)::numeric) AS producedquantity,
    replacementto.number AS replacementto,
    tipt.name AS technologyinputproducttypename
   FROM (((((((public.basicproductioncounting_productioncountingquantity pcq
     JOIN public.basic_product product ON ((product.id = pcq.product_id)))
     JOIN public.orders_order o ON ((o.id = pcq.order_id)))
     LEFT JOIN public.technologies_technologyoperationcomponent toc ON ((pcq.technologyoperationcomponent_id = toc.id)))
     LEFT JOIN public.technologies_operation op ON ((op.id = toc.operation_id)))
     LEFT JOIN public.technologies_technologyinputproducttype tipt ON ((tipt.id = pcq.technologyinputproducttype_id)))
     LEFT JOIN public.orders_operationaltask ot ON (((ot.order_id = o.id) AND (ot.technologyoperationcomponent_id = toc.id))))
     LEFT JOIN public.basic_product replacementto ON ((replacementto.id = pcq.replacementto_id)))
  WHERE (((o.typeofproductionrecording)::text = '02cumulated'::text) AND ((o.state)::text = ANY (ARRAY[('02accepted'::character varying)::text, ('03inProgress'::character varying)::text, ('06interrupted'::character varying)::text])))
UNION
 SELECT pcq.id,
    o.number AS ordernumber,
    (o.id)::integer AS orderid,
    ot.number AS operationaltasknumber,
    (ot.id)::integer AS operationaltaskid,
    COALESCE(ot.startdate, o.startdate) AS startdate,
    product.number AS productnumber,
    product.name AS productname,
    product.unit AS productunit,
    toc.nodenumber,
    op.number AS operationnumber,
    op.name AS operationname,
    pcq.role,
    pcq.typeofmaterial,
    pcq.plannedquantity,
    COALESCE(pcq.usedquantity, (0)::numeric) AS usedquantity,
    COALESCE(pcq.producedquantity, (0)::numeric) AS producedquantity,
    replacementto.number AS replacementto,
    tipt.name AS technologyinputproducttypename
   FROM (((((((public.basicproductioncounting_productioncountingquantity pcq
     JOIN public.basic_product product ON ((product.id = pcq.product_id)))
     JOIN public.orders_order o ON ((o.id = pcq.order_id)))
     JOIN public.technologies_technologyoperationcomponent toc ON ((pcq.technologyoperationcomponent_id = toc.id)))
     JOIN public.technologies_operation op ON ((op.id = toc.operation_id)))
     LEFT JOIN public.technologies_technologyinputproducttype tipt ON ((tipt.id = pcq.technologyinputproducttype_id)))
     LEFT JOIN public.orders_operationaltask ot ON (((ot.order_id = o.id) AND (ot.technologyoperationcomponent_id = toc.id))))
     LEFT JOIN public.basic_product replacementto ON ((replacementto.id = pcq.replacementto_id)))
  WHERE (((o.typeofproductionrecording)::text = '03forEach'::text) AND ((o.state)::text = ANY (ARRAY[('02accepted'::character varying)::text, ('03inProgress'::character varying)::text, ('06interrupted'::character varying)::text])));


--
-- Name: basicproductioncounting_productioncountingquantitylistdto_id_se; Type: SEQUENCE; Schema: public; Owner: -
--

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


--
-- Name: basicproductioncounting_productioncountingreplacementhelper; Type: TABLE; Schema: public; Owner: -
--

CREATE TABLE public.basicproductioncounting_productioncountingreplacementhelper (
    id bigint NOT NULL,
    order_id bigint,
    product_id bigint,
    basicproduct_id bigint,
    plannedquantity numeric(14,5),
    replacesquantity numeric(14,5),
    productioncountingquantity_id bigint
);


--
-- Name: basicproductioncounting_productioncountingreplacementhelper_id_; Type: SEQUENCE; Schema: public; Owner: -
--

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


--
-- Name: basicproductioncounting_productioncountingreplacementhelper_id_; Type: SEQUENCE OWNED BY; Schema: public; Owner: -
--

ALTER SEQUENCE public.basicproductioncounting_productioncountingreplacementhelper_id_ OWNED BY public.basicproductioncounting_productioncountingreplacementhelper.id;


--
-- Name: basicproductioncounting_section; Type: TABLE; Schema: public; Owner: -
--

CREATE TABLE public.basicproductioncounting_section (
    id bigint NOT NULL,
    productioncountingquantity_id bigint,
    length numeric(14,5),
    quantity integer,
    unit character varying(255)
);


--
-- Name: basicproductioncounting_section_id_seq; Type: SEQUENCE; Schema: public; Owner: -
--

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


--
-- Name: basicproductioncounting_section_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: -
--

ALTER SEQUENCE public.basicproductioncounting_section_id_seq OWNED BY public.basicproductioncounting_section.id;


--
-- Name: productioncounting_trackingoperationproductincomponent; Type: TABLE; Schema: public; Owner: -
--

CREATE TABLE public.productioncounting_trackingoperationproductincomponent (
    id bigint NOT NULL,
    productiontracking_id bigint,
    product_id bigint,
    usedquantity numeric(14,5),
    balance numeric(14,5),
    obtainedquantity numeric(14,5),
    remainedquantity numeric(14,5),
    effectiveusedquantity numeric(15,5),
    givenunit character varying(255),
    givenquantity numeric(14,5),
    entityversion bigint DEFAULT 0,
    typeofmaterial character varying(255) DEFAULT '01component'::character varying,
    wasteused boolean DEFAULT false,
    wasteusedonly boolean DEFAULT false,
    wasteusedquantity numeric,
    wasteunit character varying,
    additionalinformation character varying,
    replacementto_id bigint
);


--
-- Name: basicproductioncounting_usedquantity_helper; Type: VIEW; Schema: public; Owner: -
--

CREATE VIEW public.basicproductioncounting_usedquantity_helper AS
 SELECT sum(topic.usedquantity) AS usedquantity,
    pt.order_id,
    topic.product_id,
    pt.technologyoperationcomponent_id
   FROM (public.productioncounting_trackingoperationproductincomponent topic
     JOIN public.productioncounting_productiontracking pt ON ((pt.id = topic.productiontracking_id)))
  WHERE ((pt.state)::text = '02accepted'::text)
  GROUP BY pt.order_id, topic.product_id, pt.technologyoperationcomponent_id;


--
-- Name: cdnrcgoodfood_cancelprotocol; Type: TABLE; Schema: public; Owner: -
--

CREATE TABLE public.cdnrcgoodfood_cancelprotocol (
    id bigint NOT NULL,
    extrusionprotocol_id bigint,
    confectionprotocol_id bigint,
    createdate timestamp without time zone,
    laststatechangefailcause character varying(8192),
    iscanceled boolean DEFAULT false
);


--
-- Name: cdnrcgoodfood_cancelprotocol_id_seq; Type: SEQUENCE; Schema: public; Owner: -
--

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


--
-- Name: cdnrcgoodfood_cancelprotocol_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: -
--

ALTER SEQUENCE public.cdnrcgoodfood_cancelprotocol_id_seq OWNED BY public.cdnrcgoodfood_cancelprotocol.id;


--
-- Name: cdnrcgoodfood_highestmasterordernum; Type: TABLE; Schema: public; Owner: -
--

CREATE TABLE public.cdnrcgoodfood_highestmasterordernum (
    id bigint NOT NULL,
    type character varying(32),
    number integer,
    entityversion bigint DEFAULT 0
);


--
-- Name: cdnrcgoodfood_highestmasterordernum_id_seq; Type: SEQUENCE; Schema: public; Owner: -
--

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


--
-- Name: cdnrcgoodfood_highestmasterordernum_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: -
--

ALTER SEQUENCE public.cdnrcgoodfood_highestmasterordernum_id_seq OWNED BY public.cdnrcgoodfood_highestmasterordernum.id;


--
-- Name: cmmsmachineparts_action; Type: TABLE; Schema: public; Owner: -
--

CREATE TABLE public.cmmsmachineparts_action (
    id bigint NOT NULL,
    name character varying(255),
    appliesto character varying(255) DEFAULT '01workstationOrSubassembly'::character varying,
    entityversion bigint DEFAULT 0,
    isdefault boolean DEFAULT false
);


--
-- Name: cmmsmachineparts_action_id_seq; Type: SEQUENCE; Schema: public; Owner: -
--

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


--
-- Name: cmmsmachineparts_action_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: -
--

ALTER SEQUENCE public.cmmsmachineparts_action_id_seq OWNED BY public.cmmsmachineparts_action.id;


--
-- Name: cmmsmachineparts_actionforplannedevent; Type: TABLE; Schema: public; Owner: -
--

CREATE TABLE public.cmmsmachineparts_actionforplannedevent (
    id bigint NOT NULL,
    plannedevent_id bigint,
    description character varying(1024),
    action_id bigint,
    responsibleworker_id bigint,
    responsibleworkername character varying(255),
    state character varying(255) DEFAULT '01correct'::character varying,
    reason character varying(1024),
    entityversion bigint DEFAULT 0,
    actionname character varying(255)
);


--
-- Name: cmmsmachineparts_actionforplannedevent_id_seq; Type: SEQUENCE; Schema: public; Owner: -
--

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


--
-- Name: cmmsmachineparts_actionforplannedevent_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: -
--

ALTER SEQUENCE public.cmmsmachineparts_actionforplannedevent_id_seq OWNED BY public.cmmsmachineparts_actionforplannedevent.id;


--
-- Name: cmmsmachineparts_eventattachment; Type: TABLE; Schema: public; Owner: -
--

CREATE TABLE public.cmmsmachineparts_eventattachment (
    id bigint NOT NULL,
    maintenanceevent_id bigint,
    attachment character varying(255),
    name character varying(255),
    size numeric(12,5),
    ext character varying(255),
    entityversion bigint DEFAULT 0
);


--
-- Name: cmmsmachineparts_eventattachment_id_seq; Type: SEQUENCE; Schema: public; Owner: -
--

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


--
-- Name: cmmsmachineparts_eventattachment_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: -
--

ALTER SEQUENCE public.cmmsmachineparts_eventattachment_id_seq OWNED BY public.cmmsmachineparts_eventattachment.id;


--
-- Name: cmmsmachineparts_machinepartattachment_id_seq; Type: SEQUENCE; Schema: public; Owner: -
--

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


--
-- Name: cmmsmachineparts_machinepartattachment_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: -
--

ALTER SEQUENCE public.cmmsmachineparts_machinepartattachment_id_seq OWNED BY public.cmmsmachineparts_machinepartattachment.id;


--
-- Name: cmmsmachineparts_machinepartforevent; Type: TABLE; Schema: public; Owner: -
--

CREATE TABLE public.cmmsmachineparts_machinepartforevent (
    id bigint NOT NULL,
    maintenanceevent_id bigint,
    machinepart_id bigint,
    warehouse_id bigint,
    plannedquantity numeric(14,5),
    availablequantity numeric(14,5),
    plannedevent_id bigint,
    machinepartname character varying(255),
    machinepartnumber character varying(255),
    machinepartunit character varying(255),
    warehousenumber character varying(255),
    entityversion bigint DEFAULT 0,
    recurringevent_id bigint
);


--
-- Name: cmmsmachineparts_machinepartforevent_id_seq; Type: SEQUENCE; Schema: public; Owner: -
--

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


--
-- Name: cmmsmachineparts_machinepartforevent_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: -
--

ALTER SEQUENCE public.cmmsmachineparts_machinepartforevent_id_seq OWNED BY public.cmmsmachineparts_machinepartforevent.id;


--
-- Name: cmmsmachineparts_maintenanceevent_id_seq; Type: SEQUENCE; Schema: public; Owner: -
--

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


--
-- Name: cmmsmachineparts_maintenanceevent_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: -
--

ALTER SEQUENCE public.cmmsmachineparts_maintenanceevent_id_seq OWNED BY public.cmmsmachineparts_maintenanceevent.id;


--
-- Name: cmmsmachineparts_maintenanceevent_number_seq; Type: SEQUENCE; Schema: public; Owner: -
--

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


--
-- Name: cmmsmachineparts_maintenanceeventcontext; Type: TABLE; Schema: public; Owner: -
--

CREATE TABLE public.cmmsmachineparts_maintenanceeventcontext (
    id bigint NOT NULL,
    factory_id bigint,
    division_id bigint,
    generated boolean DEFAULT false,
    confirmed boolean DEFAULT false,
    entityversion bigint DEFAULT 0,
    datefrom date,
    dateto date
);


--
-- Name: cmmsmachineparts_maintenanceeventcontext_id_seq; Type: SEQUENCE; Schema: public; Owner: -
--

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


--
-- Name: cmmsmachineparts_maintenanceeventcontext_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: -
--

ALTER SEQUENCE public.cmmsmachineparts_maintenanceeventcontext_id_seq OWNED BY public.cmmsmachineparts_maintenanceeventcontext.id;


--
-- Name: cmmsmachineparts_maintenanceeventlistdto; Type: VIEW; Schema: public; Owner: -
--

CREATE VIEW public.cmmsmachineparts_maintenanceeventlistdto AS
 SELECT maintenanceevent.id,
    maintenanceevent.number,
    maintenanceevent.type,
    maintenanceevent.createuser,
    maintenanceevent.createdate,
    maintenanceevent.state,
    maintenanceevent.description,
    context.id AS maintenanceeventcontext_id,
    (((staff.name)::text || ' '::text) || (staff.surname)::text) AS personreceivingname,
    (((reportingemployee.name)::text || ' '::text) || (reportingemployee.surname)::text) AS reportingemployeename,
    (factory.id)::integer AS factory_id,
    factory.number AS factorynumber,
    (division.id)::integer AS division_id,
    division.number AS divisionnumber,
    workstation.number AS workstationnumber,
    subassembly.number AS subassemblynumber,
    faulttype.name AS faulttypename,
    productionline.number AS productionlinenumber,
    maintenanceevent.highestpriority
   FROM (((((((((public.cmmsmachineparts_maintenanceevent maintenanceevent
     LEFT JOIN public.cmmsmachineparts_maintenanceeventcontext context ON ((maintenanceevent.maintenanceeventcontext_id = context.id)))
     LEFT JOIN public.basic_staff staff ON ((maintenanceevent.personreceiving_id = staff.id)))
     LEFT JOIN public.basic_staff reportingemployee ON ((maintenanceevent.reportingemployee_id = reportingemployee.id)))
     LEFT JOIN public.basic_factory factory ON ((maintenanceevent.factory_id = factory.id)))
     LEFT JOIN public.basic_division division ON ((maintenanceevent.division_id = division.id)))
     LEFT JOIN public.basic_workstation workstation ON ((maintenanceevent.workstation_id = workstation.id)))
     LEFT JOIN public.basic_subassembly subassembly ON ((maintenanceevent.subassembly_id = subassembly.id)))
     LEFT JOIN public.basic_faulttype faulttype ON ((maintenanceevent.faulttype_id = faulttype.id)))
     LEFT JOIN public.productionlines_productionline productionline ON ((maintenanceevent.productionline_id = productionline.id)));


--
-- Name: cmmsmachineparts_maintenanceeventlistdto_id_seq; Type: SEQUENCE; Schema: public; Owner: -
--

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


--
-- Name: cmmsmachineparts_maintenanceeventstatechange; Type: TABLE; Schema: public; Owner: -
--

CREATE TABLE public.cmmsmachineparts_maintenanceeventstatechange (
    id bigint NOT NULL,
    dateandtime timestamp without time zone,
    sourcestate character varying(255),
    targetstate character varying(255),
    status character varying(255),
    phase integer,
    worker character varying(255),
    maintenanceevent_id bigint,
    shift_id bigint,
    comment character varying(255),
    commentrequired boolean DEFAULT false,
    entityversion bigint DEFAULT 0,
    plannedeventtype character varying(255),
    plannedeventtyperequired boolean DEFAULT false
);


--
-- Name: cmmsmachineparts_maintenanceeventstatechange_id_seq; Type: SEQUENCE; Schema: public; Owner: -
--

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


--
-- Name: cmmsmachineparts_maintenanceeventstatechange_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: -
--

ALTER SEQUENCE public.cmmsmachineparts_maintenanceeventstatechange_id_seq OWNED BY public.cmmsmachineparts_maintenanceeventstatechange.id;


--
-- Name: cmmsmachineparts_maintenanceeventxlshelper_id_seq; Type: SEQUENCE; Schema: public; Owner: -
--

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


--
-- Name: cmmsmachineparts_maintenanceeventxlshelper; Type: TABLE; Schema: public; Owner: -
--

CREATE TABLE public.cmmsmachineparts_maintenanceeventxlshelper (
    id bigint DEFAULT nextval('public.cmmsmachineparts_maintenanceeventxlshelper_id_seq'::regclass) NOT NULL,
    query text,
    createdate timestamp without time zone,
    updatedate timestamp without time zone,
    createuser character varying(255),
    updateuser character varying(255)
);


--
-- Name: cmmsmachineparts_operationtool; Type: TABLE; Schema: public; Owner: -
--

CREATE TABLE public.cmmsmachineparts_operationtool (
    id bigint NOT NULL,
    toolcategory character varying(255),
    operation_id bigint,
    tool_id bigint,
    description character varying(2048),
    plannedquantity numeric(12,5),
    unit character varying(255),
    quantity numeric(12,5)
);


--
-- Name: cmmsmachineparts_operationtool_id_seq; Type: SEQUENCE; Schema: public; Owner: -
--

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


--
-- Name: cmmsmachineparts_operationtool_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: -
--

ALTER SEQUENCE public.cmmsmachineparts_operationtool_id_seq OWNED BY public.cmmsmachineparts_operationtool.id;


--
-- Name: cmmsmachineparts_orderstoolrequirement; Type: TABLE; Schema: public; Owner: -
--

CREATE TABLE public.cmmsmachineparts_orderstoolrequirement (
    id bigint NOT NULL,
    number character varying(256),
    name character varying(1024),
    generated boolean,
    worker character varying(255),
    date timestamp without time zone,
    filename character varying(255)
);


--
-- Name: cmmsmachineparts_orderstoolrequirement_id_seq; Type: SEQUENCE; Schema: public; Owner: -
--

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


--
-- Name: cmmsmachineparts_orderstoolrequirement_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: -
--

ALTER SEQUENCE public.cmmsmachineparts_orderstoolrequirement_id_seq OWNED BY public.cmmsmachineparts_orderstoolrequirement.id;


--
-- Name: cmmsmachineparts_orderstoolrequirement_number_seq; Type: SEQUENCE; Schema: public; Owner: -
--

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


--
-- Name: cmmsmachineparts_orderstoolrequirementtool; Type: TABLE; Schema: public; Owner: -
--

CREATE TABLE public.cmmsmachineparts_orderstoolrequirementtool (
    id bigint NOT NULL,
    orderstoolrequirement_id bigint,
    date date,
    order_id bigint,
    operation_id bigint,
    technologyoperationtool_id bigint,
    quantity numeric(14,5)
);


--
-- Name: cmmsmachineparts_orderstoolrequirementtool_id_seq; Type: SEQUENCE; Schema: public; Owner: -
--

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


--
-- Name: cmmsmachineparts_orderstoolrequirementtool_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: -
--

ALTER SEQUENCE public.cmmsmachineparts_orderstoolrequirementtool_id_seq OWNED BY public.cmmsmachineparts_orderstoolrequirementtool.id;


--
-- Name: cmmsmachineparts_plannedevent_id_seq; Type: SEQUENCE; Schema: public; Owner: -
--

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


--
-- Name: cmmsmachineparts_plannedevent_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: -
--

ALTER SEQUENCE public.cmmsmachineparts_plannedevent_id_seq OWNED BY public.cmmsmachineparts_plannedevent.id;


--
-- Name: cmmsmachineparts_plannedeventattachment; Type: TABLE; Schema: public; Owner: -
--

CREATE TABLE public.cmmsmachineparts_plannedeventattachment (
    id bigint NOT NULL,
    plannedevent_id bigint,
    attachment character varying(255),
    name character varying(255),
    size numeric(12,5),
    ext character varying(255),
    entityversion bigint DEFAULT 0
);


--
-- Name: cmmsmachineparts_plannedeventattachment_id_seq; Type: SEQUENCE; Schema: public; Owner: -
--

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


--
-- Name: cmmsmachineparts_plannedeventattachment_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: -
--

ALTER SEQUENCE public.cmmsmachineparts_plannedeventattachment_id_seq OWNED BY public.cmmsmachineparts_plannedeventattachment.id;


--
-- Name: cmmsmachineparts_plannedeventcontext; Type: TABLE; Schema: public; Owner: -
--

CREATE TABLE public.cmmsmachineparts_plannedeventcontext (
    id bigint NOT NULL,
    factory_id bigint,
    division_id bigint,
    generated boolean DEFAULT false,
    confirmed boolean DEFAULT false,
    entityversion bigint DEFAULT 0,
    datefrom date,
    dateto date
);


--
-- Name: cmmsmachineparts_plannedeventcontext_id_seq; Type: SEQUENCE; Schema: public; Owner: -
--

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


--
-- Name: cmmsmachineparts_plannedeventcontext_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: -
--

ALTER SEQUENCE public.cmmsmachineparts_plannedeventcontext_id_seq OWNED BY public.cmmsmachineparts_plannedeventcontext.id;


--
-- Name: cmmsmachineparts_sourcecost; Type: TABLE; Schema: public; Owner: -
--

CREATE TABLE public.cmmsmachineparts_sourcecost (
    id bigint NOT NULL,
    number character varying(255),
    name character varying(1024),
    factory_id bigint,
    defaultcost boolean DEFAULT false,
    active boolean DEFAULT true
);


--
-- Name: cmmsmachineparts_plannedeventlistdto; Type: VIEW; Schema: public; Owner: -
--

CREATE VIEW public.cmmsmachineparts_plannedeventlistdto AS
 SELECT e.id,
    e.number,
    e.type,
    (((owner.name)::text || ' '::text) || (owner.surname)::text) AS ownername,
    e.description,
    factory.number AS factorynumber,
    (factory.id)::integer AS factory_id,
    division.number AS divisionnumber,
    (division.id)::integer AS division_id,
    productionline.number AS productionlinenumber,
    workstation.number AS workstationnumber,
    subassembly.number AS subassemblynumber,
    (e.date)::timestamp without time zone AS date,
    e.counter,
    e.createuser,
    e.createdate,
    e.state,
    context.id AS plannedeventcontext_id,
    workstation.id AS workstation_id,
    subassembly.id AS subassembly_id,
    company.id AS company_id,
    sourcecost.id AS sourcecost_id
   FROM (((((((((public.cmmsmachineparts_plannedevent e
     LEFT JOIN public.basic_staff owner ON ((e.owner_id = owner.id)))
     JOIN public.basic_factory factory ON ((e.factory_id = factory.id)))
     JOIN public.basic_division division ON ((e.division_id = division.id)))
     LEFT JOIN public.productionlines_productionline productionline ON ((e.productionline_id = productionline.id)))
     LEFT JOIN public.basic_workstation workstation ON ((e.workstation_id = workstation.id)))
     LEFT JOIN public.basic_subassembly subassembly ON ((e.subassembly_id = subassembly.id)))
     LEFT JOIN public.cmmsmachineparts_plannedeventcontext context ON ((e.plannedeventcontext_id = context.id)))
     LEFT JOIN public.basic_company company ON ((e.company_id = company.id)))
     LEFT JOIN public.cmmsmachineparts_sourcecost sourcecost ON ((e.sourcecost_id = sourcecost.id)));


--
-- Name: cmmsmachineparts_plannedeventlistdto_id_seq; Type: SEQUENCE; Schema: public; Owner: -
--

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


--
-- Name: cmmsmachineparts_plannedeventrealization; Type: TABLE; Schema: public; Owner: -
--

CREATE TABLE public.cmmsmachineparts_plannedeventrealization (
    id bigint NOT NULL,
    plannedevent_id bigint,
    worker_id bigint,
    action_id bigint,
    startdate timestamp without time zone,
    finishdate timestamp without time zone,
    duration integer DEFAULT 0,
    entityversion bigint DEFAULT 0,
    confirmed boolean DEFAULT true
);


--
-- Name: cmmsmachineparts_plannedeventrealization_id_seq; Type: SEQUENCE; Schema: public; Owner: -
--

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


--
-- Name: cmmsmachineparts_plannedeventrealization_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: -
--

ALTER SEQUENCE public.cmmsmachineparts_plannedeventrealization_id_seq OWNED BY public.cmmsmachineparts_plannedeventrealization.id;


--
-- Name: cmmsmachineparts_plannedeventstatechange; Type: TABLE; Schema: public; Owner: -
--

CREATE TABLE public.cmmsmachineparts_plannedeventstatechange (
    id bigint NOT NULL,
    dateandtime timestamp without time zone,
    sourcestate character varying(255),
    targetstate character varying(255),
    status character varying(255),
    phase integer,
    worker character varying(255),
    plannedevent_id bigint,
    shift_id bigint,
    comment character varying(255),
    commentrequired boolean DEFAULT false
);


--
-- Name: cmmsmachineparts_plannedeventstatechange_id_seq; Type: SEQUENCE; Schema: public; Owner: -
--

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


--
-- Name: cmmsmachineparts_plannedeventstatechange_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: -
--

ALTER SEQUENCE public.cmmsmachineparts_plannedeventstatechange_id_seq OWNED BY public.cmmsmachineparts_plannedeventstatechange.id;


--
-- Name: cmmsmachineparts_plannedeventxlshelper; Type: TABLE; Schema: public; Owner: -
--

CREATE TABLE public.cmmsmachineparts_plannedeventxlshelper (
    id bigint NOT NULL,
    query text,
    createdate timestamp without time zone,
    updatedate timestamp without time zone,
    createuser character varying(255),
    updateuser character varying(255)
);


--
-- Name: cmmsmachineparts_plannedeventxlshelper_id_seq; Type: SEQUENCE; Schema: public; Owner: -
--

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


--
-- Name: cmmsmachineparts_plannedeventxlshelper_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: -
--

ALTER SEQUENCE public.cmmsmachineparts_plannedeventxlshelper_id_seq OWNED BY public.cmmsmachineparts_plannedeventxlshelper.id;


--
-- Name: cmmsmachineparts_sourcecost_id_seq; Type: SEQUENCE; Schema: public; Owner: -
--

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


--
-- Name: cmmsmachineparts_sourcecost_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: -
--

ALTER SEQUENCE public.cmmsmachineparts_sourcecost_id_seq OWNED BY public.cmmsmachineparts_sourcecost.id;


--
-- Name: cmmsmachineparts_sourcecostreportfilter; Type: TABLE; Schema: public; Owner: -
--

CREATE TABLE public.cmmsmachineparts_sourcecostreportfilter (
    id bigint NOT NULL,
    fromdate date,
    todate date,
    sourcecost_id bigint,
    createdate timestamp without time zone,
    updatedate timestamp without time zone,
    createuser character varying(255),
    updateuser character varying(255),
    dontsave boolean
);


--
-- Name: cmmsmachineparts_sourcecostreportfilter_id_seq; Type: SEQUENCE; Schema: public; Owner: -
--

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


--
-- Name: cmmsmachineparts_sourcecostreportfilter_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: -
--

ALTER SEQUENCE public.cmmsmachineparts_sourcecostreportfilter_id_seq OWNED BY public.cmmsmachineparts_sourcecostreportfilter.id;


--
-- Name: cmmsmachineparts_staffworktime; Type: TABLE; Schema: public; Owner: -
--

CREATE TABLE public.cmmsmachineparts_staffworktime (
    id bigint NOT NULL,
    maintenanceevent_id bigint,
    worker_id bigint,
    labortime integer DEFAULT 0,
    effectiveexecutiontimestart timestamp without time zone,
    effectiveexecutiontimeend timestamp without time zone,
    entityversion bigint DEFAULT 0
);


--
-- Name: cmmsmachineparts_staffworktime_id_seq; Type: SEQUENCE; Schema: public; Owner: -
--

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


--
-- Name: cmmsmachineparts_staffworktime_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: -
--

ALTER SEQUENCE public.cmmsmachineparts_staffworktime_id_seq OWNED BY public.cmmsmachineparts_staffworktime.id;


--
-- Name: cmmsmachineparts_technologyoperationtool; Type: TABLE; Schema: public; Owner: -
--

CREATE TABLE public.cmmsmachineparts_technologyoperationtool (
    id bigint NOT NULL,
    toolcategory character varying(255),
    technologyoperationcomponent_id bigint,
    tool_id bigint,
    description character varying(2048),
    quantity numeric(12,5),
    unit character varying(255)
);


--
-- Name: cmmsmachineparts_technologyoperationtool_id_seq; Type: SEQUENCE; Schema: public; Owner: -
--

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


--
-- Name: cmmsmachineparts_technologyoperationtool_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: -
--

ALTER SEQUENCE public.cmmsmachineparts_technologyoperationtool_id_seq OWNED BY public.cmmsmachineparts_technologyoperationtool.id;


--
-- Name: cmmsmachineparts_timeusagereportfilter; Type: TABLE; Schema: public; Owner: -
--

CREATE TABLE public.cmmsmachineparts_timeusagereportfilter (
    id bigint NOT NULL,
    fromdate date,
    todate date,
    workersselection character varying(255),
    createdate timestamp without time zone,
    updatedate timestamp without time zone,
    createuser character varying(255),
    updateuser character varying(255)
);


--
-- Name: cmmsmachineparts_timeusagereportfilter_id_seq; Type: SEQUENCE; Schema: public; Owner: -
--

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


--
-- Name: cmmsmachineparts_timeusagereportfilter_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: -
--

ALTER SEQUENCE public.cmmsmachineparts_timeusagereportfilter_id_seq OWNED BY public.cmmsmachineparts_timeusagereportfilter.id;


--
-- Name: cmmsmachineparts_tool_id_seq; Type: SEQUENCE; Schema: public; Owner: -
--

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


--
-- Name: cmmsmachineparts_tool_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: -
--

ALTER SEQUENCE public.cmmsmachineparts_tool_id_seq OWNED BY public.cmmsmachineparts_tool.id;


--
-- Name: cmmsmachineparts_toolattachment_id_seq; Type: SEQUENCE; Schema: public; Owner: -
--

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


--
-- Name: cmmsmachineparts_toolattachment_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: -
--

ALTER SEQUENCE public.cmmsmachineparts_toolattachment_id_seq OWNED BY public.cmmsmachineparts_toolattachment.id;


--
-- Name: cmmsmachineparts_worktimeforuserdto_internal; Type: VIEW; Schema: public; Owner: -
--

CREATE VIEW public.cmmsmachineparts_worktimeforuserdto_internal AS
 SELECT u.username,
    swt.effectiveexecutiontimestart AS startdate,
    swt.effectiveexecutiontimeend AS finishdate,
    swt.labortime AS duration,
    me.number AS eventnumber,
    me.type AS eventtype,
    COALESCE(s.number, w.number, p.number, d.number, f.number) AS objectnumber,
    NULL::character varying AS actionname
   FROM (((((((public.cmmsmachineparts_staffworktime swt
     JOIN public.qcadoosecurity_user u ON ((swt.worker_id = u.staff_id)))
     JOIN public.cmmsmachineparts_maintenanceevent me ON ((me.id = swt.maintenanceevent_id)))
     JOIN public.basic_factory f ON ((me.factory_id = f.id)))
     JOIN public.basic_division d ON ((me.division_id = d.id)))
     LEFT JOIN public.productionlines_productionline p ON ((me.productionline_id = p.id)))
     LEFT JOIN public.basic_workstation w ON ((me.workstation_id = w.id)))
     LEFT JOIN public.basic_subassembly s ON ((me.subassembly_id = s.id)))
UNION ALL
 SELECT u.username,
    per.startdate,
    per.finishdate,
    per.duration,
    pe.number AS eventnumber,
    pe.type AS eventtype,
    COALESCE(s.number, w.number, p.number, d.number, f.number) AS objectnumber,
    a.name AS actionname
   FROM (((((((((public.cmmsmachineparts_plannedeventrealization per
     JOIN public.qcadoosecurity_user u ON ((per.worker_id = u.staff_id)))
     JOIN public.cmmsmachineparts_plannedevent pe ON ((pe.id = per.plannedevent_id)))
     JOIN public.basic_factory f ON ((pe.factory_id = f.id)))
     JOIN public.basic_division d ON ((pe.division_id = d.id)))
     LEFT JOIN public.productionlines_productionline p ON ((pe.productionline_id = p.id)))
     LEFT JOIN public.basic_workstation w ON ((pe.workstation_id = w.id)))
     LEFT JOIN public.basic_subassembly s ON ((pe.subassembly_id = s.id)))
     LEFT JOIN public.cmmsmachineparts_actionforplannedevent afpe ON ((per.action_id = afpe.id)))
     LEFT JOIN public.cmmsmachineparts_action a ON ((afpe.action_id = a.id)));


--
-- Name: cmmsmachineparts_worktimeforuserdto; Type: VIEW; Schema: public; Owner: -
--

CREATE VIEW public.cmmsmachineparts_worktimeforuserdto AS
 SELECT row_number() OVER () AS id,
    internal.username,
    internal.startdate,
    internal.finishdate,
    internal.duration,
    internal.eventnumber,
    internal.eventtype,
    internal.objectnumber,
    internal.actionname
   FROM public.cmmsmachineparts_worktimeforuserdto_internal internal;


--
-- Name: cmmsmachineparts_worktimeforuserdto_id_seq; Type: SEQUENCE; Schema: public; Owner: -
--

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


--
-- Name: cmmsscheduler_actionforrecurringevent; Type: TABLE; Schema: public; Owner: -
--

CREATE TABLE public.cmmsscheduler_actionforrecurringevent (
    id bigint NOT NULL,
    recurringevent_id bigint,
    description character varying(1024),
    action_id bigint
);


--
-- Name: cmmsscheduler_actionforrecurringevent_id_seq; Type: SEQUENCE; Schema: public; Owner: -
--

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


--
-- Name: cmmsscheduler_actionforrecurringevent_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: -
--

ALTER SEQUENCE public.cmmsscheduler_actionforrecurringevent_id_seq OWNED BY public.cmmsscheduler_actionforrecurringevent.id;


--
-- Name: cmmsscheduler_recurringevent; Type: TABLE; Schema: public; Owner: -
--

CREATE TABLE public.cmmsscheduler_recurringevent (
    id bigint NOT NULL,
    number character varying(255),
    type character varying(255) DEFAULT '01review'::character varying,
    periodicitydate character varying(255),
    periodicitystate numeric(14,5),
    generation character varying(255) DEFAULT '01recurring'::character varying,
    description character varying(255),
    owner_id bigint,
    ownername character varying(255),
    state character varying(255) DEFAULT '01draft'::character varying,
    factory_id bigint,
    division_id bigint,
    productionline_id bigint,
    workstation_id bigint,
    subassembly_id bigint,
    company_id bigint,
    sourcecost_id bigint,
    plannedseparately boolean DEFAULT false,
    requiresshutdown boolean DEFAULT false,
    basedon character varying(255) DEFAULT '01date'::character varying,
    date date,
    counter numeric(14,5),
    countertolerance numeric(14,5),
    duration integer DEFAULT 0,
    effectiveduration integer DEFAULT 0,
    effectivecounter numeric(14,5),
    recurringeventcontext_id bigint,
    active boolean DEFAULT true,
    createdate timestamp without time zone,
    updatedate timestamp without time zone,
    createuser character varying(255),
    updateuser character varying(255),
    nextgenerationdate date,
    nextdate date,
    multiplier integer DEFAULT 1
);


--
-- Name: cmmsscheduler_recurringevent_id_seq; Type: SEQUENCE; Schema: public; Owner: -
--

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


--
-- Name: cmmsscheduler_recurringevent_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: -
--

ALTER SEQUENCE public.cmmsscheduler_recurringevent_id_seq OWNED BY public.cmmsscheduler_recurringevent.id;


--
-- Name: cmmsscheduler_recurringeventattachment; Type: TABLE; Schema: public; Owner: -
--

CREATE TABLE public.cmmsscheduler_recurringeventattachment (
    id bigint NOT NULL,
    recurringevent_id bigint,
    attachment character varying(255),
    name character varying(255),
    size numeric(12,5),
    ext character varying(255)
);


--
-- Name: cmmsscheduler_recurringeventattachment_id_seq; Type: SEQUENCE; Schema: public; Owner: -
--

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


--
-- Name: cmmsscheduler_recurringeventattachment_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: -
--

ALTER SEQUENCE public.cmmsscheduler_recurringeventattachment_id_seq OWNED BY public.cmmsscheduler_recurringeventattachment.id;


--
-- Name: cmmsscheduler_recurringeventcontext; Type: TABLE; Schema: public; Owner: -
--

CREATE TABLE public.cmmsscheduler_recurringeventcontext (
    id bigint NOT NULL,
    factory_id bigint,
    division_id bigint,
    generated boolean DEFAULT false,
    confirmed boolean DEFAULT false,
    datefrom date,
    dateto date
);


--
-- Name: cmmsscheduler_recurringeventcontext_id_seq; Type: SEQUENCE; Schema: public; Owner: -
--

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


--
-- Name: cmmsscheduler_recurringeventcontext_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: -
--

ALTER SEQUENCE public.cmmsscheduler_recurringeventcontext_id_seq OWNED BY public.cmmsscheduler_recurringeventcontext.id;


--
-- Name: cmmsscheduler_recurringeventstatechange; Type: TABLE; Schema: public; Owner: -
--

CREATE TABLE public.cmmsscheduler_recurringeventstatechange (
    id bigint NOT NULL,
    dateandtime timestamp without time zone,
    sourcestate character varying(255),
    targetstate character varying(255),
    status character varying(255),
    phase integer,
    worker character varying(255),
    recurringevent_id bigint,
    shift_id bigint
);


--
-- Name: cmmsscheduler_recurringeventstatechange_id_seq; Type: SEQUENCE; Schema: public; Owner: -
--

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


--
-- Name: cmmsscheduler_recurringeventstatechange_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: -
--

ALTER SEQUENCE public.cmmsscheduler_recurringeventstatechange_id_seq OWNED BY public.cmmsscheduler_recurringeventstatechange.id;


--
-- Name: costcalculation_additionaldirectcost; Type: TABLE; Schema: public; Owner: -
--

CREATE TABLE public.costcalculation_additionaldirectcost (
    id bigint NOT NULL,
    number character varying(255),
    name character varying(1024),
    active boolean DEFAULT true
);


--
-- Name: costcalculation_additionaldirectcost_id_seq; Type: SEQUENCE; Schema: public; Owner: -
--

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


--
-- Name: costcalculation_additionaldirectcost_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: -
--

ALTER SEQUENCE public.costcalculation_additionaldirectcost_id_seq OWNED BY public.costcalculation_additionaldirectcost.id;


--
-- Name: costcalculation_additionaldirectcostitem; Type: TABLE; Schema: public; Owner: -
--

CREATE TABLE public.costcalculation_additionaldirectcostitem (
    id bigint NOT NULL,
    additionaldirectcost_id bigint,
    actualcost numeric(9,2),
    datefrom date,
    dateto date
);


--
-- Name: costcalculation_additionaldirectcostitem_id_seq; Type: SEQUENCE; Schema: public; Owner: -
--

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


--
-- Name: costcalculation_additionaldirectcostitem_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: -
--

ALTER SEQUENCE public.costcalculation_additionaldirectcostitem_id_seq OWNED BY public.costcalculation_additionaldirectcostitem.id;


--
-- Name: costcalculation_calculationresult; Type: TABLE; Schema: public; Owner: -
--

CREATE TABLE public.costcalculation_calculationresult (
    id bigint NOT NULL,
    costcalculation_id bigint,
    product_id bigint,
    technology_id bigint,
    materialcosts numeric(19,5),
    labourcost numeric(19,5),
    productioncosts numeric(19,5),
    totalcost numeric(19,5),
    registrationprice numeric(19,5),
    technicalproductioncost numeric(19,5),
    sellingprice numeric(19,5),
    nomaterialprice boolean DEFAULT false,
    profitvalue numeric(12,5),
    registrationpriceoverheadvalue numeric(12,5),
    materialcostmarginvalue numeric(12,5),
    labourcostmarginvalue numeric(12,5),
    totalmanufacturingcost numeric(19,5),
    technicalproductioncostoverheadvalue numeric(19,5)
);


--
-- Name: costcalculation_calculationresult_id_seq; Type: SEQUENCE; Schema: public; Owner: -
--

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


--
-- Name: costcalculation_calculationresult_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: -
--

ALTER SEQUENCE public.costcalculation_calculationresult_id_seq OWNED BY public.costcalculation_calculationresult.id;


--
-- Name: costcalculation_componentcost; Type: TABLE; Schema: public; Owner: -
--

CREATE TABLE public.costcalculation_componentcost (
    id bigint NOT NULL,
    costcalculation_id bigint,
    product_id bigint,
    priceperunit numeric(19,5)
);


--
-- Name: costcalculation_componentcost_id_seq; Type: SEQUENCE; Schema: public; Owner: -
--

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


--
-- Name: costcalculation_componentcost_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: -
--

ALTER SEQUENCE public.costcalculation_componentcost_id_seq OWNED BY public.costcalculation_componentcost.id;


--
-- Name: costcalculation_costcalculation; Type: TABLE; Schema: public; Owner: -
--

CREATE TABLE public.costcalculation_costcalculation (
    id bigint NOT NULL,
    number character varying(255),
    quantity numeric(12,5) DEFAULT 0,
    productioncostmargin numeric(19,5) DEFAULT (0)::numeric,
    materialcostmargin numeric(19,5) DEFAULT (0)::numeric,
    additionaloverhead numeric(19,5) DEFAULT (0)::numeric,
    description character varying(255),
    includetpz boolean DEFAULT true,
    includeadditionaltime boolean DEFAULT false,
    materialcostsused character varying(255) DEFAULT 'nominal'::character varying,
    date timestamp without time zone,
    generated boolean,
    filename character varying(255),
    includecomponents boolean DEFAULT false,
    entityversion bigint DEFAULT 0,
    sourceofoperationcosts character varying(255),
    registrationpriceoverhead numeric(19,5),
    profit numeric(19,5),
    standardlaborcost_id bigint,
    averagemachinehourlycost numeric(12,5),
    averagelaborhourlycost numeric(12,5),
    usenominalcostpricenotspecified boolean DEFAULT false,
    pdf boolean DEFAULT false,
    technicalproductioncostoverhead numeric(19,5) DEFAULT 0,
    offer_id bigint
);


--
-- Name: costcalculation_costcalculation_id_seq; Type: SEQUENCE; Schema: public; Owner: -
--

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


--
-- Name: costcalculation_costcalculation_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: -
--

ALTER SEQUENCE public.costcalculation_costcalculation_id_seq OWNED BY public.costcalculation_costcalculation.id;


--
-- Name: costcalculation_orderadditionaldirectcost; Type: TABLE; Schema: public; Owner: -
--

CREATE TABLE public.costcalculation_orderadditionaldirectcost (
    id bigint NOT NULL,
    additionaldirectcost_id bigint,
    order_id bigint,
    actualcost numeric(9,2)
);


--
-- Name: costcalculation_orderadditionaldirectcost_id_seq; Type: SEQUENCE; Schema: public; Owner: -
--

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


--
-- Name: costcalculation_orderadditionaldirectcost_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: -
--

ALTER SEQUENCE public.costcalculation_orderadditionaldirectcost_id_seq OWNED BY public.costcalculation_orderadditionaldirectcost.id;


--
-- Name: costcalculation_standard_labor_cost_number_seq; Type: SEQUENCE; Schema: public; Owner: -
--

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


--
-- Name: costcalculation_standardlaborcost; Type: TABLE; Schema: public; Owner: -
--

CREATE TABLE public.costcalculation_standardlaborcost (
    id bigint NOT NULL,
    number character varying(255),
    name character varying(255),
    laborcost numeric(19,5)
);


--
-- Name: costcalculation_standardlaborcost_id_seq; Type: SEQUENCE; Schema: public; Owner: -
--

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


--
-- Name: costcalculation_standardlaborcost_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: -
--

ALTER SEQUENCE public.costcalculation_standardlaborcost_id_seq OWNED BY public.costcalculation_standardlaborcost.id;


--
-- Name: costnormsformaterials_technologyinstoperproductincomp; Type: TABLE; Schema: public; Owner: -
--

CREATE TABLE public.costnormsformaterials_technologyinstoperproductincomp (
    id bigint NOT NULL,
    order_id bigint,
    product_id bigint,
    costfororder numeric(12,5) DEFAULT (0)::numeric,
    entityversion bigint DEFAULT 0,
    averagepricesubcontractor numeric(12,5) DEFAULT 0
);


--
-- Name: costnormsformaterials_technologyinstoperproductincomp_id_seq; Type: SEQUENCE; Schema: public; Owner: -
--

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


--
-- Name: costnormsformaterials_technologyinstoperproductincomp_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: -
--

ALTER SEQUENCE public.costnormsformaterials_technologyinstoperproductincomp_id_seq OWNED BY public.costnormsformaterials_technologyinstoperproductincomp.id;


--
-- Name: costnormsformaterials_technologyinstoperproductincompdto; Type: VIEW; Schema: public; Owner: -
--

CREATE VIEW public.costnormsformaterials_technologyinstoperproductincompdto AS
 SELECT tiopic.id,
    (tiopic.order_id)::integer AS orderid,
    p.number AS productnumber,
    p.name AS productname,
    p.nominalcost,
    ncur.alphabeticcode AS nominalcostcurrency,
    p.lastpurchasecost,
    lcur.alphabeticcode AS lastpurchasecostcurrency,
    p.averagecost,
    acur.alphabeticcode AS averagecostcurrency,
    tiopic.costfororder,
    cur.alphabeticcode AS costforordercurrency,
    p.lastoffercost,
    cur.alphabeticcode AS lastoffercostcurrency,
    p.averageoffercost,
    cur.alphabeticcode AS averageoffercostcurrency,
    p.costfornumber,
    p.unit
   FROM ((((((public.costnormsformaterials_technologyinstoperproductincomp tiopic
     JOIN public.basic_product p ON ((tiopic.product_id = p.id)))
     CROSS JOIN public.basic_parameter par)
     LEFT JOIN public.basic_currency cur ON ((cur.id = par.currency_id)))
     LEFT JOIN public.basic_currency acur ON ((acur.id = p.averagecostcurrency_id)))
     LEFT JOIN public.basic_currency lcur ON ((lcur.id = p.lastpurchasecostcurrency_id)))
     LEFT JOIN public.basic_currency ncur ON ((ncur.id = p.nominalcostcurrency_id)));


--
-- Name: costnormsformaterials_technologyinstoperproductincompdto_id_seq; Type: SEQUENCE; Schema: public; Owner: -
--

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


--
-- Name: costnormsforoperation_calculationoperationcomponent; Type: TABLE; Schema: public; Owner: -
--

CREATE TABLE public.costnormsforoperation_calculationoperationcomponent (
    id bigint NOT NULL,
    nodenumber character varying(255),
    operation_id bigint,
    technologyoperationcomponent_id bigint,
    parent_id bigint,
    entitytype character varying(255) DEFAULT 'operation'::character varying,
    priority integer,
    tpz integer,
    tj integer,
    areproductquantitiesdivisible boolean DEFAULT false,
    istjdivisible boolean DEFAULT false,
    machineutilization numeric(12,5),
    laborutilization numeric(12,5),
    productioninonecycle numeric(12,5) DEFAULT (1)::numeric,
    nextoperationafterproducedtype character varying(255) DEFAULT '01all'::character varying,
    nextoperationafterproducedquantity numeric(12,5),
    timenextoperation integer,
    operationoffset integer,
    effectiveoperationrealizationtime integer,
    effectivedatefrom timestamp without time zone,
    effectivedateto timestamp without time zone,
    duration integer DEFAULT 0,
    machineworktime integer DEFAULT 0,
    laborworktime integer DEFAULT 0,
    operationcost numeric(12,5) DEFAULT (0)::numeric,
    totalmachineoperationcost numeric(12,5) DEFAULT (0)::numeric,
    totallaboroperationcost numeric(12,5) DEFAULT (0)::numeric,
    laborhourlycost numeric(12,5) DEFAULT (0)::numeric,
    machinehourlycost numeric(12,5) DEFAULT (0)::numeric,
    costcalculation_id bigint,
    entityversion bigint DEFAULT 0
);


--
-- Name: costnormsforoperation_calculationoperationcomponent_id_seq; Type: SEQUENCE; Schema: public; Owner: -
--

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


--
-- Name: costnormsforoperation_calculationoperationcomponent_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: -
--

ALTER SEQUENCE public.costnormsforoperation_calculationoperationcomponent_id_seq OWNED BY public.costnormsforoperation_calculationoperationcomponent.id;


--
-- Name: deliveries_companyproduct; Type: TABLE; Schema: public; Owner: -
--

CREATE TABLE public.deliveries_companyproduct (
    id bigint NOT NULL,
    company_id bigint,
    product_id bigint,
    isdefault boolean DEFAULT false,
    entityversion bigint DEFAULT 0,
    minimumorderquantity numeric(12,5),
    bufferfordeliverytimes integer
);


--
-- Name: deliveries_bufferfordeliverytimes_family; Type: VIEW; Schema: public; Owner: -
--

CREATE VIEW public.deliveries_bufferfordeliverytimes_family AS
 SELECT product.id AS product_id,
    _companyproductsfamily.bufferfordeliverytimes AS bufferfordeliverytimesfamily,
    _companyproductsfamily.company_id,
    _companyproductsfamily.product_id AS product_family_id
   FROM ((public.basic_product product
     LEFT JOIN public.basic_product parent ON ((parent.id = product.parent_id)))
     LEFT JOIN public.deliveries_companyproduct _companyproductsfamily ON ((_companyproductsfamily.product_id = parent.id)));


--
-- Name: deliveries_bufferfordeliverytimes_product; Type: VIEW; Schema: public; Owner: -
--

CREATE VIEW public.deliveries_bufferfordeliverytimes_product AS
 SELECT _companyproduct.bufferfordeliverytimes,
    _companyproduct.company_id,
    _companyproduct.product_id
   FROM (public.basic_product product
     LEFT JOIN public.deliveries_companyproduct _companyproduct ON ((_companyproduct.product_id = product.id)));


--
-- Name: deliveries_columnfordeliveries; Type: TABLE; Schema: public; Owner: -
--

CREATE TABLE public.deliveries_columnfordeliveries (
    id bigint NOT NULL,
    identifier character varying(255),
    name character varying(1024),
    description character varying(1024),
    columnfiller character varying(255),
    alignment character varying(255) DEFAULT '01left'::character varying,
    parameter_id bigint,
    succession integer,
    entityversion bigint DEFAULT 0
);


--
-- Name: deliveries_columnfordeliveries_id_seq; Type: SEQUENCE; Schema: public; Owner: -
--

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


--
-- Name: deliveries_columnfordeliveries_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: -
--

ALTER SEQUENCE public.deliveries_columnfordeliveries_id_seq OWNED BY public.deliveries_columnfordeliveries.id;


--
-- Name: deliveries_columnfororders; Type: TABLE; Schema: public; Owner: -
--

CREATE TABLE public.deliveries_columnfororders (
    id bigint NOT NULL,
    identifier character varying(255),
    name character varying(1024),
    description character varying(1024),
    columnfiller character varying(255),
    alignment character varying(255) DEFAULT '01left'::character varying,
    parameter_id bigint,
    succession integer,
    entityversion bigint DEFAULT 0
);


--
-- Name: deliveries_columnfororders_id_seq; Type: SEQUENCE; Schema: public; Owner: -
--

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


--
-- Name: deliveries_columnfororders_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: -
--

ALTER SEQUENCE public.deliveries_columnfororders_id_seq OWNED BY public.deliveries_columnfororders.id;


--
-- Name: deliveries_companyproduct_id_seq; Type: SEQUENCE; Schema: public; Owner: -
--

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


--
-- Name: deliveries_companyproduct_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: -
--

ALTER SEQUENCE public.deliveries_companyproduct_id_seq OWNED BY public.deliveries_companyproduct.id;


--
-- Name: deliveries_deliveredpackage; Type: TABLE; Schema: public; Owner: -
--

CREATE TABLE public.deliveries_deliveredpackage (
    id bigint NOT NULL,
    delivery_id bigint,
    product_id bigint,
    deliveredquantity numeric(14,5)
);


--
-- Name: deliveries_deliveredpackage_id_seq; Type: SEQUENCE; Schema: public; Owner: -
--

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


--
-- Name: deliveries_deliveredpackage_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: -
--

ALTER SEQUENCE public.deliveries_deliveredpackage_id_seq OWNED BY public.deliveries_deliveredpackage.id;


--
-- Name: deliveries_deliveredproduct; Type: TABLE; Schema: public; Owner: -
--

CREATE TABLE public.deliveries_deliveredproduct (
    id bigint NOT NULL,
    delivery_id bigint,
    product_id bigint,
    deliveredquantity numeric(12,5),
    damagedquantity numeric(12,5),
    priceperunit numeric(12,5),
    totalprice numeric(12,5),
    succession integer,
    operation_id bigint,
    offer_id bigint,
    batchnumber character varying(255),
    productiondate date,
    expirationdate date,
    entityversion bigint DEFAULT 0,
    palletnumber_id bigint,
    pallettype character varying(255),
    storagelocation_id bigint,
    additionalquantity numeric(12,5),
    conversion numeric(12,5),
    iswaste boolean,
    additionalunit character varying(255),
    damaged boolean DEFAULT false,
    batch_id bigint,
    orderedproduct_id bigint,
    qualityrating character varying(255)
);


--
-- Name: deliveries_deliveredproduct_id_seq; Type: SEQUENCE; Schema: public; Owner: -
--

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


--
-- Name: deliveries_deliveredproduct_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: -
--

ALTER SEQUENCE public.deliveries_deliveredproduct_id_seq OWNED BY public.deliveries_deliveredproduct.id;


--
-- Name: deliveries_deliveredproductattributeval; Type: TABLE; Schema: public; Owner: -
--

CREATE TABLE public.deliveries_deliveredproductattributeval (
    id bigint NOT NULL,
    deliveredproduct_id bigint,
    attribute_id bigint,
    attributevalue_id bigint,
    value character varying(255)
);


--
-- Name: deliveries_deliveredproductattributeval_id_seq; Type: SEQUENCE; Schema: public; Owner: -
--

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


--
-- Name: deliveries_deliveredproductattributeval_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: -
--

ALTER SEQUENCE public.deliveries_deliveredproductattributeval_id_seq OWNED BY public.deliveries_deliveredproductattributeval.id;


--
-- Name: productcatalognumbers_productcatalognumbers; Type: TABLE; Schema: public; Owner: -
--

CREATE TABLE public.productcatalognumbers_productcatalognumbers (
    id bigint NOT NULL,
    catalognumber character varying(256),
    product_id bigint,
    company_id bigint,
    entityversion bigint DEFAULT 0
);


--
-- Name: supplynegotiations_offer; Type: TABLE; Schema: public; Owner: -
--

CREATE TABLE public.supplynegotiations_offer (
    id bigint NOT NULL,
    number character varying(255),
    name character varying(1024),
    description character varying(2048),
    supplier_id bigint,
    requestforquotation_id bigint,
    offereddate timestamp without time zone,
    attachment character varying(255),
    transportcost numeric(12,5),
    state character varying(255) DEFAULT '01draft'::character varying,
    active boolean DEFAULT true,
    createdate timestamp without time zone,
    updatedate timestamp without time zone,
    createuser character varying(255),
    updateuser character varying(255),
    workingdaysafterorder integer,
    negotiation_id bigint,
    entityversion bigint DEFAULT 0,
    offerdate date,
    currency_id bigint
);


--
-- Name: deliveries_deliveredproductdto; Type: VIEW; Schema: public; Owner: -
--

CREATE VIEW public.deliveries_deliveredproductdto AS
 SELECT deliveredproduct.id,
    deliveredproduct.succession,
    deliveredproduct.damagedquantity,
    deliveredproduct.deliveredquantity,
    deliveredproduct.priceperunit,
    deliveredproduct.totalprice,
    deliveredproduct.conversion,
    deliveredproduct.additionalquantity,
    deliveredproduct.iswaste,
    delivery.id AS delivery,
    (delivery.id)::integer AS deliveryid,
    delivery.supplier_id AS supplier,
    product.number AS productnumber,
    product.name AS productname,
    product.unit AS productunit,
    offer.number AS offernumber,
    operation.number AS operationnumber,
    storagelocation.number AS storagelocationnumber,
    palletnumber.number AS palletnumber,
    batch.number AS batchnumber,
    ( SELECT productcatalognumbers_productcatalognumbers.catalognumber
           FROM public.productcatalognumbers_productcatalognumbers
          WHERE ((productcatalognumbers_productcatalognumbers.product_id = product.id) AND (productcatalognumbers_productcatalognumbers.company_id = delivery.supplier_id))) AS productcatalognumber,
    deliveredproduct.pallettype,
    deliveredproduct.additionalunit,
    deliveredproduct.damaged,
    deliveredproduct.expirationdate
   FROM (((((((public.deliveries_deliveredproduct deliveredproduct
     LEFT JOIN public.deliveries_delivery delivery ON ((delivery.id = deliveredproduct.delivery_id)))
     LEFT JOIN public.basic_product product ON ((product.id = deliveredproduct.product_id)))
     LEFT JOIN public.supplynegotiations_offer offer ON ((offer.id = deliveredproduct.offer_id)))
     LEFT JOIN public.technologies_operation operation ON ((operation.id = deliveredproduct.operation_id)))
     LEFT JOIN public.materialflowresources_storagelocation storagelocation ON ((storagelocation.id = deliveredproduct.storagelocation_id)))
     LEFT JOIN public.basic_palletnumber palletnumber ON ((palletnumber.id = deliveredproduct.palletnumber_id)))
     LEFT JOIN public.advancedgenealogy_batch batch ON ((batch.id = deliveredproduct.batch_id)));


--
-- Name: deliveries_deliveredproductdto_id_seq; Type: SEQUENCE; Schema: public; Owner: -
--

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


--
-- Name: deliveries_deliveredproductmulti; Type: TABLE; Schema: public; Owner: -
--

CREATE TABLE public.deliveries_deliveredproductmulti (
    id bigint NOT NULL,
    delivery_id bigint,
    palletnumber_id bigint,
    pallettype character varying(255),
    storagelocation_id bigint,
    createdate timestamp without time zone,
    updatedate timestamp without time zone,
    createuser character varying(255),
    updateuser character varying(255)
);


--
-- Name: deliveries_deliveredproductmulti_id_seq; Type: SEQUENCE; Schema: public; Owner: -
--

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


--
-- Name: deliveries_deliveredproductmulti_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: -
--

ALTER SEQUENCE public.deliveries_deliveredproductmulti_id_seq OWNED BY public.deliveries_deliveredproductmulti.id;


--
-- Name: deliveries_deliveredproductmultiposition; Type: TABLE; Schema: public; Owner: -
--

CREATE TABLE public.deliveries_deliveredproductmultiposition (
    id bigint NOT NULL,
    deliveredproductmulti_id bigint,
    product_id bigint,
    quantity numeric(12,5),
    additionalquantity numeric(12,5),
    conversion numeric(12,5),
    iswaste boolean,
    expirationdate date,
    unit character varying(255),
    additionalunit character varying(255),
    offer_id bigint,
    batch_id bigint,
    priceperunit numeric(12,5)
);


--
-- Name: deliveries_deliveredproductmultiposition_id_seq; Type: SEQUENCE; Schema: public; Owner: -
--

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


--
-- Name: deliveries_deliveredproductmultiposition_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: -
--

ALTER SEQUENCE public.deliveries_deliveredproductmultiposition_id_seq OWNED BY public.deliveries_deliveredproductmultiposition.id;


--
-- Name: deliveries_delivery_id_seq; Type: SEQUENCE; Schema: public; Owner: -
--

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


--
-- Name: deliveries_delivery_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: -
--

ALTER SEQUENCE public.deliveries_delivery_id_seq OWNED BY public.deliveries_delivery.id;


--
-- Name: deliveries_deliveryattachment_id_seq; Type: SEQUENCE; Schema: public; Owner: -
--

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


--
-- Name: deliveries_deliveryattachment_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: -
--

ALTER SEQUENCE public.deliveries_deliveryattachment_id_seq OWNED BY public.deliveries_deliveryattachment.id;


--
-- Name: deliveries_deliverybypallettypereport; Type: TABLE; Schema: public; Owner: -
--

CREATE TABLE public.deliveries_deliverybypallettypereport (
    id bigint NOT NULL,
    fromdate date,
    todate date
);


--
-- Name: deliveries_deliverybypallettypereport_id_seq; Type: SEQUENCE; Schema: public; Owner: -
--

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


--
-- Name: deliveries_deliverybypallettypereport_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: -
--

ALTER SEQUENCE public.deliveries_deliverybypallettypereport_id_seq OWNED BY public.deliveries_deliverybypallettypereport.id;


--
-- Name: deliveries_deliverystatechange; Type: TABLE; Schema: public; Owner: -
--

CREATE TABLE public.deliveries_deliverystatechange (
    id bigint NOT NULL,
    dateandtime timestamp without time zone,
    sourcestate character varying(255),
    targetstate character varying(255),
    status character varying(255),
    phase integer,
    shift_id bigint,
    worker character varying(255),
    delivery_id bigint,
    entityversion bigint DEFAULT 0
);


--
-- Name: deliveries_deliverystatechange_id_seq; Type: SEQUENCE; Schema: public; Owner: -
--

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


--
-- Name: deliveries_deliverystatechange_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: -
--

ALTER SEQUENCE public.deliveries_deliverystatechange_id_seq OWNED BY public.deliveries_deliverystatechange.id;


--
-- Name: deliveries_orderedproduct; Type: TABLE; Schema: public; Owner: -
--

CREATE TABLE public.deliveries_orderedproduct (
    id bigint NOT NULL,
    delivery_id bigint,
    product_id bigint,
    orderedquantity numeric(12,5),
    priceperunit numeric(12,5),
    totalprice numeric(12,5),
    description character varying(2048),
    succession integer,
    operation_id bigint,
    offer_id bigint,
    actualversion character varying(255),
    entityversion bigint DEFAULT 0,
    additionalquantity numeric(12,5),
    conversion numeric(12,5),
    deliveredquantity numeric,
    additionaldeliveredquantity numeric,
    batchnumber character varying(255),
    batch_id bigint,
    qualitycard_id bigint
);


--
-- Name: deliveries_orderedproduct_id_seq; Type: SEQUENCE; Schema: public; Owner: -
--

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


--
-- Name: deliveries_orderedproduct_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: -
--

ALTER SEQUENCE public.deliveries_orderedproduct_id_seq OWNED BY public.deliveries_orderedproduct.id;


--
-- Name: supplynegotiations_negotiation; Type: TABLE; Schema: public; Owner: -
--

CREATE TABLE public.supplynegotiations_negotiation (
    id bigint NOT NULL,
    number character varying(255),
    name character varying(1024),
    state character varying(255) DEFAULT '01draft'::character varying,
    generatedate timestamp without time zone,
    active boolean DEFAULT true,
    createdate timestamp without time zone,
    updatedate timestamp without time zone,
    createuser character varying(255),
    updateuser character varying(255),
    entityversion bigint DEFAULT 0
);


--
-- Name: deliveries_orderedproductdto; Type: VIEW; Schema: public; Owner: -
--

CREATE VIEW public.deliveries_orderedproductdto AS
 WITH product_attachments AS (
         SELECT product_1.id AS productid,
            (count(attachment.id) <> 0) AS hasattachments
           FROM (public.basic_product product_1
             LEFT JOIN public.basic_productattachment attachment ON ((attachment.product_id = product_1.id)))
          GROUP BY product_1.id
        )
 SELECT orderedproduct.id,
    orderedproduct.succession,
    orderedproduct.orderedquantity,
    orderedproduct.priceperunit,
    orderedproduct.totalprice,
    orderedproduct.conversion,
    orderedproduct.additionalquantity,
    orderedproduct.description,
    orderedproduct.actualversion,
    delivery.id AS delivery,
    (delivery.id)::integer AS deliveryid,
    delivery.supplier_id AS supplier,
    delivery.deliverydate,
    delivery.state AS deliverystate,
    delivery.number AS deliverynumber,
    delivery.name AS deliveryname,
    delivery.active AS deliveryactive,
    currency.alphabeticcode AS deliverycurrency,
    supplier.name AS suppliername,
    product.number AS productnumber,
    product.name AS productname,
    product.norm AS productnorm,
    product.unit AS productunit,
    product.additionalunit,
    offer.number AS offernumber,
    negotiation.number AS negotiationnumber,
    operation.number AS operationnumber,
    ( SELECT productcatalognumbers_productcatalognumbers.catalognumber
           FROM public.productcatalognumbers_productcatalognumbers
          WHERE ((productcatalognumbers_productcatalognumbers.product_id = product.id) AND (productcatalognumbers_productcatalognumbers.company_id = delivery.supplier_id))) AS productcatalognumber,
    COALESCE(orderedproduct.deliveredquantity, (0)::numeric) AS deliveredquantity,
    COALESCE(orderedproduct.additionaldeliveredquantity, (0)::numeric) AS additionaldeliveredquantity,
        CASE
            WHEN ((orderedproduct.orderedquantity - COALESCE(orderedproduct.deliveredquantity, (0)::numeric)) > (0)::numeric) THEN (orderedproduct.orderedquantity - COALESCE(orderedproduct.deliveredquantity, (0)::numeric))
            ELSE (0)::numeric
        END AS lefttoreceivequantity,
        CASE
            WHEN ((orderedproduct.additionalquantity - COALESCE(orderedproduct.additionaldeliveredquantity, (0)::numeric)) > (0)::numeric) THEN (orderedproduct.additionalquantity - COALESCE(orderedproduct.additionaldeliveredquantity, (0)::numeric))
            ELSE (0)::numeric
        END AS additionallefttoreceivequantity,
    attachments.hasattachments,
    batch.number AS batchnumber,
    qualitycard.number AS qualitycardnumber,
    parentproduct.number AS parentproductnumber,
    companyproduct.minimumorderquantity,
    companyproductsfamily.minimumorderquantity AS minimumfamilyorderquantity,
        CASE
            WHEN (companyproduct.minimumorderquantity IS NOT NULL) THEN companyproduct.minimumorderquantity
            ELSE companyproductsfamily.minimumorderquantity
        END AS minorderquantity,
        CASE
            WHEN ((companyproduct.minimumorderquantity IS NULL) AND (companyproductsfamily.minimumorderquantity IS NULL)) THEN false
            WHEN ((companyproduct.minimumorderquantity IS NOT NULL) AND (companyproduct.minimumorderquantity <= orderedproduct.orderedquantity)) THEN false
            WHEN ((companyproductsfamily.minimumorderquantity IS NOT NULL) AND (companyproductsfamily.minimumorderquantity <= orderedproduct.orderedquantity)) THEN false
            ELSE true
        END AS belowminorderquantity
   FROM (((((((((((((public.deliveries_orderedproduct orderedproduct
     LEFT JOIN public.deliveries_delivery delivery ON ((delivery.id = orderedproduct.delivery_id)))
     LEFT JOIN public.basic_currency currency ON ((currency.id = delivery.currency_id)))
     LEFT JOIN public.basic_company supplier ON ((supplier.id = delivery.supplier_id)))
     LEFT JOIN public.basic_product product ON ((product.id = orderedproduct.product_id)))
     LEFT JOIN public.basic_product parentproduct ON ((product.parent_id = parentproduct.id)))
     LEFT JOIN public.deliveries_companyproduct companyproduct ON (((product.id = companyproduct.product_id) AND (supplier.id = companyproduct.company_id))))
     LEFT JOIN public.deliveries_companyproduct companyproductsfamily ON (((parentproduct.id = companyproductsfamily.product_id) AND (supplier.id = companyproductsfamily.company_id))))
     LEFT JOIN public.supplynegotiations_offer offer ON ((offer.id = orderedproduct.offer_id)))
     LEFT JOIN public.supplynegotiations_negotiation negotiation ON ((negotiation.id = offer.negotiation_id)))
     LEFT JOIN public.technologies_operation operation ON ((operation.id = orderedproduct.operation_id)))
     LEFT JOIN product_attachments attachments ON ((attachments.productid = product.id)))
     LEFT JOIN public.advancedgenealogy_batch batch ON ((batch.id = orderedproduct.batch_id)))
     LEFT JOIN public.basic_qualitycard qualitycard ON ((qualitycard.id = orderedproduct.qualitycard_id)));


--
-- Name: deliveries_orderedproductdto_id_seq; Type: SEQUENCE; Schema: public; Owner: -
--

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


--
-- Name: deliveries_orderedproductlistdto; Type: VIEW; Schema: public; Owner: -
--

CREATE VIEW public.deliveries_orderedproductlistdto AS
 SELECT orderedproduct.id,
    orderedproduct.succession,
    orderedproduct.orderedquantity,
    orderedproduct.priceperunit,
    orderedproduct.conversion,
    orderedproduct.additionalquantity,
    orderedproduct.description,
    orderedproduct.actualversion,
    delivery.id AS delivery,
    (delivery.id)::integer AS deliveryid,
    delivery.supplier_id AS supplier,
    delivery.deliverydate,
    delivery.state AS deliverystate,
    delivery.number AS deliverynumber,
    delivery.name AS deliveryname,
    delivery.active AS deliveryactive,
    currency.alphabeticcode AS deliverycurrency,
    supplier.name AS suppliername,
    product.number AS productnumber,
    product.name AS productname,
    product.norm AS productnorm,
    product.unit AS productunit,
    offer.number AS offernumber,
    negotiation.number AS negotiationnumber,
    operation.number AS operationnumber,
    ( SELECT productcatalognumbers_productcatalognumbers.catalognumber
           FROM public.productcatalognumbers_productcatalognumbers
          WHERE ((productcatalognumbers_productcatalognumbers.product_id = product.id) AND (productcatalognumbers_productcatalognumbers.company_id = delivery.supplier_id))) AS productcatalognumber,
    (delivery.location_id)::integer AS location_id,
    COALESCE(orderedproduct.deliveredquantity, (0)::numeric) AS deliveredquantity,
    batch.number AS batchnumber
   FROM ((((((((public.deliveries_orderedproduct orderedproduct
     LEFT JOIN public.deliveries_delivery delivery ON ((orderedproduct.delivery_id = delivery.id)))
     LEFT JOIN public.basic_currency currency ON ((delivery.currency_id = currency.id)))
     LEFT JOIN public.basic_company supplier ON ((delivery.supplier_id = supplier.id)))
     LEFT JOIN public.basic_product product ON ((orderedproduct.product_id = product.id)))
     LEFT JOIN public.supplynegotiations_offer offer ON ((orderedproduct.offer_id = offer.id)))
     LEFT JOIN public.supplynegotiations_negotiation negotiation ON ((offer.negotiation_id = negotiation.id)))
     LEFT JOIN public.technologies_operation operation ON ((orderedproduct.operation_id = operation.id)))
     LEFT JOIN public.advancedgenealogy_batch batch ON ((batch.id = orderedproduct.batch_id)));


--
-- Name: deliveries_orderedproductlistdto_id_seq; Type: SEQUENCE; Schema: public; Owner: -
--

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


--
-- Name: deliveries_parameterdeliveryordercolumn; Type: TABLE; Schema: public; Owner: -
--

CREATE TABLE public.deliveries_parameterdeliveryordercolumn (
    id bigint NOT NULL,
    parameter_id bigint,
    columnfororders_id bigint,
    succession integer,
    entityversion bigint DEFAULT 0
);


--
-- Name: deliveries_parameterdeliveryordercolumn_id_seq; Type: SEQUENCE; Schema: public; Owner: -
--

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


--
-- Name: deliveries_parameterdeliveryordercolumn_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: -
--

ALTER SEQUENCE public.deliveries_parameterdeliveryordercolumn_id_seq OWNED BY public.deliveries_parameterdeliveryordercolumn.id;


--
-- Name: emailnotifications_staffnotification; Type: TABLE; Schema: public; Owner: -
--

CREATE TABLE public.emailnotifications_staffnotification (
    id bigint NOT NULL,
    email character varying(255),
    staff_id bigint,
    createdate timestamp without time zone,
    updatedate timestamp without time zone,
    createuser character varying(255),
    updateuser character varying(255),
    parameter_id bigint,
    createdeliveryminstate boolean,
    entityversion bigint DEFAULT 0,
    pmmnotification boolean DEFAULT false
);


--
-- Name: emailnotifications_staffnotification_id_seq; Type: SEQUENCE; Schema: public; Owner: -
--

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


--
-- Name: emailnotifications_staffnotification_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: -
--

ALTER SEQUENCE public.emailnotifications_staffnotification_id_seq OWNED BY public.emailnotifications_staffnotification.id;


--
-- Name: goodfood_confectionadditionalinputproduct; Type: TABLE; Schema: public; Owner: -
--

CREATE TABLE public.goodfood_confectionadditionalinputproduct (
    id bigint NOT NULL,
    confectionprotocol_id bigint,
    batch_id bigint,
    product_id bigint,
    takenonquantity numeric(12,5),
    takenofquantity numeric(12,5),
    cullquantity numeric(12,5),
    effectivequantity numeric(12,5),
    entityversion bigint DEFAULT 0
);


--
-- Name: goodfood_confectionadditionalinputproduct_id_seq; Type: SEQUENCE; Schema: public; Owner: -
--

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


--
-- Name: goodfood_confectionadditionalinputproduct_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: -
--

ALTER SEQUENCE public.goodfood_confectionadditionalinputproduct_id_seq OWNED BY public.goodfood_confectionadditionalinputproduct.id;


--
-- Name: goodfood_confectioncontext; Type: TABLE; Schema: public; Owner: -
--

CREATE TABLE public.goodfood_confectioncontext (
    id bigint NOT NULL,
    day date,
    generated boolean DEFAULT false,
    confirmed boolean DEFAULT false,
    place character varying(255),
    productionline_id bigint,
    shift_id bigint,
    operator_id bigint,
    entityversion bigint DEFAULT 0
);


--
-- Name: goodfood_confectioncontext_id_seq; Type: SEQUENCE; Schema: public; Owner: -
--

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


--
-- Name: goodfood_confectioncontext_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: -
--

ALTER SEQUENCE public.goodfood_confectioncontext_id_seq OWNED BY public.goodfood_confectioncontext.id;


--
-- Name: goodfood_confectionfilmproduct; Type: TABLE; Schema: public; Owner: -
--

CREATE TABLE public.goodfood_confectionfilmproduct (
    id bigint NOT NULL,
    confectionprotocol_id bigint,
    filmproduct_id bigint,
    beyondrecipe boolean DEFAULT false
);


--
-- Name: goodfood_confectionfilmproductentry; Type: TABLE; Schema: public; Owner: -
--

CREATE TABLE public.goodfood_confectionfilmproductentry (
    id bigint NOT NULL,
    batch_id bigint,
    confectionfilmproduct_id bigint,
    takenonquantity numeric(12,5),
    takenofquantity numeric(12,5),
    cullquantity numeric(12,5),
    effectivequantity numeric(12,5)
);


--
-- Name: goodfood_confectioninputproduct; Type: TABLE; Schema: public; Owner: -
--

CREATE TABLE public.goodfood_confectioninputproduct (
    id bigint NOT NULL,
    confectionprotocol_id bigint,
    batch_id bigint,
    product_id bigint,
    takenonquantity numeric(12,5),
    takenofquantity numeric(12,5),
    cullquantity numeric(12,5),
    effectivequantity numeric(12,5),
    entityversion bigint DEFAULT 0
);


--
-- Name: goodfood_confectionprotocol; Type: TABLE; Schema: public; Owner: -
--

CREATE TABLE public.goodfood_confectionprotocol (
    id bigint NOT NULL,
    generationdate date,
    state character varying(255) DEFAULT '01draft'::character varying,
    laststatechangefails boolean DEFAULT false,
    confectioncontext_id bigint,
    number character varying(1024),
    dayofshiftstart date,
    productionline_id bigint,
    toproduce numeric(12,5),
    startdate timestamp without time zone,
    finishdate timestamp without time zone,
    order_id bigint,
    ordernumber character varying(255),
    productnameandnumber character varying(255),
    qcp5code character varying(255),
    filmproduct_id bigint,
    restoneofcartonsquantity numeric(12,5),
    resttwoofcartonsquantity numeric(12,5),
    allpalletquantity numeric(12,5),
    quantityofallcartonsquantity numeric(12,5),
    wastewafers numeric(12,5),
    effectiveproducedquantity numeric(12,5),
    effectiveexecutiontimestart timestamp without time zone,
    effectiveexecutiontimeend timestamp without time zone,
    externalnumber integer NOT NULL,
    externalsynchronized boolean DEFAULT true,
    active boolean DEFAULT true,
    laststatechangefailcause character varying(8192),
    showlaststatechangeresult boolean DEFAULT false,
    isdoubled boolean DEFAULT false,
    additionalfilmproduct_id bigint,
    iscorrected boolean DEFAULT false,
    productiondate date,
    entityversion bigint DEFAULT 0,
    comments text,
    sendagaintoblackbox boolean DEFAULT false,
    finalprotocol boolean,
    plannextorderinfo character varying(8192),
    plannextorderinfoargs character varying(8192),
    plannextorderstatechangeinfo character varying
);


--
-- Name: goodfood_confectionfilmprepare; Type: VIEW; Schema: public; Owner: -
--

CREATE VIEW public.goodfood_confectionfilmprepare AS
 SELECT confectionprotocol.number AS protocolnumber,
    confectionprotocol.dayofshiftstart,
    confectionprotocol.state AS confectionprotocolstate,
    ordersorder.number AS ordernumber,
    productionline.number AS productionlinenumber,
    product.number AS productnumber,
    confectionfilmproductentry.cullquantity
   FROM (((((public.goodfood_confectionprotocol confectionprotocol
     JOIN public.productionlines_productionline productionline ON ((productionline.id = confectionprotocol.productionline_id)))
     JOIN public.orders_order ordersorder ON ((ordersorder.id = confectionprotocol.order_id)))
     JOIN public.goodfood_confectionfilmproduct confectionfilmproduct ON ((confectionfilmproduct.confectionprotocol_id = confectionprotocol.id)))
     LEFT JOIN public.goodfood_confectionfilmproductentry confectionfilmproductentry ON ((confectionfilmproduct.id = confectionfilmproductentry.confectionfilmproduct_id)))
     JOIN public.basic_product product ON ((product.id = confectionfilmproduct.filmproduct_id)))
UNION
 SELECT confectionprotocol.number AS protocolnumber,
    confectionprotocol.dayofshiftstart,
    confectionprotocol.state AS confectionprotocolstate,
    ordersorder.number AS ordernumber,
    productionline.number AS productionlinenumber,
    product.number AS productnumber,
    confectioninputproduct.cullquantity
   FROM ((((public.goodfood_confectionprotocol confectionprotocol
     JOIN public.productionlines_productionline productionline ON ((productionline.id = confectionprotocol.productionline_id)))
     JOIN public.orders_order ordersorder ON ((ordersorder.id = confectionprotocol.order_id)))
     JOIN public.goodfood_confectioninputproduct confectioninputproduct ON ((confectioninputproduct.confectionprotocol_id = confectionprotocol.id)))
     JOIN public.basic_product product ON ((product.id = confectioninputproduct.product_id)))
UNION
 SELECT confectionprotocol.number AS protocolnumber,
    confectionprotocol.dayofshiftstart,
    confectionprotocol.state AS confectionprotocolstate,
    ordersorder.number AS ordernumber,
    productionline.number AS productionlinenumber,
    product.number AS productnumber,
    confectioninputproduct.cullquantity
   FROM ((((public.goodfood_confectionprotocol confectionprotocol
     JOIN public.productionlines_productionline productionline ON ((productionline.id = confectionprotocol.productionline_id)))
     JOIN public.orders_order ordersorder ON ((ordersorder.id = confectionprotocol.order_id)))
     JOIN public.goodfood_confectionadditionalinputproduct confectioninputproduct ON ((confectioninputproduct.confectionprotocol_id = confectionprotocol.id)))
     JOIN public.basic_product product ON ((product.id = confectioninputproduct.product_id)));


--
-- Name: goodfood_confectionfilm; Type: VIEW; Schema: public; Owner: -
--

CREATE VIEW public.goodfood_confectionfilm AS
 SELECT row_number() OVER () AS id,
    cf.protocolnumber,
    cf.dayofshiftstart,
    cf.confectionprotocolstate,
    cf.ordernumber,
    cf.productionlinenumber,
    cf.productnumber,
    cf.cullquantity
   FROM public.goodfood_confectionfilmprepare cf;


--
-- Name: goodfood_confectionfilm_id_seq; Type: SEQUENCE; Schema: public; Owner: -
--

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


--
-- Name: goodfood_confectionfilmproduct_id_seq; Type: SEQUENCE; Schema: public; Owner: -
--

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


--
-- Name: goodfood_confectionfilmproduct_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: -
--

ALTER SEQUENCE public.goodfood_confectionfilmproduct_id_seq OWNED BY public.goodfood_confectionfilmproduct.id;


--
-- Name: goodfood_confectionfilmproductentry_id_seq; Type: SEQUENCE; Schema: public; Owner: -
--

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


--
-- Name: goodfood_confectionfilmproductentry_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: -
--

ALTER SEQUENCE public.goodfood_confectionfilmproductentry_id_seq OWNED BY public.goodfood_confectionfilmproductentry.id;


--
-- Name: goodfood_confectioninputproduct_id_seq; Type: SEQUENCE; Schema: public; Owner: -
--

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


--
-- Name: goodfood_confectioninputproduct_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: -
--

ALTER SEQUENCE public.goodfood_confectioninputproduct_id_seq OWNED BY public.goodfood_confectioninputproduct.id;


--
-- Name: goodfood_confectionprotocol_externalnumber_seq; Type: SEQUENCE; Schema: public; Owner: -
--

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


--
-- Name: goodfood_confectionprotocol_id_seq; Type: SEQUENCE; Schema: public; Owner: -
--

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


--
-- Name: goodfood_confectionprotocol_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: -
--

ALTER SEQUENCE public.goodfood_confectionprotocol_id_seq OWNED BY public.goodfood_confectionprotocol.id;


--
-- Name: goodfood_confectionprotocolcorrect; Type: TABLE; Schema: public; Owner: -
--

CREATE TABLE public.goodfood_confectionprotocolcorrect (
    id bigint NOT NULL,
    confectionprotocol_id bigint,
    correctdate date,
    correctreason character varying(2048),
    createdate timestamp without time zone,
    updatedate timestamp without time zone,
    createuser character varying(255),
    updateuser character varying(255),
    isconfirmed boolean DEFAULT false,
    entityversion bigint DEFAULT 0
);


--
-- Name: goodfood_confectionprotocolcorrect_id_seq; Type: SEQUENCE; Schema: public; Owner: -
--

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


--
-- Name: goodfood_confectionprotocolcorrect_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: -
--

ALTER SEQUENCE public.goodfood_confectionprotocolcorrect_id_seq OWNED BY public.goodfood_confectionprotocolcorrect.id;


--
-- Name: goodfood_confectionprotocoldto; Type: VIEW; Schema: public; Owner: -
--

CREATE VIEW public.goodfood_confectionprotocoldto AS
 SELECT cp.id,
    cp.active,
    cp.number,
    cp.dayofshiftstart,
    shift.name AS confectioncontextshift,
    confectioncontext.place AS confectioncontextplace,
    productionline.number AS productionlinenumber,
    productionline.name AS productionlinename,
    o.number AS ordernumber,
    cp.qcp5code,
    staff.name AS confectioncontextoperatorname,
    staff.surname AS confectioncontextoperatorsurname,
    cp.state,
    cp.iscorrected,
    cp.generationdate
   FROM (((((public.goodfood_confectionprotocol cp
     JOIN public.productionlines_productionline productionline ON ((cp.productionline_id = productionline.id)))
     JOIN public.orders_order o ON ((cp.order_id = o.id)))
     LEFT JOIN public.goodfood_confectioncontext confectioncontext ON ((cp.confectioncontext_id = confectioncontext.id)))
     LEFT JOIN public.basic_shift shift ON ((confectioncontext.shift_id = shift.id)))
     LEFT JOIN public.basic_staff staff ON ((confectioncontext.operator_id = staff.id)));


--
-- Name: goodfood_confectionprotocoldto_id_seq; Type: SEQUENCE; Schema: public; Owner: -
--

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


--
-- Name: goodfood_confectionprotocolstatechange; Type: TABLE; Schema: public; Owner: -
--

CREATE TABLE public.goodfood_confectionprotocolstatechange (
    id bigint NOT NULL,
    dateandtime timestamp without time zone,
    sourcestate character varying(255),
    targetstate character varying(255),
    status character varying(255),
    phase integer,
    shift_id bigint,
    worker character varying(255),
    confectionprotocol_id bigint,
    entityversion bigint DEFAULT 0
);


--
-- Name: goodfood_confectionprotocolstatechange_id_seq; Type: SEQUENCE; Schema: public; Owner: -
--

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


--
-- Name: goodfood_confectionprotocolstatechange_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: -
--

ALTER SEQUENCE public.goodfood_confectionprotocolstatechange_id_seq OWNED BY public.goodfood_confectionprotocolstatechange.id;


--
-- Name: goodfood_confectionremainderinputproduct; Type: TABLE; Schema: public; Owner: -
--

CREATE TABLE public.goodfood_confectionremainderinputproduct (
    id bigint NOT NULL,
    confectionprotocol_id bigint,
    product_id bigint,
    usedquantity numeric(12,5),
    isdoubled boolean DEFAULT false,
    entityversion bigint DEFAULT 0,
    usedbatches text,
    beyondrecipe boolean DEFAULT false
);


--
-- Name: goodfood_confectionremainderinputproduct_id_seq; Type: SEQUENCE; Schema: public; Owner: -
--

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


--
-- Name: goodfood_confectionremainderinputproduct_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: -
--

ALTER SEQUENCE public.goodfood_confectionremainderinputproduct_id_seq OWNED BY public.goodfood_confectionremainderinputproduct.id;


--
-- Name: goodfood_confectionstaff; Type: TABLE; Schema: public; Owner: -
--

CREATE TABLE public.goodfood_confectionstaff (
    id bigint NOT NULL,
    confectionprotocol_id bigint,
    worker_id bigint,
    labortime integer,
    effectiveexecutiontimestart timestamp without time zone,
    effectiveexecutiontimeend timestamp without time zone,
    entityversion bigint DEFAULT 0
);


--
-- Name: goodfood_confectionstaff_id_seq; Type: SEQUENCE; Schema: public; Owner: -
--

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


--
-- Name: goodfood_confectionstaff_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: -
--

ALTER SEQUENCE public.goodfood_confectionstaff_id_seq OWNED BY public.goodfood_confectionstaff.id;


--
-- Name: goodfood_eventlog; Type: TABLE; Schema: public; Owner: -
--

CREATE TABLE public.goodfood_eventlog (
    id bigint NOT NULL,
    eventtype character varying(255) DEFAULT '01other'::character varying,
    description character varying(2048),
    user_id bigint,
    startdate timestamp without time zone,
    finishdate timestamp without time zone,
    product_id bigint,
    ssccnumber character varying(20),
    quantity numeric(12,5),
    sourcelocation character varying(16),
    destinationlocation character varying(16),
    createdate timestamp without time zone,
    updatedate timestamp without time zone,
    createuser character varying(255),
    updateuser character varying(255),
    entityversion bigint DEFAULT 0
);


--
-- Name: goodfood_eventlog_id_seq; Type: SEQUENCE; Schema: public; Owner: -
--

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


--
-- Name: goodfood_eventlog_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: -
--

ALTER SEQUENCE public.goodfood_eventlog_id_seq OWNED BY public.goodfood_eventlog.id;


--
-- Name: goodfood_extrusionaddedmixentry; Type: TABLE; Schema: public; Owner: -
--

CREATE TABLE public.goodfood_extrusionaddedmixentry (
    id bigint NOT NULL,
    extrusionprotocol_id bigint,
    quantity numeric(9,2),
    entityversion bigint DEFAULT 0,
    extrusionmix_id bigint
);


--
-- Name: goodfood_extrusionaddedmixentry_id_seq; Type: SEQUENCE; Schema: public; Owner: -
--

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


--
-- Name: goodfood_extrusionaddedmixentry_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: -
--

ALTER SEQUENCE public.goodfood_extrusionaddedmixentry_id_seq OWNED BY public.goodfood_extrusionaddedmixentry.id;


--
-- Name: goodfood_extrusionaddedmixingredient; Type: TABLE; Schema: public; Owner: -
--

CREATE TABLE public.goodfood_extrusionaddedmixingredient (
    id bigint NOT NULL,
    extrusionaddedmixentry_id bigint,
    extrusionmixingredient_id bigint,
    product_id bigint,
    batch_id bigint,
    quantity numeric(9,2),
    beyondrecipe boolean DEFAULT false
);


--
-- Name: goodfood_extrusionaddedmixingredient_id_seq; Type: SEQUENCE; Schema: public; Owner: -
--

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


--
-- Name: goodfood_extrusionaddedmixingredient_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: -
--

ALTER SEQUENCE public.goodfood_extrusionaddedmixingredient_id_seq OWNED BY public.goodfood_extrusionaddedmixingredient.id;


--
-- Name: goodfood_extrusionbatchingredientdto; Type: VIEW; Schema: public; Owner: -
--

CREATE VIEW public.goodfood_extrusionbatchingredientdto AS
SELECT
    NULL::bigint AS id,
    NULL::bigint AS extrusionprotocol_id,
    NULL::character varying(255) AS productnumber,
    NULL::character varying(255) AS unit,
    NULL::character varying(255) AS batchnumber,
    NULL::numeric AS quantity;


--
-- Name: goodfood_extrusionbatchingredientdto_id_seq; Type: SEQUENCE; Schema: public; Owner: -
--

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


--
-- Name: goodfood_extrusioncontext; Type: TABLE; Schema: public; Owner: -
--

CREATE TABLE public.goodfood_extrusioncontext (
    id bigint NOT NULL,
    day date,
    generated boolean DEFAULT false,
    confirmed boolean DEFAULT false,
    place character varying(255),
    productionline_id bigint,
    shift_id bigint,
    operator_id bigint,
    entityversion bigint DEFAULT 0
);


--
-- Name: goodfood_extrusioncontext_id_seq; Type: SEQUENCE; Schema: public; Owner: -
--

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


--
-- Name: goodfood_extrusioncontext_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: -
--

ALTER SEQUENCE public.goodfood_extrusioncontext_id_seq OWNED BY public.goodfood_extrusioncontext.id;


--
-- Name: goodfood_extrusionmix; Type: TABLE; Schema: public; Owner: -
--

CREATE TABLE public.goodfood_extrusionmix (
    id bigint NOT NULL,
    number character varying(1024),
    technology_id bigint,
    product_id bigint,
    productionline_id bigint,
    takenoffdate timestamp without time zone,
    shift_id bigint,
    quantity numeric(9,2),
    operator_id bigint,
    comment text,
    active boolean DEFAULT true
);


--
-- Name: goodfood_extrusionmix_id_seq; Type: SEQUENCE; Schema: public; Owner: -
--

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


--
-- Name: goodfood_extrusionmix_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: -
--

ALTER SEQUENCE public.goodfood_extrusionmix_id_seq OWNED BY public.goodfood_extrusionmix.id;


--
-- Name: goodfood_extrusionmix_number_seq; Type: SEQUENCE; Schema: public; Owner: -
--

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


--
-- Name: goodfood_extrusionmixingredient; Type: TABLE; Schema: public; Owner: -
--

CREATE TABLE public.goodfood_extrusionmixingredient (
    id bigint NOT NULL,
    extrusionmix_id bigint,
    product_id bigint,
    batch_id bigint,
    quantity numeric(9,2),
    beyondrecipe boolean DEFAULT false
);


--
-- Name: goodfood_extrusionmixingredient_id_seq; Type: SEQUENCE; Schema: public; Owner: -
--

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


--
-- Name: goodfood_extrusionmixingredient_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: -
--

ALTER SEQUENCE public.goodfood_extrusionmixingredient_id_seq OWNED BY public.goodfood_extrusionmixingredient.id;


--
-- Name: goodfood_extrusionpouring; Type: TABLE; Schema: public; Owner: -
--

CREATE TABLE public.goodfood_extrusionpouring (
    id bigint NOT NULL,
    extrusionprotocol_id bigint,
    finaladdedquantity numeric(9,2),
    addedquantity numeric(9,2),
    totalmixquantity numeric(12,5),
    addedquantitymanual boolean DEFAULT false,
    addedquantityrelatesto character varying(255) DEFAULT '01mix'::character varying,
    mixwaterquantity numeric(12,5),
    priority integer
);


--
-- Name: goodfood_extrusionpouring_id_seq; Type: SEQUENCE; Schema: public; Owner: -
--

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


--
-- Name: goodfood_extrusionpouring_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: -
--

ALTER SEQUENCE public.goodfood_extrusionpouring_id_seq OWNED BY public.goodfood_extrusionpouring.id;


--
-- Name: goodfood_extrusionpouringdto; Type: VIEW; Schema: public; Owner: -
--

CREATE VIEW public.goodfood_extrusionpouringdto AS
 SELECT pouring.id,
    pouring.addedquantity,
    pouring.finaladdedquantity,
    pouring.addedquantitymanual,
    pouring.addedquantityrelatesto,
    pouring.extrusionprotocol_id,
    (pouring.extrusionprotocol_id)::integer AS extrusionprotocolid,
    pouring.priority
   FROM public.goodfood_extrusionpouring pouring;


--
-- Name: goodfood_extrusionpouringdto_id_seq; Type: SEQUENCE; Schema: public; Owner: -
--

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


--
-- Name: goodfood_extrusionpouringingredient; Type: TABLE; Schema: public; Owner: -
--

CREATE TABLE public.goodfood_extrusionpouringingredient (
    id bigint NOT NULL,
    extrusionpouring_id bigint,
    product_id bigint,
    batch_id bigint,
    quantity numeric(9,2),
    ratio numeric(12,5),
    manual boolean DEFAULT false,
    skip boolean DEFAULT false,
    frommix boolean DEFAULT false,
    requiredquantity numeric(9,2),
    quantityinmix numeric(12,5),
    beyondrecipe boolean DEFAULT false,
    addedbyuser boolean DEFAULT false,
    extrusionpouringmix_id bigint
);


--
-- Name: goodfood_extrusionpouringingredient_id_seq; Type: SEQUENCE; Schema: public; Owner: -
--

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


--
-- Name: goodfood_extrusionpouringingredient_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: -
--

ALTER SEQUENCE public.goodfood_extrusionpouringingredient_id_seq OWNED BY public.goodfood_extrusionpouringingredient.id;


--
-- Name: goodfood_extrusionpouringmix; Type: TABLE; Schema: public; Owner: -
--

CREATE TABLE public.goodfood_extrusionpouringmix (
    id bigint NOT NULL,
    extrusionpouring_id bigint,
    mixid character varying(255),
    requiredscalequantity numeric(9,2),
    scalequantity numeric(9,2),
    scalequantitymanual boolean DEFAULT false,
    totalmixquantity numeric(12,5),
    mixwaterquantity numeric(12,5)
);


--
-- Name: goodfood_extrusionpouringmix_id_seq; Type: SEQUENCE; Schema: public; Owner: -
--

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


--
-- Name: goodfood_extrusionpouringmix_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: -
--

ALTER SEQUENCE public.goodfood_extrusionpouringmix_id_seq OWNED BY public.goodfood_extrusionpouringmix.id;


--
-- Name: goodfood_extrusionprotocol; Type: TABLE; Schema: public; Owner: -
--

CREATE TABLE public.goodfood_extrusionprotocol (
    id bigint NOT NULL,
    generationdate date,
    state character varying(255) DEFAULT '01draft'::character varying,
    laststatechangefails boolean DEFAULT false,
    extrusioncontext_id bigint,
    number character varying(1024),
    dayofshiftstart date,
    productionline_id bigint,
    toproduce numeric(12,5),
    changeover integer,
    startdate timestamp without time zone,
    finishdate timestamp without time zone,
    numberofavailableworkstation integer,
    order_id bigint,
    ordernumber character varying(255),
    productnameandnumber character varying(255),
    mixproduct character varying(255),
    operatorworkstartdate timestamp without time zone,
    operatorworkfinishdate timestamp without time zone,
    externalnumber integer NOT NULL,
    externalsynchronized boolean DEFAULT true,
    active boolean DEFAULT true,
    laststatechangefailcause character varying(8192),
    showlaststatechangeresult boolean DEFAULT false,
    iscorrected boolean DEFAULT false,
    entityversion bigint DEFAULT 0,
    comments text,
    sendagaintoblackbox boolean DEFAULT false
);


--
-- Name: goodfood_extrusionprotocol_externalnumber_seq; Type: SEQUENCE; Schema: public; Owner: -
--

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


--
-- Name: goodfood_extrusionprotocol_id_seq; Type: SEQUENCE; Schema: public; Owner: -
--

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


--
-- Name: goodfood_extrusionprotocol_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: -
--

ALTER SEQUENCE public.goodfood_extrusionprotocol_id_seq OWNED BY public.goodfood_extrusionprotocol.id;


--
-- Name: goodfood_extrusionprotocolcorrect; Type: TABLE; Schema: public; Owner: -
--

CREATE TABLE public.goodfood_extrusionprotocolcorrect (
    id bigint NOT NULL,
    extrusionprotocol_id bigint,
    correctdate date,
    correctreason character varying(2048),
    createdate timestamp without time zone,
    updatedate timestamp without time zone,
    createuser character varying(255),
    updateuser character varying(255),
    isconfirmed boolean DEFAULT false,
    entityversion bigint DEFAULT 0
);


--
-- Name: goodfood_extrusionprotocolcorrect_id_seq; Type: SEQUENCE; Schema: public; Owner: -
--

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


--
-- Name: goodfood_extrusionprotocolcorrect_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: -
--

ALTER SEQUENCE public.goodfood_extrusionprotocolcorrect_id_seq OWNED BY public.goodfood_extrusionprotocolcorrect.id;


--
-- Name: goodfood_extrusionprotocoldto; Type: VIEW; Schema: public; Owner: -
--

CREATE VIEW public.goodfood_extrusionprotocoldto AS
 SELECT ep.id,
    ep.active,
    ep.number,
    ep.dayofshiftstart,
    shift.name AS extrusioncontextshift,
    extrusioncontext.place AS extrusioncontextplace,
    productionline.number AS productionlinenumber,
    productionline.name AS productionlinename,
    o.number AS ordernumber,
    staff.name AS extrusioncontextoperatorname,
    staff.surname AS extrusioncontextoperatorsurname,
    ep.state,
    ep.iscorrected,
    ep.generationdate
   FROM (((((public.goodfood_extrusionprotocol ep
     JOIN public.productionlines_productionline productionline ON ((ep.productionline_id = productionline.id)))
     JOIN public.orders_order o ON ((ep.order_id = o.id)))
     LEFT JOIN public.goodfood_extrusioncontext extrusioncontext ON ((ep.extrusioncontext_id = extrusioncontext.id)))
     LEFT JOIN public.basic_shift shift ON ((extrusioncontext.shift_id = shift.id)))
     LEFT JOIN public.basic_staff staff ON ((extrusioncontext.operator_id = staff.id)));


--
-- Name: goodfood_extrusionprotocoldto_id_seq; Type: SEQUENCE; Schema: public; Owner: -
--

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


--
-- Name: goodfood_extrusionprotocolstatechange; Type: TABLE; Schema: public; Owner: -
--

CREATE TABLE public.goodfood_extrusionprotocolstatechange (
    id bigint NOT NULL,
    dateandtime timestamp without time zone,
    sourcestate character varying(255),
    targetstate character varying(255),
    status character varying(255),
    phase integer,
    shift_id bigint,
    worker character varying(255),
    extrusionprotocol_id bigint,
    entityversion bigint DEFAULT 0
);


--
-- Name: goodfood_extrusionprotocolstatechange_id_seq; Type: SEQUENCE; Schema: public; Owner: -
--

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


--
-- Name: goodfood_extrusionprotocolstatechange_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: -
--

ALTER SEQUENCE public.goodfood_extrusionprotocolstatechange_id_seq OWNED BY public.goodfood_extrusionprotocolstatechange.id;


--
-- Name: goodfood_extrusionsouse; Type: TABLE; Schema: public; Owner: -
--

CREATE TABLE public.goodfood_extrusionsouse (
    id bigint NOT NULL,
    extrusionprotocol_id bigint,
    category character varying(255),
    datesouse timestamp without time zone,
    datedownload timestamp without time zone,
    worker_id bigint,
    wetness numeric(5,2),
    entityversion bigint DEFAULT 0
);


--
-- Name: goodfood_extrusionsouse_id_seq; Type: SEQUENCE; Schema: public; Owner: -
--

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


--
-- Name: goodfood_extrusionsouse_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: -
--

ALTER SEQUENCE public.goodfood_extrusionsouse_id_seq OWNED BY public.goodfood_extrusionsouse.id;


--
-- Name: goodfood_extrusiontakenoffmixentry; Type: TABLE; Schema: public; Owner: -
--

CREATE TABLE public.goodfood_extrusiontakenoffmixentry (
    id bigint NOT NULL,
    extrusionprotocol_id bigint,
    quantity numeric(9,2),
    entityversion bigint DEFAULT 0,
    extrusionmix_id bigint
);


--
-- Name: goodfood_extrusiontakenoffmixentry_id_seq; Type: SEQUENCE; Schema: public; Owner: -
--

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


--
-- Name: goodfood_extrusiontakenoffmixentry_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: -
--

ALTER SEQUENCE public.goodfood_extrusiontakenoffmixentry_id_seq OWNED BY public.goodfood_extrusiontakenoffmixentry.id;


--
-- Name: goodfood_extrusiontakenoffmixingredient; Type: TABLE; Schema: public; Owner: -
--

CREATE TABLE public.goodfood_extrusiontakenoffmixingredient (
    id bigint NOT NULL,
    extrusiontakenoffmixentry_id bigint,
    extrusionmixingredient_id bigint,
    product_id bigint,
    batch_id bigint,
    quantity numeric(9,2),
    beyondrecipe boolean DEFAULT false
);


--
-- Name: goodfood_extrusiontakenoffmixingredient_id_seq; Type: SEQUENCE; Schema: public; Owner: -
--

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


--
-- Name: goodfood_extrusiontakenoffmixingredient_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: -
--

ALTER SEQUENCE public.goodfood_extrusiontakenoffmixingredient_id_seq OWNED BY public.goodfood_extrusiontakenoffmixingredient.id;


--
-- Name: goodfood_extrusionusedbatchingredientdto; Type: VIEW; Schema: public; Owner: -
--

CREATE VIEW public.goodfood_extrusionusedbatchingredientdto AS
SELECT
    NULL::bigint AS id,
    NULL::bigint AS extrusionprotocol_id,
    NULL::character varying(255) AS productnumber,
    NULL::character varying(255) AS unit,
    NULL::character varying(255) AS batchnumber,
    NULL::integer AS priority,
    NULL::numeric AS quantity;


--
-- Name: goodfood_extrusionusedbatchingredientdto_id_seq; Type: SEQUENCE; Schema: public; Owner: -
--

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


--
-- Name: goodfood_goodfoodreport; Type: TABLE; Schema: public; Owner: -
--

CREATE TABLE public.goodfood_goodfoodreport (
    id bigint NOT NULL,
    number character varying(1024),
    name character varying(1024),
    datefrom date,
    dateto date,
    filename character varying(255),
    generated boolean DEFAULT false,
    createdate timestamp without time zone,
    updatedate timestamp without time zone,
    createuser character varying(255),
    updateuser character varying(255),
    entityversion bigint DEFAULT 0
);


--
-- Name: goodfood_goodfoodreport_id_seq; Type: SEQUENCE; Schema: public; Owner: -
--

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


--
-- Name: goodfood_goodfoodreport_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: -
--

ALTER SEQUENCE public.goodfood_goodfoodreport_id_seq OWNED BY public.goodfood_goodfoodreport.id;


--
-- Name: goodfood_labeldto_id_seq; Type: SEQUENCE; Schema: public; Owner: -
--

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


--
-- Name: goodfood_pallet; Type: TABLE; Schema: public; Owner: -
--

CREATE TABLE public.goodfood_pallet (
    id bigint NOT NULL,
    palletcontext_id bigint,
    palletlabel_id bigint,
    typeoflogistics character varying(255) DEFAULT '01fullPallet'::character varying,
    printedcount integer,
    ssccnumber character varying(20),
    palletnumber character varying(6),
    secondpallet_id bigint,
    state character varying(255),
    isstateerror boolean,
    stateerror character varying(255),
    registrationdate timestamp without time zone,
    senddate timestamp without time zone,
    active boolean DEFAULT true,
    packagescount integer,
    laststatechangefails boolean DEFAULT false,
    laststatechangefailcause character varying(2048),
    externalnumber integer NOT NULL,
    externalsynchronized boolean DEFAULT true,
    eurocod character varying(7),
    entityversion bigint DEFAULT 0,
    sendagaintoblackbox boolean DEFAULT false,
    product_id bigint
);


--
-- Name: goodfood_pallet_externalnumber_seq; Type: SEQUENCE; Schema: public; Owner: -
--

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


--
-- Name: goodfood_pallet_id_seq; Type: SEQUENCE; Schema: public; Owner: -
--

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


--
-- Name: goodfood_pallet_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: -
--

ALTER SEQUENCE public.goodfood_pallet_id_seq OWNED BY public.goodfood_pallet.id;


--
-- Name: goodfood_palletcontext; Type: TABLE; Schema: public; Owner: -
--

CREATE TABLE public.goodfood_palletcontext (
    id bigint NOT NULL,
    confirmed boolean DEFAULT false,
    day date,
    shift_id bigint,
    createdate timestamp without time zone,
    updatedate timestamp without time zone,
    createuser character varying(255),
    updateuser character varying(255),
    operator_id bigint,
    entityversion bigint DEFAULT 0
);


--
-- Name: goodfood_palletlabel; Type: TABLE; Schema: public; Owner: -
--

CREATE TABLE public.goodfood_palletlabel (
    id bigint NOT NULL,
    palletcontext_id bigint,
    printedcount integer,
    firstssccnumber character varying(20),
    firstpalletnumber character varying(6),
    lastssccnumber character varying(20),
    lastpalletnumber character varying(6),
    masterorder_id bigint,
    productionline_id bigint,
    batchnumber character varying(255),
    bestbefore character varying(255),
    registrationdate date,
    active boolean DEFAULT true,
    batch_id bigint,
    state character varying(255) DEFAULT '01draft'::character varying,
    entityversion bigint DEFAULT 0
);


--
-- Name: masterorders_masterorder; Type: TABLE; Schema: public; Owner: -
--

CREATE TABLE public.masterorders_masterorder (
    id bigint NOT NULL,
    number character varying(255),
    name character varying(1024),
    description character varying(2048),
    externalnumber character varying(255),
    deadline timestamp without time zone,
    addmasterprefixtonumber boolean,
    masterorderstate character varying(255),
    company_id bigint,
    externalsynchronized boolean DEFAULT true,
    generationdateoneec date,
    cancelsynchronizationreason character varying(255),
    active boolean DEFAULT true,
    pw2prod boolean DEFAULT false,
    batch_id bigint,
    masterorderdefinition_id bigint,
    startdate timestamp without time zone,
    finishdate timestamp without time zone,
    entityversion bigint DEFAULT 0,
    sendagaintoblackbox boolean DEFAULT false,
    dateofreceipt timestamp without time zone,
    address_id bigint,
    externalproductionorderid character varying(255),
    ponumber character varying(255),
    direction character varying(255),
    createdate timestamp without time zone,
    updatedate timestamp without time zone,
    createuser character varying,
    updateuser character varying,
    deliverynotenumber character varying,
    cancelsynchronizationtype character varying,
    companypayer_id bigint,
    productioncode character varying,
    commissionnumber character varying,
    machinetype character varying,
    pipedriveupdate timestamp without time zone,
    state character varying(255) DEFAULT '01new'::character varying,
    asanataskid character varying,
    asanatasknameupdated boolean DEFAULT false,
    asanataskcommentadded boolean DEFAULT false,
    sendagaintoasana boolean DEFAULT false,
    sendagaintoasanatries integer DEFAULT 0,
    asanastatecompleteddate timestamp without time zone,
    colourral character varying(255),
    salesplan_id bigint,
    materialsissued boolean DEFAULT false,
    warehouseorder boolean DEFAULT false,
    synchronize boolean DEFAULT false,
    synchronizationdate timestamp without time zone
);


--
-- Name: masterorders_masterorderproduct; Type: TABLE; Schema: public; Owner: -
--

CREATE TABLE public.masterorders_masterorderproduct (
    id bigint NOT NULL,
    product_id bigint,
    technology_id bigint,
    masterorder_id bigint,
    masterorderquantity numeric(14,5),
    cumulatedorderquantity numeric(14,5),
    producedorderquantity numeric(14,5),
    entityversion bigint DEFAULT 0,
    lefttorelease numeric(14,5),
    comments text,
    masterorderpositionstatus character varying(255),
    quantitytakenfromwarehouse numeric(14,5),
    quantityremainingtoorder numeric(14,5),
    deliverydate timestamp without time zone,
    line character varying(255),
    vendorinfo character varying(255),
    vendorso character varying(255),
    price numeric(14,5),
    priceslistprice numeric(9,2)
);


--
-- Name: qcadoomodel_unitconversionitem; Type: TABLE; Schema: public; Owner: -
--

CREATE TABLE public.qcadoomodel_unitconversionitem (
    id bigint NOT NULL,
    quantityfrom numeric(12,5),
    quantityto numeric(12,5),
    unitfrom character varying(255),
    unitto character varying(255),
    globalunitconversionsaggregate_id bigint,
    product_id bigint,
    entityversion bigint DEFAULT 0
);


--
-- Name: goodfood_palletactivedto; Type: VIEW; Schema: public; Owner: -
--

CREATE VIEW public.goodfood_palletactivedto AS
 WITH orders_orderproduct AS (
         SELECT orders_order.masterorder_id,
            sum(orders_order.plannedquantity) AS orderquantity
           FROM public.orders_order
          WHERE (orders_order.masterorder_id IS NOT NULL)
          GROUP BY orders_order.masterorder_id
        )
 SELECT pallet.id,
    pallet.registrationdate,
    pallet.senddate,
    palletcontext.day AS palletcontextday,
    shift.name AS palletcontextshiftname,
    staff.name AS palletcontextoperatorname,
    staff.surname AS palletcontextoperatorsurname,
    productionline.number AS productionlinenumber,
    masterorder.number AS masterordernumber,
    product.number AS productnumber,
    pallet.ssccnumber,
    pallet.palletnumber,
    secondpallet.palletnumber AS secondpalletnumber,
        CASE
            WHEN (orderproduct.masterorder_id IS NULL) THEN ((row_number() OVER (PARTITION BY masterorder.id ORDER BY pallet.id) || ' z '::text) || (ceiling((masterorderproduct.masterorderquantity / unitconversionitem.quantityfrom)))::integer)
            ELSE ((row_number() OVER (PARTITION BY masterorder.id ORDER BY pallet.id) || ' z '::text) || (ceiling((orderproduct.orderquantity / unitconversionitem.quantityfrom)))::integer)
        END AS numberofpallets,
    pallet.state,
    pallet.laststatechangefails
   FROM (((((((((((public.goodfood_pallet pallet
     LEFT JOIN public.goodfood_pallet secondpallet ON ((secondpallet.id = pallet.secondpallet_id)))
     LEFT JOIN public.goodfood_palletcontext palletcontext ON ((palletcontext.id = pallet.palletcontext_id)))
     LEFT JOIN public.goodfood_palletlabel palletlabel ON ((palletlabel.id = pallet.palletlabel_id)))
     LEFT JOIN public.basic_shift shift ON ((shift.id = palletcontext.shift_id)))
     LEFT JOIN public.basic_staff staff ON ((staff.id = palletcontext.operator_id)))
     LEFT JOIN public.productionlines_productionline productionline ON ((productionline.id = palletlabel.productionline_id)))
     LEFT JOIN public.masterorders_masterorder masterorder ON ((masterorder.id = palletlabel.masterorder_id)))
     LEFT JOIN public.masterorders_masterorderproduct masterorderproduct ON ((masterorderproduct.masterorder_id = masterorder.id)))
     LEFT JOIN orders_orderproduct orderproduct ON ((orderproduct.masterorder_id = masterorder.id)))
     LEFT JOIN public.basic_product product ON ((product.id = masterorderproduct.product_id)))
     LEFT JOIN public.qcadoomodel_unitconversionitem unitconversionitem ON (((unitconversionitem.product_id = product.id) AND ((unitconversionitem.unitfrom)::text = 'szt.'::text) AND ((unitconversionitem.unitto)::text = 'paleta'::text))))
  WHERE (pallet.active = true);


--
-- Name: goodfood_palletactivedto_id_seq; Type: SEQUENCE; Schema: public; Owner: -
--

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


--
-- Name: goodfood_palletcontext_id_seq; Type: SEQUENCE; Schema: public; Owner: -
--

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


--
-- Name: goodfood_palletcontext_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: -
--

ALTER SEQUENCE public.goodfood_palletcontext_id_seq OWNED BY public.goodfood_palletcontext.id;


--
-- Name: goodfood_palletdto; Type: VIEW; Schema: public; Owner: -
--

CREATE VIEW public.goodfood_palletdto AS
 WITH orders_orderproduct AS (
         SELECT orders_order.masterorder_id,
            sum(orders_order.plannedquantity) AS orderquantity
           FROM public.orders_order
          WHERE (orders_order.masterorder_id IS NOT NULL)
          GROUP BY orders_order.masterorder_id
        )
 SELECT pallet.id,
    pallet.registrationdate,
    pallet.senddate,
    palletcontext.day AS palletcontextday,
    shift.name AS palletcontextshiftname,
    staff.name AS palletcontextoperatorname,
    staff.surname AS palletcontextoperatorsurname,
    productionline.number AS productionlinenumber,
    masterorder.number AS masterordernumber,
    product.number AS productnumber,
    pallet.ssccnumber,
    pallet.palletnumber,
    secondpallet.palletnumber AS secondpalletnumber,
        CASE
            WHEN (orderproduct.masterorder_id IS NULL) THEN ((row_number() OVER (PARTITION BY masterorder.id ORDER BY pallet.id) || ' z '::text) || (ceiling((masterorderproduct.masterorderquantity / unitconversionitem.quantityfrom)))::integer)
            ELSE ((row_number() OVER (PARTITION BY masterorder.id ORDER BY pallet.id) || ' z '::text) || (ceiling((orderproduct.orderquantity / unitconversionitem.quantityfrom)))::integer)
        END AS numberofpallets,
    pallet.state,
    pallet.laststatechangefails,
    pallet.active
   FROM (((((((((((public.goodfood_pallet pallet
     LEFT JOIN public.goodfood_pallet secondpallet ON ((secondpallet.id = pallet.secondpallet_id)))
     LEFT JOIN public.goodfood_palletcontext palletcontext ON ((palletcontext.id = pallet.palletcontext_id)))
     LEFT JOIN public.goodfood_palletlabel palletlabel ON ((palletlabel.id = pallet.palletlabel_id)))
     LEFT JOIN public.basic_shift shift ON ((shift.id = palletcontext.shift_id)))
     LEFT JOIN public.basic_staff staff ON ((staff.id = palletcontext.operator_id)))
     LEFT JOIN public.productionlines_productionline productionline ON ((productionline.id = palletlabel.productionline_id)))
     LEFT JOIN public.masterorders_masterorder masterorder ON ((masterorder.id = palletlabel.masterorder_id)))
     LEFT JOIN public.masterorders_masterorderproduct masterorderproduct ON ((masterorderproduct.masterorder_id = masterorder.id)))
     LEFT JOIN orders_orderproduct orderproduct ON ((orderproduct.masterorder_id = masterorder.id)))
     LEFT JOIN public.basic_product product ON ((product.id = masterorderproduct.product_id)))
     LEFT JOIN public.qcadoomodel_unitconversionitem unitconversionitem ON (((unitconversionitem.product_id = product.id) AND ((unitconversionitem.unitfrom)::text = 'szt.'::text) AND ((unitconversionitem.unitto)::text = 'paleta'::text))));


--
-- Name: goodfood_palletdto_id_seq; Type: SEQUENCE; Schema: public; Owner: -
--

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


--
-- Name: goodfood_palletlabel_id_seq; Type: SEQUENCE; Schema: public; Owner: -
--

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


--
-- Name: goodfood_palletlabel_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: -
--

ALTER SEQUENCE public.goodfood_palletlabel_id_seq OWNED BY public.goodfood_palletlabel.id;


--
-- Name: goodfood_palletlabelactivedto; Type: VIEW; Schema: public; Owner: -
--

CREATE VIEW public.goodfood_palletlabelactivedto AS
 SELECT palletlabel.id,
    palletlabel.registrationdate,
    palletcontext.day AS palletcontextday,
    shift.name AS palletcontextshiftname,
    staff.name AS palletcontextoperatorname,
    staff.surname AS palletcontextoperatorsurname,
    productionline.number AS productionlinenumber,
    productionline.isblocked AS productionlineisblocked,
    masterorder.number AS masterordernumber,
    product.number AS productnumber,
    palletlabel.printedcount,
    palletlabel.firstssccnumber,
    palletlabel.lastssccnumber,
    palletlabel.state
   FROM (((((((public.goodfood_palletlabel palletlabel
     LEFT JOIN public.goodfood_palletcontext palletcontext ON ((palletcontext.id = palletlabel.palletcontext_id)))
     LEFT JOIN public.basic_shift shift ON ((shift.id = palletcontext.shift_id)))
     LEFT JOIN public.basic_staff staff ON ((staff.id = palletcontext.operator_id)))
     LEFT JOIN public.productionlines_productionline productionline ON ((productionline.id = palletlabel.productionline_id)))
     LEFT JOIN public.masterorders_masterorder masterorder ON ((masterorder.id = palletlabel.masterorder_id)))
     LEFT JOIN public.masterorders_masterorderproduct masterorderproduct ON ((masterorderproduct.masterorder_id = masterorder.id)))
     LEFT JOIN public.basic_product product ON ((product.id = masterorderproduct.product_id)))
  WHERE (palletlabel.active = true);


--
-- Name: goodfood_palletlabelactivedto_id_seq; Type: SEQUENCE; Schema: public; Owner: -
--

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


--
-- Name: goodfood_palletlabeldto; Type: VIEW; Schema: public; Owner: -
--

CREATE VIEW public.goodfood_palletlabeldto AS
 SELECT palletlabel.id,
    palletlabel.registrationdate,
    palletcontext.day AS palletcontextday,
    shift.name AS palletcontextshiftname,
    staff.name AS palletcontextoperatorname,
    staff.surname AS palletcontextoperatorsurname,
    productionline.number AS productionlinenumber,
    productionline.isblocked AS productionlineisblocked,
    masterorder.number AS masterordernumber,
    product.number AS productnumber,
    palletlabel.printedcount,
    palletlabel.firstssccnumber,
    palletlabel.lastssccnumber,
    palletlabel.state,
    palletlabel.active
   FROM (((((((public.goodfood_palletlabel palletlabel
     LEFT JOIN public.goodfood_palletcontext palletcontext ON ((palletcontext.id = palletlabel.palletcontext_id)))
     LEFT JOIN public.basic_shift shift ON ((shift.id = palletcontext.shift_id)))
     LEFT JOIN public.basic_staff staff ON ((staff.id = palletcontext.operator_id)))
     LEFT JOIN public.productionlines_productionline productionline ON ((productionline.id = palletlabel.productionline_id)))
     LEFT JOIN public.masterorders_masterorder masterorder ON ((masterorder.id = palletlabel.masterorder_id)))
     LEFT JOIN public.masterorders_masterorderproduct masterorderproduct ON ((masterorderproduct.masterorder_id = masterorder.id)))
     LEFT JOIN public.basic_product product ON ((product.id = masterorderproduct.product_id)));


--
-- Name: goodfood_palletlabeldto_id_seq; Type: SEQUENCE; Schema: public; Owner: -
--

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


--
-- Name: goodfood_palletlabelstatechange; Type: TABLE; Schema: public; Owner: -
--

CREATE TABLE public.goodfood_palletlabelstatechange (
    id bigint NOT NULL,
    dateandtime timestamp without time zone,
    sourcestate character varying(255),
    targetstate character varying(255),
    status character varying(255),
    phase integer,
    shift_id bigint,
    worker character varying(255),
    palletlabel_id bigint,
    entityversion bigint DEFAULT 0
);


--
-- Name: goodfood_palletlabelstatechange_id_seq; Type: SEQUENCE; Schema: public; Owner: -
--

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


--
-- Name: goodfood_palletlabelstatechange_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: -
--

ALTER SEQUENCE public.goodfood_palletlabelstatechange_id_seq OWNED BY public.goodfood_palletlabelstatechange.id;


--
-- Name: goodfood_palletstatechange; Type: TABLE; Schema: public; Owner: -
--

CREATE TABLE public.goodfood_palletstatechange (
    id bigint NOT NULL,
    dateandtime timestamp without time zone,
    sourcestate character varying(255),
    targetstate character varying(255),
    status character varying(255),
    phase integer,
    shift_id bigint,
    worker character varying(255),
    pallet_id bigint,
    entityversion bigint DEFAULT 0
);


--
-- Name: goodfood_palletstatechange_id_seq; Type: SEQUENCE; Schema: public; Owner: -
--

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


--
-- Name: goodfood_palletstatechange_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: -
--

ALTER SEQUENCE public.goodfood_palletstatechange_id_seq OWNED BY public.goodfood_palletstatechange.id;


--
-- Name: goodfood_palnumber; Type: TABLE; Schema: public; Owner: -
--

CREATE TABLE public.goodfood_palnumber (
    id bigint NOT NULL,
    number character varying(255),
    masterorder_id bigint,
    ssccnumber character varying(20)
);


--
-- Name: goodfood_palnumber_id_seq; Type: SEQUENCE; Schema: public; Owner: -
--

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


--
-- Name: goodfood_palnumber_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: -
--

ALTER SEQUENCE public.goodfood_palnumber_id_seq OWNED BY public.goodfood_palnumber.id;


--
-- Name: goodfood_printedlabel; Type: TABLE; Schema: public; Owner: -
--

CREATE TABLE public.goodfood_printedlabel (
    id bigint NOT NULL,
    cartonlabel character varying(255),
    masterorder_id bigint,
    ssccnumber character varying(1024),
    palletcontext_id bigint,
    productionline_id bigint,
    createdate timestamp without time zone,
    updatedate timestamp without time zone,
    createuser character varying(255),
    updateuser character varying(255),
    active boolean DEFAULT true
);


--
-- Name: goodfood_printedlabel_id_seq; Type: SEQUENCE; Schema: public; Owner: -
--

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


--
-- Name: goodfood_printedlabel_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: -
--

ALTER SEQUENCE public.goodfood_printedlabel_id_seq OWNED BY public.goodfood_printedlabel.id;


--
-- Name: goodfood_printedlabeldto; Type: VIEW; Schema: public; Owner: -
--

CREATE VIEW public.goodfood_printedlabeldto AS
 SELECT printedlabel.id,
    date(printedlabel.createdate) AS printdate,
    staff.name AS palletcontextoperatorname,
    staff.surname AS palletcontextoperatorsurname,
    productionline.number AS productionlinenumber,
    masterorder.number AS masterordernumber,
    product.number AS productnumber,
    printedlabel.ssccnumber,
    printedlabel.active
   FROM ((((((public.goodfood_printedlabel printedlabel
     JOIN public.goodfood_palletcontext palletcontext ON ((palletcontext.id = printedlabel.palletcontext_id)))
     JOIN public.basic_staff staff ON ((staff.id = palletcontext.operator_id)))
     LEFT JOIN public.productionlines_productionline productionline ON ((productionline.id = printedlabel.productionline_id)))
     JOIN public.masterorders_masterorder masterorder ON ((masterorder.id = printedlabel.masterorder_id)))
     JOIN public.masterorders_masterorderproduct masterorderproduct ON ((masterorderproduct.masterorder_id = masterorder.id)))
     JOIN public.basic_product product ON ((product.id = masterorderproduct.product_id)));


--
-- Name: goodfood_printedlabeldto_id_seq; Type: SEQUENCE; Schema: public; Owner: -
--

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


--
-- Name: goodfood_ssccnumber; Type: TABLE; Schema: public; Owner: -
--

CREATE TABLE public.goodfood_ssccnumber (
    id bigint NOT NULL,
    prefix character varying(10),
    number integer,
    suffix integer,
    entityversion bigint DEFAULT 0
);


--
-- Name: goodfood_ssccnumber_id_seq; Type: SEQUENCE; Schema: public; Owner: -
--

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


--
-- Name: goodfood_ssccnumber_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: -
--

ALTER SEQUENCE public.goodfood_ssccnumber_id_seq OWNED BY public.goodfood_ssccnumber.id;


--
-- Name: hibernate_sequence; Type: SEQUENCE; Schema: public; Owner: -
--

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


--
-- Name: integrationbartender_printer_id_seq; Type: SEQUENCE; Schema: public; Owner: -
--

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


--
-- Name: integrationbartender_printer; Type: TABLE; Schema: public; Owner: -
--

CREATE TABLE public.integrationbartender_printer (
    id bigint DEFAULT nextval('public.integrationbartender_printer_id_seq'::regclass) NOT NULL,
    name character varying(255),
    description character varying(2048),
    printertype character varying(255),
    createdate timestamp without time zone,
    updatedate timestamp without time zone,
    createuser character varying(255),
    updateuser character varying(255),
    active boolean DEFAULT true
);


--
-- Name: integrationbartender_printlabelshelper; Type: TABLE; Schema: public; Owner: -
--

CREATE TABLE public.integrationbartender_printlabelshelper (
    id bigint NOT NULL,
    createdate timestamp without time zone,
    updatedate timestamp without time zone,
    createuser character varying(255),
    updateuser character varying(255),
    quantity integer,
    masterorder_id bigint,
    printer_id bigint,
    path character varying(255),
    ssccnumbers text,
    order_id bigint,
    barcodeismasterorderid boolean DEFAULT false
);


--
-- Name: integrationbartender_sendtoprint; Type: TABLE; Schema: public; Owner: -
--

CREATE TABLE public.integrationbartender_sendtoprint (
    id bigint NOT NULL,
    printlabelshelper_id bigint,
    createdate timestamp without time zone,
    updatedate timestamp without time zone,
    createuser character varying(255),
    updateuser character varying(255)
);


--
-- Name: jointable_order_printlabelshelper; Type: TABLE; Schema: public; Owner: -
--

CREATE TABLE public.jointable_order_printlabelshelper (
    printlabelshelper_id bigint NOT NULL,
    order_id bigint NOT NULL
);


--
-- Name: jointable_palletlabel_printlabelshelper; Type: TABLE; Schema: public; Owner: -
--

CREATE TABLE public.jointable_palletlabel_printlabelshelper (
    printlabelshelper_id bigint NOT NULL,
    palletlabel_id bigint NOT NULL
);


--
-- Name: jointable_printlabelshelper_printedlabel; Type: TABLE; Schema: public; Owner: -
--

CREATE TABLE public.jointable_printlabelshelper_printedlabel (
    printedlabel_id bigint NOT NULL,
    printlabelshelper_id bigint NOT NULL
);


--
-- Name: integrationbartender_printedcartonlabeldto; Type: VIEW; Schema: public; Owner: -
--

CREATE VIEW public.integrationbartender_printedcartonlabeldto AS
 SELECT printlabelshelper.id,
    sendtoprint.createdate,
    sendtoprint.createuser,
    (printlabelshelper.masterorder_id)::integer AS masterorder_id,
    masterorder.number AS masterordernumber,
    printlabelshelper.quantity,
    (printlabelshelper.printer_id)::integer AS printer_id,
    printer.name AS printername
   FROM ((((((public.integrationbartender_sendtoprint sendtoprint
     JOIN public.integrationbartender_printlabelshelper printlabelshelper ON ((printlabelshelper.id = sendtoprint.printlabelshelper_id)))
     JOIN public.masterorders_masterorder masterorder ON ((masterorder.id = printlabelshelper.masterorder_id)))
     JOIN public.integrationbartender_printer printer ON ((printer.id = printlabelshelper.printer_id)))
     LEFT JOIN public.jointable_palletlabel_printlabelshelper palletlabel_printlabelshelper ON ((palletlabel_printlabelshelper.printlabelshelper_id = printlabelshelper.id)))
     LEFT JOIN public.jointable_printlabelshelper_printedlabel printlabelshelper_printedlabel ON ((printlabelshelper_printedlabel.printlabelshelper_id = printlabelshelper.id)))
     LEFT JOIN public.jointable_order_printlabelshelper order_printlabelshelper ON ((order_printlabelshelper.printlabelshelper_id = printlabelshelper.id)))
  WHERE ((palletlabel_printlabelshelper.* IS NULL) AND (printlabelshelper_printedlabel.* IS NULL) AND (order_printlabelshelper.* IS NULL));


--
-- Name: integrationbartender_printedcartonlabeldto_id_seq; Type: SEQUENCE; Schema: public; Owner: -
--

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


--
-- Name: integrationbartender_printedpalletlabeldto; Type: VIEW; Schema: public; Owner: -
--

CREATE VIEW public.integrationbartender_printedpalletlabeldto AS
 SELECT row_number() OVER () AS id,
    sendtoprint.createdate,
    sendtoprint.createuser,
    ssccnumber.ssccnumber,
    (printlabelshelper.id)::integer AS printlabelshelper_id,
    (printlabelshelper.printer_id)::integer AS printer_id,
    printer.name AS printername
   FROM (((public.integrationbartender_sendtoprint sendtoprint
     JOIN public.integrationbartender_printlabelshelper printlabelshelper ON ((printlabelshelper.id = sendtoprint.printlabelshelper_id)))
     JOIN LATERAL unnest(string_to_array(printlabelshelper.ssccnumbers, ', '::text)) ssccnumber(ssccnumber) ON (true))
     JOIN public.integrationbartender_printer printer ON ((printer.id = printlabelshelper.printer_id)))
  WHERE (printlabelshelper.id IN ( SELECT jointable_palletlabel_printlabelshelper.printlabelshelper_id
           FROM public.jointable_palletlabel_printlabelshelper
        UNION
         SELECT jointable_printlabelshelper_printedlabel.printlabelshelper_id
           FROM public.jointable_printlabelshelper_printedlabel));


--
-- Name: integrationbartender_printedpalletlabeldto_id_seq; Type: SEQUENCE; Schema: public; Owner: -
--

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


--
-- Name: integrationbartender_printlabelshelper_id_seq; Type: SEQUENCE; Schema: public; Owner: -
--

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


--
-- Name: integrationbartender_printlabelshelper_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: -
--

ALTER SEQUENCE public.integrationbartender_printlabelshelper_id_seq OWNED BY public.integrationbartender_printlabelshelper.id;


--
-- Name: integrationbartender_sendtoprint_id_seq; Type: SEQUENCE; Schema: public; Owner: -
--

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


--
-- Name: integrationbartender_sendtoprint_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: -
--

ALTER SEQUENCE public.integrationbartender_sendtoprint_id_seq OWNED BY public.integrationbartender_sendtoprint.id;


--
-- Name: integrationbaselinker_baselinkerparameters; Type: TABLE; Schema: public; Owner: -
--

CREATE TABLE public.integrationbaselinker_baselinkerparameters (
    id bigint NOT NULL,
    documenttype character varying(255) DEFAULT '01receipt'::character varying,
    locationfrom_id bigint,
    locationto_id bigint,
    createmasterorders boolean DEFAULT false,
    createdocuments boolean DEFAULT false
);


--
-- Name: integrationbaselinker_baselinkerparameters_id_seq; Type: SEQUENCE; Schema: public; Owner: -
--

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


--
-- Name: integrationbaselinker_baselinkerparameters_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: -
--

ALTER SEQUENCE public.integrationbaselinker_baselinkerparameters_id_seq OWNED BY public.integrationbaselinker_baselinkerparameters.id;


--
-- Name: integrationbaselinker_statusesfordocument; Type: TABLE; Schema: public; Owner: -
--

CREATE TABLE public.integrationbaselinker_statusesfordocument (
    id bigint NOT NULL,
    baselinkerparameters_id bigint,
    statustaken character varying(255),
    statusawarded character varying(255)
);


--
-- Name: integrationbaselinker_statusesfordocument_id_seq; Type: SEQUENCE; Schema: public; Owner: -
--

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


--
-- Name: integrationbaselinker_statusesfordocument_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: -
--

ALTER SEQUENCE public.integrationbaselinker_statusesfordocument_id_seq OWNED BY public.integrationbaselinker_statusesfordocument.id;


--
-- Name: integrationbaselinker_statusesformasterorder; Type: TABLE; Schema: public; Owner: -
--

CREATE TABLE public.integrationbaselinker_statusesformasterorder (
    id bigint NOT NULL,
    baselinkerparameters_id bigint,
    statustaken character varying(255),
    statusawarded character varying(255)
);


--
-- Name: integrationbaselinker_statusesformasterorder_id_seq; Type: SEQUENCE; Schema: public; Owner: -
--

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


--
-- Name: integrationbaselinker_statusesformasterorder_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: -
--

ALTER SEQUENCE public.integrationbaselinker_statusesformasterorder_id_seq OWNED BY public.integrationbaselinker_statusesformasterorder.id;


--
-- Name: integrationscales_productionlineforscale; Type: TABLE; Schema: public; Owner: -
--

CREATE TABLE public.integrationscales_productionlineforscale (
    id bigint NOT NULL,
    productionline_id bigint,
    master boolean DEFAULT false,
    scale_id bigint
);


--
-- Name: integrationscales_productionlineforscale_id_seq; Type: SEQUENCE; Schema: public; Owner: -
--

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


--
-- Name: integrationscales_productionlineforscale_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: -
--

ALTER SEQUENCE public.integrationscales_productionlineforscale_id_seq OWNED BY public.integrationscales_productionlineforscale.id;


--
-- Name: integrationscales_scale; Type: TABLE; Schema: public; Owner: -
--

CREATE TABLE public.integrationscales_scale (
    id bigint NOT NULL,
    name character varying(255),
    comment character varying(255),
    port character varying(255),
    ip character varying(255),
    type character varying(255) DEFAULT '01siemens'::character varying
);


--
-- Name: integrationscales_scale_id_seq; Type: SEQUENCE; Schema: public; Owner: -
--

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


--
-- Name: integrationscales_scale_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: -
--

ALTER SEQUENCE public.integrationscales_scale_id_seq OWNED BY public.integrationscales_scale.id;


--
-- Name: integrationscales_scaledto; Type: VIEW; Schema: public; Owner: -
--

CREATE VIEW public.integrationscales_scaledto AS
SELECT
    NULL::bigint AS id,
    NULL::character varying(255) AS name,
    NULL::character varying(255) AS comment,
    NULL::character varying(255) AS type,
    NULL::text AS ip,
    NULL::text AS productionlines;


--
-- Name: integrationscales_scaledto_id_seq; Type: SEQUENCE; Schema: public; Owner: -
--

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


--
-- Name: jointable_action_subassembly; Type: TABLE; Schema: public; Owner: -
--

CREATE TABLE public.jointable_action_subassembly (
    action_id bigint NOT NULL,
    subassembly_id bigint NOT NULL
);


--
-- Name: jointable_action_workstation; Type: TABLE; Schema: public; Owner: -
--

CREATE TABLE public.jointable_action_workstation (
    action_id bigint NOT NULL,
    workstation_id bigint NOT NULL
);


--
-- Name: jointable_action_workstationtype; Type: TABLE; Schema: public; Owner: -
--

CREATE TABLE public.jointable_action_workstationtype (
    action_id bigint NOT NULL,
    workstationtype_id bigint NOT NULL
);


--
-- Name: jointable_additionaldirectcost_technology; Type: TABLE; Schema: public; Owner: -
--

CREATE TABLE public.jointable_additionaldirectcost_technology (
    additionaldirectcost_id bigint NOT NULL,
    technology_id bigint NOT NULL
);


--
-- Name: jointable_anomaly_anomalyreason; Type: TABLE; Schema: public; Owner: -
--

CREATE TABLE public.jointable_anomaly_anomalyreason (
    anomalyreason_id bigint NOT NULL,
    anomaly_id bigint NOT NULL
);


--
-- Name: jointable_batch_productioncountingquantity; Type: TABLE; Schema: public; Owner: -
--

CREATE TABLE public.jointable_batch_productioncountingquantity (
    productioncountingquantity_id bigint NOT NULL,
    batch_id bigint NOT NULL
);


--
-- Name: jointable_company_negotiation; Type: TABLE; Schema: public; Owner: -
--

CREATE TABLE public.jointable_company_negotiation (
    negotiation_id bigint NOT NULL,
    company_id bigint NOT NULL
);


--
-- Name: jointable_company_subassembly; Type: TABLE; Schema: public; Owner: -
--

CREATE TABLE public.jointable_company_subassembly (
    company_id bigint NOT NULL,
    subassembly_id bigint NOT NULL
);


--
-- Name: jointable_company_workstation; Type: TABLE; Schema: public; Owner: -
--

CREATE TABLE public.jointable_company_workstation (
    company_id bigint NOT NULL,
    workstation_id bigint NOT NULL
);


--
-- Name: jointable_costcalculation_technology; Type: TABLE; Schema: public; Owner: -
--

CREATE TABLE public.jointable_costcalculation_technology (
    costcalculation_id bigint NOT NULL,
    technology_id bigint NOT NULL
);


--
-- Name: jointable_division_productionline; Type: TABLE; Schema: public; Owner: -
--

CREATE TABLE public.jointable_division_productionline (
    productionline_id bigint NOT NULL,
    division_id bigint NOT NULL
);


--
-- Name: jointable_faulttype_subassembly; Type: TABLE; Schema: public; Owner: -
--

CREATE TABLE public.jointable_faulttype_subassembly (
    faulttype_id bigint NOT NULL,
    subassembly_id bigint NOT NULL
);


--
-- Name: jointable_faulttype_workstation; Type: TABLE; Schema: public; Owner: -
--

CREATE TABLE public.jointable_faulttype_workstation (
    workstation_id bigint NOT NULL,
    faulttype_id bigint NOT NULL
);


--
-- Name: jointable_faulttype_workstationtype; Type: TABLE; Schema: public; Owner: -
--

CREATE TABLE public.jointable_faulttype_workstationtype (
    workstationtype_id bigint NOT NULL,
    faulttype_id bigint NOT NULL
);


--
-- Name: jointable_group_role; Type: TABLE; Schema: public; Owner: -
--

CREATE TABLE public.jointable_group_role (
    group_id bigint NOT NULL,
    role_id bigint NOT NULL
);


--
-- Name: jointable_issue_productstoissuehelper; Type: TABLE; Schema: public; Owner: -
--

CREATE TABLE public.jointable_issue_productstoissuehelper (
    productstoissuehelper_id bigint NOT NULL,
    issue_id bigint NOT NULL
);


--
-- Name: jointable_masterorder_masterordersmaterialrequirement; Type: TABLE; Schema: public; Owner: -
--

CREATE TABLE public.jointable_masterorder_masterordersmaterialrequirement (
    masterorder_id bigint NOT NULL,
    masterordersmaterialrequirement_id bigint NOT NULL
);


--
-- Name: jointable_materialrequirement_order; Type: TABLE; Schema: public; Owner: -
--

CREATE TABLE public.jointable_materialrequirement_order (
    materialrequirement_id bigint NOT NULL,
    order_id bigint NOT NULL
);


--
-- Name: jointable_materialrequirementcoverage_order; Type: TABLE; Schema: public; Owner: -
--

CREATE TABLE public.jointable_materialrequirementcoverage_order (
    materialrequirementcoverage_id bigint NOT NULL,
    order_id bigint NOT NULL
);


--
-- Name: jointable_multiassignmenttoshift_staff; Type: TABLE; Schema: public; Owner: -
--

CREATE TABLE public.jointable_multiassignmenttoshift_staff (
    multiassignmenttoshift_id bigint NOT NULL,
    staff_id bigint NOT NULL
);


--
-- Name: jointable_oee_productionline; Type: TABLE; Schema: public; Owner: -
--

CREATE TABLE public.jointable_oee_productionline (
    oee_id bigint NOT NULL,
    productionline_id bigint NOT NULL
);


--
-- Name: jointable_oee_workstation; Type: TABLE; Schema: public; Owner: -
--

CREATE TABLE public.jointable_oee_workstation (
    oee_id bigint NOT NULL,
    workstation_id bigint NOT NULL
);


--
-- Name: jointable_operation_workstation; Type: TABLE; Schema: public; Owner: -
--

CREATE TABLE public.jointable_operation_workstation (
    workstation_id bigint NOT NULL,
    operation_id bigint NOT NULL
);


--
-- Name: jointable_operationaltask_staff; Type: TABLE; Schema: public; Owner: -
--

CREATE TABLE public.jointable_operationaltask_staff (
    staff_id bigint NOT NULL,
    operationaltask_id bigint NOT NULL
);


--
-- Name: jointable_order_orderstoolrequirement; Type: TABLE; Schema: public; Owner: -
--

CREATE TABLE public.jointable_order_orderstoolrequirement (
    order_id bigint NOT NULL,
    orderstoolrequirement_id bigint NOT NULL
);


--
-- Name: jointable_order_productionbalance; Type: TABLE; Schema: public; Owner: -
--

CREATE TABLE public.jointable_order_productionbalance (
    productionbalance_id bigint NOT NULL,
    order_id bigint NOT NULL
);


--
-- Name: jointable_order_productionlineschedule; Type: TABLE; Schema: public; Owner: -
--

CREATE TABLE public.jointable_order_productionlineschedule (
    order_id bigint NOT NULL,
    productionlineschedule_id bigint NOT NULL
);


--
-- Name: jointable_order_schedule; Type: TABLE; Schema: public; Owner: -
--

CREATE TABLE public.jointable_order_schedule (
    order_id bigint NOT NULL,
    schedule_id bigint NOT NULL
);


--
-- Name: jointable_order_staff; Type: TABLE; Schema: public; Owner: -
--

CREATE TABLE public.jointable_order_staff (
    order_id bigint NOT NULL,
    staff_id bigint NOT NULL
);


--
-- Name: jointable_order_workplan; Type: TABLE; Schema: public; Owner: -
--

CREATE TABLE public.jointable_order_workplan (
    workplan_id bigint NOT NULL,
    order_id bigint NOT NULL
);


--
-- Name: jointable_palletnumber_palletnumberhelper; Type: TABLE; Schema: public; Owner: -
--

CREATE TABLE public.jointable_palletnumber_palletnumberhelper (
    palletnumberhelper_id bigint NOT NULL,
    palletnumber_id bigint NOT NULL
);


--
-- Name: jointable_parameter_productionline; Type: TABLE; Schema: public; Owner: -
--

CREATE TABLE public.jointable_parameter_productionline (
    parameter_id bigint NOT NULL,
    productionline_id bigint NOT NULL
);


--
-- Name: jointable_plannedevent_plannedevent; Type: TABLE; Schema: public; Owner: -
--

CREATE TABLE public.jointable_plannedevent_plannedevent (
    plannedevent_id bigint NOT NULL,
    relatedevent_id bigint NOT NULL
);


--
-- Name: jointable_plannedevent_staff; Type: TABLE; Schema: public; Owner: -
--

CREATE TABLE public.jointable_plannedevent_staff (
    plannedevent_id bigint NOT NULL,
    staff_id bigint NOT NULL
);


--
-- Name: jointable_product_qualitycard; Type: TABLE; Schema: public; Owner: -
--

CREATE TABLE public.jointable_product_qualitycard (
    product_id bigint NOT NULL,
    qualitycard_id bigint NOT NULL
);


--
-- Name: jointable_product_salesvolumemulti; Type: TABLE; Schema: public; Owner: -
--

CREATE TABLE public.jointable_product_salesvolumemulti (
    product_id bigint NOT NULL,
    salesvolumemulti_id bigint NOT NULL
);


--
-- Name: jointable_product_scale; Type: TABLE; Schema: public; Owner: -
--

CREATE TABLE public.jointable_product_scale (
    product_id bigint NOT NULL,
    scale_id bigint NOT NULL
);


--
-- Name: jointable_product_storagelocation; Type: TABLE; Schema: public; Owner: -
--

CREATE TABLE public.jointable_product_storagelocation (
    product_id bigint NOT NULL,
    storagelocation_id bigint NOT NULL
);


--
-- Name: jointable_product_warehouseminimumstatemulti; Type: TABLE; Schema: public; Owner: -
--

CREATE TABLE public.jointable_product_warehouseminimumstatemulti (
    product_id bigint NOT NULL,
    warehouseminimumstatemulti_id bigint NOT NULL
);


--
-- Name: jointable_productionline_scale; Type: TABLE; Schema: public; Owner: -
--

CREATE TABLE public.jointable_productionline_scale (
    productionline_id bigint NOT NULL,
    scale_id bigint NOT NULL
);


--
-- Name: jointable_productionline_shift; Type: TABLE; Schema: public; Owner: -
--

CREATE TABLE public.jointable_productionline_shift (
    productionline_id bigint NOT NULL,
    shift_id bigint NOT NULL
);


--
-- Name: jointable_productionline_technology; Type: TABLE; Schema: public; Owner: -
--

CREATE TABLE public.jointable_productionline_technology (
    technology_id bigint NOT NULL,
    productionline_id bigint NOT NULL
);


--
-- Name: jointable_productionline_technologygroup; Type: TABLE; Schema: public; Owner: -
--

CREATE TABLE public.jointable_productionline_technologygroup (
    technologygroup_id bigint NOT NULL,
    productionline_id bigint NOT NULL
);


--
-- Name: jointable_size_sizegroup; Type: TABLE; Schema: public; Owner: -
--

CREATE TABLE public.jointable_size_sizegroup (
    size_id bigint NOT NULL,
    sizegroup_id bigint NOT NULL
);


--
-- Name: jointable_staff_timeusagereportfilter; Type: TABLE; Schema: public; Owner: -
--

CREATE TABLE public.jointable_staff_timeusagereportfilter (
    staff_id bigint NOT NULL,
    timeusagereportfilter_id bigint NOT NULL
);


--
-- Name: jointable_stocktaking_storagelocation; Type: TABLE; Schema: public; Owner: -
--

CREATE TABLE public.jointable_stocktaking_storagelocation (
    stocktaking_id bigint NOT NULL,
    storagelocation_id bigint NOT NULL
);


--
-- Name: jointable_storagelocation_storagelocationnumberhelper; Type: TABLE; Schema: public; Owner: -
--

CREATE TABLE public.jointable_storagelocation_storagelocationnumberhelper (
    storagelocation_id bigint NOT NULL,
    storagelocationnumberhelper_id bigint NOT NULL
);


--
-- Name: jointable_storagelocation_warehousestockreport; Type: TABLE; Schema: public; Owner: -
--

CREATE TABLE public.jointable_storagelocation_warehousestockreport (
    storagelocation_id bigint NOT NULL,
    warehousestockreport_id bigint NOT NULL
);


--
-- Name: jointable_technologyoperationcomponent_workstation; Type: TABLE; Schema: public; Owner: -
--

CREATE TABLE public.jointable_technologyoperationcomponent_workstation (
    technologyoperationcomponent_id bigint NOT NULL,
    workstation_id bigint NOT NULL
);


--
-- Name: linechangeovernorms_groupsview_id_seq; Type: SEQUENCE; Schema: public; Owner: -
--

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


--
-- Name: linechangeovernorms_linechangeovernorms; Type: TABLE; Schema: public; Owner: -
--

CREATE TABLE public.linechangeovernorms_linechangeovernorms (
    id bigint NOT NULL,
    number character varying(255),
    changeovertype character varying(255) DEFAULT '01fromTechForSpecificLine'::character varying,
    fromtechnology_id bigint,
    totechnology_id bigint,
    fromtechnologygroup_id bigint,
    totechnologygroup_id bigint,
    productionline_id bigint,
    duration integer,
    name character varying(1024),
    entityversion bigint DEFAULT 0
);


--
-- Name: linechangeovernorms_linechangeovernorms_id_seq; Type: SEQUENCE; Schema: public; Owner: -
--

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


--
-- Name: linechangeovernorms_linechangeovernorms_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: -
--

ALTER SEQUENCE public.linechangeovernorms_linechangeovernorms_id_seq OWNED BY public.linechangeovernorms_linechangeovernorms.id;


--
-- Name: linechangeovernorms_linechangeovernormsdto; Type: VIEW; Schema: public; Owner: -
--

CREATE VIEW public.linechangeovernorms_linechangeovernormsdto AS
 SELECT linechangeovernorms.number,
    linechangeovernorms.name,
    linechangeovernorms.duration,
    linechangeovernorms.changeovertype,
    linechangeovernorms.productionline_id,
    linechangeovernorms.fromtechnology_id AS technologyfrom_id,
    linechangeovernorms.totechnology_id AS technologyto_id,
    technologyfrom.number AS technologyfromnumber,
    technologyto.number AS technologytonumber
   FROM ((public.linechangeovernorms_linechangeovernorms linechangeovernorms
     JOIN public.technologies_technology technologyfrom ON ((technologyfrom.id = linechangeovernorms.fromtechnology_id)))
     JOIN public.technologies_technology technologyto ON ((technologyto.id = linechangeovernorms.totechnology_id)))
  WHERE ((linechangeovernorms.changeovertype)::text = '01forTechnology'::text)
UNION ALL
 SELECT linechangeovernorms.number,
    linechangeovernorms.name,
    linechangeovernorms.duration,
    linechangeovernorms.changeovertype,
    linechangeovernorms.productionline_id,
    technologyfrom.id AS technologyfrom_id,
    technologyto.id AS technologyto_id,
    technologyfrom.number AS technologyfromnumber,
    technologyto.number AS technologytonumber
   FROM ((((public.linechangeovernorms_linechangeovernorms linechangeovernorms
     JOIN public.technologies_technologygroup technologygroupfrom ON ((technologygroupfrom.id = linechangeovernorms.fromtechnologygroup_id)))
     JOIN public.technologies_technology technologyfrom ON (((technologyfrom.technologygroup_id = technologygroupfrom.id) AND (technologyfrom.active = true))))
     JOIN public.technologies_technologygroup technologygroupto ON ((technologygroupto.id = linechangeovernorms.totechnologygroup_id)))
     JOIN public.technologies_technology technologyto ON (((technologyto.technologygroup_id = technologygroupto.id) AND (technologyto.active = true))))
  WHERE ((linechangeovernorms.changeovertype)::text = '02forTechnologyGroup'::text);


--
-- Name: linechangeovernorms_normflatview_id_seq; Type: SEQUENCE; Schema: public; Owner: -
--

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


--
-- Name: linechangeovernorms_ordersnormview; Type: VIEW; Schema: public; Owner: -
--

CREATE VIEW public.linechangeovernorms_ordersnormview AS
 SELECT (((ordersorder.id)::text || ', '::text) || (linechangeovernormsdto.number)::text) AS id,
    ordersorder.id AS orderid,
    ordersorder.number,
    linechangeovernormsdto.number AS normnumber,
    linechangeovernormsdto.name AS normname,
    linechangeovernormsdto.duration,
    linechangeovernormsdto.technologyfromnumber,
    linechangeovernormsdto.technologytonumber
   FROM (public.orders_order ordersorder
     JOIN public.linechangeovernorms_linechangeovernormsdto linechangeovernormsdto ON (((linechangeovernormsdto.technologyto_id = ordersorder.technology_id) AND (linechangeovernormsdto.technologyfrom_id = ( SELECT previousorder.technology_id
           FROM public.orders_order previousorder
          WHERE ((previousorder.active = true) AND (previousorder.productionline_id = ordersorder.productionline_id) AND (previousorder.finishdate < ordersorder.finishdate) AND ((previousorder.state)::text <> ALL (ARRAY[('05declined'::character varying)::text, ('07abandoned'::character varying)::text])))
          ORDER BY previousorder.finishdate DESC
         LIMIT 1)))))
  WHERE ((ordersorder.active = true) AND (ordersorder.finishdate > (now() - '1 mon'::interval)) AND (((linechangeovernormsdto.productionline_id IS NOT NULL) AND (linechangeovernormsdto.productionline_id = ordersorder.productionline_id)) OR (linechangeovernormsdto.productionline_id IS NULL)))
  ORDER BY linechangeovernormsdto.changeovertype, linechangeovernormsdto.productionline_id;


--
-- Name: linechangeovernorms_ordersnormview_id_seq; Type: SEQUENCE; Schema: public; Owner: -
--

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


--
-- Name: linechangeovernormsfororders_linechangeoverfororderdtohelper; Type: VIEW; Schema: public; Owner: -
--

CREATE VIEW public.linechangeovernormsfororders_linechangeoverfororderdtohelper AS
 SELECT ordersorder.id,
    ordersorder.active,
    ordersorder.number AS ordernumber,
    ordersorder.startdate AS orderstartdate,
    ordersorder.finishdate AS orderfinishdate,
    productionline.number AS productionlinenumber,
    linechangeovernormsdto.number AS linechangeovernormsnumber,
    linechangeovernormsdto.name AS linechangeovernormsname,
    COALESCE(ordersorder.ownlinechangeoverduration, linechangeovernormsdto.duration) AS linechangeoverduration
   FROM ((public.orders_order ordersorder
     LEFT JOIN public.productionlines_productionline productionline ON ((productionline.id = ordersorder.productionline_id)))
     JOIN public.linechangeovernorms_linechangeovernormsdto linechangeovernormsdto ON (((linechangeovernormsdto.technologyto_id = ordersorder.technology_id) AND (linechangeovernormsdto.technologyfrom_id = ( SELECT previousorder.technology_id
           FROM public.orders_order previousorder
          WHERE ((previousorder.productionline_id = ordersorder.productionline_id) AND (previousorder.finishdate < ordersorder.startdate) AND ((previousorder.state)::text <> ALL (ARRAY[('05declined'::character varying)::text, ('07abandoned'::character varying)::text])))
          ORDER BY previousorder.finishdate DESC
         LIMIT 1)) AND (((linechangeovernormsdto.productionline_id IS NOT NULL) AND (linechangeovernormsdto.productionline_id = ordersorder.productionline_id)) OR (linechangeovernormsdto.productionline_id IS NULL)))))
  WHERE ((ordersorder.state)::text <> ALL (ARRAY[('05declined'::character varying)::text, ('07abandoned'::character varying)::text]))
  ORDER BY linechangeovernormsdto.changeovertype, linechangeovernormsdto.productionline_id;


--
-- Name: linechangeovernormsfororders_linechangeoverfororderdto; Type: VIEW; Schema: public; Owner: -
--

CREATE VIEW public.linechangeovernormsfororders_linechangeoverfororderdto AS
 SELECT ordersorder.id,
    ordersorder.active,
    ordersorder.number AS ordernumber,
    linechangeoverfororderdto.orderstartdate,
    linechangeoverfororderdto.orderfinishdate,
    linechangeoverfororderdto.productionlinenumber,
    linechangeoverfororderdto.linechangeovernormsnumber,
    linechangeoverfororderdto.linechangeovernormsname,
    linechangeoverfororderdto.linechangeoverduration
   FROM (public.orders_order ordersorder
     JOIN LATERAL ( SELECT linechangeovernormsfororders_linechangeoverfororderdtohelper.id,
            linechangeovernormsfororders_linechangeoverfororderdtohelper.active,
            linechangeovernormsfororders_linechangeoverfororderdtohelper.ordernumber,
            linechangeovernormsfororders_linechangeoverfororderdtohelper.orderstartdate,
            linechangeovernormsfororders_linechangeoverfororderdtohelper.orderfinishdate,
            linechangeovernormsfororders_linechangeoverfororderdtohelper.productionlinenumber,
            linechangeovernormsfororders_linechangeoverfororderdtohelper.linechangeovernormsnumber,
            linechangeovernormsfororders_linechangeoverfororderdtohelper.linechangeovernormsname,
            linechangeovernormsfororders_linechangeoverfororderdtohelper.linechangeoverduration
           FROM public.linechangeovernormsfororders_linechangeoverfororderdtohelper
          WHERE (linechangeovernormsfororders_linechangeoverfororderdtohelper.id = ordersorder.id)
         LIMIT 1) linechangeoverfororderdto ON ((1 = 1)))
  WHERE ((ordersorder.state)::text <> ALL (ARRAY[('05declined'::character varying)::text, ('07abandoned'::character varying)::text]));


--
-- Name: linechangeovernormsfororders_linechangeoverfororderdto_id_seq; Type: SEQUENCE; Schema: public; Owner: -
--

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


--
-- Name: linechangeovernormsfororders_linechangeoverfororderdtohelper_id; Type: SEQUENCE; Schema: public; Owner: -
--

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


--
-- Name: masterorders_generatingordershelper; Type: TABLE; Schema: public; Owner: -
--

CREATE TABLE public.masterorders_generatingordershelper (
    id bigint NOT NULL,
    selectedentities character varying(4096),
    startdate timestamp without time zone,
    finishdate timestamp without time zone
);


--
-- Name: masterorders_generatingordershelper_id_seq; Type: SEQUENCE; Schema: public; Owner: -
--

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


--
-- Name: masterorders_generatingordershelper_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: -
--

ALTER SEQUENCE public.masterorders_generatingordershelper_id_seq OWNED BY public.masterorders_generatingordershelper.id;


--
-- Name: masterorders_masterorder_id_seq; Type: SEQUENCE; Schema: public; Owner: -
--

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


--
-- Name: masterorders_masterorder_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: -
--

ALTER SEQUENCE public.masterorders_masterorder_id_seq OWNED BY public.masterorders_masterorder.id;


--
-- Name: masterorders_masterorderdefinition_id_seq; Type: SEQUENCE; Schema: public; Owner: -
--

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


--
-- Name: masterorders_masterorderdefinition_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: -
--

ALTER SEQUENCE public.masterorders_masterorderdefinition_id_seq OWNED BY public.masterorders_masterorderdefinition.id;


--
-- Name: masterorders_masterorderposition_manyproducts; Type: VIEW; Schema: public; Owner: -
--

CREATE VIEW public.masterorders_masterorderposition_manyproducts AS
SELECT
    NULL::bigint AS id,
    NULL::character varying(255) AS masterorderdefinitionnumber,
    NULL::integer AS masterorderid,
    NULL::integer AS productid,
    NULL::integer AS masterorderproductid,
    NULL::character varying(1024) AS name,
    NULL::character varying(255) AS number,
    NULL::timestamp without time zone AS deadline,
    NULL::character varying(255) AS masterorderstatus,
    NULL::character varying(255) AS masterorderpositionstatus,
    NULL::numeric AS masterorderquantity,
    NULL::numeric AS cumulatedmasterorderquantity,
    NULL::numeric AS producedorderquantity,
    NULL::numeric AS lefttorelease,
    NULL::text AS comments,
    NULL::character varying(255) AS productnumber,
    NULL::character varying(1024) AS productname,
    NULL::character varying(255) AS unit,
    NULL::character varying(255) AS technologyname,
    NULL::character varying(255) AS companyname,
    NULL::boolean AS active,
    NULL::character varying(255) AS companypayer,
    NULL::character varying(255) AS assortmentname,
    NULL::character varying(255) AS state,
    NULL::character varying(2048) AS description,
    NULL::numeric(14,5) AS quantitytakenfromwarehouse,
    NULL::numeric(14,5) AS quantityremainingtoorder,
    NULL::numeric(14,5) AS quantityremainingtoorderwithoutstock,
    NULL::character varying(1024) AS modelname,
    NULL::character varying(255) AS companycategory,
    NULL::character varying(255) AS salesplannumber,
    NULL::character varying(255) AS salesplanname,
    NULL::numeric AS warehouseminimumstatequantity,
    NULL::boolean AS warehouseorder,
    NULL::numeric AS warehousestate,
    NULL::numeric AS deliveredquantity,
    NULL::numeric AS producequantity,
    NULL::numeric(14,5) AS price;


--
-- Name: masterorders_masterorderpositiondto; Type: VIEW; Schema: public; Owner: -
--

CREATE VIEW public.masterorders_masterorderpositiondto AS
 SELECT masterorders_masterorderposition_manyproducts.id,
    masterorders_masterorderposition_manyproducts.masterorderdefinitionnumber,
    masterorders_masterorderposition_manyproducts.masterorderid,
    masterorders_masterorderposition_manyproducts.productid,
    masterorders_masterorderposition_manyproducts.masterorderproductid,
    masterorders_masterorderposition_manyproducts.name,
    masterorders_masterorderposition_manyproducts.number,
    masterorders_masterorderposition_manyproducts.deadline,
    masterorders_masterorderposition_manyproducts.masterorderstatus,
    masterorders_masterorderposition_manyproducts.masterorderpositionstatus,
    masterorders_masterorderposition_manyproducts.masterorderquantity,
    masterorders_masterorderposition_manyproducts.cumulatedmasterorderquantity,
    masterorders_masterorderposition_manyproducts.producedorderquantity,
    masterorders_masterorderposition_manyproducts.lefttorelease,
    masterorders_masterorderposition_manyproducts.comments,
    masterorders_masterorderposition_manyproducts.productnumber,
    masterorders_masterorderposition_manyproducts.productname,
    masterorders_masterorderposition_manyproducts.unit,
    masterorders_masterorderposition_manyproducts.technologyname,
    masterorders_masterorderposition_manyproducts.companyname,
    masterorders_masterorderposition_manyproducts.active,
    masterorders_masterorderposition_manyproducts.companypayer,
    masterorders_masterorderposition_manyproducts.assortmentname,
    masterorders_masterorderposition_manyproducts.state,
    masterorders_masterorderposition_manyproducts.description,
    masterorders_masterorderposition_manyproducts.quantitytakenfromwarehouse,
    masterorders_masterorderposition_manyproducts.quantityremainingtoorder,
    masterorders_masterorderposition_manyproducts.quantityremainingtoorderwithoutstock,
    masterorders_masterorderposition_manyproducts.modelname,
    masterorders_masterorderposition_manyproducts.companycategory,
    masterorders_masterorderposition_manyproducts.salesplannumber,
    masterorders_masterorderposition_manyproducts.salesplanname,
    COALESCE(masterorders_masterorderposition_manyproducts.warehouseminimumstatequantity, (0)::numeric) AS warehouseminimumstatequantity,
    masterorders_masterorderposition_manyproducts.warehouseorder,
    masterorders_masterorderposition_manyproducts.warehousestate,
    masterorders_masterorderposition_manyproducts.deliveredquantity,
    masterorders_masterorderposition_manyproducts.producequantity,
    masterorders_masterorderposition_manyproducts.price
   FROM public.masterorders_masterorderposition_manyproducts;


--
-- Name: masterorders_salesplan; Type: TABLE; Schema: public; Owner: -
--

CREATE TABLE public.masterorders_salesplan (
    id bigint NOT NULL,
    number character varying(255),
    name character varying(255),
    description character varying(2048),
    state character varying(255),
    datefrom date,
    dateto date
);


--
-- Name: masterorders_masterorderdto; Type: VIEW; Schema: public; Owner: -
--

CREATE VIEW public.masterorders_masterorderdto AS
 SELECT masterorder.id,
    masterorderdefinition.number AS masterorderdefinitionnumber,
    masterorder.number,
    masterorder.name,
    masterorder.deadline,
    company.number AS company,
    companypayer.number AS companypayer,
    COALESCE((orderedpositions.count)::integer, 0) AS orderedpositionquantity,
    COALESCE((cumulatedpositions.count)::integer, 0) AS commissionedpositionquantity,
    (COALESCE((orderedpositions.count)::integer, 0) - COALESCE((cumulatedpositions.count)::integer, 0)) AS quantityforcommission,
    masterorder.masterorderstate,
    masterorder.active,
    masterorder.pipedriveupdate,
    masterorder.state,
    masterorder.externalnumber,
    masterorder.externalsynchronized,
    masterorder.asanataskid,
    masterorder.description,
    salesplan.number AS salesplannumber,
    salesplan.name AS salesplanname,
    company.contractorcategory AS companycategory,
    masterorder.warehouseorder
   FROM ((((((public.masterorders_masterorder masterorder
     LEFT JOIN public.masterorders_salesplan salesplan ON ((salesplan.id = masterorder.salesplan_id)))
     LEFT JOIN public.masterorders_masterorderdefinition masterorderdefinition ON ((masterorderdefinition.id = masterorder.masterorderdefinition_id)))
     LEFT JOIN public.basic_company company ON ((company.id = masterorder.company_id)))
     LEFT JOIN public.basic_company companypayer ON ((companypayer.id = masterorder.companypayer_id)))
     LEFT JOIN ( SELECT masterorders_masterorderpositiondto.masterorderid,
            count(*) AS count
           FROM public.masterorders_masterorderpositiondto
          GROUP BY masterorders_masterorderpositiondto.masterorderid) orderedpositions ON ((orderedpositions.masterorderid = masterorder.id)))
     LEFT JOIN ( SELECT masterorders_masterorderpositiondto.masterorderid,
            count(*) AS count
           FROM public.masterorders_masterorderpositiondto
          WHERE (masterorders_masterorderpositiondto.cumulatedmasterorderquantity > (0)::numeric)
          GROUP BY masterorders_masterorderpositiondto.masterorderid) cumulatedpositions ON ((cumulatedpositions.masterorderid = masterorder.id)));


--
-- Name: masterorders_masterorderdto_id_seq; Type: SEQUENCE; Schema: public; Owner: -
--

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


--
-- Name: masterorders_masterorderposition_manyproducts_id_seq; Type: SEQUENCE; Schema: public; Owner: -
--

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


--
-- Name: masterorders_masterorderposition_oneproduct_id_seq; Type: SEQUENCE; Schema: public; Owner: -
--

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


--
-- Name: masterorders_masterorderpositiondto_id_seq; Type: SEQUENCE; Schema: public; Owner: -
--

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


--
-- Name: masterorders_masterorderproduct_id_seq; Type: SEQUENCE; Schema: public; Owner: -
--

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


--
-- Name: masterorders_masterorderproduct_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: -
--

ALTER SEQUENCE public.masterorders_masterorderproduct_id_seq OWNED BY public.masterorders_masterorderproduct.id;


--
-- Name: masterorders_masterorderproductattrvalue; Type: TABLE; Schema: public; Owner: -
--

CREATE TABLE public.masterorders_masterorderproductattrvalue (
    id bigint NOT NULL,
    masterorderproduct_id bigint,
    attribute_id bigint,
    attributevalue_id bigint,
    value character varying(255),
    succession integer
);


--
-- Name: masterorders_masterorderproductattrvalue_id_seq; Type: SEQUENCE; Schema: public; Owner: -
--

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


--
-- Name: masterorders_masterorderproductattrvalue_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: -
--

ALTER SEQUENCE public.masterorders_masterorderproductattrvalue_id_seq OWNED BY public.masterorders_masterorderproductattrvalue.id;


--
-- Name: masterorders_masterordersmaterialrequirement; Type: TABLE; Schema: public; Owner: -
--

CREATE TABLE public.masterorders_masterordersmaterialrequirement (
    id bigint NOT NULL,
    number character varying(256),
    name character varying(1024),
    generated boolean,
    worker character varying(255),
    date timestamp without time zone,
    includecomponents boolean DEFAULT false
);


--
-- Name: masterorders_masterordersmaterialrequirement_id_seq; Type: SEQUENCE; Schema: public; Owner: -
--

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


--
-- Name: masterorders_masterordersmaterialrequirement_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: -
--

ALTER SEQUENCE public.masterorders_masterordersmaterialrequirement_id_seq OWNED BY public.masterorders_masterordersmaterialrequirement.id;


--
-- Name: masterorders_masterordersmaterialrequirement_number_seq; Type: SEQUENCE; Schema: public; Owner: -
--

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


--
-- Name: masterorders_masterordersmaterialrequirementproduct; Type: TABLE; Schema: public; Owner: -
--

CREATE TABLE public.masterorders_masterordersmaterialrequirementproduct (
    id bigint NOT NULL,
    masterordersmaterialrequirement_id bigint,
    product_id bigint,
    technologyinputproducttype_id bigint,
    quantity numeric(14,5),
    currentstock numeric(14,5),
    neededquantity numeric(14,5),
    supplier_id bigint
);


--
-- Name: masterorders_masterordersmaterialrequirementproduct_id_seq; Type: SEQUENCE; Schema: public; Owner: -
--

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


--
-- Name: masterorders_masterordersmaterialrequirementproduct_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: -
--

ALTER SEQUENCE public.masterorders_masterordersmaterialrequirementproduct_id_seq OWNED BY public.masterorders_masterordersmaterialrequirementproduct.id;


--
-- Name: masterorders_orderedproductconfigurator; Type: TABLE; Schema: public; Owner: -
--

CREATE TABLE public.masterorders_orderedproductconfigurator (
    id bigint NOT NULL,
    number character varying(255),
    name character varying(1024)
);


--
-- Name: masterorders_orderedproductconfigurator_id_seq; Type: SEQUENCE; Schema: public; Owner: -
--

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


--
-- Name: masterorders_orderedproductconfigurator_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: -
--

ALTER SEQUENCE public.masterorders_orderedproductconfigurator_id_seq OWNED BY public.masterorders_orderedproductconfigurator.id;


--
-- Name: masterorders_orderedproductconfiguratorattribute; Type: TABLE; Schema: public; Owner: -
--

CREATE TABLE public.masterorders_orderedproductconfiguratorattribute (
    id bigint NOT NULL,
    orderedproductconfigurator_id bigint,
    attribute_id bigint,
    succession integer
);


--
-- Name: masterorders_orderedproductconfiguratorattribute_id_seq; Type: SEQUENCE; Schema: public; Owner: -
--

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


--
-- Name: masterorders_orderedproductconfiguratorattribute_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: -
--

ALTER SEQUENCE public.masterorders_orderedproductconfiguratorattribute_id_seq OWNED BY public.masterorders_orderedproductconfiguratorattribute.id;


--
-- Name: masterorders_ordersgenerationhelper; Type: TABLE; Schema: public; Owner: -
--

CREATE TABLE public.masterorders_ordersgenerationhelper (
    id bigint NOT NULL,
    plannedquantity numeric(12,5),
    datefrom timestamp without time zone,
    dateto timestamp without time zone
);


--
-- Name: masterorders_ordersgenerationhelper_id_seq; Type: SEQUENCE; Schema: public; Owner: -
--

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


--
-- Name: masterorders_ordersgenerationhelper_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: -
--

ALTER SEQUENCE public.masterorders_ordersgenerationhelper_id_seq OWNED BY public.masterorders_ordersgenerationhelper.id;


--
-- Name: masterorders_outsourceprocessingcomponenthelper; Type: TABLE; Schema: public; Owner: -
--

CREATE TABLE public.masterorders_outsourceprocessingcomponenthelper (
    id bigint NOT NULL,
    quantity numeric(12,5),
    datefrom timestamp without time zone,
    dateto timestamp without time zone
);


--
-- Name: masterorders_outsourceprocessingcomponenthelper_id_seq; Type: SEQUENCE; Schema: public; Owner: -
--

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


--
-- Name: masterorders_outsourceprocessingcomponenthelper_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: -
--

ALTER SEQUENCE public.masterorders_outsourceprocessingcomponenthelper_id_seq OWNED BY public.masterorders_outsourceprocessingcomponenthelper.id;


--
-- Name: masterorders_position_deliveryproductquantityhelper; Type: TABLE; Schema: public; Owner: -
--

CREATE TABLE public.masterorders_position_deliveryproductquantityhelper (
    id bigint NOT NULL,
    product_id bigint,
    quantity numeric(11,5)
);


--
-- Name: masterorders_position_deliveryproductquantityhelper_id_seq; Type: SEQUENCE; Schema: public; Owner: -
--

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


--
-- Name: masterorders_position_deliveryproductquantityhelper_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: -
--

ALTER SEQUENCE public.masterorders_position_deliveryproductquantityhelper_id_seq OWNED BY public.masterorders_position_deliveryproductquantityhelper.id;


--
-- Name: masterorders_position_warehousestatehelper; Type: TABLE; Schema: public; Owner: -
--

CREATE TABLE public.masterorders_position_warehousestatehelper (
    id bigint NOT NULL,
    product_id bigint,
    location_id bigint,
    quantity numeric(12,5)
);


--
-- Name: masterorders_position_warehousestatehelper_id_seq; Type: SEQUENCE; Schema: public; Owner: -
--

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


--
-- Name: masterorders_position_warehousestatehelper_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: -
--

ALTER SEQUENCE public.masterorders_position_warehousestatehelper_id_seq OWNED BY public.masterorders_position_warehousestatehelper.id;


--
-- Name: masterorders_priceslist; Type: TABLE; Schema: public; Owner: -
--

CREATE TABLE public.masterorders_priceslist (
    id bigint NOT NULL,
    product_id bigint,
    productcategory character varying(255),
    attribute1value_id bigint,
    value1 character varying(255),
    attribute2value_id bigint,
    value2 character varying(255),
    price numeric(9,2),
    datefrom date,
    dateto date
);


--
-- Name: masterorders_priceslist_id_seq; Type: SEQUENCE; Schema: public; Owner: -
--

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


--
-- Name: masterorders_priceslist_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: -
--

ALTER SEQUENCE public.masterorders_priceslist_id_seq OWNED BY public.masterorders_priceslist.id;


--
-- Name: masterorders_productsbyattributeentryhelper; Type: TABLE; Schema: public; Owner: -
--

CREATE TABLE public.masterorders_productsbyattributeentryhelper (
    id bigint NOT NULL,
    productsbyattributehelper_id bigint,
    product_id bigint,
    attribute_id bigint,
    attributevalue_id bigint,
    value character varying(255)
);


--
-- Name: masterorders_productsbyattributeentryhelper_id_seq; Type: SEQUENCE; Schema: public; Owner: -
--

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


--
-- Name: masterorders_productsbyattributeentryhelper_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: -
--

ALTER SEQUENCE public.masterorders_productsbyattributeentryhelper_id_seq OWNED BY public.masterorders_productsbyattributeentryhelper.id;


--
-- Name: masterorders_productsbyattributehelper; Type: TABLE; Schema: public; Owner: -
--

CREATE TABLE public.masterorders_productsbyattributehelper (
    id bigint NOT NULL,
    masterorder_id bigint,
    product_id bigint,
    orderedquantity numeric(12,5),
    comments character varying(2048)
);


--
-- Name: masterorders_productsbyattributehelper_id_seq; Type: SEQUENCE; Schema: public; Owner: -
--

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


--
-- Name: masterorders_productsbyattributehelper_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: -
--

ALTER SEQUENCE public.masterorders_productsbyattributehelper_id_seq OWNED BY public.masterorders_productsbyattributehelper.id;


--
-- Name: masterorders_productsbysizeentryhelper; Type: TABLE; Schema: public; Owner: -
--

CREATE TABLE public.masterorders_productsbysizeentryhelper (
    id bigint NOT NULL,
    size_id bigint,
    productsbysizehelper_id bigint,
    quantity numeric(12,5),
    product_id bigint
);


--
-- Name: masterorders_productsbysizeentryhelper_id_seq; Type: SEQUENCE; Schema: public; Owner: -
--

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


--
-- Name: masterorders_productsbysizeentryhelper_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: -
--

ALTER SEQUENCE public.masterorders_productsbysizeentryhelper_id_seq OWNED BY public.masterorders_productsbysizeentryhelper.id;


--
-- Name: masterorders_productsbysizehelper; Type: TABLE; Schema: public; Owner: -
--

CREATE TABLE public.masterorders_productsbysizehelper (
    id bigint NOT NULL,
    product_id bigint,
    totalquantity numeric(12,5),
    masterorder_id bigint,
    salesplan_id bigint,
    ordersgroup_id bigint
);


--
-- Name: masterorders_productsbysizehelper_id_seq; Type: SEQUENCE; Schema: public; Owner: -
--

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


--
-- Name: masterorders_productsbysizehelper_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: -
--

ALTER SEQUENCE public.masterorders_productsbysizehelper_id_seq OWNED BY public.masterorders_productsbysizehelper.id;


--
-- Name: masterorders_sales_plan_number_seq; Type: SEQUENCE; Schema: public; Owner: -
--

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


--
-- Name: masterorders_salesplan_id_seq; Type: SEQUENCE; Schema: public; Owner: -
--

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


--
-- Name: masterorders_salesplan_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: -
--

ALTER SEQUENCE public.masterorders_salesplan_id_seq OWNED BY public.masterorders_salesplan.id;


--
-- Name: masterorders_salesplanmaterialrequirement; Type: TABLE; Schema: public; Owner: -
--

CREATE TABLE public.masterorders_salesplanmaterialrequirement (
    id bigint NOT NULL,
    number character varying(256),
    salesplan_id bigint,
    generated boolean,
    worker character varying(255),
    date timestamp without time zone,
    includecomponents boolean DEFAULT false
);


--
-- Name: masterorders_salesplanmaterialrequirement_id_seq; Type: SEQUENCE; Schema: public; Owner: -
--

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


--
-- Name: masterorders_salesplanmaterialrequirement_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: -
--

ALTER SEQUENCE public.masterorders_salesplanmaterialrequirement_id_seq OWNED BY public.masterorders_salesplanmaterialrequirement.id;


--
-- Name: masterorders_salesplanmaterialrequirement_number_seq; Type: SEQUENCE; Schema: public; Owner: -
--

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


--
-- Name: masterorders_salesplanmaterialrequirementproduct; Type: TABLE; Schema: public; Owner: -
--

CREATE TABLE public.masterorders_salesplanmaterialrequirementproduct (
    id bigint NOT NULL,
    salesplanmaterialrequirement_id bigint,
    product_id bigint,
    quantity numeric(14,5),
    sizegroup_id bigint,
    sumforsizes numeric(14,5),
    currentstock numeric(14,5),
    neededquantity numeric(14,5),
    supplier_id bigint,
    minimumorderquantity numeric(12,5),
    isdeliverycreated boolean DEFAULT false
);


--
-- Name: masterorders_salesplanmaterialrequirementproduct_id_seq; Type: SEQUENCE; Schema: public; Owner: -
--

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


--
-- Name: masterorders_salesplanmaterialrequirementproduct_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: -
--

ALTER SEQUENCE public.masterorders_salesplanmaterialrequirementproduct_id_seq OWNED BY public.masterorders_salesplanmaterialrequirementproduct.id;


--
-- Name: masterorders_salesplanordersgroupentryhelper; Type: TABLE; Schema: public; Owner: -
--

CREATE TABLE public.masterorders_salesplanordersgroupentryhelper (
    id bigint NOT NULL,
    salesplanordersgrouphelper_id bigint,
    productfamily_id bigint,
    product_id bigint,
    plannedquantity numeric(12,5),
    orderedquantity numeric(12,5),
    orderquantity numeric(12,5),
    technology_id bigint
);


--
-- Name: masterorders_salesplanordersgroupentryhelper_id_seq; Type: SEQUENCE; Schema: public; Owner: -
--

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


--
-- Name: masterorders_salesplanordersgroupentryhelper_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: -
--

ALTER SEQUENCE public.masterorders_salesplanordersgroupentryhelper_id_seq OWNED BY public.masterorders_salesplanordersgroupentryhelper.id;


--
-- Name: masterorders_salesplanordersgrouphelper; Type: TABLE; Schema: public; Owner: -
--

CREATE TABLE public.masterorders_salesplanordersgrouphelper (
    id bigint NOT NULL,
    salesplan_id bigint
);


--
-- Name: masterorders_salesplanordersgrouphelper_id_seq; Type: SEQUENCE; Schema: public; Owner: -
--

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


--
-- Name: masterorders_salesplanordersgrouphelper_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: -
--

ALTER SEQUENCE public.masterorders_salesplanordersgrouphelper_id_seq OWNED BY public.masterorders_salesplanordersgrouphelper.id;


--
-- Name: ordersgroups_ordersgroup; Type: TABLE; Schema: public; Owner: -
--

CREATE TABLE public.ordersgroups_ordersgroup (
    id bigint NOT NULL,
    number character varying(255),
    assortment_id bigint,
    productionline_id bigint,
    startdate timestamp without time zone,
    finishdate timestamp without time zone,
    deadline timestamp without time zone,
    quantity numeric(14,5),
    producedquantity numeric(14,5),
    remainingquantity numeric(14,5),
    state character varying(255) DEFAULT '01draft'::character varying,
    active boolean DEFAULT true,
    masterorder_id bigint,
    parent_id bigint,
    remainingquantityinorders numeric(14,5),
    description character varying(2048),
    salesplan_id bigint
);


--
-- Name: masterorders_salesplanpalnnedproductdto; Type: VIEW; Schema: public; Owner: -
--

CREATE VIEW public.masterorders_salesplanpalnnedproductdto AS
 SELECT o.id AS orderid,
    og.id AS ordergroupid,
    sp.id AS salesplanid,
    o.product_id AS productid,
    o.plannedquantity
   FROM ((public.orders_order o
     LEFT JOIN public.ordersgroups_ordersgroup og ON ((og.id = o.ordersgroup_id)))
     LEFT JOIN public.masterorders_salesplan sp ON (((sp.id = o.salesplan_id) OR (sp.id = og.salesplan_id))))
  WHERE (sp.id IS NOT NULL);


--
-- Name: masterorders_salesplanproduct; Type: TABLE; Schema: public; Owner: -
--

CREATE TABLE public.masterorders_salesplanproduct (
    id bigint NOT NULL,
    salesplan_id bigint NOT NULL,
    product_id bigint NOT NULL,
    technology_id bigint,
    plannedquantity numeric(14,5),
    orderedquantity numeric(14,5) DEFAULT 0,
    surplusfromplan numeric(14,5),
    orderedtowarehouse numeric(14,5) DEFAULT 0
);


--
-- Name: masterorders_salesplanproduct_id_seq; Type: SEQUENCE; Schema: public; Owner: -
--

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


--
-- Name: masterorders_salesplanproduct_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: -
--

ALTER SEQUENCE public.masterorders_salesplanproduct_id_seq OWNED BY public.masterorders_salesplanproduct.id;


--
-- Name: masterorders_salesplanproductdto; Type: VIEW; Schema: public; Owner: -
--

CREATE VIEW public.masterorders_salesplanproductdto AS
 SELECT spp.id,
    (spp.salesplan_id)::integer AS salesplanid,
    spp.salesplan_id,
    p.number AS productnumber,
    p.name AS productname,
    p.entitytype AS productentitytype,
    assortment.name AS productassortment,
    family.number AS productfamily,
    model.name AS productmodel,
    p.unit AS productunit,
    t.number AS technologynumber,
    spp.plannedquantity,
    spp.orderedquantity,
    spp.surplusfromplan,
        CASE
            WHEN ((p.entitytype)::text = '01particularProduct'::text) THEN COALESCE(( SELECT sum(sppp.plannedquantity) AS sum
               FROM public.masterorders_salesplanpalnnedproductdto sppp
              WHERE ((sppp.salesplanid = spp.salesplan_id) AND (sppp.productid = p.id))), (0)::numeric)
            ELSE COALESCE(( SELECT sum(sppp.plannedquantity) AS sum
               FROM public.masterorders_salesplanpalnnedproductdto sppp
              WHERE ((sppp.salesplanid = spp.salesplan_id) AND (sppp.productid IN ( SELECT prod.id
                       FROM public.basic_product prod
                      WHERE (prod.parent_id = p.id))))), (0)::numeric)
        END AS ordersplannedquantity,
    spp.orderedtowarehouse
   FROM (((((public.masterorders_salesplanproduct spp
     JOIN public.basic_product p ON ((spp.product_id = p.id)))
     LEFT JOIN public.basic_assortment assortment ON ((p.assortment_id = assortment.id)))
     LEFT JOIN public.basic_model model ON ((p.model_id = model.id)))
     LEFT JOIN public.technologies_technology t ON ((t.id = spp.technology_id)))
     LEFT JOIN public.basic_product family ON ((p.parent_id = family.id)));


--
-- Name: masterorders_salesplanproductdto_id_seq; Type: SEQUENCE; Schema: public; Owner: -
--

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


--
-- Name: masterorders_salesplanstatechange; Type: TABLE; Schema: public; Owner: -
--

CREATE TABLE public.masterorders_salesplanstatechange (
    id bigint NOT NULL,
    dateandtime timestamp without time zone,
    salesplan_id bigint,
    shift_id bigint,
    sourcestate character varying(255),
    targetstate character varying(255),
    status character varying(255),
    phase integer,
    worker character varying(255)
);


--
-- Name: masterorders_salesplanstatechange_id_seq; Type: SEQUENCE; Schema: public; Owner: -
--

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


--
-- Name: masterorders_salesplanstatechange_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: -
--

ALTER SEQUENCE public.masterorders_salesplanstatechange_id_seq OWNED BY public.masterorders_salesplanstatechange.id;


--
-- Name: masterorders_salesvolume; Type: TABLE; Schema: public; Owner: -
--

CREATE TABLE public.masterorders_salesvolume (
    id bigint NOT NULL,
    product_id bigint,
    dailysalesvolume numeric(14,5),
    optimalstock numeric(14,5),
    currentstock numeric(14,5),
    stockfordays integer
);


--
-- Name: masterorders_salesvolume_id_seq; Type: SEQUENCE; Schema: public; Owner: -
--

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


--
-- Name: masterorders_salesvolume_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: -
--

ALTER SEQUENCE public.masterorders_salesvolume_id_seq OWNED BY public.masterorders_salesvolume.id;


--
-- Name: masterorders_salesvolumemulti; Type: TABLE; Schema: public; Owner: -
--

CREATE TABLE public.masterorders_salesvolumemulti (
    id bigint NOT NULL,
    dailysalesvolume numeric(14,5),
    optimalstock numeric(14,5),
    createdate timestamp without time zone,
    updatedate timestamp without time zone,
    createuser character varying(255),
    updateuser character varying(255)
);


--
-- Name: masterorders_salesvolumemulti_id_seq; Type: SEQUENCE; Schema: public; Owner: -
--

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


--
-- Name: masterorders_salesvolumemulti_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: -
--

ALTER SEQUENCE public.masterorders_salesvolumemulti_id_seq OWNED BY public.masterorders_salesvolumemulti.id;


--
-- Name: materialflow_location_id_seq; Type: SEQUENCE; Schema: public; Owner: -
--

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


--
-- Name: materialflow_location_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: -
--

ALTER SEQUENCE public.materialflow_location_id_seq OWNED BY public.materialflow_location.id;


--
-- Name: materialflow_userlocation; Type: TABLE; Schema: public; Owner: -
--

CREATE TABLE public.materialflow_userlocation (
    id bigint NOT NULL,
    location_id bigint,
    user_id bigint
);


--
-- Name: materialflow_userlocation_id_seq; Type: SEQUENCE; Schema: public; Owner: -
--

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


--
-- Name: materialflow_userlocation_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: -
--

ALTER SEQUENCE public.materialflow_userlocation_id_seq OWNED BY public.materialflow_userlocation.id;


--
-- Name: materialflowresources_costnormsgenerator; Type: TABLE; Schema: public; Owner: -
--

CREATE TABLE public.materialflowresources_costnormsgenerator (
    id bigint NOT NULL,
    costssource character varying(255) DEFAULT '01mes'::character varying,
    productstoupdate character varying(255) DEFAULT '01all'::character varying,
    entityversion bigint DEFAULT 0
);


--
-- Name: materialflowresources_costnormsgenerator_id_seq; Type: SEQUENCE; Schema: public; Owner: -
--

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


--
-- Name: materialflowresources_costnormsgenerator_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: -
--

ALTER SEQUENCE public.materialflowresources_costnormsgenerator_id_seq OWNED BY public.materialflowresources_costnormsgenerator.id;


--
-- Name: materialflowresources_costnormslocation; Type: TABLE; Schema: public; Owner: -
--

CREATE TABLE public.materialflowresources_costnormslocation (
    id bigint NOT NULL,
    costnormsgenerator_id bigint,
    location_id bigint,
    entityversion bigint DEFAULT 0,
    parameter_id bigint
);


--
-- Name: materialflowresources_costnormslocation_id_seq; Type: SEQUENCE; Schema: public; Owner: -
--

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


--
-- Name: materialflowresources_costnormslocation_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: -
--

ALTER SEQUENCE public.materialflowresources_costnormslocation_id_seq OWNED BY public.materialflowresources_costnormslocation.id;


--
-- Name: materialflowresources_defaultstoragelocationdto; Type: VIEW; Schema: public; Owner: -
--

CREATE VIEW public.materialflowresources_defaultstoragelocationdto AS
 SELECT row_number() OVER () AS id,
    storagelocation.active,
    storagelocation.number,
    storagelocation.location_id,
    product_storagelocation.storagelocation_id,
    product_storagelocation.product_id
   FROM (public.materialflowresources_storagelocation storagelocation
     RIGHT JOIN public.jointable_product_storagelocation product_storagelocation ON ((product_storagelocation.storagelocation_id = storagelocation.id)));


--
-- Name: materialflowresources_defaultstoragelocationdto_id_seq; Type: SEQUENCE; Schema: public; Owner: -
--

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


--
-- Name: materialflowresources_document; Type: TABLE; Schema: public; Owner: -
--

CREATE TABLE public.materialflowresources_document (
    id bigint NOT NULL,
    number character varying(255) NOT NULL,
    type character varying(255) NOT NULL,
    "time" timestamp without time zone,
    state character varying(255) DEFAULT '01draft'::character varying,
    locationfrom_id bigint,
    locationto_id bigint,
    user_id bigint,
    delivery_id bigint,
    active boolean DEFAULT true,
    createdate timestamp without time zone,
    updatedate timestamp without time zone,
    createuser character varying(255),
    updateuser character varying(255),
    order_id bigint,
    description character varying(2048),
    suborder_id bigint,
    company_id bigint,
    maintenanceevent_id bigint,
    entityversion bigint DEFAULT 0,
    plannedevent_id bigint,
    name character varying(255),
    createlinkeddocument boolean,
    linkeddocumentlocation_id bigint,
    address_id bigint,
    generationdate timestamp without time zone,
    filename character varying(255),
    acceptationinprogress boolean DEFAULT false,
    externalnumber character varying(255),
    issend boolean DEFAULT false,
    wms boolean DEFAULT false,
    datesendtowms timestamp without time zone,
    stateinwms character varying(255),
    pickingworker character varying(255),
    dateconfirmationofcompletion timestamp without time zone,
    editinwms boolean DEFAULT true,
    staff_id bigint,
    ordersgroup_id bigint,
    invoicenumber character varying(2048)
);


--
-- Name: materialflowresources_document_id_seq; Type: SEQUENCE; Schema: public; Owner: -
--

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


--
-- Name: materialflowresources_document_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: -
--

ALTER SEQUENCE public.materialflowresources_document_id_seq OWNED BY public.materialflowresources_document.id;


--
-- Name: materialflowresources_document_number_mm; Type: SEQUENCE; Schema: public; Owner: -
--

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


--
-- Name: materialflowresources_document_number_pw; Type: SEQUENCE; Schema: public; Owner: -
--

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


--
-- Name: materialflowresources_document_number_pz; Type: SEQUENCE; Schema: public; Owner: -
--

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


--
-- Name: materialflowresources_document_number_rw; Type: SEQUENCE; Schema: public; Owner: -
--

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


--
-- Name: materialflowresources_document_number_wz; Type: SEQUENCE; Schema: public; Owner: -
--

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


--
-- Name: materialflowresources_documentdto; Type: VIEW; Schema: public; Owner: -
--

CREATE VIEW public.materialflowresources_documentdto AS
 SELECT document.id,
    document.number,
    document.description,
    document.name,
    document.type,
    document."time",
    document.state,
    document.active,
    (locationfrom.id)::integer AS locationfrom_id,
    locationfrom.number AS locationfromnumber,
    (locationto.id)::integer AS locationto_id,
    locationto.number AS locationtonumber,
    (company.id)::integer AS company_id,
    company.name AS companyname,
        CASE
            WHEN (address.name IS NULL) THEN (address.number)::text
            ELSE (((address.number)::text || ' - '::text) || (address.name)::text)
        END AS documentaddress,
    (securityuser.id)::integer AS user_id,
    (((securityuser.firstname)::text || ' '::text) || (securityuser.lastname)::text) AS username,
    (maintenanceevent.id)::integer AS maintenanceevent_id,
    maintenanceevent.number AS maintenanceeventnumber,
    (plannedevent.id)::integer AS plannedevent_id,
    plannedevent.number AS plannedeventnumber,
    (delivery.id)::integer AS delivery_id,
    delivery.number AS deliverynumber,
    (ordersorder.id)::integer AS order_id,
    ordersorder.number AS ordernumber,
    (suborder.id)::integer AS suborder_id,
    suborder.number AS subordernumber,
    document.issend,
    document.wms,
    document.stateinwms,
    document.pickingworker,
    (((stf.surname)::text || ' '::text) || (stf.name)::text) AS staff,
    og.number AS ordersgroup,
    document.invoicenumber
   FROM ((((((((((((public.materialflowresources_document document
     LEFT JOIN public.materialflow_location locationfrom ON ((locationfrom.id = document.locationfrom_id)))
     LEFT JOIN public.materialflow_location locationto ON ((locationto.id = document.locationto_id)))
     LEFT JOIN public.basic_company company ON ((company.id = document.company_id)))
     LEFT JOIN public.basic_address address ON ((address.id = document.address_id)))
     LEFT JOIN public.qcadoosecurity_user securityuser ON ((securityuser.id = document.user_id)))
     LEFT JOIN public.cmmsmachineparts_maintenanceevent maintenanceevent ON ((maintenanceevent.id = document.maintenanceevent_id)))
     LEFT JOIN public.cmmsmachineparts_plannedevent plannedevent ON ((plannedevent.id = document.plannedevent_id)))
     LEFT JOIN public.deliveries_delivery delivery ON ((delivery.id = document.delivery_id)))
     LEFT JOIN public.orders_order ordersorder ON ((ordersorder.id = document.order_id)))
     LEFT JOIN public.subcontractorportal_suborder suborder ON ((suborder.id = document.suborder_id)))
     LEFT JOIN public.basic_staff stf ON ((stf.id = document.staff_id)))
     LEFT JOIN public.ordersgroups_ordersgroup og ON ((og.id = document.ordersgroup_id)));


--
-- Name: materialflowresources_documentdto_id_seq; Type: SEQUENCE; Schema: public; Owner: -
--

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


--
-- Name: materialflowresources_documentpositionparameters; Type: TABLE; Schema: public; Owner: -
--

CREATE TABLE public.materialflowresources_documentpositionparameters (
    id bigint NOT NULL,
    suggestresource boolean DEFAULT false,
    acceptanceofdocumentbeforeprinting boolean DEFAULT false,
    notshowprices boolean DEFAULT false,
    presenttotalamountandrest boolean DEFAULT false,
    pallettoshift integer,
    palletwithfreeplace integer,
    fillresourceirrespectiveofconversion boolean DEFAULT false,
    numberofmonthsforpositionsdata integer DEFAULT 1,
    colorresourcesafterdeadline boolean DEFAULT false,
    shortexpirydate integer DEFAULT 14,
    transferpallettoreceivingwarehouse boolean DEFAULT false,
    runningoutofstockdays integer DEFAULT 0
);


--
-- Name: materialflowresources_documentpositionparameters_id_seq; Type: SEQUENCE; Schema: public; Owner: -
--

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


--
-- Name: materialflowresources_documentpositionparameters_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: -
--

ALTER SEQUENCE public.materialflowresources_documentpositionparameters_id_seq OWNED BY public.materialflowresources_documentpositionparameters.id;


--
-- Name: materialflowresources_documentpositionparametersitem; Type: TABLE; Schema: public; Owner: -
--

CREATE TABLE public.materialflowresources_documentpositionparametersitem (
    id bigint NOT NULL,
    checked boolean DEFAULT true,
    editable boolean DEFAULT true,
    parameters_id bigint,
    name character varying(255),
    ordering integer,
    forattribute boolean DEFAULT false,
    attribute_id bigint
);


--
-- Name: materialflowresources_documentpositionparametersitem_id_seq; Type: SEQUENCE; Schema: public; Owner: -
--

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


--
-- Name: materialflowresources_documentpositionparametersitem_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: -
--

ALTER SEQUENCE public.materialflowresources_documentpositionparametersitem_id_seq OWNED BY public.materialflowresources_documentpositionparametersitem.id;


--
-- Name: materialflowresources_documentstatechange; Type: TABLE; Schema: public; Owner: -
--

CREATE TABLE public.materialflowresources_documentstatechange (
    id bigint NOT NULL,
    dateandtime timestamp without time zone,
    document_id bigint,
    sourcestate character varying(255),
    targetstate character varying(255),
    status character varying(255),
    worker character varying(255)
);


--
-- Name: materialflowresources_documentstatechange_id_seq; Type: SEQUENCE; Schema: public; Owner: -
--

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


--
-- Name: materialflowresources_documentstatechange_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: -
--

ALTER SEQUENCE public.materialflowresources_documentstatechange_id_seq OWNED BY public.materialflowresources_documentstatechange.id;


--
-- Name: materialflowresources_importstoragelocation; Type: TABLE; Schema: public; Owner: -
--

CREATE TABLE public.materialflowresources_importstoragelocation (
    id bigint NOT NULL,
    location_id bigint,
    positionsfile character varying(255)
);


--
-- Name: materialflowresources_importstoragelocation_id_seq; Type: SEQUENCE; Schema: public; Owner: -
--

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


--
-- Name: materialflowresources_importstoragelocation_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: -
--

ALTER SEQUENCE public.materialflowresources_importstoragelocation_id_seq OWNED BY public.materialflowresources_importstoragelocation.id;


--
-- Name: materialflowresources_palletbalance; Type: TABLE; Schema: public; Owner: -
--

CREATE TABLE public.materialflowresources_palletbalance (
    id bigint NOT NULL,
    number character varying(255),
    name character varying(255),
    datefrom date,
    dateto date,
    includeweekends boolean DEFAULT false,
    createdate timestamp without time zone,
    updatedate timestamp without time zone,
    createuser character varying(255),
    updateuser character varying(255),
    generated boolean DEFAULT false,
    filename character varying(255),
    generateddate date,
    generatedby character varying
);


--
-- Name: materialflowresources_palletbalance_id_seq; Type: SEQUENCE; Schema: public; Owner: -
--

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


--
-- Name: materialflowresources_palletbalance_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: -
--

ALTER SEQUENCE public.materialflowresources_palletbalance_id_seq OWNED BY public.materialflowresources_palletbalance.id;


--
-- Name: materialflowresources_palletmovehelper; Type: TABLE; Schema: public; Owner: -
--

CREATE TABLE public.materialflowresources_palletmovehelper (
    id bigint NOT NULL
);


--
-- Name: materialflowresources_palletmovehelper_id_seq; Type: SEQUENCE; Schema: public; Owner: -
--

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


--
-- Name: materialflowresources_palletmovehelper_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: -
--

ALTER SEQUENCE public.materialflowresources_palletmovehelper_id_seq OWNED BY public.materialflowresources_palletmovehelper.id;


--
-- Name: materialflowresources_resource; Type: TABLE; Schema: public; Owner: -
--

CREATE TABLE public.materialflowresources_resource (
    id bigint NOT NULL,
    location_id bigint,
    product_id bigint,
    quantity numeric(14,5),
    price numeric(12,5) DEFAULT (0)::numeric,
    _batch character varying(255),
    "time" timestamp without time zone NOT NULL,
    productiondate date,
    expirationdate date,
    iscorrected boolean,
    entityversion bigint DEFAULT 0,
    storagelocation_id bigint,
    number character varying(255) NOT NULL,
    quantityinadditionalunit numeric(14,5),
    conversion numeric(12,5) DEFAULT (0)::numeric,
    palletnumber_id bigint,
    typeofpallet character varying(255),
    givenunit character varying(255),
    username character varying(255),
    waste boolean DEFAULT false,
    availablequantity numeric(14,5),
    reservedquantity numeric(14,5),
    deliverynumber character varying,
    documentnumber character varying,
    batch_id bigint,
    blockedforqualitycontrol boolean DEFAULT false,
    qualityrating character varying(255)
);


--
-- Name: materialflowresources_palletstoragestatedetailsdto; Type: VIEW; Schema: public; Owner: -
--

CREATE VIEW public.materialflowresources_palletstoragestatedetailsdto AS
 SELECT resource.id,
    true AS active,
    resource.number AS resourcenumber,
    product.number AS productnumber,
    product.name AS productname,
    resource.quantity,
    product.unit,
    resource.quantityinadditionalunit AS additionalquantity,
    resource.givenunit AS additionalunit,
    resource.expirationdate,
    palletnumber.number AS palletnumber,
    palletnumber.active AS palletnumberactive,
    resource.typeofpallet,
    storagelocation.number AS storagelocationnumber,
    location.number AS locationnumber,
    (location.id)::integer AS location_id,
    resource.palletnumber_id AS palletid
   FROM ((((public.materialflowresources_resource resource
     LEFT JOIN public.basic_product product ON ((product.id = resource.product_id)))
     LEFT JOIN public.basic_palletnumber palletnumber ON ((palletnumber.id = resource.palletnumber_id)))
     LEFT JOIN public.materialflowresources_storagelocation storagelocation ON ((storagelocation.id = resource.storagelocation_id)))
     LEFT JOIN public.materialflow_location location ON ((location.id = resource.location_id)))
  WHERE (resource.palletnumber_id IS NOT NULL)
  ORDER BY palletnumber.number;


--
-- Name: materialflowresources_palletstoragestatedetailsdto_id_seq; Type: SEQUENCE; Schema: public; Owner: -
--

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


--
-- Name: materialflowresources_palletstoragestatedto; Type: VIEW; Schema: public; Owner: -
--

CREATE VIEW public.materialflowresources_palletstoragestatedto AS
 SELECT palletstoragestatedetails.palletid AS id,
    true AS active,
    palletstoragestatedetails.palletnumber,
    palletstoragestatedetails.palletnumberactive,
    palletstoragestatedetails.typeofpallet,
    palletstoragestatedetails.storagelocationnumber,
    palletstoragestatedetails.locationnumber,
    (sum(palletstoragestatedetails.quantity))::numeric(14,5) AS totalquantity,
    NULL::bigint AS palletmovehelper_id,
    NULL::bigint AS newstoragelocation_id,
    NULL::bigint AS newpalletnumber_id,
    palletstoragestatedetails.location_id
   FROM public.materialflowresources_palletstoragestatedetailsdto palletstoragestatedetails
  GROUP BY palletstoragestatedetails.palletid, palletstoragestatedetails.palletnumber, palletstoragestatedetails.palletnumberactive, palletstoragestatedetails.typeofpallet, palletstoragestatedetails.storagelocationnumber, palletstoragestatedetails.locationnumber, palletstoragestatedetails.location_id
  ORDER BY palletstoragestatedetails.palletnumber, palletstoragestatedetails.locationnumber;


--
-- Name: materialflowresources_palletstoragestatedto_id_seq; Type: SEQUENCE; Schema: public; Owner: -
--

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


--
-- Name: materialflowresources_position; Type: TABLE; Schema: public; Owner: -
--

CREATE TABLE public.materialflowresources_position (
    id bigint NOT NULL,
    document_id bigint,
    product_id bigint,
    quantity numeric(14,5),
    price numeric(12,5) DEFAULT (0)::numeric,
    productiondate date,
    expirationdate date,
    number integer,
    resource_id bigint,
    givenunit character varying(255),
    givenquantity numeric(14,5),
    entityversion bigint DEFAULT 0,
    storagelocation_id bigint,
    conversion numeric(12,5) DEFAULT (0)::numeric,
    palletnumber_id bigint,
    typeofpallet character varying(255),
    waste boolean DEFAULT false,
    resourcereceiptdocument character varying,
    lastresource boolean DEFAULT false,
    resourcenumber character varying(255),
    externaldocumentnumber character varying(255),
    orderid integer,
    sellingprice numeric(12,5) DEFAULT '0'::numeric,
    batch_id bigint,
    qualityrating character varying(255),
    pickingdate timestamp without time zone,
    pickingworker_id bigint,
    documentpart_id bigint
);


--
-- Name: materialflowresources_position_id_seq; Type: SEQUENCE; Schema: public; Owner: -
--

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


--
-- Name: materialflowresources_position_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: -
--

ALTER SEQUENCE public.materialflowresources_position_id_seq OWNED BY public.materialflowresources_position.id;


--
-- Name: materialflowresources_positionaddmultihelper; Type: TABLE; Schema: public; Owner: -
--

CREATE TABLE public.materialflowresources_positionaddmultihelper (
    id bigint NOT NULL
);


--
-- Name: materialflowresources_positionaddmultihelper_id_seq; Type: SEQUENCE; Schema: public; Owner: -
--

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


--
-- Name: materialflowresources_positionaddmultihelper_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: -
--

ALTER SEQUENCE public.materialflowresources_positionaddmultihelper_id_seq OWNED BY public.materialflowresources_positionaddmultihelper.id;


--
-- Name: materialflowresources_positionattributevalue; Type: TABLE; Schema: public; Owner: -
--

CREATE TABLE public.materialflowresources_positionattributevalue (
    id bigint NOT NULL,
    position_id bigint,
    attribute_id bigint,
    attributevalue_id bigint,
    value character varying(255)
);


--
-- Name: materialflowresources_positionattributevalue_id_seq; Type: SEQUENCE; Schema: public; Owner: -
--

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


--
-- Name: materialflowresources_positionattributevalue_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: -
--

ALTER SEQUENCE public.materialflowresources_positionattributevalue_id_seq OWNED BY public.materialflowresources_positionattributevalue.id;


--
-- Name: materialflowresources_positiondto; Type: VIEW; Schema: public; Owner: -
--

CREATE VIEW public.materialflowresources_positiondto AS
 SELECT "position".id,
    locationfrom.number AS locationfrom,
    locationto.number AS locationto,
    product.number AS productnumber,
    product.name AS productname,
    product.globaltypeofmaterial AS productglobaltypeofmaterial,
    product.category AS productcategory,
    "position".quantity,
    "position".price,
    product.unit AS productunit,
    document."time" AS documentdate,
    ("position".expirationdate)::timestamp without time zone AS expirationdate,
    ("position".productiondate)::timestamp without time zone AS productiondate,
        CASE
            WHEN ("position".externaldocumentnumber IS NULL) THEN document.type
            ELSE '03internalOutbound'::character varying(255)
        END AS documenttype,
    document.state,
        CASE
            WHEN ("position".externaldocumentnumber IS NULL) THEN document.number
            ELSE "position".externaldocumentnumber
        END AS documentnumber,
    document.name AS documentname,
    company.name AS companyname,
        CASE
            WHEN (address.name IS NULL) THEN (address.number)::text
            ELSE (((address.number)::text || ' - '::text) || (address.name)::text)
        END AS documentaddress,
    batch.number AS batch,
    storagelocation.number AS storagelocation,
    "position".waste,
    delivery.number AS deliverynumber,
    plannedevent.number AS plannedeventnumber,
    maintenanceevent.number AS maintenanceeventnumber,
    suborder.number AS subordernumber,
    ordersorder.number AS ordernumber,
    "position".typeofpallet AS pallettype,
    palletnumber.number AS palletnumber,
    (locationfrom.id)::integer AS locationfrom_id,
    (locationto.id)::integer AS locationto_id,
    "position".givenquantity,
    "position".givenunit,
    "position".conversion,
    (document.id)::integer AS documentid,
        CASE
            WHEN ("position".orderid IS NULL) THEN (document.order_id)::integer
            ELSE "position".orderid
        END AS orderid,
    round(("position".price * "position".quantity), 5) AS value,
    "position".resourcenumber,
    "position".sellingprice,
    (((staff.surname)::text || ' '::text) || (staff.name)::text) AS staff,
    (document.suborder_id)::integer AS suborderid,
    document.invoicenumber
   FROM (((((((((((((((public.materialflowresources_position "position"
     LEFT JOIN public.materialflowresources_document document ON ((document.id = "position".document_id)))
     LEFT JOIN public.materialflow_location locationfrom ON ((locationfrom.id = document.locationfrom_id)))
     LEFT JOIN public.materialflow_location locationto ON ((locationto.id = document.locationto_id)))
     JOIN public.basic_product product ON ((product.id = "position".product_id)))
     LEFT JOIN public.basic_company company ON ((company.id = document.company_id)))
     LEFT JOIN public.basic_address address ON ((address.id = document.address_id)))
     LEFT JOIN public.materialflowresources_storagelocation storagelocation ON ((storagelocation.id = "position".storagelocation_id)))
     LEFT JOIN public.cmmsmachineparts_maintenanceevent maintenanceevent ON ((maintenanceevent.id = document.maintenanceevent_id)))
     LEFT JOIN public.cmmsmachineparts_plannedevent plannedevent ON ((plannedevent.id = document.plannedevent_id)))
     LEFT JOIN public.deliveries_delivery delivery ON ((delivery.id = document.delivery_id)))
     LEFT JOIN public.subcontractorportal_suborder suborder ON ((suborder.id = document.suborder_id)))
     LEFT JOIN public.orders_order ordersorder ON (((ordersorder.id = document.order_id) OR (ordersorder.id = "position".orderid))))
     LEFT JOIN public.basic_palletnumber palletnumber ON ((palletnumber.id = "position".palletnumber_id)))
     LEFT JOIN public.advancedgenealogy_batch batch ON ((batch.id = "position".batch_id)))
     LEFT JOIN public.basic_staff staff ON ((staff.id = document.staff_id)));


--
-- Name: materialflowresources_positiondto_id_seq; Type: SEQUENCE; Schema: public; Owner: -
--

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


--
-- Name: materialflowresources_reservation; Type: TABLE; Schema: public; Owner: -
--

CREATE TABLE public.materialflowresources_reservation (
    id bigint NOT NULL,
    location_id bigint,
    product_id bigint,
    quantity numeric(12,5),
    position_id bigint,
    productstoissue_id bigint,
    resource_id bigint,
    order_id bigint,
    orderproductresourcereservation_id bigint,
    date timestamp without time zone
);


--
-- Name: materialflowresources_reservation_id_seq; Type: SEQUENCE; Schema: public; Owner: -
--

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


--
-- Name: materialflowresources_reservation_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: -
--

ALTER SEQUENCE public.materialflowresources_reservation_id_seq OWNED BY public.materialflowresources_reservation.id;


--
-- Name: materialflowresources_resource_id_seq; Type: SEQUENCE; Schema: public; Owner: -
--

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


--
-- Name: materialflowresources_resource_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: -
--

ALTER SEQUENCE public.materialflowresources_resource_id_seq OWNED BY public.materialflowresources_resource.id;


--
-- Name: materialflowresources_resource_number_2014; Type: SEQUENCE; Schema: public; Owner: -
--

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


--
-- Name: materialflowresources_resource_number_2015; Type: SEQUENCE; Schema: public; Owner: -
--

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


--
-- Name: materialflowresources_resource_number_2016; Type: SEQUENCE; Schema: public; Owner: -
--

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


--
-- Name: materialflowresources_resource_number_2017; Type: SEQUENCE; Schema: public; Owner: -
--

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


--
-- Name: materialflowresources_resourceattributevalue; Type: TABLE; Schema: public; Owner: -
--

CREATE TABLE public.materialflowresources_resourceattributevalue (
    id bigint NOT NULL,
    resource_id bigint,
    attribute_id bigint,
    attributevalue_id bigint,
    value character varying(255),
    fromdefinition boolean DEFAULT false
);


--
-- Name: materialflowresources_resourceattributevalue_id_seq; Type: SEQUENCE; Schema: public; Owner: -
--

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


--
-- Name: materialflowresources_resourceattributevalue_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: -
--

ALTER SEQUENCE public.materialflowresources_resourceattributevalue_id_seq OWNED BY public.materialflowresources_resourceattributevalue.id;


--
-- Name: materialflowresources_resourceattributevalueaftercorrection; Type: TABLE; Schema: public; Owner: -
--

CREATE TABLE public.materialflowresources_resourceattributevalueaftercorrection (
    id bigint NOT NULL,
    resourcecorrection_id bigint,
    attribute_id bigint,
    value character varying(255)
);


--
-- Name: materialflowresources_resourceattributevalueaftercorrection_id_; Type: SEQUENCE; Schema: public; Owner: -
--

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


--
-- Name: materialflowresources_resourceattributevalueaftercorrection_id_; Type: SEQUENCE OWNED BY; Schema: public; Owner: -
--

ALTER SEQUENCE public.materialflowresources_resourceattributevalueaftercorrection_id_ OWNED BY public.materialflowresources_resourceattributevalueaftercorrection.id;


--
-- Name: materialflowresources_resourceattributevaluebeforecorrection; Type: TABLE; Schema: public; Owner: -
--

CREATE TABLE public.materialflowresources_resourceattributevaluebeforecorrection (
    id bigint NOT NULL,
    resourcecorrection_id bigint,
    attribute_id bigint,
    value character varying(255)
);


--
-- Name: materialflowresources_resourceattributevaluebeforecorrection_id; Type: SEQUENCE; Schema: public; Owner: -
--

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


--
-- Name: materialflowresources_resourceattributevaluebeforecorrection_id; Type: SEQUENCE OWNED BY; Schema: public; Owner: -
--

ALTER SEQUENCE public.materialflowresources_resourceattributevaluebeforecorrection_id OWNED BY public.materialflowresources_resourceattributevaluebeforecorrection.id;


--
-- Name: materialflowresources_resourcecorrection; Type: TABLE; Schema: public; Owner: -
--

CREATE TABLE public.materialflowresources_resourcecorrection (
    id bigint NOT NULL,
    number character varying(255),
    product_id bigint,
    newquantity numeric(14,5),
    oldquantity numeric(14,5),
    location_id bigint,
    "time" timestamp without time zone,
    createdate timestamp without time zone,
    updatedate timestamp without time zone,
    createuser character varying(255),
    updateuser character varying(255),
    _oldbatch character varying(255),
    resource_id bigint,
    entityversion bigint DEFAULT 0,
    oldstoragelocation_id bigint,
    newstoragelocation_id bigint,
    oldprice numeric(12,5),
    newprice numeric(12,5),
    _newbatch character varying,
    oldpalletnumber_id bigint,
    newpalletnumber_id bigint,
    oldtypeofpallet character varying,
    newtypeofpallet character varying,
    oldexpirationdate date,
    newexpirationdate date,
    productiondate date,
    oldconversion numeric,
    newconversion numeric,
    resourcenumber character varying(255),
    deliverynumber character varying,
    oldbatch_id bigint,
    newbatch_id bigint,
    oldqualityrating character varying(255),
    newqualityrating character varying(255)
);


--
-- Name: materialflowresources_resourcecorrection_id_seq; Type: SEQUENCE; Schema: public; Owner: -
--

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


--
-- Name: materialflowresources_resourcecorrection_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: -
--

ALTER SEQUENCE public.materialflowresources_resourcecorrection_id_seq OWNED BY public.materialflowresources_resourcecorrection.id;


--
-- Name: materialflowresources_resourcecorrectiondto; Type: VIEW; Schema: public; Owner: -
--

CREATE VIEW public.materialflowresources_resourcecorrectiondto AS
 SELECT resourcecorrection.id,
    resourcecorrection.createdate,
    product.number AS productnumber,
    product.name AS productname,
    resourcecorrection.resourcenumber,
    resourcecorrection.number AS correctionnumber,
    (resourcecorrection.oldquantity <> resourcecorrection.newquantity) AS quantitycorrected,
    (COALESCE(resourcecorrection.oldprice, (0)::numeric) <> COALESCE(resourcecorrection.newprice, (0)::numeric)) AS pricecorrected,
    ((COALESCE(resourcecorrection.oldbatch_id, (0)::bigint))::text <> (COALESCE(resourcecorrection.newbatch_id, (0)::bigint))::text) AS batchcorrected,
    (COALESCE(resourcecorrection.oldexpirationdate, '1900-01-01'::date) <> COALESCE(resourcecorrection.newexpirationdate, '1900-01-01'::date)) AS expirationdatecorrected,
    (COALESCE(resourcecorrection.oldstoragelocation_id, (0)::bigint) <> COALESCE(resourcecorrection.newstoragelocation_id, (0)::bigint)) AS storagelocationcorrected,
    (COALESCE(resourcecorrection.oldpalletnumber_id, (0)::bigint) <> COALESCE(resourcecorrection.newpalletnumber_id, (0)::bigint)) AS palletnumbercorrected,
    ((COALESCE(resourcecorrection.oldtypeofpallet, ''::character varying))::text <> (COALESCE(resourcecorrection.newtypeofpallet, ''::character varying))::text) AS typeofpalletcorrected,
    resourcecorrection.deliverynumber,
    (resourcecorrection.location_id)::integer AS location_id,
    location.number AS locationnumber,
    newpallet.number AS newpalletnumber,
    oldpallet.number AS oldpalletnumber,
    newstoragelocation.number AS newstoragelocationnumber,
    oldstoragelocation.number AS oldstoragelocationnumber,
        CASE
            WHEN (( SELECT count(*) AS count
               FROM public.materialflowresources_resourceattributevalueaftercorrection resourceattributevalue
              WHERE (resourceattributevalue.resourcecorrection_id = resourcecorrection.id)) > 0) THEN true
            WHEN (( SELECT count(*) AS count
               FROM public.materialflowresources_resourceattributevaluebeforecorrection resourceattributevalue
              WHERE (resourceattributevalue.resourcecorrection_id = resourcecorrection.id)) > 0) THEN true
            ELSE false
        END AS attributecorrection,
    ((COALESCE(resourcecorrection.oldqualityrating, ''::character varying))::text <> (COALESCE(resourcecorrection.newqualityrating, ''::character varying))::text) AS qualityratingcorrected,
    resourcecorrection.newqualityrating,
    resourcecorrection.oldqualityrating
   FROM (((((((public.materialflowresources_resourcecorrection resourcecorrection
     JOIN public.basic_product product ON ((product.id = resourcecorrection.product_id)))
     LEFT JOIN public.materialflowresources_resource resource ON ((resource.id = resourcecorrection.resource_id)))
     LEFT JOIN public.materialflow_location location ON ((location.id = resourcecorrection.location_id)))
     LEFT JOIN public.basic_palletnumber newpallet ON ((newpallet.id = resourcecorrection.newpalletnumber_id)))
     LEFT JOIN public.basic_palletnumber oldpallet ON ((oldpallet.id = resourcecorrection.oldpalletnumber_id)))
     LEFT JOIN public.materialflowresources_storagelocation newstoragelocation ON ((newstoragelocation.id = resourcecorrection.newstoragelocation_id)))
     LEFT JOIN public.materialflowresources_storagelocation oldstoragelocation ON ((oldstoragelocation.id = resourcecorrection.oldstoragelocation_id)));


--
-- Name: materialflowresources_resourcecorrectiondto_id_seq; Type: SEQUENCE; Schema: public; Owner: -
--

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


--
-- Name: materialflowresources_resourcedto; Type: VIEW; Schema: public; Owner: -
--

CREATE VIEW public.materialflowresources_resourcedto AS
 SELECT resource.id,
    resource.number,
    resource.quantity,
    resource.quantityinadditionalunit,
    location.number AS locationnumber,
    product.number AS productnumber,
    product.name AS productname,
    product.globaltypeofmaterial AS productglobaltypeofmaterial,
    product.unit AS productunit,
    product.category AS productcategory,
    resource.givenunit,
    resource.conversion,
    resource.reservedquantity,
    resource.availablequantity,
    resource.price,
    (resource.quantity * resource.price) AS value,
    resource."time",
    resource.productiondate,
    resource.expirationdate,
    batch.number AS batchnumber,
    storagelocation.number AS storagelocationnumber,
    palletnumber.number AS palletnumber,
    resource.typeofpallet,
    resource.username,
    resource.iscorrected,
    resource.waste,
    resource.deliverynumber,
    (resource.location_id)::integer AS location_id,
    NULL::bigint AS positionaddmultihelper_id,
    resource.documentnumber,
    resource.qualityrating,
    resource.blockedforqualitycontrol,
    COALESCE(supplier.number, document_supplier.number) AS suppliernumber,
        CASE
            WHEN ( SELECT materialflowresources_documentpositionparameters.colorresourcesafterdeadline
               FROM public.materialflowresources_documentpositionparameters
             LIMIT 1) THEN (1)::numeric
            ELSE (0)::numeric
        END AS colorresourcesafterdeadline,
        CASE
            WHEN (resource.expirationdate < CURRENT_DATE) THEN 'red-cell'::character varying(255)
            WHEN (( SELECT (materialflowresources_documentpositionparameters.shortexpirydate IS NOT NULL)
               FROM public.materialflowresources_documentpositionparameters
             LIMIT 1) AND (resource.expirationdate >= CURRENT_DATE) AND (resource.expirationdate <= (CURRENT_DATE + ((( SELECT materialflowresources_documentpositionparameters.shortexpirydate
               FROM public.materialflowresources_documentpositionparameters
             LIMIT 1))::double precision * '1 day'::interval)))) THEN 'orange-cell'::character varying(255)
            ELSE NULL::character varying
        END AS expirationdatecellcolor
   FROM (((((((((public.materialflowresources_resource resource
     JOIN public.materialflow_location location ON ((location.id = resource.location_id)))
     JOIN public.basic_product product ON ((product.id = resource.product_id)))
     LEFT JOIN public.basic_palletnumber palletnumber ON ((palletnumber.id = resource.palletnumber_id)))
     LEFT JOIN public.materialflowresources_storagelocation storagelocation ON ((storagelocation.id = resource.storagelocation_id)))
     LEFT JOIN public.advancedgenealogy_batch batch ON ((batch.id = resource.batch_id)))
     LEFT JOIN public.deliveries_delivery delivery ON (((delivery.number)::text = (resource.deliverynumber)::text)))
     LEFT JOIN public.basic_company supplier ON ((delivery.supplier_id = supplier.id)))
     LEFT JOIN public.materialflowresources_document document ON (((document.number)::text = (resource.documentnumber)::text)))
     LEFT JOIN public.basic_company document_supplier ON ((document.company_id = document_supplier.id)));


--
-- Name: materialflowresources_resourcedto_id_seq; Type: SEQUENCE; Schema: public; Owner: -
--

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


--
-- Name: materialflowresources_resourcestock; Type: TABLE; Schema: public; Owner: -
--

CREATE TABLE public.materialflowresources_resourcestock (
    id bigint NOT NULL,
    location_id bigint,
    product_id bigint
);


--
-- Name: materialflowresources_resourcestock_id_seq; Type: SEQUENCE; Schema: public; Owner: -
--

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


--
-- Name: materialflowresources_resourcestock_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: -
--

ALTER SEQUENCE public.materialflowresources_resourcestock_id_seq OWNED BY public.materialflowresources_resourcestock.id;


--
-- Name: warehouseminimalstate_warehouseminimumstate; Type: TABLE; Schema: public; Owner: -
--

CREATE TABLE public.warehouseminimalstate_warehouseminimumstate (
    id bigint NOT NULL,
    product_id bigint,
    location_id bigint,
    minimumstate numeric(12,5),
    optimalorderquantity numeric(12,5),
    createdate timestamp without time zone,
    updatedate timestamp without time zone,
    createuser character varying(255),
    updateuser character varying(255),
    entityversion bigint DEFAULT 0
);


--
-- Name: materialflowresources_resourcestockdto; Type: VIEW; Schema: public; Owner: -
--

CREATE VIEW public.materialflowresources_resourcestockdto AS
 WITH minimum_states AS (
         SELECT warehouseminimumstate.product_id,
            warehouseminimumstate.location_id,
            sum(warehouseminimumstate.minimumstate) AS quantity
           FROM public.warehouseminimalstate_warehouseminimumstate warehouseminimumstate
          GROUP BY warehouseminimumstate.product_id, warehouseminimumstate.location_id
        ), quantities AS (
         SELECT resource.product_id,
            resource.location_id,
            sum(resource.quantity) AS quantity,
            sum(resource.quantityinadditionalunit) AS quantityinadditionalunit,
            sum((resource.quantity * resource.price)) AS totalvalue
           FROM public.materialflowresources_resource resource
          GROUP BY resource.product_id, resource.location_id
        ), blocked_quantities AS (
         SELECT resource.product_id,
            resource.location_id,
            sum(resource.quantity) AS quantity
           FROM public.materialflowresources_resource resource
          WHERE (resource.blockedforqualitycontrol = true)
          GROUP BY resource.product_id, resource.location_id
        ), reserved_quantities AS (
         SELECT reservation.product_id,
            reservation.location_id,
            sum(reservation.quantity) AS quantity
           FROM public.materialflowresources_reservation reservation
          GROUP BY reservation.product_id, reservation.location_id
        ), ordered_quantities AS (
         SELECT orderedproduct.product_id,
            delivery.location_id,
            sum(orderedproduct.orderedquantity) AS quantity
           FROM (public.deliveries_orderedproduct orderedproduct
             JOIN public.deliveries_delivery delivery ON ((delivery.id = orderedproduct.delivery_id)))
          WHERE ((delivery.active = true) AND ((delivery.state)::text = ANY (ARRAY[('01draft'::character varying)::text, ('02prepared'::character varying)::text, ('03duringCorrection'::character varying)::text, ('05approved'::character varying)::text])))
          GROUP BY orderedproduct.product_id, delivery.location_id
        )
 SELECT resourcestock.id,
    (resourcestock.location_id)::integer AS location_id,
    (resourcestock.product_id)::integer AS product_id,
    location.number AS locationnumber,
    location.name AS locationname,
    product.number AS productnumber,
    product.name AS productname,
    product.globaltypeofmaterial AS productglobaltypeofmaterial,
    product.unit AS productunit,
    family.number AS familynumber,
    COALESCE(minimum_states.quantity, (0)::numeric) AS minimumstate,
    COALESCE(quantities.quantity, (0)::numeric) AS quantity,
    COALESCE(quantities.quantityinadditionalunit, (0)::numeric) AS quantityinadditionalunit,
    COALESCE(quantities.totalvalue, (0)::numeric) AS totalvalue,
    COALESCE(ordered_quantities.quantity, (0)::numeric) AS orderedquantity,
    COALESCE(reserved_quantities.quantity, (0)::numeric) AS reservedquantity,
    (COALESCE(quantities.quantity, (0)::numeric) - COALESCE(reserved_quantities.quantity, (0)::numeric)) AS availablequantity,
    COALESCE(blocked_quantities.quantity, (0)::numeric) AS blockedquantity,
    COALESCE(product.additionalunit, product.unit) AS productadditionalunit
   FROM ((((((((public.materialflowresources_resourcestock resourcestock
     JOIN public.materialflow_location location ON ((location.id = resourcestock.location_id)))
     JOIN public.basic_product product ON ((product.id = resourcestock.product_id)))
     LEFT JOIN public.basic_product family ON ((product.parent_id = family.id)))
     LEFT JOIN minimum_states ON (((minimum_states.product_id = resourcestock.product_id) AND (minimum_states.location_id = resourcestock.location_id))))
     LEFT JOIN quantities ON (((quantities.product_id = resourcestock.product_id) AND (quantities.location_id = resourcestock.location_id))))
     LEFT JOIN blocked_quantities ON (((blocked_quantities.product_id = resourcestock.product_id) AND (blocked_quantities.location_id = resourcestock.location_id))))
     LEFT JOIN ordered_quantities ON (((ordered_quantities.product_id = resourcestock.product_id) AND (ordered_quantities.location_id = resourcestock.location_id))))
     LEFT JOIN reserved_quantities ON (((reserved_quantities.product_id = resourcestock.product_id) AND (reserved_quantities.location_id = resourcestock.location_id))));


--
-- Name: materialflowresources_resourcestockdto_id_seq; Type: SEQUENCE; Schema: public; Owner: -
--

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


--
-- Name: materialflowresources_resourcestockdto_internal_id_seq; Type: SEQUENCE; Schema: public; Owner: -
--

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


--
-- Name: materialflowresources_stocktaking; Type: TABLE; Schema: public; Owner: -
--

CREATE TABLE public.materialflowresources_stocktaking (
    id bigint NOT NULL,
    number character varying(255),
    stocktakingdate date,
    generationdate timestamp without time zone,
    category character varying(255),
    wastemode character varying(255) DEFAULT '01ALL'::character varying,
    storagelocationmode character varying(255) DEFAULT '01ALL'::character varying,
    location_id bigint,
    generated boolean DEFAULT false,
    filename character varying(255),
    active boolean DEFAULT true
);


--
-- Name: materialflowresources_stocktaking_id_seq; Type: SEQUENCE; Schema: public; Owner: -
--

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


--
-- Name: materialflowresources_stocktaking_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: -
--

ALTER SEQUENCE public.materialflowresources_stocktaking_id_seq OWNED BY public.materialflowresources_stocktaking.id;


--
-- Name: materialflowresources_storagelocation_id_seq; Type: SEQUENCE; Schema: public; Owner: -
--

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


--
-- Name: materialflowresources_storagelocation_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: -
--

ALTER SEQUENCE public.materialflowresources_storagelocation_id_seq OWNED BY public.materialflowresources_storagelocation.id;


--
-- Name: materialflowresources_storagelocationdto_internal; Type: VIEW; Schema: public; Owner: -
--

CREATE VIEW public.materialflowresources_storagelocationdto_internal AS
 SELECT location.number AS locationnumber,
    storagelocation.number AS storagelocationnumber,
    product.number AS productnumber,
    product.name AS productname,
    COALESCE(sum(resource.quantity), (0)::numeric) AS resourcequantity,
    product.unit AS productunit,
    COALESCE(sum(resource.quantityinadditionalunit), (0)::numeric) AS quantityinadditionalunit,
    COALESCE(product.additionalunit, product.unit) AS productadditionalunit,
    (location.id)::integer AS location_id
   FROM (((public.materialflowresources_storagelocation storagelocation
     JOIN public.materialflow_location location ON ((storagelocation.location_id = location.id)))
     LEFT JOIN public.materialflowresources_resource resource ON ((resource.storagelocation_id = storagelocation.id)))
     LEFT JOIN public.basic_product product ON ((product.id = resource.product_id)))
  WHERE (storagelocation.active = true)
  GROUP BY location.number, location.id, storagelocation.number, product.number, product.name, product.unit, COALESCE(product.additionalunit, product.unit);


--
-- Name: materialflowresources_storagelocationdto; Type: VIEW; Schema: public; Owner: -
--

CREATE VIEW public.materialflowresources_storagelocationdto AS
 SELECT row_number() OVER () AS id,
    internal.locationnumber,
    internal.storagelocationnumber,
    internal.productnumber,
    internal.productname,
    internal.resourcequantity,
    internal.productunit,
    internal.quantityinadditionalunit,
    internal.productadditionalunit,
    internal.location_id
   FROM public.materialflowresources_storagelocationdto_internal internal;


--
-- Name: materialflowresources_storagelocationdto_id_seq; Type: SEQUENCE; Schema: public; Owner: -
--

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


--
-- Name: materialflowresources_storagelocationhelper; Type: TABLE; Schema: public; Owner: -
--

CREATE TABLE public.materialflowresources_storagelocationhelper (
    id bigint NOT NULL,
    prefix character varying(255),
    number character varying(255),
    location_id bigint,
    placestoragelocation boolean DEFAULT false,
    numberofstoragelocations numeric(12,5),
    maximumnumberofpallets numeric(12,5),
    highstoragelocation boolean
);


--
-- Name: materialflowresources_storagelocationhelper_id_seq; Type: SEQUENCE; Schema: public; Owner: -
--

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


--
-- Name: materialflowresources_storagelocationhelper_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: -
--

ALTER SEQUENCE public.materialflowresources_storagelocationhelper_id_seq OWNED BY public.materialflowresources_storagelocationhelper.id;


--
-- Name: materialflowresources_storagelocationnumberhelper; Type: TABLE; Schema: public; Owner: -
--

CREATE TABLE public.materialflowresources_storagelocationnumberhelper (
    id bigint NOT NULL
);


--
-- Name: materialflowresources_storagelocationnumberhelper_id_seq; Type: SEQUENCE; Schema: public; Owner: -
--

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


--
-- Name: materialflowresources_storagelocationnumberhelper_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: -
--

ALTER SEQUENCE public.materialflowresources_storagelocationnumberhelper_id_seq OWNED BY public.materialflowresources_storagelocationnumberhelper.id;


--
-- Name: materialflowresources_warehousestock_id_seq; Type: SEQUENCE; Schema: public; Owner: -
--

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


--
-- Name: materialflowresources_warehousestocklistdto_id_seq; Type: SEQUENCE; Schema: public; Owner: -
--

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


--
-- Name: materialflowresources_warehousestocklistdto_internal_id_seq; Type: SEQUENCE; Schema: public; Owner: -
--

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


--
-- Name: materialflowresources_warehousestockreport; Type: TABLE; Schema: public; Owner: -
--

CREATE TABLE public.materialflowresources_warehousestockreport (
    id bigint NOT NULL,
    warehousestockdate date,
    generationdate timestamp without time zone,
    category character varying(255),
    wastemode character varying(255) DEFAULT '01ALL'::character varying,
    storagelocationmode character varying(255) DEFAULT '01ALL'::character varying,
    location_id bigint,
    generated boolean DEFAULT false,
    filename character varying(255),
    active boolean DEFAULT true
);


--
-- Name: materialflowresources_warehousestockreport_id_seq; Type: SEQUENCE; Schema: public; Owner: -
--

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


--
-- Name: materialflowresources_warehousestockreport_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: -
--

ALTER SEQUENCE public.materialflowresources_warehousestockreport_id_seq OWNED BY public.materialflowresources_warehousestockreport.id;


--
-- Name: materialrequirementcoveragefororder_columnforcoveragesfororder; Type: TABLE; Schema: public; Owner: -
--

CREATE TABLE public.materialrequirementcoveragefororder_columnforcoveragesfororder (
    id bigint NOT NULL,
    identifier character varying(255),
    name character varying(1024),
    description character varying(1024),
    columnfiller character varying(255),
    alignment character varying(255) DEFAULT '01left'::character varying,
    succession integer,
    entityversion bigint DEFAULT 0
);


--
-- Name: materialrequirementcoveragefororder_columnforcoveragesfororder_; Type: SEQUENCE; Schema: public; Owner: -
--

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


--
-- Name: materialrequirementcoveragefororder_columnforcoveragesfororder_; Type: SEQUENCE OWNED BY; Schema: public; Owner: -
--

ALTER SEQUENCE public.materialrequirementcoveragefororder_columnforcoveragesfororder_ OWNED BY public.materialrequirementcoveragefororder_columnforcoveragesfororder.id;


--
-- Name: materialrequirementcoveragefororder_coveragefororder; Type: TABLE; Schema: public; Owner: -
--

CREATE TABLE public.materialrequirementcoveragefororder_coveragefororder (
    id bigint NOT NULL,
    number character varying(255),
    coveragetodate timestamp without time zone,
    actualdate timestamp without time zone,
    generateddate timestamp without time zone,
    generatedby character varying(255),
    generated boolean,
    saved boolean,
    filename character varying(1024),
    coveragetype character varying(255) DEFAULT '01all'::character varying,
    includedraftdeliveries boolean,
    order_id bigint,
    createdate timestamp without time zone,
    updatedate timestamp without time zone,
    createuser character varying(255),
    updateuser character varying(255),
    generatedorders boolean,
    entityversion bigint DEFAULT 0
);


--
-- Name: materialrequirementcoveragefororder_coveragefororder_id_seq; Type: SEQUENCE; Schema: public; Owner: -
--

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


--
-- Name: materialrequirementcoveragefororder_coveragefororder_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: -
--

ALTER SEQUENCE public.materialrequirementcoveragefororder_coveragefororder_id_seq OWNED BY public.materialrequirementcoveragefororder_coveragefororder.id;


--
-- Name: materialrequirementcoveragefororder_coveragelocation; Type: TABLE; Schema: public; Owner: -
--

CREATE TABLE public.materialrequirementcoveragefororder_coveragelocation (
    id bigint NOT NULL,
    coveragefororder_id bigint,
    location_id bigint,
    parameter_id bigint,
    entityversion bigint DEFAULT 0
);


--
-- Name: materialrequirementcoveragefororder_coveragelocation_id_seq; Type: SEQUENCE; Schema: public; Owner: -
--

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


--
-- Name: materialrequirementcoveragefororder_coveragelocation_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: -
--

ALTER SEQUENCE public.materialrequirementcoveragefororder_coveragelocation_id_seq OWNED BY public.materialrequirementcoveragefororder_coveragelocation.id;


--
-- Name: materialrequirementcoveragefororder_coverageproduct; Type: TABLE; Schema: public; Owner: -
--

CREATE TABLE public.materialrequirementcoveragefororder_coverageproduct (
    id bigint NOT NULL,
    coveragefororder_id bigint,
    product_id bigint,
    lackfromdate timestamp without time zone,
    demandquantity numeric(12,5),
    coveredquantity numeric(12,5),
    reservemissingquantity numeric(12,5),
    deliveredquantity numeric(12,5),
    locationsquantity numeric(12,5),
    state character varying(255),
    ispurchased boolean DEFAULT false,
    issubcontracted boolean DEFAULT false,
    producttype character varying(255),
    order_id bigint,
    planedquantity numeric(12,5),
    entityversion bigint DEFAULT 0
);


--
-- Name: materialrequirementcoveragefororder_coverageproduct_id_seq; Type: SEQUENCE; Schema: public; Owner: -
--

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


--
-- Name: materialrequirementcoveragefororder_coverageproduct_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: -
--

ALTER SEQUENCE public.materialrequirementcoveragefororder_coverageproduct_id_seq OWNED BY public.materialrequirementcoveragefororder_coverageproduct.id;


--
-- Name: materialrequirements_materialrequirement; Type: TABLE; Schema: public; Owner: -
--

CREATE TABLE public.materialrequirements_materialrequirement (
    id bigint NOT NULL,
    name character varying(1024),
    number character varying(256),
    date timestamp without time zone,
    worker character varying(255),
    mrpalgorithm character varying(255) DEFAULT '01onlyComponents'::character varying,
    generated boolean,
    filename character varying(255),
    active boolean DEFAULT true,
    entityversion bigint DEFAULT 0,
    includewarehouse boolean DEFAULT false,
    showcurrentstocklevel boolean DEFAULT false,
    includestartdateorder boolean DEFAULT false,
    location_id bigint
);


--
-- Name: materialrequirements_materialrequirement_id_seq; Type: SEQUENCE; Schema: public; Owner: -
--

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


--
-- Name: materialrequirements_materialrequirement_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: -
--

ALTER SEQUENCE public.materialrequirements_materialrequirement_id_seq OWNED BY public.materialrequirements_materialrequirement.id;


--
-- Name: materialrequirements_materialrequirementproduct; Type: TABLE; Schema: public; Owner: -
--

CREATE TABLE public.materialrequirements_materialrequirementproduct (
    id bigint NOT NULL,
    materialrequirement_id bigint,
    product_id bigint,
    location_id bigint,
    quantity numeric(14,5),
    currentstock numeric(14,5),
    orderstartdate date,
    batch_id bigint,
    batchstock numeric(14,5)
);


--
-- Name: materialrequirements_materialrequirementproduct_id_seq; Type: SEQUENCE; Schema: public; Owner: -
--

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


--
-- Name: materialrequirements_materialrequirementproduct_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: -
--

ALTER SEQUENCE public.materialrequirements_materialrequirementproduct_id_seq OWNED BY public.materialrequirements_materialrequirementproduct.id;


--
-- Name: mobilewms_wmsdocumentpart; Type: TABLE; Schema: public; Owner: -
--

CREATE TABLE public.mobilewms_wmsdocumentpart (
    id bigint NOT NULL,
    number character varying(255),
    part integer,
    company character varying(255),
    stateinwms character varying(255),
    pickingworker character varying(255),
    document_id bigint,
    parts integer,
    type character varying(255) NOT NULL,
    documentdate timestamp without time zone
);


--
-- Name: mobilewms_wmsdocumentpart_id_seq; Type: SEQUENCE; Schema: public; Owner: -
--

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


--
-- Name: mobilewms_wmsdocumentpart_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: -
--

ALTER SEQUENCE public.mobilewms_wmsdocumentpart_id_seq OWNED BY public.mobilewms_wmsdocumentpart.id;


--
-- Name: model_card_number_seq; Type: SEQUENCE; Schema: public; Owner: -
--

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


--
-- Name: technologiesgenerator_generatorcontext; Type: TABLE; Schema: public; Owner: -
--

CREATE TABLE public.technologiesgenerator_generatorcontext (
    id bigint NOT NULL,
    technology_id bigint,
    product_id bigint,
    fetchtechnologiesforcomponents boolean DEFAULT true,
    createandswapproducts boolean DEFAULT true,
    createdate timestamp without time zone,
    updatedate timestamp without time zone,
    createuser character varying(255),
    updateuser character varying(255),
    generated boolean DEFAULT false,
    entityversion bigint DEFAULT 0,
    saved boolean DEFAULT true,
    generationinprogress boolean DEFAULT false,
    number character varying(255)
);


--
-- Name: productioncounting_performanceanalysisdetaildto; Type: VIEW; Schema: public; Owner: -
--

CREATE VIEW public.productioncounting_performanceanalysisdetaildto AS
 SELECT productiontracking.id,
    productiontracking.active,
    (productionline.id)::integer AS productionline_id,
    productionline.number AS productionlinenumber,
    (staff.id)::integer AS staff_id,
    (((staff.surname)::text || ' '::text) || (staff.name)::text) AS staffname,
    (assortment.id)::integer AS assortment_id,
    assortment.name AS assortmentname,
    (product.id)::integer AS product_id,
    product.number AS productnumber,
    product.name AS productname,
    product.unit AS productunit,
    size.number AS sizenumber,
    tpl.standardperformance AS performancenorm,
    ((COALESCE(trackingoperationproductoutcomponent.usedquantity, (0)::numeric) + COALESCE(trackingoperationproductoutcomponent.wastesquantity, (0)::numeric)))::numeric(14,5) AS donequantity,
    ((((COALESCE(trackingoperationproductoutcomponent.usedquantity, (0)::numeric) + COALESCE(trackingoperationproductoutcomponent.wastesquantity, (0)::numeric)) * (60)::numeric) / tpl.standardperformance))::integer AS timebasedonnorms,
    (shift.id)::integer AS shift_id,
    shift.name AS shiftname,
    productiontracking.timerangefrom,
    productiontracking.timerangeto,
    (ordersorder.id)::integer AS order_id,
    ordersorder.number AS ordernumber,
    (tcontext.id)::integer AS generator_id,
    tcontext.number AS generatorname,
    COALESCE(productiontracking.shiftstartday, (productiontracking.timerangefrom)::date) AS timerangefromwithouttime,
    (productiontracking.timerangeto)::date AS timerangetowithouttime,
    date_part('epoch'::text, (productiontracking.timerangeto - productiontracking.timerangefrom)) AS labortimesum
   FROM (((((((((((public.productioncounting_productiontracking productiontracking
     LEFT JOIN public.orders_order ordersorder ON ((ordersorder.id = productiontracking.order_id)))
     LEFT JOIN public.productionlines_productionline productionline ON ((productionline.id = ordersorder.productionline_id)))
     LEFT JOIN public.basic_staff staff ON ((staff.id = productiontracking.staff_id)))
     LEFT JOIN public.productioncounting_trackingoperationproductoutcomponent trackingoperationproductoutcomponent ON ((trackingoperationproductoutcomponent.productiontracking_id = productiontracking.id)))
     LEFT JOIN public.basic_product product ON ((product.id = trackingoperationproductoutcomponent.product_id)))
     LEFT JOIN public.basic_assortment assortment ON ((assortment.id = product.assortment_id)))
     LEFT JOIN public.basic_size size ON ((size.id = product.size_id)))
     LEFT JOIN public.technologies_technologyproductionline tpl ON (((tpl.technology_id = ordersorder.technology_id) AND tpl.master)))
     LEFT JOIN public.basic_shift shift ON ((shift.id = productiontracking.shift_id)))
     LEFT JOIN public.technologies_technology technologyprototype ON ((ordersorder.technology_id = technologyprototype.id)))
     LEFT JOIN public.technologiesgenerator_generatorcontext tcontext ON ((tcontext.id = technologyprototype.generatorcontext_id)))
  WHERE ((productiontracking.state)::text = ANY (ARRAY[('01draft'::character varying)::text, ('02accepted'::character varying)::text]))
UNION ALL
 SELECT productiontracking.id,
    productiontracking.active,
    (productionline.id)::integer AS productionline_id,
    productionline.number AS productionlinenumber,
    (staff.id)::integer AS staff_id,
    (((staff.surname)::text || ' '::text) || (staff.name)::text) AS staffname,
    (assortment.id)::integer AS assortment_id,
    assortment.name AS assortmentname,
    (product.id)::integer AS product_id,
    product.number AS productnumber,
    product.name AS productname,
    product.unit AS productunit,
    size.number AS sizenumber,
    tpl.standardperformance AS performancenorm,
    ((COALESCE(trackingoperationproductoutcomponent.usedquantity, (0)::numeric) + COALESCE(trackingoperationproductoutcomponent.wastesquantity, (0)::numeric)))::numeric(14,5) AS donequantity,
    ((((COALESCE(trackingoperationproductoutcomponent.usedquantity, (0)::numeric) + COALESCE(trackingoperationproductoutcomponent.wastesquantity, (0)::numeric)) * (60)::numeric) / tpl.standardperformance))::integer AS timebasedonnorms,
    (shift.id)::integer AS shift_id,
    shift.name AS shiftname,
    productiontracking.timerangefrom,
    productiontracking.timerangeto,
    (ordersorder.id)::integer AS order_id,
    ordersorder.number AS ordernumber,
    (tcontext.id)::integer AS generator_id,
    tcontext.number AS generatorname,
    COALESCE(productiontracking.shiftstartday, (productiontracking.timerangefrom)::date) AS timerangefromwithouttime,
    (productiontracking.timerangeto)::date AS timerangetowithouttime,
    date_part('epoch'::text, (productiontracking.timerangeto - productiontracking.timerangefrom)) AS labortimesum
   FROM (((((((((((public.arch_productioncounting_productiontracking productiontracking
     LEFT JOIN public.arch_orders_order ordersorder ON ((ordersorder.id = productiontracking.order_id)))
     LEFT JOIN public.productionlines_productionline productionline ON ((productionline.id = ordersorder.productionline_id)))
     LEFT JOIN public.basic_staff staff ON ((staff.id = productiontracking.staff_id)))
     LEFT JOIN public.arch_productioncounting_trackingoperationproductoutcomponent trackingoperationproductoutcomponent ON ((trackingoperationproductoutcomponent.productiontracking_id = productiontracking.id)))
     LEFT JOIN public.basic_product product ON ((product.id = trackingoperationproductoutcomponent.product_id)))
     LEFT JOIN public.basic_assortment assortment ON ((assortment.id = product.assortment_id)))
     LEFT JOIN public.basic_size size ON ((size.id = product.size_id)))
     LEFT JOIN public.technologies_technologyproductionline tpl ON (((tpl.technology_id = ordersorder.technology_id) AND tpl.master)))
     LEFT JOIN public.basic_shift shift ON ((shift.id = productiontracking.shift_id)))
     LEFT JOIN public.technologies_technology technologyprototype ON ((ordersorder.technology_id = technologyprototype.id)))
     LEFT JOIN public.technologiesgenerator_generatorcontext tcontext ON ((tcontext.id = technologyprototype.generatorcontext_id)))
  WHERE ((productiontracking.state)::text = ANY (ARRAY[('01draft'::character varying)::text, ('02accepted'::character varying)::text]));


--
-- Name: productioncounting_performanceanalysislabortimesumdto_helper; Type: VIEW; Schema: public; Owner: -
--

CREATE VIEW public.productioncounting_performanceanalysislabortimesumdto_helper AS
 SELECT performanceanalysisdetaildto.staff_id,
    performanceanalysisdetaildto.timerangefromwithouttime,
        CASE
            WHEN (min(performanceanalysisdetaildto.labortimesum) <> max(performanceanalysisdetaildto.labortimesum)) THEN (0)::double precision
            ELSE min(performanceanalysisdetaildto.labortimesum)
        END AS labortimesum
   FROM public.productioncounting_performanceanalysisdetaildto performanceanalysisdetaildto
  GROUP BY performanceanalysisdetaildto.staff_id, performanceanalysisdetaildto.timerangefromwithouttime, performanceanalysisdetaildto.shift_id, performanceanalysisdetaildto.productionline_id;


--
-- Name: productioncounting_performanceanalysisdto_helper; Type: VIEW; Schema: public; Owner: -
--

CREATE VIEW public.productioncounting_performanceanalysisdto_helper AS
 SELECT
        CASE
            WHEN (min(helper.labortimesum) = (0)::double precision) THEN (0)::numeric
            ELSE ((((sub.dailyperformance)::numeric)::double precision / sum(helper.labortimesum)))::numeric(14,2)
        END AS dailyperformance,
    sub.productionlinequantity,
    sub.staff_id,
    sub.timerangefromwithouttime
   FROM (( SELECT (100 * sum(performanceanalysisdetaildto.timebasedonnorms)) AS dailyperformance,
            count(DISTINCT performanceanalysisdetaildto.productionline_id) AS productionlinequantity,
            performanceanalysisdetaildto.staff_id,
            performanceanalysisdetaildto.timerangefromwithouttime
           FROM public.productioncounting_performanceanalysisdetaildto performanceanalysisdetaildto
          GROUP BY performanceanalysisdetaildto.staff_id, performanceanalysisdetaildto.timerangefromwithouttime) sub
     LEFT JOIN public.productioncounting_performanceanalysislabortimesumdto_helper helper ON (((helper.staff_id = sub.staff_id) AND (helper.timerangefromwithouttime = sub.timerangefromwithouttime))))
  GROUP BY sub.staff_id, sub.timerangefromwithouttime, sub.productionlinequantity, sub.dailyperformance;


--
-- Name: mv_productioncounting_performanceanalysisdto; Type: MATERIALIZED VIEW; Schema: public; Owner: -
--

CREATE MATERIALIZED VIEW public.mv_productioncounting_performanceanalysisdto AS
 SELECT row_number() OVER () AS id,
    bool_or(performanceanalysisdetaildto.active) AS active,
    performanceanalysisdetaildto.productionline_id,
    performanceanalysisdetaildto.productionlinenumber,
    performanceanalysisdetaildto.staff_id,
    performanceanalysisdetaildto.staffname,
    COALESCE((sum(performanceanalysisdetaildto.timebasedonnorms))::integer, 0) AS timebasedonnormssum,
        CASE
            WHEN (min(performanceanalysisdetaildto.labortimesum) <> max(performanceanalysisdetaildto.labortimesum)) THEN 0
            ELSE (min(performanceanalysisdetaildto.labortimesum))::integer
        END AS labortimesum,
        CASE
            WHEN (min(performanceanalysisdetaildto.labortimesum) <> max(performanceanalysisdetaildto.labortimesum)) THEN (COALESCE(sum(performanceanalysisdetaildto.timebasedonnorms), (0)::bigint))::integer
            ELSE (((COALESCE((sum(performanceanalysisdetaildto.timebasedonnorms))::integer, 0))::double precision - min(performanceanalysisdetaildto.labortimesum)))::integer
        END AS timedeviation,
        CASE
            WHEN (min(performanceanalysisdetaildto.labortimesum) <> max(performanceanalysisdetaildto.labortimesum)) THEN (0)::numeric
            ELSE (((((100)::numeric * (sum(performanceanalysisdetaildto.timebasedonnorms))::numeric))::double precision / min(performanceanalysisdetaildto.labortimesum)))::numeric(14,2)
        END AS performance,
    performanceanalysisdetaildto.shift_id,
    performanceanalysisdetaildto.shiftname,
    performanceanalysisdetaildto.timerangefromwithouttime AS timerangefrom,
    performanceanalysisdetaildto.timerangetowithouttime AS timerangeto,
    sum(performanceanalysisdetaildto.donequantity) AS donequantity,
    (min(helper.productionlinequantity))::integer AS productionlinequantity,
    (count(DISTINCT performanceanalysisdetaildto.assortment_id))::integer AS assortmentquantity,
    (min(helper.dailyperformance))::numeric(14,2) AS dailyperformance
   FROM (public.productioncounting_performanceanalysisdetaildto performanceanalysisdetaildto
     LEFT JOIN public.productioncounting_performanceanalysisdto_helper helper ON (((performanceanalysisdetaildto.staff_id = helper.staff_id) AND (performanceanalysisdetaildto.timerangefromwithouttime = helper.timerangefromwithouttime))))
  GROUP BY performanceanalysisdetaildto.productionline_id, performanceanalysisdetaildto.productionlinenumber, performanceanalysisdetaildto.staff_id, performanceanalysisdetaildto.staffname, performanceanalysisdetaildto.shift_id, performanceanalysisdetaildto.shiftname, performanceanalysisdetaildto.timerangefromwithouttime, performanceanalysisdetaildto.timerangetowithouttime
  WITH NO DATA;


--
-- Name: number_pattern_number_seq; Type: SEQUENCE; Schema: public; Owner: -
--

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


--
-- Name: nutritionfacts_nutrientcalculation; Type: TABLE; Schema: public; Owner: -
--

CREATE TABLE public.nutritionfacts_nutrientcalculation (
    id bigint NOT NULL,
    product_id bigint,
    productportion numeric(12,5),
    formatue boolean DEFAULT true,
    formatusa boolean DEFAULT true,
    generated boolean,
    entityversion bigint DEFAULT 0
);


--
-- Name: nutritionfacts_nutrientcalculation_id_seq; Type: SEQUENCE; Schema: public; Owner: -
--

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


--
-- Name: nutritionfacts_nutrientcalculation_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: -
--

ALTER SEQUENCE public.nutritionfacts_nutrientcalculation_id_seq OWNED BY public.nutritionfacts_nutrientcalculation.id;


--
-- Name: nutritionfacts_nutrition; Type: TABLE; Schema: public; Owner: -
--

CREATE TABLE public.nutritionfacts_nutrition (
    id bigint NOT NULL,
    name character varying(255),
    nameen character varying(255),
    unit character varying(255),
    nutritiongroup_id bigint,
    priority integer,
    rwsvalue numeric(12,5),
    reportue boolean DEFAULT true,
    dvvalue numeric(12,5),
    entityversion bigint DEFAULT 0
);


--
-- Name: nutritionfacts_nutrition_id_seq; Type: SEQUENCE; Schema: public; Owner: -
--

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


--
-- Name: nutritionfacts_nutrition_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: -
--

ALTER SEQUENCE public.nutritionfacts_nutrition_id_seq OWNED BY public.nutritionfacts_nutrition.id;


--
-- Name: nutritionfacts_nutritionelement; Type: TABLE; Schema: public; Owner: -
--

CREATE TABLE public.nutritionfacts_nutritionelement (
    id bigint NOT NULL,
    nutrition_id bigint,
    quantity numeric(12,5),
    product_id bigint,
    prototypeproduct_id bigint,
    entityversion bigint DEFAULT 0
);


--
-- Name: nutritionfacts_nutritionelement_id_seq; Type: SEQUENCE; Schema: public; Owner: -
--

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


--
-- Name: nutritionfacts_nutritionelement_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: -
--

ALTER SEQUENCE public.nutritionfacts_nutritionelement_id_seq OWNED BY public.nutritionfacts_nutritionelement.id;


--
-- Name: nutritionfacts_nutritiongroup; Type: TABLE; Schema: public; Owner: -
--

CREATE TABLE public.nutritionfacts_nutritiongroup (
    id bigint NOT NULL,
    name character varying(255),
    priority integer,
    rws character varying(255) DEFAULT '02drws'::character varying,
    entityversion bigint DEFAULT 0
);


--
-- Name: nutritionfacts_nutritiongroup_id_seq; Type: SEQUENCE; Schema: public; Owner: -
--

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


--
-- Name: nutritionfacts_nutritiongroup_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: -
--

ALTER SEQUENCE public.nutritionfacts_nutritiongroup_id_seq OWNED BY public.nutritionfacts_nutritiongroup.id;


--
-- Name: nutritionfacts_prototypeproduct; Type: TABLE; Schema: public; Owner: -
--

CREATE TABLE public.nutritionfacts_prototypeproduct (
    id bigint NOT NULL,
    name character varying(255),
    number character varying(255),
    status character varying(255) DEFAULT '01draft'::character varying,
    createdate timestamp without time zone,
    updatedate timestamp without time zone,
    createuser character varying(255),
    updateuser character varying(255),
    generated boolean,
    productportion numeric(12,5),
    entityversion bigint DEFAULT 0
);


--
-- Name: nutritionfacts_prototypeproduct_id_seq; Type: SEQUENCE; Schema: public; Owner: -
--

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


--
-- Name: nutritionfacts_prototypeproduct_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: -
--

ALTER SEQUENCE public.nutritionfacts_prototypeproduct_id_seq OWNED BY public.nutritionfacts_prototypeproduct.id;


--
-- Name: nutritionfacts_prototypeproductcomponent; Type: TABLE; Schema: public; Owner: -
--

CREATE TABLE public.nutritionfacts_prototypeproductcomponent (
    id bigint NOT NULL,
    prototypeproduct_id bigint,
    quantity numeric(12,5),
    product_id bigint,
    entityversion bigint DEFAULT 0
);


--
-- Name: nutritionfacts_prototypeproductcomponent_id_seq; Type: SEQUENCE; Schema: public; Owner: -
--

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


--
-- Name: nutritionfacts_prototypeproductcomponent_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: -
--

ALTER SEQUENCE public.nutritionfacts_prototypeproductcomponent_id_seq OWNED BY public.nutritionfacts_prototypeproductcomponent.id;


--
-- Name: oee_oee; Type: TABLE; Schema: public; Owner: -
--

CREATE TABLE public.oee_oee (
    id bigint NOT NULL,
    datefrom date,
    dateto date,
    oeefor character varying(255) DEFAULT '01productionLine'::character varying,
    oeepercent numeric(12,5),
    generated boolean,
    date timestamp without time zone,
    worker character varying(255),
    active boolean DEFAULT true,
    createdate timestamp without time zone,
    updatedate timestamp without time zone,
    createuser character varying(255),
    updateuser character varying(255)
);


--
-- Name: oee_oee_id_seq; Type: SEQUENCE; Schema: public; Owner: -
--

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


--
-- Name: oee_oee_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: -
--

ALTER SEQUENCE public.oee_oee_id_seq OWNED BY public.oee_oee.id;


--
-- Name: oee_oeevalue; Type: TABLE; Schema: public; Owner: -
--

CREATE TABLE public.oee_oeevalue (
    id bigint NOT NULL,
    oee_id bigint,
    productionline_id bigint,
    workstation_id bigint,
    totalavailabletime integer,
    effectivetime integer,
    oeepercent numeric(12,5)
);


--
-- Name: oee_oeevalue_id_seq; Type: SEQUENCE; Schema: public; Owner: -
--

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


--
-- Name: oee_oeevalue_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: -
--

ALTER SEQUENCE public.oee_oeevalue_id_seq OWNED BY public.oee_oeevalue.id;


--
-- Name: oee_productionlinedto; Type: VIEW; Schema: public; Owner: -
--

CREATE VIEW public.oee_productionlinedto AS
 SELECT productionline.id,
    productionline.number,
    productionline.name,
    productionline.active,
    string_agg((division.number)::text, ', '::text) AS divisions
   FROM ((public.productionlines_productionline productionline
     LEFT JOIN public.jointable_division_productionline division_productionline ON ((division_productionline.productionline_id = productionline.id)))
     LEFT JOIN public.basic_division division ON ((division.id = division_productionline.division_id)))
  GROUP BY productionline.id, productionline.number, productionline.name, productionline.active;


--
-- Name: oee_productionlinedto_id_seq; Type: SEQUENCE; Schema: public; Owner: -
--

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


--
-- Name: oee_workstationdto; Type: VIEW; Schema: public; Owner: -
--

CREATE VIEW public.oee_workstationdto AS
 SELECT workstation.id,
    workstation.number,
    workstation.name,
    workstation.active,
    productionline.number AS productionlinenumber,
    string_agg((division.number)::text, ', '::text) AS divisions
   FROM (((public.basic_workstation workstation
     LEFT JOIN public.productionlines_productionline productionline ON ((productionline.id = workstation.productionline_id)))
     LEFT JOIN public.jointable_division_productionline division_productionline ON ((division_productionline.productionline_id = productionline.id)))
     LEFT JOIN public.basic_division division ON ((division.id = division_productionline.division_id)))
  GROUP BY workstation.id, workstation.number, workstation.name, workstation.active, productionline.number;


--
-- Name: oee_workstationdto_id_seq; Type: SEQUENCE; Schema: public; Owner: -
--

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


--
-- Name: orders_changedateshelper; Type: TABLE; Schema: public; Owner: -
--

CREATE TABLE public.orders_changedateshelper (
    id bigint NOT NULL,
    datefrom timestamp without time zone,
    dateto timestamp without time zone,
    commentreasontypecorrectiondatefrom character varying(255),
    commentreasontypecorrectiondateto character varying(255),
    ids character varying(255),
    orderids character varying(255)
);


--
-- Name: orders_changedateshelper_id_seq; Type: SEQUENCE; Schema: public; Owner: -
--

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


--
-- Name: orders_changedateshelper_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: -
--

ALTER SEQUENCE public.orders_changedateshelper_id_seq OWNED BY public.orders_changedateshelper.id;


--
-- Name: orders_dimensioncontrolattribute; Type: TABLE; Schema: public; Owner: -
--

CREATE TABLE public.orders_dimensioncontrolattribute (
    id bigint NOT NULL,
    parameter_id bigint,
    attribute_id bigint
);


--
-- Name: orders_dimensioncontrolattribute_id_seq; Type: SEQUENCE; Schema: public; Owner: -
--

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


--
-- Name: orders_dimensioncontrolattribute_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: -
--

ALTER SEQUENCE public.orders_dimensioncontrolattribute_id_seq OWNED BY public.orders_dimensioncontrolattribute.id;


--
-- Name: orders_group_material_requirement_number_seq; Type: SEQUENCE; Schema: public; Owner: -
--

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


--
-- Name: orders_group_production_balance_number_seq; Type: SEQUENCE; Schema: public; Owner: -
--

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


--
-- Name: orders_operational_task_number_seq; Type: SEQUENCE; Schema: public; Owner: -
--

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


--
-- Name: orders_operationaltask_id_seq; Type: SEQUENCE; Schema: public; Owner: -
--

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


--
-- Name: orders_operationaltask_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: -
--

ALTER SEQUENCE public.orders_operationaltask_id_seq OWNED BY public.orders_operationaltask.id;


--
-- Name: orders_operationaltaskdto; Type: VIEW; Schema: public; Owner: -
--

CREATE VIEW public.orders_operationaltaskdto AS
 SELECT operationaltask.id,
    operationaltask.number,
    operationaltask.name,
    operationaltask.description,
    operationaltask.type,
    operationaltask.state,
    operationaltask.startdate,
    operationaltask.finishdate,
    operationaltask.actualstaff,
    (((staff.surname)::text || ' '::text) || (staff.name)::text) AS staffname,
    division.number AS divisionnumber,
    productionline.number AS productionlinenumber,
    workstation.number AS workstationnumber,
    (workstation.id)::integer AS workstationid,
    (ordersorder.id)::integer AS orderid,
    ordersorder.number AS ordernumber,
    (technologyoperationcomponent.id)::integer AS tocid,
    (technologyoperationcomponent.operation_id)::integer AS operationid,
    technologyoperationcomponent.nodenumber AS technologyoperationcomponentnodenumber,
    technologyoperationcomponent.issubcontracting AS technologyoperationcomponentissubcontracting,
    (product.number)::text AS productnumber,
    (product.name)::text AS productname,
    (product.unit)::text AS productunit,
    NULL::numeric AS plannedquantity,
    NULL::numeric AS usedquantity,
    NULL::numeric AS remainingquantity,
    NULL::numeric AS doneinpercentage,
    NULL::integer AS suborderid
   FROM (((((((public.orders_operationaltask operationaltask
     LEFT JOIN public.basic_staff staff ON ((staff.id = operationaltask.staff_id)))
     LEFT JOIN public.basic_division division ON ((operationaltask.division_id = division.id)))
     LEFT JOIN public.basic_workstation workstation ON ((workstation.id = operationaltask.workstation_id)))
     LEFT JOIN public.orders_order ordersorder ON ((ordersorder.id = operationaltask.order_id)))
     LEFT JOIN public.technologies_technologyoperationcomponent technologyoperationcomponent ON ((technologyoperationcomponent.id = operationaltask.technologyoperationcomponent_id)))
     LEFT JOIN public.basic_product product ON ((product.id = operationaltask.product_id)))
     LEFT JOIN public.productionlines_productionline productionline ON ((productionline.id = workstation.productionline_id)))
  WHERE ((operationaltask.type)::text = '01otherCase'::text)
UNION ALL
 SELECT operationaltask.id,
    operationaltask.number,
    operationaltask.name,
    operationaltask.description,
    operationaltask.type,
    operationaltask.state,
    operationaltask.startdate,
    operationaltask.finishdate,
    operationaltask.actualstaff,
    (((staff.surname)::text || ' '::text) || (staff.name)::text) AS staffname,
    division.number AS divisionnumber,
    productionline.number AS productionlinenumber,
    workstation.number AS workstationnumber,
    (workstation.id)::integer AS workstationid,
    (ordersorder.id)::integer AS orderid,
    ordersorder.number AS ordernumber,
    (technologyoperationcomponent.id)::integer AS tocid,
    (technologyoperationcomponent.operation_id)::integer AS operationid,
    technologyoperationcomponent.nodenumber AS technologyoperationcomponentnodenumber,
    technologyoperationcomponent.issubcontracting AS technologyoperationcomponentissubcontracting,
    (product.number)::text AS productnumber,
    (product.name)::text AS productname,
    (product.unit)::text AS productunit,
    productioncountingquantitydto.plannedquantity,
    GREATEST(productioncountingquantitydto.producedquantity, (0)::numeric) AS usedquantity,
    GREATEST((COALESCE(productioncountingquantitydto.plannedquantity, (0)::numeric) - COALESCE(productioncountingquantitydto.producedquantity, (0)::numeric)), (0)::numeric) AS remainingquantity,
    ceil(((COALESCE(productioncountingquantitydto.producedquantity, (0)::numeric) * (100)::numeric) / productioncountingquantitydto.plannedquantity)) AS doneinpercentage,
    (operationaltask.suborder_id)::integer AS suborderid
   FROM ((((((((public.orders_operationaltask operationaltask
     LEFT JOIN public.basic_staff staff ON ((staff.id = operationaltask.staff_id)))
     LEFT JOIN public.basic_division division ON ((operationaltask.division_id = division.id)))
     LEFT JOIN public.basic_workstation workstation ON ((workstation.id = operationaltask.workstation_id)))
     LEFT JOIN public.orders_order ordersorder ON ((ordersorder.id = operationaltask.order_id)))
     LEFT JOIN public.technologies_technologyoperationcomponent technologyoperationcomponent ON ((technologyoperationcomponent.id = operationaltask.technologyoperationcomponent_id)))
     LEFT JOIN public.basic_product product ON ((product.id = operationaltask.product_id)))
     LEFT JOIN public.productionlines_productionline productionline ON ((productionline.id = workstation.productionline_id)))
     LEFT JOIN public.basicproductioncounting_productioncountingquantitydto productioncountingquantitydto ON (((productioncountingquantitydto.orderid = ordersorder.id) AND (productioncountingquantitydto.tocid = technologyoperationcomponent.id) AND ((productioncountingquantitydto.role)::text = '02produced'::text) AND (((productioncountingquantitydto.typeofmaterial)::text = '02intermediate'::text) OR ((productioncountingquantitydto.typeofmaterial)::text = '03finalProduct'::text)))))
  WHERE ((operationaltask.type)::text = '02executionOperationInOrder'::text);


--
-- Name: orders_operationaltaskdto_id_seq; Type: SEQUENCE; Schema: public; Owner: -
--

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


--
-- Name: orders_operationaltaskstatechange; Type: TABLE; Schema: public; Owner: -
--

CREATE TABLE public.orders_operationaltaskstatechange (
    id bigint NOT NULL,
    dateandtime timestamp without time zone,
    sourcestate character varying(255),
    targetstate character varying(255),
    status character varying(255),
    phase integer,
    worker character varying(255),
    operationaltask_id bigint,
    shift_id bigint
);


--
-- Name: orders_operationaltaskstatechange_id_seq; Type: SEQUENCE; Schema: public; Owner: -
--

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


--
-- Name: orders_operationaltaskstatechange_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: -
--

ALTER SEQUENCE public.orders_operationaltaskstatechange_id_seq OWNED BY public.orders_operationaltaskstatechange.id;


--
-- Name: orders_workstationchangeoverforoperationaltask; Type: TABLE; Schema: public; Owner: -
--

CREATE TABLE public.orders_workstationchangeoverforoperationaltask (
    id bigint NOT NULL,
    number character varying(255),
    name character varying(1024),
    description character varying(2048),
    workstation_id bigint,
    currentoperationaltask_id bigint,
    previousoperationaltask_id bigint,
    changeovertype character varying(255) DEFAULT '01anyChange'::character varying,
    workstationchangeovernorm_id bigint,
    attribute_id bigint,
    fromattributevalue_id bigint,
    toattributevalue_id bigint,
    startdate timestamp without time zone,
    finishdate timestamp without time zone,
    duration integer,
    isparallel boolean
);


--
-- Name: orders_operationaltaskwithcolordto; Type: VIEW; Schema: public; Owner: -
--

CREATE VIEW public.orders_operationaltaskwithcolordto AS
 WITH operational_task_staff AS (
         SELECT jos.operationaltask_id,
            string_agg((((staff.surname)::text || ' '::text) || (staff.name)::text), ', '::text) AS staffname
           FROM (public.jointable_operationaltask_staff jos
             JOIN public.basic_staff staff ON ((jos.staff_id = staff.id)))
          GROUP BY jos.operationaltask_id
        )
 SELECT operationaltask.id,
    operationaltask.number,
    operationaltask.name,
    operationaltask.description,
    operationaltask.type,
    operationaltask.state,
    operationaltask.startdate,
    operationaltask.finishdate,
    ots.staffname,
    division.number AS divisionnumber,
    (workstation.id)::integer AS workstationid,
    workstation.number AS workstationnumber,
    (ordersorder.id)::integer AS orderid,
    ordersorder.number AS ordernumber,
    (technologyoperationcomponent.id)::integer AS tocid,
    technologyoperationcomponent.nodenumber AS technologyoperationcomponentnodenumber,
    technologyoperationcomponent.issubcontracting AS technologyoperationcomponentissubcontracting,
    (product.number)::text AS productnumber,
    (product.name)::text AS productname,
    NULL::text AS productunit,
    NULL::numeric AS plannedquantity,
    NULL::numeric AS usedquantity,
    NULL::numeric AS remainingquantity,
    NULL::numeric AS doneinpercentage,
    NULL::numeric AS opertaskflagpercentexecutionwithcolor,
    NULL::character varying AS percentageofexecutioncellcolor,
    (orderproduct.number)::text AS orderproductnumber,
    (orderproduct.name)::text AS orderproductname,
    operationaltask.actualstaff,
    NULL::numeric AS wastesquantity,
    NULL::integer AS suborder_id,
    NULL::text AS subordernumber,
    (count(workstationchangeoverforoperationaltask.id) <> 0) AS haschangeovers
   FROM ((((((((public.orders_operationaltask operationaltask
     LEFT JOIN public.orders_workstationchangeoverforoperationaltask workstationchangeoverforoperationaltask ON ((workstationchangeoverforoperationaltask.currentoperationaltask_id = operationaltask.id)))
     LEFT JOIN operational_task_staff ots ON ((operationaltask.id = ots.operationaltask_id)))
     LEFT JOIN public.basic_division division ON ((operationaltask.division_id = division.id)))
     LEFT JOIN public.basic_workstation workstation ON ((workstation.id = operationaltask.workstation_id)))
     LEFT JOIN public.orders_order ordersorder ON ((ordersorder.id = operationaltask.order_id)))
     LEFT JOIN public.technologies_technologyoperationcomponent technologyoperationcomponent ON ((technologyoperationcomponent.id = operationaltask.technologyoperationcomponent_id)))
     LEFT JOIN public.basic_product product ON ((product.id = operationaltask.product_id)))
     LEFT JOIN public.basic_product orderproduct ON ((orderproduct.id = ordersorder.product_id)))
  WHERE ((operationaltask.type)::text = '01otherCase'::text)
  GROUP BY operationaltask.id, operationaltask.number, operationaltask.name, operationaltask.description, operationaltask.type, operationaltask.state, operationaltask.startdate, operationaltask.finishdate, ots.staffname, division.number, ((workstation.id)::integer), workstation.number, ((ordersorder.id)::integer), ordersorder.number, ((technologyoperationcomponent.id)::integer), technologyoperationcomponent.nodenumber, technologyoperationcomponent.issubcontracting, (product.number)::text, (product.name)::text, (product.unit)::text, (orderproduct.number)::text, (orderproduct.name)::text, operationaltask.actualstaff
UNION ALL
 SELECT operationaltask.id,
    operationaltask.number,
    operationaltask.name,
    operationaltask.description,
    operationaltask.type,
    operationaltask.state,
    operationaltask.startdate,
    operationaltask.finishdate,
    ots.staffname,
    division.number AS divisionnumber,
    (workstation.id)::integer AS workstationid,
    workstation.number AS workstationnumber,
    (ordersorder.id)::integer AS orderid,
    ordersorder.number AS ordernumber,
    (technologyoperationcomponent.id)::integer AS tocid,
    technologyoperationcomponent.nodenumber AS technologyoperationcomponentnodenumber,
    technologyoperationcomponent.issubcontracting AS technologyoperationcomponentissubcontracting,
    (product.number)::text AS productnumber,
    (product.name)::text AS productname,
    (product.unit)::text AS productunit,
    productioncountingquantitydto.plannedquantity,
    max(GREATEST(productioncountingquantitydto.producedquantity, (0)::numeric)) AS usedquantity,
    max(GREATEST((COALESCE(productioncountingquantitydto.plannedquantity, (0)::numeric) - COALESCE(productioncountingquantitydto.producedquantity, (0)::numeric)), (0)::numeric)) AS remainingquantity,
    max(ceil(((COALESCE(productioncountingquantitydto.producedquantity, (0)::numeric) * (100)::numeric) / productioncountingquantitydto.plannedquantity))) AS doneinpercentage,
    max(
        CASE
            WHEN (( SELECT basic_parameter.opertaskflagpercentexecutionwithcolor
               FROM public.basic_parameter
             LIMIT 1) AND ((operationaltask.type)::text = '02executionOperationInOrder'::text)) THEN (1)::numeric
            ELSE (0)::numeric
        END) AS opertaskflagpercentexecutionwithcolor,
    max((
        CASE
            WHEN (((COALESCE(productioncountingquantitydto.producedquantity, (0)::numeric) * (100)::numeric) / productioncountingquantitydto.plannedquantity) >= (100)::numeric) THEN 'green-cell'::character varying(255)
            WHEN (((COALESCE(productioncountingquantitydto.producedquantity, (0)::numeric) * (100)::numeric) / productioncountingquantitydto.plannedquantity) = (0)::numeric) THEN 'red-cell'::character varying(255)
            ELSE 'yellow-cell'::character varying(255)
        END)::text) AS percentageofexecutioncellcolor,
    (orderproduct.number)::text AS orderproductnumber,
    (orderproduct.name)::text AS orderproductname,
    operationaltask.actualstaff,
    sum((COALESCE(trackingoperationproductoutcomponent.wastesquantity, (0)::numeric))::numeric(14,5)) AS wastesquantity,
    (suborder.id)::integer AS suborder_id,
    (suborder.number)::text AS subordernumber,
    (count(workstationchangeoverforoperationaltask.id) <> 0) AS haschangeovers
   FROM ((((((((((((public.orders_operationaltask operationaltask
     LEFT JOIN public.orders_workstationchangeoverforoperationaltask workstationchangeoverforoperationaltask ON ((workstationchangeoverforoperationaltask.currentoperationaltask_id = operationaltask.id)))
     LEFT JOIN operational_task_staff ots ON ((operationaltask.id = ots.operationaltask_id)))
     LEFT JOIN public.basic_division division ON ((operationaltask.division_id = division.id)))
     LEFT JOIN public.basic_workstation workstation ON ((workstation.id = operationaltask.workstation_id)))
     LEFT JOIN public.orders_order ordersorder ON ((ordersorder.id = operationaltask.order_id)))
     LEFT JOIN public.technologies_technologyoperationcomponent technologyoperationcomponent ON ((technologyoperationcomponent.id = operationaltask.technologyoperationcomponent_id)))
     LEFT JOIN public.basic_product product ON ((product.id = operationaltask.product_id)))
     LEFT JOIN public.basic_product orderproduct ON ((orderproduct.id = ordersorder.product_id)))
     LEFT JOIN public.basicproductioncounting_productioncountingquantitydto productioncountingquantitydto ON (((productioncountingquantitydto.orderid = ordersorder.id) AND (productioncountingquantitydto.tocid = technologyoperationcomponent.id) AND ((productioncountingquantitydto.role)::text = '02produced'::text) AND (((productioncountingquantitydto.typeofmaterial)::text = '02intermediate'::text) OR ((productioncountingquantitydto.typeofmaterial)::text = '03finalProduct'::text)))))
     LEFT JOIN public.productioncounting_productiontracking productiontracking ON (((productiontracking.order_id = ordersorder.id) AND (productiontracking.technologyoperationcomponent_id = technologyoperationcomponent.id) AND ((productiontracking.state)::text = ('02accepted'::character varying)::text))))
     LEFT JOIN public.productioncounting_trackingoperationproductoutcomponent trackingoperationproductoutcomponent ON (((trackingoperationproductoutcomponent.productiontracking_id = productiontracking.id) AND (trackingoperationproductoutcomponent.product_id = product.id))))
     LEFT JOIN public.subcontractorportal_suborder suborder ON ((suborder.id = operationaltask.suborder_id)))
  WHERE ((operationaltask.type)::text = '02executionOperationInOrder'::text)
  GROUP BY operationaltask.id, operationaltask.number, operationaltask.name, operationaltask.description, operationaltask.type, operationaltask.state, operationaltask.startdate, operationaltask.finishdate, ots.staffname, division.number, ((workstation.id)::integer), workstation.number, ((ordersorder.id)::integer), ordersorder.number, ((technologyoperationcomponent.id)::integer), technologyoperationcomponent.nodenumber, technologyoperationcomponent.issubcontracting, (product.number)::text, (product.name)::text, (product.unit)::text, productioncountingquantitydto.plannedquantity, (orderproduct.number)::text, (orderproduct.name)::text, operationaltask.actualstaff, ((suborder.id)::integer), (suborder.number)::text;


--
-- Name: orders_operationaltaskwithcolordto_id_seq; Type: SEQUENCE; Schema: public; Owner: -
--

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


--
-- Name: orders_order_id_seq; Type: SEQUENCE; Schema: public; Owner: -
--

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


--
-- Name: orders_order_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: -
--

ALTER SEQUENCE public.orders_order_id_seq OWNED BY public.orders_order.id;


--
-- Name: orders_order_pack_number_seq; Type: SEQUENCE; Schema: public; Owner: -
--

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


--
-- Name: orders_orderattachment_id_seq; Type: SEQUENCE; Schema: public; Owner: -
--

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


--
-- Name: orders_orderattachment_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: -
--

ALTER SEQUENCE public.orders_orderattachment_id_seq OWNED BY public.orders_orderattachment.id;


--
-- Name: orders_ordercategorycolor; Type: TABLE; Schema: public; Owner: -
--

CREATE TABLE public.orders_ordercategorycolor (
    id bigint NOT NULL,
    parameter_id bigint,
    ordercategory character varying(255),
    color character varying(255)
);


--
-- Name: orders_ordercategorycolor_id_seq; Type: SEQUENCE; Schema: public; Owner: -
--

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


--
-- Name: orders_ordercategorycolor_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: -
--

ALTER SEQUENCE public.orders_ordercategorycolor_id_seq OWNED BY public.orders_ordercategorycolor.id;


--
-- Name: orders_orderdto; Type: VIEW; Schema: public; Owner: -
--

CREATE VIEW public.orders_orderdto AS
 SELECT orders_order.id,
    orders_order.active,
    orders_order.number,
    orders_order.name,
    orders_order.state,
    orders_order.typeofproductionrecording,
    orders_order.plannedquantity
   FROM public.orders_order;


--
-- Name: orders_orderdto_id_seq; Type: SEQUENCE; Schema: public; Owner: -
--

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


--
-- Name: orders_orderlistdto; Type: VIEW; Schema: public; Owner: -
--

CREATE VIEW public.orders_orderlistdto AS
 SELECT ordersorder.id,
    ordersorder.active,
    ordersorder.number,
    ordersorder.name,
    ordersorder.description,
    ordersorder.datefrom,
    ordersorder.dateto,
    ordersorder.startdate,
    ordersorder.finishdate,
    ordersorder.state,
    ordersorder.externalnumber,
    ordersorder.externalsynchronized,
    ordersorder.plannedquantity,
    ordersorder.donequantity,
    ordersorder.workplandelivered,
    ordersorder.deadline,
    ordersorder.ordercategory,
    ordersorder.typeofproductionrecording,
    COALESCE(ordersorder.plannedquantityforadditionalunit, ordersorder.plannedquantity) AS plannedquantityforadditionalunit,
    COALESCE(product.additionalunit, product.unit) AS unitforadditionalunit,
    product.number AS productnumber,
    product.name AS productname,
    ordersorder.additionalfinalproducts,
    technology.number AS technologynumber,
    product.unit,
    masterorder.number AS masterordernumber,
    division.name AS divisionname,
    company.name AS companyname,
    address.number AS addressnumber,
    masterorderdefinition.number AS masterorderdefinitionnumber,
        CASE
            WHEN (EXISTS ( SELECT repairoder.id
               FROM public.repairs_repairorder repairoder
              WHERE (repairoder.order_id = ordersorder.id))) THEN true
            ELSE false
        END AS existsrepairorders,
    (masterorder.id)::integer AS masterorderid,
    ordersgroup.number AS ordersgroupnumber,
    productionline.number AS productionlinenumber,
    ''::character varying(255) AS annotation,
    (product.id)::integer AS productid,
    ordersorder.reportedproductionquantity,
    (productionline.id)::integer AS productionlineid,
    (ordersorder.correcteddatefrom IS NOT NULL) AS datechange
   FROM (((((((((public.orders_order ordersorder
     JOIN public.basic_product product ON ((product.id = ordersorder.product_id)))
     LEFT JOIN public.technologies_technology technology ON ((technology.id = ordersorder.technology_id)))
     LEFT JOIN public.basic_company company ON ((company.id = ordersorder.company_id)))
     LEFT JOIN public.basic_address address ON ((address.id = ordersorder.address_id)))
     LEFT JOIN public.masterorders_masterorder masterorder ON ((masterorder.id = ordersorder.masterorder_id)))
     LEFT JOIN public.masterorders_masterorderdefinition masterorderdefinition ON ((masterorderdefinition.id = masterorder.masterorderdefinition_id)))
     LEFT JOIN public.ordersgroups_ordersgroup ordersgroup ON ((ordersorder.ordersgroup_id = ordersgroup.id)))
     LEFT JOIN public.basic_division division ON ((division.id = ordersorder.division_id)))
     LEFT JOIN public.productionlines_productionline productionline ON ((productionline.id = ordersorder.productionline_id)));


--
-- Name: orders_orderlistdto_id_seq; Type: SEQUENCE; Schema: public; Owner: -
--

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


--
-- Name: orders_orderpack; Type: TABLE; Schema: public; Owner: -
--

CREATE TABLE public.orders_orderpack (
    id bigint NOT NULL,
    number character varying(255),
    order_id bigint,
    quantity numeric(12,5),
    state character varying(255) DEFAULT '01pending'::character varying
);


--
-- Name: orders_orderpack_id_seq; Type: SEQUENCE; Schema: public; Owner: -
--

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


--
-- Name: orders_orderpack_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: -
--

ALTER SEQUENCE public.orders_orderpack_id_seq OWNED BY public.orders_orderpack.id;


--
-- Name: orders_orderpackdto; Type: VIEW; Schema: public; Owner: -
--

CREATE VIEW public.orders_orderpackdto AS
 SELECT oop.id,
    (o.id)::integer AS orderid,
    oop.number,
    o.number AS ordernumber,
    p.number AS orderproduct,
    o.state AS orderstate,
    s.number AS size,
    o.plannedquantity AS orderquantity,
    oop.quantity,
    p.unit,
    oop.state
   FROM (((public.orders_orderpack oop
     JOIN public.orders_order o ON ((o.id = oop.order_id)))
     JOIN public.basic_product p ON ((o.product_id = p.id)))
     LEFT JOIN public.basic_size s ON ((p.size_id = s.id)));


--
-- Name: orders_orderpackdto_id_seq; Type: SEQUENCE; Schema: public; Owner: -
--

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


--
-- Name: orders_orderpackstatechange; Type: TABLE; Schema: public; Owner: -
--

CREATE TABLE public.orders_orderpackstatechange (
    id bigint NOT NULL,
    dateandtime timestamp without time zone,
    sourcestate character varying(255),
    targetstate character varying(255),
    status character varying(255),
    phase integer,
    worker character varying(255),
    orderpack_id bigint,
    shift_id bigint
);


--
-- Name: orders_orderpackstatechange_id_seq; Type: SEQUENCE; Schema: public; Owner: -
--

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


--
-- Name: orders_orderpackstatechange_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: -
--

ALTER SEQUENCE public.orders_orderpackstatechange_id_seq OWNED BY public.orders_orderpackstatechange.id;


--
-- Name: orders_orderplanninglistdto; Type: VIEW; Schema: public; Owner: -
--

CREATE VIEW public.orders_orderplanninglistdto AS
 WITH order_packs AS (
         SELECT order_1.id AS orderid,
            (count(pack.id) <> 0) AS haspacks
           FROM (public.orders_order order_1
             LEFT JOIN public.orders_orderpack pack ON ((pack.order_id = order_1.id)))
          GROUP BY order_1.id
        )
 SELECT ordersorder.id,
    ordersorder.active,
    ordersorder.number,
    ordersorder.name,
    ordersorder.additionalfinalproducts,
    ordersorder.datefrom,
    ordersorder.dateto,
    ordersorder.startdate,
    ordersorder.finishdate,
    ordersorder.state,
    ordersorder.externalnumber,
    ordersorder.externalsynchronized,
    ordersorder.plannedquantity,
    ordersorder.workplandelivered,
    ordersorder.ordercategory,
    COALESCE(ordersorder.amountofproductproduced, (0)::numeric) AS amountofproductproduced,
    COALESCE(ordersorder.wastesquantity, (0)::numeric) AS wastesquantity,
    GREATEST(COALESCE(ordersorder.remainingamountofproducttoproduce, (0)::numeric), (0)::numeric) AS remainingamountofproducttoproduce,
    product.number AS productnumber,
    technology.number AS technologynumber,
    product.unit,
    productionline.number AS productionlinenumber,
    masterorder.number AS masterordernumber,
    masterorder.name AS masterordername,
    masterorder.machinetype,
    division.name AS divisionname,
    division.number AS divisionnumber,
    COALESCE(ordersorder.plannedquantityforadditionalunit, ordersorder.plannedquantity) AS plannedquantityforadditionalunit,
    COALESCE(product.additionalunit, product.unit) AS unitforadditionalunit,
    company.number AS company,
    ordersorder.description,
    product.name AS productname,
    ''::character varying(255) AS annotation,
    ceil(((COALESCE(ordersorder.donequantity, (0)::numeric) * (100)::numeric) / NULLIF(ordersorder.plannedquantity, (0)::numeric))) AS doneinpercentage,
        CASE
            WHEN ( SELECT basic_parameter.flagpercentageofexecutionwithcolor
               FROM public.basic_parameter
             LIMIT 1) THEN (1)::numeric
            ELSE (0)::numeric
        END AS flagpercentageofexecutionwithcolor,
        CASE
            WHEN (((COALESCE(ordersorder.donequantity, (0)::numeric) * (100)::numeric) / NULLIF(ordersorder.plannedquantity, (0)::numeric)) >= (100)::numeric) THEN 'green-cell'::character varying(255)
            WHEN (((COALESCE(ordersorder.donequantity, (0)::numeric) * (100)::numeric) / NULLIF(ordersorder.plannedquantity, (0)::numeric)) = (0)::numeric) THEN 'red-cell'::character varying(255)
            ELSE 'yellow-cell'::character varying(255)
        END AS percentageofexecutioncellcolor,
    ordersorder.deadline,
    (date_part('day'::text, (date_trunc('day'::text, ordersorder.deadline) - (('now'::text)::date)::timestamp without time zone)))::integer AS daystodeadline,
    packs.haspacks,
    salesplan.number AS salesplannumber,
    ordersorder.priority,
    (ordersorder.correcteddatefrom IS NOT NULL) AS datechange
   FROM ((((((((public.orders_order ordersorder
     JOIN public.basic_product product ON ((product.id = ordersorder.product_id)))
     LEFT JOIN public.technologies_technology technology ON ((technology.id = ordersorder.technology_id)))
     LEFT JOIN public.productionlines_productionline productionline ON ((productionline.id = ordersorder.productionline_id)))
     LEFT JOIN public.masterorders_masterorder masterorder ON ((masterorder.id = ordersorder.masterorder_id)))
     LEFT JOIN public.basic_division division ON ((division.id = ordersorder.division_id)))
     LEFT JOIN public.basic_company company ON ((company.id = ordersorder.company_id)))
     LEFT JOIN order_packs packs ON ((packs.orderid = ordersorder.id)))
     LEFT JOIN public.masterorders_salesplan salesplan ON ((salesplan.id = ordersorder.salesplan_id)));


--
-- Name: orders_orderplanninglistdto_id_seq; Type: SEQUENCE; Schema: public; Owner: -
--

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


--
-- Name: orders_orderstatechange; Type: TABLE; Schema: public; Owner: -
--

CREATE TABLE public.orders_orderstatechange (
    id bigint NOT NULL,
    comment character varying(255),
    reasonrequired boolean DEFAULT false,
    dateandtime timestamp without time zone,
    sourcestate character varying(255),
    targetstate character varying(255),
    status character varying(255) DEFAULT '01inProgress'::character varying,
    phase integer,
    worker character varying(255),
    order_id bigint,
    shift_id bigint,
    additionalinformation character varying(255),
    sourcecorrecteddatefrom timestamp without time zone,
    sourcecorrecteddateto timestamp without time zone,
    sourcestartdate timestamp without time zone,
    sourcefinishdate timestamp without time zone,
    targetcorrecteddatefrom timestamp without time zone,
    targetcorrecteddateto timestamp without time zone,
    targetstartdate timestamp without time zone,
    targetfinishdate timestamp without time zone,
    dateschanged boolean DEFAULT false,
    entityversion bigint DEFAULT 0
);


--
-- Name: orders_orderstatechange_id_seq; Type: SEQUENCE; Schema: public; Owner: -
--

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


--
-- Name: orders_orderstatechange_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: -
--

ALTER SEQUENCE public.orders_orderstatechange_id_seq OWNED BY public.orders_orderstatechange.id;


--
-- Name: orders_ordertechnologicalprocess; Type: TABLE; Schema: public; Owner: -
--

CREATE TABLE public.orders_ordertechnologicalprocess (
    id bigint NOT NULL,
    number character varying(255),
    orderpack_id bigint,
    order_id bigint,
    product_id bigint,
    operation_id bigint,
    technologicalprocess_id bigint,
    quantity numeric(12,5),
    worker_id bigint,
    date timestamp without time zone,
    wastesquantity numeric(12,5),
    technologyoperationcomponent_id bigint,
    createdate timestamp without time zone
);


--
-- Name: orders_ordertechnologicalprocess_id_seq; Type: SEQUENCE; Schema: public; Owner: -
--

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


--
-- Name: orders_ordertechnologicalprocess_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: -
--

ALTER SEQUENCE public.orders_ordertechnologicalprocess_id_seq OWNED BY public.orders_ordertechnologicalprocess.id;


--
-- Name: orders_ordertechnologicalprocess_number_seq; Type: SEQUENCE; Schema: public; Owner: -
--

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


--
-- Name: orders_ordertechnologicalprocesswaste; Type: TABLE; Schema: public; Owner: -
--

CREATE TABLE public.orders_ordertechnologicalprocesswaste (
    id bigint NOT NULL,
    number character varying(255),
    ordertechnologicalprocess_id bigint,
    orderpack_id bigint,
    order_id bigint,
    product_id bigint,
    technologicalprocess_id bigint,
    wastequantity numeric(12,5),
    causeofwaste character varying(255),
    worker_id bigint,
    date timestamp without time zone,
    description character varying(2048)
);


--
-- Name: technologies_technologicalprocess; Type: TABLE; Schema: public; Owner: -
--

CREATE TABLE public.technologies_technologicalprocess (
    id bigint NOT NULL,
    name character varying(1024),
    workstationtype_id bigint,
    workstation_id bigint,
    tj integer DEFAULT 0,
    extendedtimeforsizegroup boolean DEFAULT false,
    increasepercent integer,
    sizegroup_id bigint,
    technologicalprocessrate_id bigint,
    tpz integer DEFAULT 0,
    additionaltime integer DEFAULT 0
);


--
-- Name: orders_ordertechnologicalprocessdto; Type: VIEW; Schema: public; Owner: -
--

CREATE VIEW public.orders_ordertechnologicalprocessdto AS
 WITH ordertechnologicalprocesswastes AS (
         SELECT ordertechnologicalprocesswaste.ordertechnologicalprocess_id,
            sum(ordertechnologicalprocesswaste.wastequantity) AS wastesquantity
           FROM public.orders_ordertechnologicalprocesswaste ordertechnologicalprocesswaste
          GROUP BY ordertechnologicalprocesswaste.ordertechnologicalprocess_id
        )
 SELECT ordertechnologicalprocess.id,
    ordertechnologicalprocess.number,
    (orderpack.id)::integer AS orderpackid,
    orderpack.number AS orderpacknumber,
    (ordersorder.id)::integer AS orderid,
    ordersorder.number AS ordernumber,
    ordersorder.startdate AS orderstartdate,
    (product.id)::integer AS productid,
    product.number AS productnumber,
    model.name AS modelname,
    size.number AS sizenumber,
    (operation.id)::integer AS operationid,
    operation.number AS operationnumber,
    technologyoperationcomponent.id AS technologyoperationcomponentid,
    technologyoperationcomponent.technologicalprocesslist_id AS technologicalprocesslistid,
    workstationtype.number AS workstationtypenumber,
    workstation.number AS workstationnumber,
    (technologicalprocess.id)::integer AS technologicalprocessid,
    technologicalprocess.name AS technologicalprocessname,
    technologicalprocess.technologicalprocessrate_id AS technologicalprocessrateid,
    ordertechnologicalprocess.quantity,
    product.unit AS productunit,
    (((staff.surname)::text || ' '::text) || (staff.name)::text) AS worker,
    ordertechnologicalprocess.createdate,
    ordertechnologicalprocess.date,
    COALESCE(ordertechnologicalprocesswastes.wastesquantity, (0)::numeric) AS wastesquantity
   FROM ((((((((((((public.orders_ordertechnologicalprocess ordertechnologicalprocess
     LEFT JOIN public.orders_orderpack orderpack ON ((orderpack.id = ordertechnologicalprocess.orderpack_id)))
     LEFT JOIN public.orders_order ordersorder ON ((ordersorder.id = ordertechnologicalprocess.order_id)))
     LEFT JOIN public.basic_product product ON ((product.id = ordertechnologicalprocess.product_id)))
     LEFT JOIN public.basic_model model ON ((model.id = product.model_id)))
     LEFT JOIN public.basic_size size ON ((size.id = product.size_id)))
     LEFT JOIN public.technologies_operation operation ON ((operation.id = ordertechnologicalprocess.operation_id)))
     LEFT JOIN public.technologies_technologyoperationcomponent technologyoperationcomponent ON ((technologyoperationcomponent.id = ordertechnologicalprocess.technologyoperationcomponent_id)))
     LEFT JOIN public.technologies_technologicalprocess technologicalprocess ON ((technologicalprocess.id = ordertechnologicalprocess.technologicalprocess_id)))
     LEFT JOIN public.basic_workstationtype workstationtype ON ((workstationtype.id = technologicalprocess.workstationtype_id)))
     LEFT JOIN public.basic_workstation workstation ON ((workstation.id = technologicalprocess.workstation_id)))
     LEFT JOIN public.basic_staff staff ON ((staff.id = ordertechnologicalprocess.worker_id)))
     LEFT JOIN ordertechnologicalprocesswastes ordertechnologicalprocesswastes ON ((ordertechnologicalprocesswastes.ordertechnologicalprocess_id = ordertechnologicalprocess.id)));


--
-- Name: orders_ordertechnologicalprocessdto_id_seq; Type: SEQUENCE; Schema: public; Owner: -
--

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


--
-- Name: orders_ordertechnologicalprocesspart; Type: TABLE; Schema: public; Owner: -
--

CREATE TABLE public.orders_ordertechnologicalprocesspart (
    id bigint NOT NULL,
    number character varying(255),
    quantity numeric(12,5),
    ordertechnologicalprocess_id bigint
);


--
-- Name: orders_ordertechnologicalprocesspart_id_seq; Type: SEQUENCE; Schema: public; Owner: -
--

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


--
-- Name: orders_ordertechnologicalprocesspart_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: -
--

ALTER SEQUENCE public.orders_ordertechnologicalprocesspart_id_seq OWNED BY public.orders_ordertechnologicalprocesspart.id;


--
-- Name: orders_ordertechnologicalprocesswaste_id_seq; Type: SEQUENCE; Schema: public; Owner: -
--

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


--
-- Name: orders_ordertechnologicalprocesswaste_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: -
--

ALTER SEQUENCE public.orders_ordertechnologicalprocesswaste_id_seq OWNED BY public.orders_ordertechnologicalprocesswaste.id;


--
-- Name: orders_ordertechnologicalprocesswaste_number_seq; Type: SEQUENCE; Schema: public; Owner: -
--

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


--
-- Name: orders_ordertechnologicalprocesswastedto; Type: VIEW; Schema: public; Owner: -
--

CREATE VIEW public.orders_ordertechnologicalprocesswastedto AS
 SELECT ordertechnologicalprocesswaste.id,
    ordertechnologicalprocesswaste.number,
    ordertechnologicalprocesswaste.date,
    (((staff.name)::text || ' '::text) || (staff.surname)::text) AS worker,
    ordertechnologicalprocesswaste.wastequantity,
    product.unit AS productunit,
    ordertechnologicalprocesswaste.causeofwaste,
    (orderpack.id)::integer AS orderpackid,
    orderpack.number AS orderpacknumber,
    (technologicalprocess.id)::integer AS technologicalprocessid,
    technologicalprocess.name AS technologicalprocessname,
    (ordersorder.id)::integer AS orderid,
    ordersorder.number AS ordernumber,
    (product.id)::integer AS productid,
    product.number AS productnumber,
    (ordertechnologicalprocess.id)::integer AS ordertechnologicalprocessid,
    ordertechnologicalprocess.number AS ordertechnologyprocessnumber,
    ordertechnologicalprocess.date AS ordertechnologicalprocessdate,
    (((orderstaff.name)::text || ' '::text) || (orderstaff.surname)::text) AS ordertechnologicalprocessworker
   FROM (((((((public.orders_ordertechnologicalprocesswaste ordertechnologicalprocesswaste
     LEFT JOIN public.basic_staff staff ON ((staff.id = ordertechnologicalprocesswaste.worker_id)))
     LEFT JOIN public.orders_orderpack orderpack ON ((orderpack.id = ordertechnologicalprocesswaste.orderpack_id)))
     LEFT JOIN public.technologies_technologicalprocess technologicalprocess ON ((technologicalprocess.id = ordertechnologicalprocesswaste.technologicalprocess_id)))
     LEFT JOIN public.orders_order ordersorder ON ((ordersorder.id = ordertechnologicalprocesswaste.order_id)))
     LEFT JOIN public.basic_product product ON ((product.id = ordertechnologicalprocesswaste.product_id)))
     LEFT JOIN public.orders_ordertechnologicalprocess ordertechnologicalprocess ON ((ordertechnologicalprocess.id = ordertechnologicalprocesswaste.ordertechnologicalprocess_id)))
     LEFT JOIN public.basic_staff orderstaff ON ((orderstaff.id = ordertechnologicalprocess.worker_id)));


--
-- Name: orders_ordertechnologicalprocesswastedto_id_seq; Type: SEQUENCE; Schema: public; Owner: -
--

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


--
-- Name: orders_prod_line_schedule_number_seq; Type: SEQUENCE; Schema: public; Owner: -
--

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


--
-- Name: orders_productionlineschedule; Type: TABLE; Schema: public; Owner: -
--

CREATE TABLE public.orders_productionlineschedule (
    id bigint NOT NULL,
    number character varying(255),
    name character varying(255),
    starttime timestamp without time zone,
    state character varying(255) DEFAULT '01draft'::character varying,
    durationofordercalculatedonbasis character varying(255) DEFAULT '01timeConsumingTechnology'::character varying,
    sortorder character varying(255) DEFAULT '01longestOrders'::character varying,
    productionlineassigncriterion character varying(255) DEFAULT '01leastProductionLines'::character varying,
    approvetime timestamp without time zone,
    allowproductionlinechange boolean DEFAULT false
);


--
-- Name: orders_productionlineschedule_id_seq; Type: SEQUENCE; Schema: public; Owner: -
--

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


--
-- Name: orders_productionlineschedule_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: -
--

ALTER SEQUENCE public.orders_productionlineschedule_id_seq OWNED BY public.orders_productionlineschedule.id;


--
-- Name: orders_productionlinescheduleposition; Type: TABLE; Schema: public; Owner: -
--

CREATE TABLE public.orders_productionlinescheduleposition (
    id bigint NOT NULL,
    productionlineschedule_id bigint,
    order_id bigint,
    productionline_id bigint,
    linechangeovernorm_id bigint,
    starttime timestamp without time zone,
    endtime timestamp without time zone,
    additionaltime integer DEFAULT 0
);


--
-- Name: orders_productionlinescheduleposition_id_seq; Type: SEQUENCE; Schema: public; Owner: -
--

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


--
-- Name: orders_productionlinescheduleposition_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: -
--

ALTER SEQUENCE public.orders_productionlinescheduleposition_id_seq OWNED BY public.orders_productionlinescheduleposition.id;


--
-- Name: orders_productionlineschedulestatechange; Type: TABLE; Schema: public; Owner: -
--

CREATE TABLE public.orders_productionlineschedulestatechange (
    id bigint NOT NULL,
    dateandtime timestamp without time zone,
    sourcestate character varying(255),
    targetstate character varying(255),
    status character varying(255),
    phase integer,
    worker character varying(255),
    productionlineschedule_id bigint,
    shift_id bigint
);


--
-- Name: orders_productionlineschedulestatechange_id_seq; Type: SEQUENCE; Schema: public; Owner: -
--

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


--
-- Name: orders_productionlineschedulestatechange_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: -
--

ALTER SEQUENCE public.orders_productionlineschedulestatechange_id_seq OWNED BY public.orders_productionlineschedulestatechange.id;


--
-- Name: orders_reasontypecorrectiondatefrom; Type: TABLE; Schema: public; Owner: -
--

CREATE TABLE public.orders_reasontypecorrectiondatefrom (
    id bigint NOT NULL,
    order_id bigint,
    reasontypeofchangingorderstate character varying(255),
    date timestamp without time zone,
    entityversion bigint DEFAULT 0,
    changedateshelper_id bigint
);


--
-- Name: orders_reasontypecorrectiondatefrom_id_seq; Type: SEQUENCE; Schema: public; Owner: -
--

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


--
-- Name: orders_reasontypecorrectiondatefrom_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: -
--

ALTER SEQUENCE public.orders_reasontypecorrectiondatefrom_id_seq OWNED BY public.orders_reasontypecorrectiondatefrom.id;


--
-- Name: orders_reasontypecorrectiondateto; Type: TABLE; Schema: public; Owner: -
--

CREATE TABLE public.orders_reasontypecorrectiondateto (
    id bigint NOT NULL,
    order_id bigint,
    reasontypeofchangingorderstate character varying(255),
    date timestamp without time zone,
    entityversion bigint DEFAULT 0,
    changedateshelper_id bigint
);


--
-- Name: orders_reasontypecorrectiondateto_id_seq; Type: SEQUENCE; Schema: public; Owner: -
--

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


--
-- Name: orders_reasontypecorrectiondateto_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: -
--

ALTER SEQUENCE public.orders_reasontypecorrectiondateto_id_seq OWNED BY public.orders_reasontypecorrectiondateto.id;


--
-- Name: orders_reasontypedeviationeffectiveend; Type: TABLE; Schema: public; Owner: -
--

CREATE TABLE public.orders_reasontypedeviationeffectiveend (
    id bigint NOT NULL,
    order_id bigint,
    reasontypeofchangingorderstate character varying(255),
    date timestamp without time zone,
    entityversion bigint DEFAULT 0
);


--
-- Name: orders_reasontypedeviationeffectiveend_id_seq; Type: SEQUENCE; Schema: public; Owner: -
--

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


--
-- Name: orders_reasontypedeviationeffectiveend_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: -
--

ALTER SEQUENCE public.orders_reasontypedeviationeffectiveend_id_seq OWNED BY public.orders_reasontypedeviationeffectiveend.id;


--
-- Name: orders_reasontypedeviationeffectivestart; Type: TABLE; Schema: public; Owner: -
--

CREATE TABLE public.orders_reasontypedeviationeffectivestart (
    id bigint NOT NULL,
    order_id bigint,
    reasontypeofchangingorderstate character varying(255),
    date timestamp without time zone,
    entityversion bigint DEFAULT 0
);


--
-- Name: orders_reasontypedeviationeffectivestart_id_seq; Type: SEQUENCE; Schema: public; Owner: -
--

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


--
-- Name: orders_reasontypedeviationeffectivestart_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: -
--

ALTER SEQUENCE public.orders_reasontypedeviationeffectivestart_id_seq OWNED BY public.orders_reasontypedeviationeffectivestart.id;


--
-- Name: orders_reasontypeofchangingorderstate; Type: TABLE; Schema: public; Owner: -
--

CREATE TABLE public.orders_reasontypeofchangingorderstate (
    id bigint NOT NULL,
    orderstatechange_id bigint,
    reasontypeofchangingorderstate character varying(255),
    entityversion bigint DEFAULT 0
);


--
-- Name: orders_reasontypeofchangingorderstate_id_seq; Type: SEQUENCE; Schema: public; Owner: -
--

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


--
-- Name: orders_reasontypeofchangingorderstate_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: -
--

ALTER SEQUENCE public.orders_reasontypeofchangingorderstate_id_seq OWNED BY public.orders_reasontypeofchangingorderstate.id;


--
-- Name: orders_schedule; Type: TABLE; Schema: public; Owner: -
--

CREATE TABLE public.orders_schedule (
    id bigint NOT NULL,
    number character varying(255),
    name character varying(255),
    starttime timestamp without time zone,
    state character varying(255) DEFAULT '01draft'::character varying,
    sortorder character varying(255) DEFAULT '01desc'::character varying,
    workstationassigncriterion character varying(255) DEFAULT '01shortestTime'::character varying,
    workerassigncriterion character varying(255) DEFAULT '01workstationLastOperatorLatestFinished'::character varying,
    approvetime timestamp without time zone,
    additionaltimeextendsoperation boolean DEFAULT true,
    includetpz boolean DEFAULT true,
    onlyworkstationsoflinefromorder boolean DEFAULT false,
    token character varying(36),
    plannerworkstationassigncriterion character varying(255) DEFAULT '01minDeadlineForOrder'::character varying,
    deadlinesort boolean DEFAULT true,
    operationlevelsort boolean DEFAULT true,
    orderprioritysort boolean DEFAULT false,
    abcanalysissort boolean DEFAULT false,
    includetpzchanged boolean DEFAULT false
);


--
-- Name: orders_schedule_id_seq; Type: SEQUENCE; Schema: public; Owner: -
--

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


--
-- Name: orders_schedule_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: -
--

ALTER SEQUENCE public.orders_schedule_id_seq OWNED BY public.orders_schedule.id;


--
-- Name: orders_schedule_number_seq; Type: SEQUENCE; Schema: public; Owner: -
--

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


--
-- Name: orders_scheduleposition; Type: TABLE; Schema: public; Owner: -
--

CREATE TABLE public.orders_scheduleposition (
    id bigint NOT NULL,
    schedule_id bigint,
    technologyoperationcomponent_id bigint,
    additionaltime integer DEFAULT 0,
    machineworktime integer DEFAULT 0,
    laborworktime integer DEFAULT 0,
    order_id bigint,
    product_id bigint,
    workstation_id bigint,
    quantity numeric(14,5),
    starttime timestamp without time zone,
    endtime timestamp without time zone,
    staff_id bigint,
    operationruns numeric(12,5),
    partialoperationruns numeric(12,5)
);


--
-- Name: orders_scheduleposition_id_seq; Type: SEQUENCE; Schema: public; Owner: -
--

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


--
-- Name: orders_scheduleposition_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: -
--

ALTER SEQUENCE public.orders_scheduleposition_id_seq OWNED BY public.orders_scheduleposition.id;


--
-- Name: orders_workstationchangeoverforscheduleposition; Type: TABLE; Schema: public; Owner: -
--

CREATE TABLE public.orders_workstationchangeoverforscheduleposition (
    id bigint NOT NULL,
    currentscheduleposition_id bigint,
    previousscheduleposition_id bigint,
    previousoperationaltask_id bigint,
    workstationchangeovernorm_id bigint,
    startdate timestamp without time zone,
    finishdate timestamp without time zone
);


--
-- Name: orders_schedulepositiondto; Type: VIEW; Schema: public; Owner: -
--

CREATE VIEW public.orders_schedulepositiondto AS
 SELECT scheduleposition.id,
    (schedule.id)::integer AS scheduleid,
    (((staff.surname)::text || ' '::text) || (staff.name)::text) AS staffname,
    workstation.number AS workstationnumber,
    technologyoperationcomponent.nodenumber,
    operation.name AS operationname,
    operation.number AS operationnumber,
    _order.number AS ordernumber,
    orderproduct.number AS orderproductnumber,
    _order.plannedquantity AS orderproductplanedquantity,
    product.name AS productname,
    product.number AS productnumber,
    product.unit AS productunit,
    scheduleposition.quantity,
    scheduleposition.additionaltime,
    scheduleposition.machineworktime,
    scheduleposition.laborworktime,
    scheduleposition.starttime,
    scheduleposition.endtime,
    (sum(date_part('epoch'::text, (wcsp.finishdate - wcsp.startdate))))::integer AS setuptime,
    _order.deadline AS orderdeadline,
    (scheduleposition.endtime > _order.deadline) AS endtimeafterorderdeadline
   FROM (((((((((public.orders_scheduleposition scheduleposition
     LEFT JOIN public.orders_schedule schedule ON ((schedule.id = scheduleposition.schedule_id)))
     LEFT JOIN public.orders_order _order ON ((_order.id = scheduleposition.order_id)))
     LEFT JOIN public.basic_product orderproduct ON ((orderproduct.id = _order.product_id)))
     LEFT JOIN public.basic_product product ON ((product.id = scheduleposition.product_id)))
     LEFT JOIN public.basic_staff staff ON ((staff.id = scheduleposition.staff_id)))
     LEFT JOIN public.technologies_technologyoperationcomponent technologyoperationcomponent ON ((technologyoperationcomponent.id = scheduleposition.technologyoperationcomponent_id)))
     LEFT JOIN public.technologies_operation operation ON ((operation.id = technologyoperationcomponent.operation_id)))
     LEFT JOIN public.basic_workstation workstation ON ((workstation.id = scheduleposition.workstation_id)))
     LEFT JOIN public.orders_workstationchangeoverforscheduleposition wcsp ON ((wcsp.currentscheduleposition_id = scheduleposition.id)))
  GROUP BY scheduleposition.id, ((schedule.id)::integer), (((staff.surname)::text || ' '::text) || (staff.name)::text), workstation.number, technologyoperationcomponent.nodenumber, operation.name, operation.number, _order.number, orderproduct.number, _order.plannedquantity, product.name, product.number, product.unit, scheduleposition.quantity, scheduleposition.additionaltime, scheduleposition.machineworktime, scheduleposition.laborworktime, scheduleposition.starttime, scheduleposition.endtime, _order.deadline, (scheduleposition.endtime > _order.deadline);


--
-- Name: orders_schedulepositiondto_id_seq; Type: SEQUENCE; Schema: public; Owner: -
--

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


--
-- Name: orders_schedulestatechange; Type: TABLE; Schema: public; Owner: -
--

CREATE TABLE public.orders_schedulestatechange (
    id bigint NOT NULL,
    dateandtime timestamp without time zone,
    sourcestate character varying(255),
    targetstate character varying(255),
    status character varying(255),
    phase integer,
    worker character varying(255),
    schedule_id bigint,
    shift_id bigint
);


--
-- Name: orders_schedulestatechange_id_seq; Type: SEQUENCE; Schema: public; Owner: -
--

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


--
-- Name: orders_schedulestatechange_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: -
--

ALTER SEQUENCE public.orders_schedulestatechange_id_seq OWNED BY public.orders_schedulestatechange.id;


--
-- Name: orders_setcategory; Type: TABLE; Schema: public; Owner: -
--

CREATE TABLE public.orders_setcategory (
    id bigint NOT NULL,
    ordercategory character varying(255)
);


--
-- Name: orders_setcategory_id_seq; Type: SEQUENCE; Schema: public; Owner: -
--

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


--
-- Name: orders_setcategory_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: -
--

ALTER SEQUENCE public.orders_setcategory_id_seq OWNED BY public.orders_setcategory.id;


--
-- Name: orders_splitorderchild; Type: TABLE; Schema: public; Owner: -
--

CREATE TABLE public.orders_splitorderchild (
    id bigint NOT NULL,
    splitorderparent_id bigint,
    number character varying(255),
    name character varying(1024),
    datefrom timestamp without time zone,
    dateto timestamp without time zone,
    plannedquantity numeric(12,5),
    unit character varying(255)
);


--
-- Name: orders_splitorderchild_id_seq; Type: SEQUENCE; Schema: public; Owner: -
--

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


--
-- Name: orders_splitorderchild_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: -
--

ALTER SEQUENCE public.orders_splitorderchild_id_seq OWNED BY public.orders_splitorderchild.id;


--
-- Name: orders_splitorderhelper; Type: TABLE; Schema: public; Owner: -
--

CREATE TABLE public.orders_splitorderhelper (
    id bigint NOT NULL,
    datefrom timestamp without time zone,
    dateto timestamp without time zone,
    parts integer
);


--
-- Name: orders_splitorderhelper_id_seq; Type: SEQUENCE; Schema: public; Owner: -
--

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


--
-- Name: orders_splitorderhelper_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: -
--

ALTER SEQUENCE public.orders_splitorderhelper_id_seq OWNED BY public.orders_splitorderhelper.id;


--
-- Name: orders_splitorderparent; Type: TABLE; Schema: public; Owner: -
--

CREATE TABLE public.orders_splitorderparent (
    id bigint NOT NULL,
    splitorderhelper_id bigint,
    order_id bigint,
    number character varying(255),
    name character varying(1024),
    datefrom timestamp without time zone,
    dateto timestamp without time zone,
    plannedquantity numeric(12,5),
    unit character varying(255)
);


--
-- Name: orders_splitorderparent_id_seq; Type: SEQUENCE; Schema: public; Owner: -
--

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


--
-- Name: orders_splitorderparent_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: -
--

ALTER SEQUENCE public.orders_splitorderparent_id_seq OWNED BY public.orders_splitorderparent.id;


--
-- Name: orders_typeofcorrectioncauses; Type: TABLE; Schema: public; Owner: -
--

CREATE TABLE public.orders_typeofcorrectioncauses (
    id bigint NOT NULL,
    order_id bigint,
    reasontype character varying(255),
    date timestamp without time zone,
    entityversion bigint DEFAULT 0
);


--
-- Name: orders_typeofcorrectioncauses_id_seq; Type: SEQUENCE; Schema: public; Owner: -
--

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


--
-- Name: orders_typeofcorrectioncauses_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: -
--

ALTER SEQUENCE public.orders_typeofcorrectioncauses_id_seq OWNED BY public.orders_typeofcorrectioncauses.id;


--
-- Name: orders_workstationchangeoverforoperationaltask_id_seq; Type: SEQUENCE; Schema: public; Owner: -
--

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


--
-- Name: orders_workstationchangeoverforoperationaltask_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: -
--

ALTER SEQUENCE public.orders_workstationchangeoverforoperationaltask_id_seq OWNED BY public.orders_workstationchangeoverforoperationaltask.id;


--
-- Name: orders_workstationchangeoverforoperationaltaskdto; Type: VIEW; Schema: public; Owner: -
--

CREATE VIEW public.orders_workstationchangeoverforoperationaltaskdto AS
 SELECT workstationchangeoverforoperationaltask.id,
    workstationchangeoverforoperationaltask.number,
    workstationchangeoverforoperationaltask.name,
    workstationchangeoverforoperationaltask.description,
    (workstation.id)::integer AS workstation_id,
    workstation.number AS workstationnumber,
    (currentoperationaltask.id)::integer AS currentoperationaltask_id,
    currentoperationaltask.number AS currentoperationaltasknumber,
    currentoperationaltask.name AS currentoperationaltaskname,
    (currentorder.id)::integer AS currentoperationaltaskorder_id,
    currentorder.number AS currentoperationaltaskordernumber,
    (currentproduct.id)::integer AS currentoperationaltaskorderproduct_id,
    currentproduct.number AS currentoperationaltaskorderproductnumber,
    (previousoperationaltask.id)::integer AS previousoperationaltask_id,
    previousoperationaltask.number AS previousoperationaltasknumber,
    previousoperationaltask.name AS previousoperationaltaskname,
    (previousorder.id)::integer AS previousoperationaltaskorder_id,
    previousorder.number AS previousoperationaltaskordernumber,
    (previousproduct.id)::integer AS previousoperationaltaskorderproduct_id,
    previousproduct.number AS previousoperationaltaskorderproductnumber,
    workstationchangeoverforoperationaltask.changeovertype,
    (attribute.id)::integer AS attribute_id,
    attribute.number AS attributenumber,
    fromattributevalue.value AS fromattributevaluevalue,
    toattributevalue.value AS toattributevaluevalue,
    workstationchangeoverforoperationaltask.startdate,
    workstationchangeoverforoperationaltask.finishdate,
    workstationchangeoverforoperationaltask.duration,
    workstationchangeoverforoperationaltask.isparallel
   FROM ((((((((((public.orders_workstationchangeoverforoperationaltask workstationchangeoverforoperationaltask
     LEFT JOIN public.basic_workstation workstation ON ((workstation.id = workstationchangeoverforoperationaltask.workstation_id)))
     LEFT JOIN public.orders_operationaltask currentoperationaltask ON ((currentoperationaltask.id = workstationchangeoverforoperationaltask.currentoperationaltask_id)))
     LEFT JOIN public.orders_order currentorder ON ((currentorder.id = currentoperationaltask.order_id)))
     LEFT JOIN public.basic_product currentproduct ON ((currentproduct.id = currentorder.product_id)))
     LEFT JOIN public.orders_operationaltask previousoperationaltask ON ((previousoperationaltask.id = workstationchangeoverforoperationaltask.previousoperationaltask_id)))
     LEFT JOIN public.orders_order previousorder ON ((previousorder.id = previousoperationaltask.order_id)))
     LEFT JOIN public.basic_product previousproduct ON ((previousproduct.id = previousorder.product_id)))
     LEFT JOIN public.basic_attribute attribute ON ((attribute.id = workstationchangeoverforoperationaltask.attribute_id)))
     LEFT JOIN public.basic_attributevalue fromattributevalue ON ((fromattributevalue.id = workstationchangeoverforoperationaltask.fromattributevalue_id)))
     LEFT JOIN public.basic_attributevalue toattributevalue ON ((toattributevalue.id = workstationchangeoverforoperationaltask.toattributevalue_id)));


--
-- Name: orders_workstationchangeoverforoperationaltaskdto_id_seq; Type: SEQUENCE; Schema: public; Owner: -
--

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


--
-- Name: orders_workstationchangeoverforscheduleposition_id_seq; Type: SEQUENCE; Schema: public; Owner: -
--

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


--
-- Name: orders_workstationchangeoverforscheduleposition_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: -
--

ALTER SEQUENCE public.orders_workstationchangeoverforscheduleposition_id_seq OWNED BY public.orders_workstationchangeoverforscheduleposition.id;


--
-- Name: ordersforsubproductsgeneration_relatedorderdto; Type: VIEW; Schema: public; Owner: -
--

CREATE VIEW public.ordersforsubproductsgeneration_relatedorderdto AS
 SELECT o.id,
    o.number,
    o.name,
    p.number AS productnumber,
    o.plannedquantity,
    COALESCE(o.amountofproductproduced, (0)::numeric) AS producedquantity,
    o.datefrom,
    o.dateto,
    COALESCE(pl.number, ''::character varying(255)) AS productionlinenumber,
    o.state,
    (o.root_id)::integer AS rootid,
    COALESCE(o.level, 0) AS level,
    NULL::bigint AS order_id
   FROM ((public.orders_order o
     JOIN public.basic_product p ON ((p.id = o.product_id)))
     LEFT JOIN public.productionlines_productionline pl ON ((pl.id = o.productionline_id)));


--
-- Name: ordersforsubproductsgeneration_relatedorderdto_id_seq; Type: SEQUENCE; Schema: public; Owner: -
--

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


--
-- Name: ordersforsubproductsgeneration_suborders; Type: TABLE; Schema: public; Owner: -
--

CREATE TABLE public.ordersforsubproductsgeneration_suborders (
    id bigint NOT NULL,
    order_id bigint,
    ordersgroup_id bigint,
    createdate timestamp without time zone,
    updatedate timestamp without time zone,
    createuser character varying(255),
    updateuser character varying(255),
    ordersgroupsgenerated boolean DEFAULT false,
    generatedorders boolean DEFAULT false,
    ordergenerationinprogress boolean DEFAULT false
);


--
-- Name: ordersforsubproductsgeneration_suborders_id_seq; Type: SEQUENCE; Schema: public; Owner: -
--

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


--
-- Name: ordersforsubproductsgeneration_suborders_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: -
--

ALTER SEQUENCE public.ordersforsubproductsgeneration_suborders_id_seq OWNED BY public.ordersforsubproductsgeneration_suborders.id;


--
-- Name: ordersgantt_ordersganttparameters; Type: TABLE; Schema: public; Owner: -
--

CREATE TABLE public.ordersgantt_ordersganttparameters (
    id bigint NOT NULL,
    datasource character varying(255) DEFAULT '01orders'::character varying,
    manualwritingplan boolean DEFAULT true,
    calculateorderstime boolean DEFAULT true,
    detectcollisions boolean DEFAULT false,
    donotletcollisions boolean DEFAULT false,
    changeovernormsfrom character varying(255) DEFAULT '01lack'::character varying,
    typeofsave character varying(255) DEFAULT '01saveOnly'::character varying
);


--
-- Name: ordersgantt_ordersganttparameters_id_seq; Type: SEQUENCE; Schema: public; Owner: -
--

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


--
-- Name: ordersgantt_ordersganttparameters_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: -
--

ALTER SEQUENCE public.ordersgantt_ordersganttparameters_id_seq OWNED BY public.ordersgantt_ordersganttparameters.id;


--
-- Name: ordersgroups_drafrptquantitydto; Type: VIEW; Schema: public; Owner: -
--

CREATE VIEW public.ordersgroups_drafrptquantitydto AS
SELECT
    NULL::bigint AS id,
    NULL::character varying(255) AS number,
    NULL::numeric AS sum;


--
-- Name: ordersgroups_drafrptquantitydto_id_seq; Type: SEQUENCE; Schema: public; Owner: -
--

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


--
-- Name: technologies_productionlinetechnologygroup; Type: TABLE; Schema: public; Owner: -
--

CREATE TABLE public.technologies_productionlinetechnologygroup (
    id bigint NOT NULL,
    technologygroup_id bigint,
    productionline_id bigint
);


--
-- Name: ordersgroups_ordersgroupdto; Type: VIEW; Schema: public; Owner: -
--

CREATE VIEW public.ordersgroups_ordersgroupdto AS
 WITH technology_group_numbers AS (
         SELECT o.ordersgroup_id,
            string_agg(DISTINCT (tg.number)::text, ', '::text) AS number
           FROM ((public.orders_order o
             JOIN public.technologies_technology t ON ((o.technology_id = t.id)))
             JOIN public.technologies_technologygroup tg ON ((t.technologygroup_id = tg.id)))
          WHERE (o.ordersgroup_id IS NOT NULL)
          GROUP BY o.ordersgroup_id
        ), performance AS (
         SELECT o.ordersgroup_id,
            first_value(tpl.standardperformance) OVER (PARTITION BY o.ordersgroup_id ORDER BY o.id) AS performancenorm
           FROM (public.orders_order o
             LEFT JOIN public.technologies_technologyproductionline tpl ON (((tpl.technology_id = o.technology_id) AND tpl.master)))
        )
 SELECT DISTINCT ordersgroup.id,
    ordersgroup.active,
    ordersgroup.number,
    assortment.name AS assortmentname,
    productionline.number AS productionlinenumber,
    ordersgroup.startdate,
    ordersgroup.finishdate,
    ordersgroup.deadline,
    ordersgroup.quantity,
    ordersgroup.producedquantity,
    ordersgroup.remainingquantity,
    ordersgroup.state,
    company.number AS company,
    ordersgroup.remainingquantityinorders,
    (COALESCE(ordersgroup.producedquantity, (0)::numeric) + COALESCE(drafrptquantity.sum, (0)::numeric)) AS producedquantitywithdraft,
    (COALESCE(ordersgroup.remainingquantityinorders, (0)::numeric) - COALESCE(drafrptquantity.sum, (0)::numeric)) AS remainingquantityinorderswithdraft,
    tgn.number AS technologygroup,
    p.performancenorm,
    (masterorder.deadline)::date AS clientdate,
    masterorder.number AS masterordernumber,
    salesplan.number AS salesplannumber,
    salesplan.name AS salesplanname,
    ( SELECT (count(productionlinetechnologygroup.id) <> 0)
           FROM (public.technologies_productionlinetechnologygroup productionlinetechnologygroup
             LEFT JOIN public.technologies_technologygroup technologygroup ON ((productionlinetechnologygroup.technologygroup_id = technologygroup.id)))
          WHERE ((productionlinetechnologygroup.productionline_id = ordersgroup.productionline_id) AND ((tgn.number ~~ (('%'::text || (technologygroup.number)::text) || '%'::text)) OR ((tgn.number IS NULL) AND (productionlinetechnologygroup.technologygroup_id IS NULL))))) AS materials,
    masterorder.id AS masterorderid,
    ordersgroup.description
   FROM ((((((((public.ordersgroups_ordersgroup ordersgroup
     LEFT JOIN public.basic_assortment assortment ON ((ordersgroup.assortment_id = assortment.id)))
     LEFT JOIN public.productionlines_productionline productionline ON ((ordersgroup.productionline_id = productionline.id)))
     LEFT JOIN public.masterorders_masterorder masterorder ON ((ordersgroup.masterorder_id = masterorder.id)))
     LEFT JOIN public.masterorders_salesplan salesplan ON ((salesplan.id = ordersgroup.salesplan_id)))
     LEFT JOIN public.basic_company company ON ((company.id = masterorder.company_id)))
     LEFT JOIN public.ordersgroups_drafrptquantitydto drafrptquantity ON ((ordersgroup.id = drafrptquantity.id)))
     LEFT JOIN technology_group_numbers tgn ON ((tgn.ordersgroup_id = ordersgroup.id)))
     LEFT JOIN performance p ON ((p.ordersgroup_id = ordersgroup.id)));


--
-- Name: ordersgroups_masterordergroupswithmaterials; Type: VIEW; Schema: public; Owner: -
--

CREATE VIEW public.ordersgroups_masterordergroupswithmaterials AS
 SELECT mo.id AS master_order_id,
    ( SELECT count(gro.id) AS count
           FROM public.ordersgroups_ordersgroupdto gro
          WHERE ((gro.masterorderid = mo.id) AND (gro.materials = true))) AS groupswithmaterials,
    ( SELECT count(gro.id) AS count
           FROM public.ordersgroups_ordersgroupdto gro
          WHERE ((gro.masterorderid = mo.id) AND (gro.materials = true) AND (gro.remainingquantityinorderswithdraft = (0)::numeric))) AS groupswithmaterialsdone
   FROM public.masterorders_masterorder mo
  WHERE ((mo.materialsissued = false) AND ((mo.state)::text = ANY (ARRAY[('01new'::character varying)::text, ('02inExecution'::character varying)::text])));


--
-- Name: ordersgroups_ordersgroup_id_seq; Type: SEQUENCE; Schema: public; Owner: -
--

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


--
-- Name: ordersgroups_ordersgroup_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: -
--

ALTER SEQUENCE public.ordersgroups_ordersgroup_id_seq OWNED BY public.ordersgroups_ordersgroup.id;


--
-- Name: ordersgroups_ordersgroupdto_id_seq; Type: SEQUENCE; Schema: public; Owner: -
--

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


--
-- Name: ordersgroups_ordersgroupissuedmaterial; Type: TABLE; Schema: public; Owner: -
--

CREATE TABLE public.ordersgroups_ordersgroupissuedmaterial (
    id bigint NOT NULL,
    ordersgroup_id bigint,
    product_id bigint,
    quantity numeric(14,5),
    value numeric(14,5),
    averageprice numeric(11,2)
);


--
-- Name: ordersgroups_ordersgroupissuedmaterial_id_seq; Type: SEQUENCE; Schema: public; Owner: -
--

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


--
-- Name: ordersgroups_ordersgroupissuedmaterial_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: -
--

ALTER SEQUENCE public.ordersgroups_ordersgroupissuedmaterial_id_seq OWNED BY public.ordersgroups_ordersgroupissuedmaterial.id;


--
-- Name: ordersgroups_ordersgroupissuedmaterialposition; Type: TABLE; Schema: public; Owner: -
--

CREATE TABLE public.ordersgroups_ordersgroupissuedmaterialposition (
    id bigint NOT NULL,
    ordersgroupissuedmaterial_id bigint,
    documentnumber character varying(255),
    quantity numeric(14,5),
    price numeric(14,5),
    value numeric(14,5),
    externaldocumentid character varying(255)
);


--
-- Name: ordersgroups_ordersgroupissuedmaterialposition_id_seq; Type: SEQUENCE; Schema: public; Owner: -
--

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


--
-- Name: ordersgroups_ordersgroupissuedmaterialposition_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: -
--

ALTER SEQUENCE public.ordersgroups_ordersgroupissuedmaterialposition_id_seq OWNED BY public.ordersgroups_ordersgroupissuedmaterialposition.id;


--
-- Name: ordersgroups_ordersgroupmaterialrequirement; Type: TABLE; Schema: public; Owner: -
--

CREATE TABLE public.ordersgroups_ordersgroupmaterialrequirement (
    id bigint NOT NULL,
    number character varying(256),
    ordersgroup_id bigint,
    generated boolean,
    worker character varying(255),
    date timestamp without time zone,
    filename character varying(255)
);


--
-- Name: ordersgroups_ordersgroupmaterialrequirement_id_seq; Type: SEQUENCE; Schema: public; Owner: -
--

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


--
-- Name: ordersgroups_ordersgroupmaterialrequirement_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: -
--

ALTER SEQUENCE public.ordersgroups_ordersgroupmaterialrequirement_id_seq OWNED BY public.ordersgroups_ordersgroupmaterialrequirement.id;


--
-- Name: ordersgroups_ordersgroupmaterialrequirementproduct; Type: TABLE; Schema: public; Owner: -
--

CREATE TABLE public.ordersgroups_ordersgroupmaterialrequirementproduct (
    id bigint NOT NULL,
    ordersgroupmaterialrequirement_id bigint,
    product_id bigint,
    quantity numeric(14,5),
    currentstock numeric(14,5),
    technologyinputproducttype_id bigint,
    orderstartdate date,
    division_id bigint,
    location_id bigint,
    issuedquantity numeric(14,5),
    supplier_id bigint
);


--
-- Name: ordersgroups_ordersgroupmaterialrequirementproduct_id_seq; Type: SEQUENCE; Schema: public; Owner: -
--

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


--
-- Name: ordersgroups_ordersgroupmaterialrequirementproduct_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: -
--

ALTER SEQUENCE public.ordersgroups_ordersgroupmaterialrequirementproduct_id_seq OWNED BY public.ordersgroups_ordersgroupmaterialrequirementproduct.id;


--
-- Name: ordersgroups_ordersgroupproducedproduct; Type: TABLE; Schema: public; Owner: -
--

CREATE TABLE public.ordersgroups_ordersgroupproducedproduct (
    id bigint NOT NULL,
    ordersgroup_id bigint,
    product_id bigint,
    location_id bigint,
    document_id bigint,
    quantity numeric(14,5),
    accepted boolean DEFAULT false,
    externaldocumentnumber character varying(255),
    batch_id bigint,
    storagelocation_id bigint,
    palletnumber_id bigint,
    typeofpallet character varying(255)
);


--
-- Name: ordersgroups_ordersgroupproducedproduct_id_seq; Type: SEQUENCE; Schema: public; Owner: -
--

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


--
-- Name: ordersgroups_ordersgroupproducedproduct_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: -
--

ALTER SEQUENCE public.ordersgroups_ordersgroupproducedproduct_id_seq OWNED BY public.ordersgroups_ordersgroupproducedproduct.id;


--
-- Name: ordersgroups_ordersgroupproductstoissueentryhelper; Type: TABLE; Schema: public; Owner: -
--

CREATE TABLE public.ordersgroups_ordersgroupproductstoissueentryhelper (
    id bigint NOT NULL,
    ordersgroupmaterialrequirementproduct_id bigint,
    ordersgroupproductstoissuehelper_id bigint,
    quantity numeric(12,5)
);


--
-- Name: ordersgroups_ordersgroupproductstoissueentryhelper_id_seq; Type: SEQUENCE; Schema: public; Owner: -
--

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


--
-- Name: ordersgroups_ordersgroupproductstoissueentryhelper_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: -
--

ALTER SEQUENCE public.ordersgroups_ordersgroupproductstoissueentryhelper_id_seq OWNED BY public.ordersgroups_ordersgroupproductstoissueentryhelper.id;


--
-- Name: ordersgroups_ordersgroupproductstoissuehelper; Type: TABLE; Schema: public; Owner: -
--

CREATE TABLE public.ordersgroups_ordersgroupproductstoissuehelper (
    id bigint NOT NULL,
    ordersgroupmaterialrequirement_id bigint
);


--
-- Name: ordersgroups_ordersgroupproductstoissuehelper_id_seq; Type: SEQUENCE; Schema: public; Owner: -
--

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


--
-- Name: ordersgroups_ordersgroupproductstoissuehelper_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: -
--

ALTER SEQUENCE public.ordersgroups_ordersgroupproductstoissuehelper_id_seq OWNED BY public.ordersgroups_ordersgroupproductstoissuehelper.id;


--
-- Name: ordersgroups_plannedworkingtimeanalysisdto; Type: VIEW; Schema: public; Owner: -
--

CREATE VIEW public.ordersgroups_plannedworkingtimeanalysisdto AS
 SELECT DISTINCT ordersgroup.id,
    ordersgroup.active,
    company.number AS company,
    productionline.number AS productionlinenumber,
    assortment.name AS assortmentname,
    ordersgroup.number,
    ordersgroup.quantity,
    first_value(product.unit) OVER (PARTITION BY ordersgroup.id ORDER BY ordersorder.id) AS unit,
    first_value(tpl.standardperformance) OVER (PARTITION BY ordersgroup.id ORDER BY ordersorder.id) AS performancenorm,
    public.duration_to_string((((ordersgroup.quantity * (60)::numeric) / first_value(tpl.standardperformance) OVER (PARTITION BY ordersgroup.id ORDER BY ordersorder.id)))::integer) AS timebasedonnorms,
    ((((ordersgroup.quantity * (60)::numeric) / first_value(tpl.standardperformance) OVER (PARTITION BY ordersgroup.id ORDER BY ordersorder.id)) / (((8 * 60) * 60))::numeric))::numeric(14,1) AS shiftquantity,
    ordersgroup.startdate,
    ordersgroup.finishdate,
    masterorder.deadline,
    first_value(tcontext.number) OVER (PARTITION BY ordersgroup.id ORDER BY ordersorder.id) AS generatorname
   FROM (((((((((public.ordersgroups_ordersgroup ordersgroup
     JOIN public.basic_assortment assortment ON ((ordersgroup.assortment_id = assortment.id)))
     JOIN public.productionlines_productionline productionline ON ((ordersgroup.productionline_id = productionline.id)))
     JOIN public.masterorders_masterorder masterorder ON ((ordersgroup.masterorder_id = masterorder.id)))
     LEFT JOIN public.basic_company company ON ((company.id = masterorder.company_id)))
     LEFT JOIN public.orders_order ordersorder ON ((ordersorder.ordersgroup_id = ordersgroup.id)))
     LEFT JOIN public.basic_product product ON ((ordersorder.product_id = product.id)))
     LEFT JOIN public.technologies_technology technologyprototype ON ((ordersorder.technology_id = technologyprototype.id)))
     LEFT JOIN public.technologiesgenerator_generatorcontext tcontext ON ((tcontext.id = technologyprototype.generatorcontext_id)))
     LEFT JOIN public.technologies_technologyproductionline tpl ON (((tpl.technology_id = ordersorder.technology_id) AND tpl.master)))
  WHERE (((ordersgroup.state)::text = ANY (ARRAY[('01draft'::character varying)::text, ('02inProgress'::character varying)::text])) AND (ordersorder.remainingamountofproducttoproduce <> (0)::numeric))
UNION ALL
 SELECT DISTINCT ordersgroup.id,
    ordersgroup.active,
    company.number AS company,
    productionline.number AS productionlinenumber,
    assortment.name AS assortmentname,
    ordersgroup.number,
    ordersgroup.quantity,
    first_value(product.unit) OVER (PARTITION BY ordersgroup.id ORDER BY ordersorder.id) AS unit,
    first_value(tpl.standardperformance) OVER (PARTITION BY ordersgroup.id ORDER BY ordersorder.id) AS performancenorm,
    public.duration_to_string((((ordersgroup.quantity * (60)::numeric) / first_value(tpl.standardperformance) OVER (PARTITION BY ordersgroup.id ORDER BY ordersorder.id)))::integer) AS timebasedonnorms,
    ((((ordersgroup.quantity * (60)::numeric) / first_value(tpl.standardperformance) OVER (PARTITION BY ordersgroup.id ORDER BY ordersorder.id)) / (((8 * 60) * 60))::numeric))::numeric(14,1) AS shiftquantity,
    ordersgroup.startdate,
    ordersgroup.finishdate,
    masterorder.deadline,
    first_value(tcontext.number) OVER (PARTITION BY ordersgroup.id ORDER BY ordersorder.id) AS generatorname
   FROM (((((((((public.arch_ordersgroups_ordersgroup ordersgroup
     JOIN public.basic_assortment assortment ON ((ordersgroup.assortment_id = assortment.id)))
     JOIN public.productionlines_productionline productionline ON ((ordersgroup.productionline_id = productionline.id)))
     JOIN public.arch_masterorders_masterorder masterorder ON ((ordersgroup.masterorder_id = masterorder.id)))
     LEFT JOIN public.basic_company company ON ((company.id = masterorder.company_id)))
     LEFT JOIN public.orders_order ordersorder ON ((ordersorder.ordersgroup_id = ordersgroup.id)))
     LEFT JOIN public.basic_product product ON ((ordersorder.product_id = product.id)))
     LEFT JOIN public.technologies_technology technologyprototype ON ((ordersorder.technology_id = technologyprototype.id)))
     LEFT JOIN public.technologiesgenerator_generatorcontext tcontext ON ((tcontext.id = technologyprototype.generatorcontext_id)))
     LEFT JOIN public.technologies_technologyproductionline tpl ON (((tpl.technology_id = ordersorder.technology_id) AND tpl.master)))
  WHERE (((ordersgroup.state)::text = ANY (ARRAY[('01draft'::character varying)::text, ('02inProgress'::character varying)::text])) AND (ordersorder.remainingamountofproducttoproduce <> (0)::numeric));


--
-- Name: ordersgroups_plannedworkingtimeanalysisdto_id_seq; Type: SEQUENCE; Schema: public; Owner: -
--

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


--
-- Name: ordersgroups_productionbalance; Type: TABLE; Schema: public; Owner: -
--

CREATE TABLE public.ordersgroups_productionbalance (
    id bigint NOT NULL,
    number character varying(255),
    name character varying(255),
    generated boolean,
    worker character varying(255),
    date timestamp without time zone,
    filename character varying(255),
    ordersgroup_id bigint,
    plannedmaterialcost character varying(255) DEFAULT '01nominal'::character varying,
    usenominalcostpricenotspecified boolean DEFAULT false,
    realmaterialcost character varying(255) DEFAULT '01ordersgroupsdocuments'::character varying,
    orderedquantity numeric(14,5),
    producedquantity numeric(14,5),
    quantitydeviation numeric(14,5),
    plannedcost numeric(14,5),
    realcost numeric(14,5),
    costdeviation numeric(14,5),
    active boolean DEFAULT true
);


--
-- Name: ordersgroups_productionbalance_id_seq; Type: SEQUENCE; Schema: public; Owner: -
--

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


--
-- Name: ordersgroups_productionbalance_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: -
--

ALTER SEQUENCE public.ordersgroups_productionbalance_id_seq OWNED BY public.ordersgroups_productionbalance.id;


--
-- Name: ordersgroups_sizegroupcolor; Type: TABLE; Schema: public; Owner: -
--

CREATE TABLE public.ordersgroups_sizegroupcolor (
    id bigint NOT NULL,
    parameter_id bigint,
    sizegroup_id bigint,
    color character varying(255),
    succession integer
);


--
-- Name: ordersgroups_sizegroupcolor_id_seq; Type: SEQUENCE; Schema: public; Owner: -
--

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


--
-- Name: ordersgroups_sizegroupcolor_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: -
--

ALTER SEQUENCE public.ordersgroups_sizegroupcolor_id_seq OWNED BY public.ordersgroups_sizegroupcolor.id;


--
-- Name: ordersupplies_columnforcoverages; Type: TABLE; Schema: public; Owner: -
--

CREATE TABLE public.ordersupplies_columnforcoverages (
    id bigint NOT NULL,
    identifier character varying(255),
    name character varying(1024),
    description character varying(1024),
    columnfiller character varying(255),
    alignment character varying(255) DEFAULT '01left'::character varying,
    succession integer,
    entityversion bigint DEFAULT 0
);


--
-- Name: ordersupplies_columnforcoverages_id_seq; Type: SEQUENCE; Schema: public; Owner: -
--

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


--
-- Name: ordersupplies_columnforcoverages_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: -
--

ALTER SEQUENCE public.ordersupplies_columnforcoverages_id_seq OWNED BY public.ordersupplies_columnforcoverages.id;


--
-- Name: ordersupplies_coverageanalysisfororder; Type: TABLE; Schema: public; Owner: -
--

CREATE TABLE public.ordersupplies_coverageanalysisfororder (
    id bigint NOT NULL,
    order_id bigint,
    orderedproduct_id bigint,
    plannedquantity numeric(16,5),
    coveragedegree character varying(255),
    coveredfromtheday timestamp without time zone,
    deliverytime timestamp without time zone,
    componentsproductiondate timestamp without time zone,
    materialrequirementcoverage_id bigint
);


--
-- Name: ordersupplies_coverageanalysisfororder_id_seq; Type: SEQUENCE; Schema: public; Owner: -
--

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


--
-- Name: ordersupplies_coverageanalysisfororder_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: -
--

ALTER SEQUENCE public.ordersupplies_coverageanalysisfororder_id_seq OWNED BY public.ordersupplies_coverageanalysisfororder.id;


--
-- Name: ordersupplies_coverageanalysisfororderdto; Type: VIEW; Schema: public; Owner: -
--

CREATE VIEW public.ordersupplies_coverageanalysisfororderdto AS
 SELECT cafo.id,
    cafo.componentsproductiondate,
    cafo.coveragedegree,
    cafo.coveredfromtheday,
    cafo.deliverytime,
    cafo.plannedquantity,
    op.number AS orderedproductnumber,
    op.name AS orderedproductname,
    op.unit AS orderedproductunit,
    o.name AS ordername,
    o.number AS ordernumber,
    o.startdate AS orderstartdate,
    o.finishdate AS orderfinishdate,
    (cafo.materialrequirementcoverage_id)::integer AS materialrequirementcoverageid
   FROM ((public.ordersupplies_coverageanalysisfororder cafo
     LEFT JOIN public.basic_product op ON ((op.id = cafo.orderedproduct_id)))
     LEFT JOIN public.orders_order o ON ((o.id = cafo.order_id)));


--
-- Name: ordersupplies_coverageanalysisfororderdto_id_seq; Type: SEQUENCE; Schema: public; Owner: -
--

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


--
-- Name: ordersupplies_coveragelocation; Type: TABLE; Schema: public; Owner: -
--

CREATE TABLE public.ordersupplies_coveragelocation (
    id bigint NOT NULL,
    materialrequirementcoverage_id bigint,
    location_id bigint,
    parameter_id bigint,
    entityversion bigint DEFAULT 0
);


--
-- Name: ordersupplies_coveragelocation_id_seq; Type: SEQUENCE; Schema: public; Owner: -
--

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


--
-- Name: ordersupplies_coveragelocation_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: -
--

ALTER SEQUENCE public.ordersupplies_coveragelocation_id_seq OWNED BY public.ordersupplies_coveragelocation.id;


--
-- Name: ordersupplies_coverageorderstate; Type: TABLE; Schema: public; Owner: -
--

CREATE TABLE public.ordersupplies_coverageorderstate (
    id bigint NOT NULL,
    materialrequirementcoverage_id bigint,
    parameter_id bigint,
    state character varying(255)
);


--
-- Name: ordersupplies_coverageorderstate_id_seq; Type: SEQUENCE; Schema: public; Owner: -
--

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


--
-- Name: ordersupplies_coverageorderstate_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: -
--

ALTER SEQUENCE public.ordersupplies_coverageorderstate_id_seq OWNED BY public.ordersupplies_coverageorderstate.id;


--
-- Name: ordersupplies_coverageproduct_id_seq; Type: SEQUENCE; Schema: public; Owner: -
--

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


--
-- Name: ordersupplies_coverageproduct; Type: TABLE; Schema: public; Owner: -
--

CREATE TABLE public.ordersupplies_coverageproduct (
    id bigint DEFAULT nextval('public.ordersupplies_coverageproduct_id_seq'::regclass) NOT NULL,
    materialrequirementcoverage_id bigint,
    product_id bigint,
    lackfromdate timestamp without time zone,
    demandquantity numeric(16,5),
    coveredquantity numeric(16,5),
    reservemissingquantity numeric(16,5),
    deliveredquantity numeric(16,5),
    locationsquantity numeric(16,5),
    state character varying(255),
    issubcontracted boolean DEFAULT false,
    ispurchased boolean DEFAULT false,
    productnumber character varying(255),
    productname character varying(1024),
    productunit character varying(255),
    producttype character varying(255),
    planedquantity numeric(16,5),
    producequantity numeric(16,5),
    fromselectedorder boolean DEFAULT false,
    entityversion bigint DEFAULT 0,
    company_id bigint,
    price numeric(12,5)
);


--
-- Name: ordersupplies_coverageproductdto; Type: VIEW; Schema: public; Owner: -
--

CREATE VIEW public.ordersupplies_coverageproductdto AS
 SELECT coverageproduct.id,
    (coverageproduct.materialrequirementcoverage_id)::integer AS materialrequirementcoverageid,
    (coverageproduct.product_id)::integer AS productid,
    coverageproduct.lackfromdate,
    coverageproduct.demandquantity,
    coverageproduct.coveredquantity,
    coverageproduct.reservemissingquantity,
    coverageproduct.deliveredquantity,
    coverageproduct.locationsquantity,
    coverageproduct.state,
    coverageproduct.issubcontracted,
    coverageproduct.ispurchased,
    coverageproduct.productnumber,
    coverageproduct.productname,
    _parent.name AS productparent,
    coverageproduct.productunit,
    coverageproduct.producttype,
    coverageproduct.planedquantity,
    coverageproduct.producequantity,
    coverageproduct.fromselectedorder,
    coverageproduct.entityversion,
    (coverageproduct.company_id)::integer AS companyid,
    _company.name AS companyname,
        CASE
            WHEN (( SELECT count(*) AS count
               FROM public.basic_substitutecomponent
              WHERE (basic_substitutecomponent.baseproduct_id = _product.id)) > 0) THEN true
            ELSE false
        END AS replacement,
    COALESCE(bufferfordeliverytimes_product.bufferfordeliverytimes, bufferfordeliverytimes_family.bufferfordeliverytimesfamily, _company.buffer) AS deliverybuffer,
    (coverageproduct.lackfromdate - make_interval(days => COALESCE(bufferfordeliverytimes_product.bufferfordeliverytimes, bufferfordeliverytimes_family.bufferfordeliverytimesfamily, _company.buffer))) AS orderatlatest,
    coverageproduct.price,
    (coverageproduct.demandquantity * coverageproduct.price) AS value
   FROM (((((public.ordersupplies_coverageproduct coverageproduct
     JOIN public.basic_product _product ON ((_product.id = coverageproduct.product_id)))
     LEFT JOIN public.basic_product _parent ON ((_parent.id = _product.parent_id)))
     LEFT JOIN public.basic_company _company ON ((_company.id = coverageproduct.company_id)))
     LEFT JOIN public.deliveries_bufferfordeliverytimes_product bufferfordeliverytimes_product ON (((bufferfordeliverytimes_product.product_id = _product.id) AND (bufferfordeliverytimes_product.company_id = _company.id))))
     LEFT JOIN public.deliveries_bufferfordeliverytimes_family bufferfordeliverytimes_family ON (((bufferfordeliverytimes_family.product_id = _product.id) AND (bufferfordeliverytimes_family.company_id = _company.id))));


--
-- Name: ordersupplies_coverageproductdto_id_seq; Type: SEQUENCE; Schema: public; Owner: -
--

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


--
-- Name: ordersupplies_coverageproductgenerated; Type: TABLE; Schema: public; Owner: -
--

CREATE TABLE public.ordersupplies_coverageproductgenerated (
    id bigint NOT NULL,
    productid integer,
    entityversion bigint DEFAULT 0
);


--
-- Name: ordersupplies_coverageproductgenerated_id_seq; Type: SEQUENCE; Schema: public; Owner: -
--

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


--
-- Name: ordersupplies_coverageproductgenerated_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: -
--

ALTER SEQUENCE public.ordersupplies_coverageproductgenerated_id_seq OWNED BY public.ordersupplies_coverageproductgenerated.id;


--
-- Name: ordersupplies_coverageproductlogging_id_seq; Type: SEQUENCE; Schema: public; Owner: -
--

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


--
-- Name: ordersupplies_coverageproductlogging; Type: TABLE; Schema: public; Owner: -
--

CREATE TABLE public.ordersupplies_coverageproductlogging (
    id bigint DEFAULT nextval('public.ordersupplies_coverageproductlogging_id_seq'::regclass) NOT NULL,
    coverageproduct_id bigint,
    date timestamp without time zone,
    delivery_id bigint,
    order_id bigint,
    operation_id bigint,
    reservemissingquantity numeric(16,5),
    changes numeric(16,5),
    eventtype character varying(255),
    state character varying(255),
    subcontractedoperation_id bigint,
    deliverynumberexternal character varying(255),
    warehousenumber character varying(255),
    entityversion bigint DEFAULT 0
);


--
-- Name: ordersupplies_coverageproductselected; Type: TABLE; Schema: public; Owner: -
--

CREATE TABLE public.ordersupplies_coverageproductselected (
    id bigint NOT NULL,
    coverageproduct_id bigint,
    entityversion bigint DEFAULT 0
);


--
-- Name: ordersupplies_coverageproductselected_id_seq; Type: SEQUENCE; Schema: public; Owner: -
--

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


--
-- Name: ordersupplies_coverageproductselected_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: -
--

ALTER SEQUENCE public.ordersupplies_coverageproductselected_id_seq OWNED BY public.ordersupplies_coverageproductselected.id;


--
-- Name: ordersupplies_coverageproducttypedto; Type: VIEW; Schema: public; Owner: -
--

CREATE VIEW public.ordersupplies_coverageproducttypedto AS
 SELECT prod.id AS productid,
    tech.id AS technologyid,
    '02intermediate'::text AS producttype
   FROM (public.basic_product prod
     LEFT JOIN public.technologies_technology tech ON ((tech.product_id = prod.id)))
  WHERE ((tech.technologytype IS NULL) AND ((tech.state)::text = '02accepted'::text) AND (tech.master = true));


--
-- Name: ordersupplies_materialrequirementcoverage; Type: TABLE; Schema: public; Owner: -
--

CREATE TABLE public.ordersupplies_materialrequirementcoverage (
    id bigint NOT NULL,
    number character varying(255),
    coveragetodate timestamp without time zone,
    actualdate timestamp without time zone,
    generateddate timestamp without time zone,
    generatedby character varying(255),
    generated boolean,
    saved boolean,
    coveragetype character varying(255),
    includedraftdeliveries boolean,
    createdate timestamp without time zone,
    updatedate timestamp without time zone,
    createuser character varying(255),
    updateuser character varying(255),
    filename character varying(1024),
    automaticsavecoverage boolean DEFAULT false,
    order_id bigint,
    entityversion bigint DEFAULT 0,
    ordergenerationinprogress boolean DEFAULT false,
    forordersgroup_id bigint,
    ordersgroupsgenerated boolean DEFAULT false,
    includeincalculationdeliveries character varying(255) DEFAULT '01confirmedDeliveries'::character varying
);


--
-- Name: ordersupplies_materialrequirementcoverage_id_seq; Type: SEQUENCE; Schema: public; Owner: -
--

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


--
-- Name: ordersupplies_materialrequirementcoverage_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: -
--

ALTER SEQUENCE public.ordersupplies_materialrequirementcoverage_id_seq OWNED BY public.ordersupplies_materialrequirementcoverage.id;


--
-- Name: ordersupplies_materialrequirementcoveragedto; Type: VIEW; Schema: public; Owner: -
--

CREATE VIEW public.ordersupplies_materialrequirementcoveragedto AS
 SELECT ordersupplies_materialrequirementcoverage.id,
    ordersupplies_materialrequirementcoverage.number,
    ordersupplies_materialrequirementcoverage.coveragetodate,
    ordersupplies_materialrequirementcoverage.actualdate,
    ordersupplies_materialrequirementcoverage.generateddate,
    ordersupplies_materialrequirementcoverage.generatedby
   FROM public.ordersupplies_materialrequirementcoverage
  WHERE (ordersupplies_materialrequirementcoverage.saved = true);


--
-- Name: ordersupplies_materialrequirementcoveragedto_id_seq; Type: SEQUENCE; Schema: public; Owner: -
--

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


--
-- Name: ordersupplies_orderdto_id_seq; Type: SEQUENCE; Schema: public; Owner: -
--

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


--
-- Name: ordersupplies_productioncountingproducedquantity; Type: VIEW; Schema: public; Owner: -
--

CREATE VIEW public.ordersupplies_productioncountingproducedquantity AS
 SELECT COALESCE(sum(topoc.usedquantity), (0)::numeric) AS producedquantity,
    pt.order_id,
    topoc.product_id
   FROM ((public.productioncounting_trackingoperationproductoutcomponent topoc
     JOIN public.productioncounting_productiontracking pt ON ((pt.id = topoc.productiontracking_id)))
     JOIN public.orders_order o ON ((o.id = pt.order_id)))
  WHERE (((pt.state)::text = ANY (ARRAY[('02accepted'::character varying)::text])) AND ((o.state)::text = ANY (ARRAY[('03inProgress'::character varying)::text, ('06interrupted'::character varying)::text])))
  GROUP BY pt.order_id, topoc.product_id, pt.technologyoperationcomponent_id;


--
-- Name: ordersupplies_productioncountingproducedquantitydrafts; Type: VIEW; Schema: public; Owner: -
--

CREATE VIEW public.ordersupplies_productioncountingproducedquantitydrafts AS
 SELECT COALESCE(sum(topoc.usedquantity), (0)::numeric) AS producedquantity,
    pt.order_id,
    topoc.product_id,
    o.product_id AS order_product_id
   FROM ((public.productioncounting_trackingoperationproductoutcomponent topoc
     JOIN public.productioncounting_productiontracking pt ON ((pt.id = topoc.productiontracking_id)))
     JOIN public.orders_order o ON ((o.id = pt.order_id)))
  WHERE (((pt.state)::text = ANY (ARRAY[('01draft'::character varying)::text, ('02accepted'::character varying)::text])) AND ((o.state)::text = ANY (ARRAY[('03inProgress'::character varying)::text, ('06interrupted'::character varying)::text])))
  GROUP BY pt.order_id, topoc.product_id, pt.technologyoperationcomponent_id, o.product_id;


--
-- Name: ordersupplies_productioncountingquantityinput; Type: VIEW; Schema: public; Owner: -
--

CREATE VIEW public.ordersupplies_productioncountingquantityinput AS
 SELECT pcq.id,
    (o.id)::integer AS orderid,
    o.startdate,
    o.state AS orderstate,
    (product.id)::integer AS productid,
    (toc.operation_id)::integer AS operationid,
    (pcq.technologyoperationcomponent_id)::integer AS technologyoperationcomponentid,
    pcq.plannedquantity,
    COALESCE(pcq.usedquantity, (0)::numeric) AS usedquantity,
    GREATEST((pcq.plannedquantity - COALESCE(pcq.usedquantity, (0)::numeric)), (0)::numeric) AS quantity,
    '04orderInput'::text AS eventtype,
    COALESCE((coverageproducttype.producttype)::character varying(255), '01component'::character varying(255)) AS producttype,
    (o.product_id)::integer AS orderproductid,
    product.averagecost AS price,
    COALESCE(product.averagecost, (0)::numeric) AS averagecost,
    COALESCE(product.lastpurchasecost, (0)::numeric) AS lastpurchasecost,
    COALESCE(product.nominalcost, (0)::numeric) AS nominalcost,
    COALESCE(product.lastoffercost, (0)::numeric) AS lastoffercost,
    COALESCE(product.averageoffercost, (0)::numeric) AS averageoffercost,
    COALESCE(product.lastoffercost, product.lastpurchasecost, (0)::numeric) AS offercostorlastpurchase
   FROM ((((public.basicproductioncounting_productioncountingquantity pcq
     JOIN public.orders_order o ON ((o.id = pcq.order_id)))
     JOIN public.basic_product product ON ((product.id = pcq.product_id)))
     LEFT JOIN public.technologies_technologyoperationcomponent toc ON ((pcq.technologyoperationcomponent_id = toc.id)))
     LEFT JOIN public.ordersupplies_coverageproducttypedto coverageproducttype ON ((coverageproducttype.productid = pcq.product_id)))
  WHERE (((pcq.role)::text = '01used'::text) AND ((pcq.typeofmaterial)::text = ANY (ARRAY[('01component'::character varying)::text])) AND ((o.state)::text = ANY (ARRAY[('01pending'::character varying)::text, ('02accepted'::character varying)::text, ('03inProgress'::character varying)::text, ('06interrupted'::character varying)::text])) AND (o.active = true) AND ((o.typeofproductionrecording)::text = '02cumulated'::text))
UNION
 SELECT pcq.id,
    (o.id)::integer AS orderid,
    o.startdate,
    o.state AS orderstate,
    (product.id)::integer AS productid,
    (toc.operation_id)::integer AS operationid,
    (pcq.technologyoperationcomponent_id)::integer AS technologyoperationcomponentid,
    pcq.plannedquantity,
    COALESCE(pcq.usedquantity, (0)::numeric) AS usedquantity,
    GREATEST((pcq.plannedquantity - COALESCE(pcq.usedquantity, (0)::numeric)), (0)::numeric) AS quantity,
    '03operationInput'::text AS eventtype,
    COALESCE((coverageproducttype.producttype)::character varying(255), '01component'::character varying(255)) AS producttype,
    (o.product_id)::integer AS orderproductid,
    product.averagecost AS price,
    COALESCE(product.averagecost, (0)::numeric) AS averagecost,
    COALESCE(product.lastpurchasecost, (0)::numeric) AS lastpurchasecost,
    COALESCE(product.nominalcost, (0)::numeric) AS nominalcost,
    COALESCE(product.lastoffercost, (0)::numeric) AS lastoffercost,
    COALESCE(product.averageoffercost, (0)::numeric) AS averageoffercost,
    COALESCE(product.lastoffercost, product.lastpurchasecost, (0)::numeric) AS offercostorlastpurchase
   FROM ((((public.basicproductioncounting_productioncountingquantity pcq
     JOIN public.orders_order o ON ((o.id = pcq.order_id)))
     JOIN public.basic_product product ON ((product.id = pcq.product_id)))
     JOIN public.technologies_technologyoperationcomponent toc ON ((pcq.technologyoperationcomponent_id = toc.id)))
     LEFT JOIN public.ordersupplies_coverageproducttypedto coverageproducttype ON ((coverageproducttype.productid = pcq.product_id)))
  WHERE (((pcq.role)::text = '01used'::text) AND ((pcq.typeofmaterial)::text = ANY (ARRAY[('01component'::character varying)::text])) AND ((o.state)::text = ANY (ARRAY[('01pending'::character varying)::text, ('02accepted'::character varying)::text, ('03inProgress'::character varying)::text, ('06interrupted'::character varying)::text])) AND (o.active = true) AND ((o.typeofproductionrecording)::text = '03forEach'::text));


--
-- Name: ordersupplies_productioncountingquantityinput_id_seq; Type: SEQUENCE; Schema: public; Owner: -
--

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


--
-- Name: ordersupplies_productioncountingquantityoutput; Type: VIEW; Schema: public; Owner: -
--

CREATE VIEW public.ordersupplies_productioncountingquantityoutput AS
 SELECT pcq.id,
    (o.id)::integer AS orderid,
    o.finishdate,
    o.state AS orderstate,
    (product.id)::integer AS productid,
    (toc.operation_id)::integer AS operationid,
    (pcq.technologyoperationcomponent_id)::integer AS technologyoperationcomponentid,
    pcq.plannedquantity,
    COALESCE(pcq.producedquantity, (0)::numeric) AS producedquantity,
    GREATEST((pcq.plannedquantity - COALESCE(pcq.producedquantity, (0)::numeric)), (0)::numeric) AS quantity,
    '05orderOutput'::text AS eventtype,
    pcq.typeofmaterial AS producttype,
    product.averagecost AS price,
    COALESCE(product.averagecost, (0)::numeric) AS averagecost,
    COALESCE(product.lastpurchasecost, (0)::numeric) AS lastpurchasecost,
    COALESCE(product.nominalcost, (0)::numeric) AS nominalcost,
    COALESCE(product.lastoffercost, (0)::numeric) AS lastoffercost,
    COALESCE(product.averageoffercost, (0)::numeric) AS averageoffercost,
    COALESCE(product.lastoffercost, product.lastpurchasecost, (0)::numeric) AS offercostorlastpurchase
   FROM (((public.basicproductioncounting_productioncountingquantity pcq
     JOIN public.orders_order o ON ((o.id = pcq.order_id)))
     JOIN public.basic_product product ON ((product.id = pcq.product_id)))
     JOIN public.technologies_technologyoperationcomponent toc ON ((pcq.technologyoperationcomponent_id = toc.id)))
  WHERE (((pcq.role)::text = '02produced'::text) AND (((pcq.typeofmaterial)::text = '03finalProduct'::text) OR ((pcq.typeofmaterial)::text = '05additionalFinalProduct'::text)) AND ((o.state)::text = ANY (ARRAY[('01pending'::character varying)::text, ('02accepted'::character varying)::text, ('03inProgress'::character varying)::text, ('06interrupted'::character varying)::text])) AND (o.active = true));


--
-- Name: ordersupplies_productioncountingquantityoutput_id_seq; Type: SEQUENCE; Schema: public; Owner: -
--

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


--
-- Name: ordersupplies_productioncountingusedquantity; Type: VIEW; Schema: public; Owner: -
--

CREATE VIEW public.ordersupplies_productioncountingusedquantity AS
 SELECT sum(topic.usedquantity) AS usedquantity,
    pt.order_id,
    topic.product_id,
    pt.technologyoperationcomponent_id
   FROM ((public.productioncounting_trackingoperationproductincomponent topic
     JOIN public.productioncounting_productiontracking pt ON ((pt.id = topic.productiontracking_id)))
     JOIN public.orders_order o ON ((o.id = pt.order_id)))
  WHERE (((pt.state)::text = ANY (ARRAY[('02accepted'::character varying)::text])) AND ((o.state)::text = ANY (ARRAY[('03inProgress'::character varying)::text, ('06interrupted'::character varying)::text])))
  GROUP BY pt.order_id, topic.product_id, pt.technologyoperationcomponent_id;


--
-- Name: productcatalognumbers_productcatalognumbers_id_seq; Type: SEQUENCE; Schema: public; Owner: -
--

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


--
-- Name: productcatalognumbers_productcatalognumbers_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: -
--

ALTER SEQUENCE public.productcatalognumbers_productcatalognumbers_id_seq OWNED BY public.productcatalognumbers_productcatalognumbers.id;


--
-- Name: productflowthrudivision_issue; Type: TABLE; Schema: public; Owner: -
--

CREATE TABLE public.productflowthrudivision_issue (
    id bigint NOT NULL,
    warehouseissue_id bigint,
    product_id bigint,
    productincomponent_id bigint,
    demandquantity numeric(12,5),
    locationsquantity numeric(12,5),
    issuequantity numeric(12,5),
    location_id bigint,
    entityversion bigint DEFAULT 0,
    locationtoquantity numeric(12,5),
    quantityperunit numeric(12,5),
    issued boolean DEFAULT false,
    additionaldemandquantity numeric(12,5),
    conversion numeric(12,5),
    dateofissued timestamp without time zone,
    document_id bigint
);


--
-- Name: productflowthrudivision_issue_id_seq; Type: SEQUENCE; Schema: public; Owner: -
--

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


--
-- Name: productflowthrudivision_issue_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: -
--

ALTER SEQUENCE public.productflowthrudivision_issue_id_seq OWNED BY public.productflowthrudivision_issue.id;


--
-- Name: productflowthrudivision_warehouseissue; Type: TABLE; Schema: public; Owner: -
--

CREATE TABLE public.productflowthrudivision_warehouseissue (
    id bigint NOT NULL,
    number character varying(255),
    description character varying(2048),
    order_id bigint,
    placeofissue_id bigint,
    division_id bigint,
    workerwhoissued_id bigint,
    workerwhocollected_id bigint,
    dateofissued timestamp without time zone,
    dateofcreation timestamp without time zone,
    technologyoperationcomponent_id bigint,
    collectionproducts character varying(255) DEFAULT '01onOrder'::character varying,
    state character varying(255) DEFAULT '01draft'::character varying,
    createdate timestamp without time zone,
    updatedate timestamp without time zone,
    createuser character varying(255),
    updateuser character varying(255),
    entityversion bigint DEFAULT 0,
    productstoissuemode character varying(255) DEFAULT '01allInputProducts'::character varying
);


--
-- Name: productflowthrudivision_issuedto; Type: VIEW; Schema: public; Owner: -
--

CREATE VIEW public.productflowthrudivision_issuedto AS
 SELECT issue.id,
    warehouseissue.number AS warehouseissuenumber,
    product.name AS productname,
    product.number AS productnumber,
    product.unit AS productunit,
    issue.demandquantity,
    issue.issuequantity,
    issue.locationtoquantity,
    issue.quantityperunit,
    issue.locationsquantity,
    issue.additionaldemandquantity,
    issue.issued,
    issue.conversion,
    issue.dateofissued,
    warehouseissue.state AS warehouseissuestate,
    location.number AS locationnumber,
    (location.id)::integer AS locationid,
    document.number AS documentnumber,
    document.state AS documentstate
   FROM ((((public.productflowthrudivision_issue issue
     LEFT JOIN public.productflowthrudivision_warehouseissue warehouseissue ON ((warehouseissue.id = issue.warehouseissue_id)))
     LEFT JOIN public.basic_product product ON ((product.id = issue.product_id)))
     LEFT JOIN public.materialflow_location location ON ((location.id = issue.location_id)))
     LEFT JOIN public.materialflowresources_document document ON ((document.id = issue.document_id)));


--
-- Name: productflowthrudivision_issuedto_id_seq; Type: SEQUENCE; Schema: public; Owner: -
--

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


--
-- Name: productflowthrudivision_materialavailability; Type: TABLE; Schema: public; Owner: -
--

CREATE TABLE public.productflowthrudivision_materialavailability (
    id bigint NOT NULL,
    order_id bigint,
    product_id bigint,
    availablequantity numeric(19,5),
    requiredquantity numeric(19,5),
    unit character varying(255),
    entityversion bigint DEFAULT 0,
    location_id bigint,
    availability character varying,
    replacement boolean DEFAULT false,
    batchesid character varying(255),
    batches character varying(255),
    batchesquantity numeric(19,5)
);


--
-- Name: productflowthrudivision_materialavailability_id_seq; Type: SEQUENCE; Schema: public; Owner: -
--

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


--
-- Name: productflowthrudivision_materialavailability_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: -
--

ALTER SEQUENCE public.productflowthrudivision_materialavailability_id_seq OWNED BY public.productflowthrudivision_materialavailability.id;


--
-- Name: productflowthrudivision_materialavailabilitydto; Type: VIEW; Schema: public; Owner: -
--

CREATE VIEW public.productflowthrudivision_materialavailabilitydto AS
 SELECT materialavailability.id,
    materialavailability.order_id,
    (materialavailability.order_id)::integer AS orderid,
    materialavailability.product_id,
    (materialavailability.product_id)::integer AS productid,
    materialavailability.location_id,
    (materialavailability.location_id)::integer AS locationid,
    location.number AS locationnumber,
    ordersorder.number AS ordernumber,
    product.number AS productnumber,
    product.name AS productname,
    product.unit AS productunit,
    materialavailability.availablequantity,
    materialavailability.requiredquantity,
    materialavailability.unit,
    materialavailability.availability,
    materialavailability.replacement,
    materialavailability.batchesid,
    materialavailability.batches,
    COALESCE(materialavailability.batchesquantity, (0)::numeric) AS batchesquantity,
        CASE
            WHEN ((materialavailability.requiredquantity > COALESCE(materialavailability.batchesquantity, (0)::numeric)) AND (materialavailability.batchesid IS NOT NULL)) THEN 'red-cell'::text
            ELSE 'base-cell'::text
        END AS batchesquantityclass,
    (defaultstoragelocationdto.storagelocation_id)::integer AS storagelocationid,
    defaultstoragelocationdto.number AS storagelocationnumber
   FROM ((((public.productflowthrudivision_materialavailability materialavailability
     JOIN public.orders_order ordersorder ON ((ordersorder.id = materialavailability.order_id)))
     JOIN public.basic_product product ON ((product.id = materialavailability.product_id)))
     LEFT JOIN public.materialflow_location location ON ((location.id = materialavailability.location_id)))
     LEFT JOIN public.materialflowresources_defaultstoragelocationdto defaultstoragelocationdto ON (((defaultstoragelocationdto.location_id = location.id) AND (defaultstoragelocationdto.product_id = product.id))));


--
-- Name: productflowthrudivision_materialavailabilitydto_id_seq; Type: SEQUENCE; Schema: public; Owner: -
--

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


--
-- Name: productflowthrudivision_modelcard; Type: TABLE; Schema: public; Owner: -
--

CREATE TABLE public.productflowthrudivision_modelcard (
    id bigint NOT NULL,
    number character varying(255),
    name character varying(1024),
    generated boolean,
    filename character varying(255),
    date timestamp without time zone,
    worker character varying(255),
    materialcostsused character varying(255) DEFAULT 'nominal'::character varying,
    usenominalcostpricenotspecified boolean DEFAULT false
);


--
-- Name: productflowthrudivision_modelcard_id_seq; Type: SEQUENCE; Schema: public; Owner: -
--

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


--
-- Name: productflowthrudivision_modelcard_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: -
--

ALTER SEQUENCE public.productflowthrudivision_modelcard_id_seq OWNED BY public.productflowthrudivision_modelcard.id;


--
-- Name: productflowthrudivision_modelcardproduct; Type: TABLE; Schema: public; Owner: -
--

CREATE TABLE public.productflowthrudivision_modelcardproduct (
    id bigint NOT NULL,
    modelcard_id bigint,
    product_id bigint,
    technology_id bigint,
    quantity numeric(14,5),
    succession integer
);


--
-- Name: productflowthrudivision_modelcardproduct_id_seq; Type: SEQUENCE; Schema: public; Owner: -
--

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


--
-- Name: productflowthrudivision_modelcardproduct_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: -
--

ALTER SEQUENCE public.productflowthrudivision_modelcardproduct_id_seq OWNED BY public.productflowthrudivision_modelcardproduct.id;


--
-- Name: productflowthrudivision_opertaskmaterialavailability; Type: TABLE; Schema: public; Owner: -
--

CREATE TABLE public.productflowthrudivision_opertaskmaterialavailability (
    id bigint NOT NULL,
    operationaltask_id bigint,
    product_id bigint,
    location_id bigint,
    availablequantity numeric(19,5),
    requiredquantity numeric(19,5),
    unit character varying(255),
    availability character varying(255),
    replacement boolean DEFAULT false,
    batchesid character varying(255),
    batches character varying(255),
    batchesquantity numeric(19,5),
    typeofmaterial character varying(255),
    produced numeric(19,5)
);


--
-- Name: productflowthrudivision_opertaskmaterialavailability_id_seq; Type: SEQUENCE; Schema: public; Owner: -
--

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


--
-- Name: productflowthrudivision_opertaskmaterialavailability_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: -
--

ALTER SEQUENCE public.productflowthrudivision_opertaskmaterialavailability_id_seq OWNED BY public.productflowthrudivision_opertaskmaterialavailability.id;


--
-- Name: productflowthrudivision_opertaskmaterialavailabilitydto; Type: VIEW; Schema: public; Owner: -
--

CREATE VIEW public.productflowthrudivision_opertaskmaterialavailabilitydto AS
 SELECT materialavailability.id,
    materialavailability.operationaltask_id,
    (materialavailability.operationaltask_id)::integer AS operationaltaskid,
    materialavailability.product_id,
    (materialavailability.product_id)::integer AS productid,
    materialavailability.location_id,
    (materialavailability.location_id)::integer AS locationid,
    location.number AS locationnumber,
    operationaltask.number AS operationaltasknumber,
    product.number AS productnumber,
    product.name AS productname,
    product.unit AS productunit,
    materialavailability.availablequantity,
    materialavailability.requiredquantity,
    materialavailability.unit,
    materialavailability.availability,
    materialavailability.replacement,
    materialavailability.batchesid,
    materialavailability.batches,
    COALESCE(materialavailability.batchesquantity, (0)::numeric) AS batchesquantity,
        CASE
            WHEN ((materialavailability.requiredquantity > COALESCE(materialavailability.batchesquantity, (0)::numeric)) AND (materialavailability.batchesid IS NOT NULL)) THEN 'red-cell'::text
            ELSE 'base-cell'::text
        END AS batchesquantityclass,
    materialavailability.typeofmaterial,
    COALESCE(materialavailability.produced, (0)::numeric) AS produced
   FROM (((public.productflowthrudivision_opertaskmaterialavailability materialavailability
     JOIN public.orders_operationaltask operationaltask ON ((operationaltask.id = materialavailability.operationaltask_id)))
     JOIN public.basic_product product ON ((product.id = materialavailability.product_id)))
     LEFT JOIN public.materialflow_location location ON ((location.id = materialavailability.location_id)));


--
-- Name: productflowthrudivision_opertaskmaterialavailabilitydto_id_seq; Type: SEQUENCE; Schema: public; Owner: -
--

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


--
-- Name: productflowthrudivision_orderproductresourcereservation; Type: TABLE; Schema: public; Owner: -
--

CREATE TABLE public.productflowthrudivision_orderproductresourcereservation (
    id bigint NOT NULL,
    resource_id bigint,
    resourcenumber character varying(255),
    planedquantity numeric(12,5),
    usedquantity numeric(12,5),
    productioncountingquantity_id bigint,
    priority integer,
    resourceunit character varying(255),
    creationdate timestamp without time zone
);


--
-- Name: productflowthrudivision_orderproductresourcereservation_id_seq; Type: SEQUENCE; Schema: public; Owner: -
--

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


--
-- Name: productflowthrudivision_orderproductresourcereservation_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: -
--

ALTER SEQUENCE public.productflowthrudivision_orderproductresourcereservation_id_seq OWNED BY public.productflowthrudivision_orderproductresourcereservation.id;


--
-- Name: productflowthrudivision_plannedconsumptioninorderdto; Type: VIEW; Schema: public; Owner: -
--

CREATE VIEW public.productflowthrudivision_plannedconsumptioninorderdto AS
 SELECT pcq.id,
    (o.id)::integer AS orderid,
    o.number AS ordernumber,
    o.startdate AS orderstartdate,
    o.state AS orderstate,
    o.plannedquantity AS orderplanedquantity,
    COALESCE(o.donequantity, (0)::numeric) AS orderdonequantity,
    op.number AS orderproduct,
    op.unit AS orderunit,
    pl.number AS productionlinenumber,
    (p.id)::integer AS productid,
    op.name AS productnumber,
    p.unit AS productunit,
    pcq.plannedquantity AS productplannedquantity,
    pcq.usedquantity AS productusedquantity,
    GREATEST((pcq.plannedquantity - COALESCE(pcq.usedquantity, (0)::numeric)), (0)::numeric) AS productactualneedquantity,
    d.number AS divisionnumber
   FROM (((((public.basicproductioncounting_productioncountingquantity pcq
     LEFT JOIN public.orders_order o ON ((o.id = pcq.order_id)))
     LEFT JOIN public.basic_product p ON ((p.id = pcq.product_id)))
     LEFT JOIN public.basic_product op ON ((op.id = o.product_id)))
     LEFT JOIN public.basic_division d ON ((d.id = o.division_id)))
     LEFT JOIN public.productionlines_productionline pl ON ((pl.id = o.productionline_id)))
  WHERE (((pcq.role)::text = '01used'::text) AND ((pcq.typeofmaterial)::text = ANY (ARRAY[('01component'::character varying)::text])) AND ((o.state)::text = ANY (ARRAY[('01pending'::character varying)::text, ('02accepted'::character varying)::text, ('03inProgress'::character varying)::text, ('06interrupted'::character varying)::text])) AND (o.active = true));


--
-- Name: productflowthrudivision_plannedconsumptioninorderdto_id_seq; Type: SEQUENCE; Schema: public; Owner: -
--

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


--
-- Name: productflowthrudivision_productandquantityhelper; Type: TABLE; Schema: public; Owner: -
--

CREATE TABLE public.productflowthrudivision_productandquantityhelper (
    id bigint NOT NULL,
    product_id bigint,
    location_id bigint,
    locationsquantity numeric(12,5)
);


--
-- Name: productflowthrudivision_productandquantityhelper_id_seq; Type: SEQUENCE; Schema: public; Owner: -
--

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


--
-- Name: productflowthrudivision_productandquantityhelper_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: -
--

ALTER SEQUENCE public.productflowthrudivision_productandquantityhelper_id_seq OWNED BY public.productflowthrudivision_productandquantityhelper.id;


--
-- Name: productflowthrudivision_productstoissue; Type: TABLE; Schema: public; Owner: -
--

CREATE TABLE public.productflowthrudivision_productstoissue (
    id bigint NOT NULL,
    warehouseissue_id bigint,
    product_id bigint,
    productincomponent_id bigint,
    demandquantity numeric(12,5),
    locationsquantity numeric(12,5),
    placeofissuequantity numeric(12,5),
    issuequantity numeric(12,5),
    location_id bigint,
    entityversion bigint DEFAULT 0,
    issued boolean DEFAULT false,
    additionaldemandquantity numeric(12,5),
    conversion numeric(12,5),
    correction numeric(12,5)
);


--
-- Name: productflowthrudivision_productstoissue_id_seq; Type: SEQUENCE; Schema: public; Owner: -
--

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


--
-- Name: productflowthrudivision_productstoissue_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: -
--

ALTER SEQUENCE public.productflowthrudivision_productstoissue_id_seq OWNED BY public.productflowthrudivision_productstoissue.id;


--
-- Name: productflowthrudivision_productstoissuehelper; Type: TABLE; Schema: public; Owner: -
--

CREATE TABLE public.productflowthrudivision_productstoissuehelper (
    id bigint NOT NULL,
    locationfrom_id bigint,
    productstoissueids character varying(255),
    generated boolean DEFAULT false,
    additionalinfo character varying(255)
);


--
-- Name: productflowthrudivision_productstoissuehelper_id_seq; Type: SEQUENCE; Schema: public; Owner: -
--

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


--
-- Name: productflowthrudivision_productstoissuehelper_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: -
--

ALTER SEQUENCE public.productflowthrudivision_productstoissuehelper_id_seq OWNED BY public.productflowthrudivision_productstoissuehelper.id;


--
-- Name: productflowthrudivision_producttoissuecorrection; Type: TABLE; Schema: public; Owner: -
--

CREATE TABLE public.productflowthrudivision_producttoissuecorrection (
    id bigint NOT NULL,
    producttoissuecorrectionhelper_id bigint,
    warehouseissue_id bigint,
    product_id bigint,
    correctionquantity numeric(12,5),
    correctionquantityinadditionalunit numeric(12,5),
    quantitytoissue numeric(12,5),
    demandquantity numeric(12,5),
    conversion numeric(12,5),
    location_id bigint,
    description character varying(255),
    createdate timestamp without time zone,
    updatedate timestamp without time zone,
    createuser character varying(255),
    updateuser character varying(255),
    productstoissue_id bigint
);


--
-- Name: productflowthrudivision_producttoissuecorrection_id_seq; Type: SEQUENCE; Schema: public; Owner: -
--

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


--
-- Name: productflowthrudivision_producttoissuecorrection_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: -
--

ALTER SEQUENCE public.productflowthrudivision_producttoissuecorrection_id_seq OWNED BY public.productflowthrudivision_producttoissuecorrection.id;


--
-- Name: productflowthrudivision_producttoissuecorrectionhelper; Type: TABLE; Schema: public; Owner: -
--

CREATE TABLE public.productflowthrudivision_producttoissuecorrectionhelper (
    id bigint NOT NULL,
    locationfrom_id bigint,
    locationto_id bigint,
    productstoissueids character varying(255)
);


--
-- Name: productflowthrudivision_producttoissuecorrectionhelper_id_seq; Type: SEQUENCE; Schema: public; Owner: -
--

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


--
-- Name: productflowthrudivision_producttoissuecorrectionhelper_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: -
--

ALTER SEQUENCE public.productflowthrudivision_producttoissuecorrectionhelper_id_seq OWNED BY public.productflowthrudivision_producttoissuecorrectionhelper.id;


--
-- Name: productflowthrudivision_producttoissuedto_internal; Type: VIEW; Schema: public; Owner: -
--

CREATE VIEW public.productflowthrudivision_producttoissuedto_internal AS
 SELECT row_number() OVER () AS id,
    resource.location_id,
    (resource.product_id)::integer AS product_id,
    sum(resource.quantity) AS quantity
   FROM public.materialflowresources_resource resource
  GROUP BY resource.location_id, resource.product_id;


--
-- Name: qcadooplugin_plugin; Type: TABLE; Schema: public; Owner: -
--

CREATE TABLE public.qcadooplugin_plugin (
    id bigint NOT NULL,
    identifier character varying(255),
    version character varying(255),
    state character varying(255),
    issystem boolean,
    entityversion bigint DEFAULT 0,
    groupname character varying(255),
    license character varying(255)
);


--
-- Name: productflowthrudivision_producttoissuedto; Type: VIEW; Schema: public; Owner: -
--

CREATE VIEW public.productflowthrudivision_producttoissuedto AS
 SELECT producttoissue.id,
    issue.number AS issuenumber,
    locationfrom.number AS locationfromnumber,
    locationto.number AS locationtonumber,
    o.number AS ordernumber,
    o.startdate AS orderstartdate,
    issue.state,
    product.number AS productnumber,
    product.name AS productname,
    producttoissue.demandquantity,
    o.plannedquantity AS orderquantity,
    round((producttoissue.demandquantity / o.plannedquantity), 5) AS quantityperunit,
    producttoissue.conversion,
    product.additionalunit AS unitadditional,
    producttoissue.issuequantity AS issuedquantity,
        CASE
            WHEN (((producttoissue.demandquantity - producttoissue.issuequantity) - COALESCE(producttoissue.correction, (0)::numeric)) < (0)::numeric) THEN (0)::numeric
            ELSE ((producttoissue.demandquantity - producttoissue.issuequantity) - COALESCE(producttoissue.correction, (0)::numeric))
        END AS quantitytoissue,
        CASE
            WHEN (((producttoissue.demandquantity - producttoissue.issuequantity) - COALESCE(producttoissue.correction, (0)::numeric)) < (0)::numeric) THEN (0)::numeric
            ELSE round((((producttoissue.demandquantity - producttoissue.issuequantity) - COALESCE(producttoissue.correction, (0)::numeric)) * producttoissue.conversion))
        END AS quantitytoissueinaddunit,
        CASE
            WHEN (((plu.state)::text = 'DISABLED'::text) AND (warehousestockfrom.quantity IS NULL)) THEN (0)::numeric
            WHEN (((plu.state)::text = 'DISABLED'::text) AND (warehousestockfrom.quantity IS NOT NULL)) THEN warehousestockfrom.quantity
            WHEN ((locationfrom.externalnumber IS NULL) AND (warehousestockfrom.quantity IS NULL)) THEN (0)::numeric
            WHEN ((locationfrom.externalnumber IS NULL) AND (warehousestockfrom.quantity IS NOT NULL)) THEN warehousestockfrom.quantity
            WHEN ((locationfrom.externalnumber IS NOT NULL) AND (warehousestockfromexternal.locationsquantity IS NULL)) THEN (0)::numeric
            WHEN ((locationfrom.externalnumber IS NOT NULL) AND (warehousestockfromexternal.locationsquantity IS NOT NULL)) THEN warehousestockfromexternal.locationsquantity
            ELSE warehousestockfrom.quantity
        END AS quantityinlocationfrom,
        CASE
            WHEN (((plu.state)::text = 'DISABLED'::text) AND (warehousestockto.quantity IS NULL)) THEN (0)::numeric
            WHEN (((plu.state)::text = 'DISABLED'::text) AND (warehousestockto.quantity IS NOT NULL)) THEN warehousestockto.quantity
            WHEN ((locationfrom.externalnumber IS NULL) AND (warehousestockto.quantity IS NULL)) THEN (0)::numeric
            WHEN ((locationfrom.externalnumber IS NULL) AND (warehousestockto.quantity IS NOT NULL)) THEN warehousestockto.quantity
            WHEN ((locationfrom.externalnumber IS NOT NULL) AND (warehousestocktoexternal.locationsquantity IS NULL)) THEN (0)::numeric
            WHEN ((locationfrom.externalnumber IS NOT NULL) AND (warehousestocktoexternal.locationsquantity IS NOT NULL)) THEN warehousestocktoexternal.locationsquantity
            ELSE warehousestockfrom.quantity
        END AS quantityinlocationto,
    product.unit,
        CASE
            WHEN ((producttoissue.demandquantity <= producttoissue.issuequantity) OR (((producttoissue.demandquantity - producttoissue.issuequantity) - COALESCE(producttoissue.correction, (0)::numeric)) <= (0)::numeric)) THEN true
            ELSE false
        END AS issued,
    product.id AS productid,
    producttoissue.correction,
    (locationfrom.id)::integer AS locationfrom_id,
    (locationto.id)::integer AS locationto_id
   FROM ((((((((((public.productflowthrudivision_productstoissue producttoissue
     JOIN public.qcadooplugin_plugin plu ON (((plu.identifier)::text = 'integration'::text)))
     LEFT JOIN public.productflowthrudivision_warehouseissue issue ON ((producttoissue.warehouseissue_id = issue.id)))
     LEFT JOIN public.materialflow_location locationfrom ON ((issue.placeofissue_id = locationfrom.id)))
     LEFT JOIN public.materialflow_location locationto ON ((producttoissue.location_id = locationto.id)))
     LEFT JOIN public.orders_order o ON ((issue.order_id = o.id)))
     LEFT JOIN public.basic_product product ON ((producttoissue.product_id = product.id)))
     LEFT JOIN public.productflowthrudivision_producttoissuedto_internal warehousestockfrom ON (((warehousestockfrom.product_id = producttoissue.product_id) AND (warehousestockfrom.location_id = locationfrom.id))))
     LEFT JOIN public.productflowthrudivision_producttoissuedto_internal warehousestockto ON (((warehousestockto.product_id = producttoissue.product_id) AND (warehousestockto.location_id = locationto.id))))
     LEFT JOIN public.productflowthrudivision_productandquantityhelper warehousestockfromexternal ON (((warehousestockfromexternal.product_id = producttoissue.product_id) AND (warehousestockfromexternal.location_id = locationfrom.id))))
     LEFT JOIN public.productflowthrudivision_productandquantityhelper warehousestocktoexternal ON (((warehousestocktoexternal.product_id = producttoissue.product_id) AND (warehousestocktoexternal.location_id = locationto.id))))
  WHERE ((issue.state)::text = ANY (ARRAY[('01draft'::character varying)::text, ('02inProgress'::character varying)::text]));


--
-- Name: productflowthrudivision_producttoissuedto_id_seq; Type: SEQUENCE; Schema: public; Owner: -
--

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


--
-- Name: productflowthrudivision_producttoissuedto_internal_id_seq; Type: SEQUENCE; Schema: public; Owner: -
--

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


--
-- Name: productflowthrudivision_trackingproductresourcereservation; Type: TABLE; Schema: public; Owner: -
--

CREATE TABLE public.productflowthrudivision_trackingproductresourcereservation (
    id bigint NOT NULL,
    priority integer,
    orderproductresourcereservation_id bigint,
    trackingoperationproductincomponent_id bigint,
    usedquantity numeric(12,5)
);


--
-- Name: productflowthrudivision_trackingproductresourcereservation_id_s; Type: SEQUENCE; Schema: public; Owner: -
--

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


--
-- Name: productflowthrudivision_trackingproductresourcereservation_id_s; Type: SEQUENCE OWNED BY; Schema: public; Owner: -
--

ALTER SEQUENCE public.productflowthrudivision_trackingproductresourcereservation_id_s OWNED BY public.productflowthrudivision_trackingproductresourcereservation.id;


--
-- Name: productflowthrudivision_warehouseissue_id_seq; Type: SEQUENCE; Schema: public; Owner: -
--

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


--
-- Name: productflowthrudivision_warehouseissue_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: -
--

ALTER SEQUENCE public.productflowthrudivision_warehouseissue_id_seq OWNED BY public.productflowthrudivision_warehouseissue.id;


--
-- Name: productflowthrudivision_warehouseissue_number_seq; Type: SEQUENCE; Schema: public; Owner: -
--

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


--
-- Name: productflowthrudivision_warehouseissuestatechange; Type: TABLE; Schema: public; Owner: -
--

CREATE TABLE public.productflowthrudivision_warehouseissuestatechange (
    id bigint NOT NULL,
    dateandtime timestamp without time zone,
    sourcestate character varying(255),
    targetstate character varying(255),
    status character varying(255),
    phase integer,
    worker character varying(255),
    warehouseissue_id bigint,
    shift_id bigint,
    additionalinformation character varying(255),
    entityversion bigint DEFAULT 0
);


--
-- Name: productflowthrudivision_warehouseissuestatechange_id_seq; Type: SEQUENCE; Schema: public; Owner: -
--

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


--
-- Name: productflowthrudivision_warehouseissuestatechange_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: -
--

ALTER SEQUENCE public.productflowthrudivision_warehouseissuestatechange_id_seq OWNED BY public.productflowthrudivision_warehouseissuestatechange.id;


--
-- Name: productioncounting_anomaly; Type: TABLE; Schema: public; Owner: -
--

CREATE TABLE public.productioncounting_anomaly (
    id bigint NOT NULL,
    number character varying(255),
    productiontracking_id bigint,
    masterproduct_id bigint,
    product_id bigint,
    usedquantity numeric(14,5),
    state character varying(255) DEFAULT '01draft'::character varying,
    issued boolean DEFAULT false,
    createdate timestamp without time zone,
    updatedate timestamp without time zone,
    createuser character varying(255),
    updateuser character varying(255),
    location_id bigint
);


--
-- Name: productioncounting_anomaly_id_seq; Type: SEQUENCE; Schema: public; Owner: -
--

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


--
-- Name: productioncounting_anomaly_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: -
--

ALTER SEQUENCE public.productioncounting_anomaly_id_seq OWNED BY public.productioncounting_anomaly.id;


--
-- Name: productioncounting_anomalyreason; Type: TABLE; Schema: public; Owner: -
--

CREATE TABLE public.productioncounting_anomalyreason (
    id bigint NOT NULL,
    name character varying(255),
    defaultreason boolean DEFAULT false
);


--
-- Name: productioncounting_anomalydto; Type: VIEW; Schema: public; Owner: -
--

CREATE VIEW public.productioncounting_anomalydto AS
 SELECT DISTINCT anomaly.id,
    anomaly.number,
    anomaly.usedquantity,
    anomaly.state,
    anomaly.issued,
    anomaly.createdate,
    product.number AS productnumber,
    product.name AS productname,
    product.unit AS productunit,
    ordersorder.number AS ordernumber,
    productionline.number AS productionlinenumber,
    division.number AS divisionnumber,
    productiontracking.number AS productiontrackingnumber,
    array_to_string(ARRAY( SELECT reson.name
           FROM (public.jointable_anomaly_anomalyreason anomaly_anomalyreason
             LEFT JOIN public.productioncounting_anomalyreason reson ON ((anomaly_anomalyreason.anomalyreason_id = reson.id)))
          WHERE (anomaly_anomalyreason.anomaly_id = anomaly.id)), ', '::text) AS reasons
   FROM (((((public.productioncounting_anomaly anomaly
     LEFT JOIN public.productioncounting_productiontracking productiontracking ON ((anomaly.productiontracking_id = productiontracking.id)))
     LEFT JOIN public.orders_order ordersorder ON ((ordersorder.id = productiontracking.order_id)))
     LEFT JOIN public.basic_product product ON ((anomaly.product_id = product.id)))
     LEFT JOIN public.productionlines_productionline productionline ON ((productionline.id = ordersorder.productionline_id)))
     LEFT JOIN public.basic_division division ON ((division.id = productiontracking.division_id)));


--
-- Name: productioncounting_anomalydto_id_seq; Type: SEQUENCE; Schema: public; Owner: -
--

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


--
-- Name: productioncounting_anomalyexplanation; Type: TABLE; Schema: public; Owner: -
--

CREATE TABLE public.productioncounting_anomalyexplanation (
    id bigint NOT NULL,
    anomaly_id bigint,
    product_id bigint,
    location_id bigint,
    usedquantity numeric(14,5),
    givenquantity numeric(14,5),
    givenunit character varying(255),
    usewaste boolean DEFAULT false,
    description character varying(1024),
    createdate timestamp without time zone,
    updatedate timestamp without time zone,
    createuser character varying(255),
    updateuser character varying(255)
);


--
-- Name: productioncounting_anomalyexplanation_id_seq; Type: SEQUENCE; Schema: public; Owner: -
--

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


--
-- Name: productioncounting_anomalyexplanation_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: -
--

ALTER SEQUENCE public.productioncounting_anomalyexplanation_id_seq OWNED BY public.productioncounting_anomalyexplanation.id;


--
-- Name: productioncounting_anomalyexplanationdto; Type: VIEW; Schema: public; Owner: -
--

CREATE VIEW public.productioncounting_anomalyexplanationdto AS
 SELECT anomalyexplanation.id,
    anomalyexplanation.usedquantity,
    anomalyexplanation.description,
    anomalyexplanation.createuser,
    anomalyexplanation.createdate,
    (anomaly.id)::integer AS anomalyid,
    product.number AS productnumber,
    product.name AS productname,
    materialflow_location.number AS locationnumber,
        CASE
            WHEN anomalyexplanation.usewaste THEN anomalyexplanation.givenunit
            ELSE product.unit
        END AS productunit
   FROM (((public.productioncounting_anomalyexplanation anomalyexplanation
     JOIN public.productioncounting_anomaly anomaly ON ((anomaly.id = anomalyexplanation.anomaly_id)))
     LEFT JOIN public.basic_product product ON ((product.id = anomalyexplanation.product_id)))
     LEFT JOIN public.materialflow_location ON ((materialflow_location.id = anomalyexplanation.location_id)));


--
-- Name: productioncounting_anomalyexplanationdto_id_seq; Type: SEQUENCE; Schema: public; Owner: -
--

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


--
-- Name: productioncounting_anomalyproductiontrackingentryhelper; Type: TABLE; Schema: public; Owner: -
--

CREATE TABLE public.productioncounting_anomalyproductiontrackingentryhelper (
    id bigint NOT NULL,
    anomalyproductiontracking_id bigint,
    trackingoperationproductincomponent_id bigint,
    createdate timestamp without time zone,
    updatedate timestamp without time zone,
    createuser character varying(255),
    updateuser character varying(255)
);


--
-- Name: productioncounting_anomalyproductiontrackingentryhelper_id_seq; Type: SEQUENCE; Schema: public; Owner: -
--

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


--
-- Name: productioncounting_anomalyproductiontrackingentryhelper_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: -
--

ALTER SEQUENCE public.productioncounting_anomalyproductiontrackingentryhelper_id_seq OWNED BY public.productioncounting_anomalyproductiontrackingentryhelper.id;


--
-- Name: productioncounting_anomalyproductiontrackinghelper; Type: TABLE; Schema: public; Owner: -
--

CREATE TABLE public.productioncounting_anomalyproductiontrackinghelper (
    id bigint NOT NULL,
    createdate timestamp without time zone,
    updatedate timestamp without time zone,
    createuser character varying(255),
    updateuser character varying(255)
);


--
-- Name: productioncounting_anomalyproductiontrackinghelper_id_seq; Type: SEQUENCE; Schema: public; Owner: -
--

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


--
-- Name: productioncounting_anomalyproductiontrackinghelper_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: -
--

ALTER SEQUENCE public.productioncounting_anomalyproductiontrackinghelper_id_seq OWNED BY public.productioncounting_anomalyproductiontrackinghelper.id;


--
-- Name: productioncounting_anomalyreason_id_seq; Type: SEQUENCE; Schema: public; Owner: -
--

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


--
-- Name: productioncounting_anomalyreason_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: -
--

ALTER SEQUENCE public.productioncounting_anomalyreason_id_seq OWNED BY public.productioncounting_anomalyreason.id;


--
-- Name: productioncounting_anomalyreasoncontainer; Type: TABLE; Schema: public; Owner: -
--

CREATE TABLE public.productioncounting_anomalyreasoncontainer (
    id bigint NOT NULL,
    anomalyproductiontrackingentryhelper_id bigint,
    anomalyreason_id bigint
);


--
-- Name: productioncounting_anomalyreasoncontainer_id_seq; Type: SEQUENCE; Schema: public; Owner: -
--

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


--
-- Name: productioncounting_anomalyreasoncontainer_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: -
--

ALTER SEQUENCE public.productioncounting_anomalyreasoncontainer_id_seq OWNED BY public.productioncounting_anomalyreasoncontainer.id;


--
-- Name: productioncounting_beforeadditionalactionsanalysisentry; Type: VIEW; Schema: public; Owner: -
--

CREATE VIEW public.productioncounting_beforeadditionalactionsanalysisentry AS
 SELECT row_number() OVER () AS id,
    pl.number AS productionlinenumber,
    ord.number AS ordernumber,
    c.number AS companynumber,
    assortment.name AS assortmentname,
    product.number AS productnumber,
    product.name AS productname,
    product.unit AS productunit,
    size.number AS sizenumber,
    sum(COALESCE(topoc.usedquantity, (0)::numeric)) AS quantity,
    sum(COALESCE(topoc.wastesquantity, (0)::numeric)) AS wastes,
    (sum(COALESCE(topoc.usedquantity, (0)::numeric)) + sum(COALESCE(topoc.wastesquantity, (0)::numeric))) AS donequantity,
    date(date_trunc('day'::text, pt.timerangefrom)) AS timerangefrom,
    date(date_trunc('day'::text, pt.timerangeto)) AS timerangeto,
    shift.name AS shiftname,
    tcontext.number AS technologygeneratornumber
   FROM (((((((((((((public.productioncounting_productiontracking pt
     JOIN public.orders_order ord ON ((ord.id = pt.order_id)))
     JOIN public.technologies_technology technologyprototype ON ((technologyprototype.id = ord.technology_id)))
     JOIN public.technologies_technology technology ON ((technology.id = ord.technology_id)))
     LEFT JOIN public.technologiesgenerator_generatorcontext tcontext ON ((tcontext.id = technologyprototype.generatorcontext_id)))
     LEFT JOIN public.orders_order parentorder ON ((ord.parent_id = parentorder.id)))
     LEFT JOIN public.technologies_technology parenttechnology ON ((parenttechnology.id = parentorder.technology_id)))
     LEFT JOIN public.basic_shift shift ON ((pt.shift_id = shift.id)))
     LEFT JOIN public.productionlines_productionline pl ON ((ord.productionline_id = pl.id)))
     LEFT JOIN public.basic_company c ON ((c.id = ord.company_id)))
     JOIN public.productioncounting_trackingoperationproductoutcomponent topoc ON ((pt.id = topoc.productiontracking_id)))
     JOIN public.basic_product product ON ((topoc.product_id = product.id)))
     LEFT JOIN public.basic_assortment assortment ON ((product.assortment_id = assortment.id)))
     LEFT JOIN public.basic_size size ON ((size.id = product.size_id)))
  WHERE ((technology.additionalactions = false) AND ((parenttechnology.additionalactions = true) OR (ord.parent_id IS NULL)) AND ((product.id = ord.product_id) OR ((pt.technologyoperationcomponent_id IS NOT NULL) AND ((topoc.typeofmaterial)::text = '02intermediate'::text))))
  GROUP BY ord.number, shift.name, (date_trunc('day'::text, pt.timerangefrom)), (date_trunc('day'::text, pt.timerangeto)), pl.number, c.number, assortment.name, product.number, product.name, product.unit, size.number, tcontext.number
UNION ALL
 SELECT row_number() OVER () AS id,
    pl.number AS productionlinenumber,
    ord.number AS ordernumber,
    c.number AS companynumber,
    assortment.name AS assortmentname,
    product.number AS productnumber,
    product.name AS productname,
    product.unit AS productunit,
    size.number AS sizenumber,
    sum(COALESCE(topoc.usedquantity, (0)::numeric)) AS quantity,
    sum(COALESCE(topoc.wastesquantity, (0)::numeric)) AS wastes,
    (sum(COALESCE(topoc.usedquantity, (0)::numeric)) + sum(COALESCE(topoc.wastesquantity, (0)::numeric))) AS donequantity,
    date(date_trunc('day'::text, pt.timerangefrom)) AS timerangefrom,
    date(date_trunc('day'::text, pt.timerangeto)) AS timerangeto,
    shift.name AS shiftname,
    tcontext.number AS technologygeneratornumber
   FROM (((((((((((((public.arch_productioncounting_productiontracking pt
     JOIN public.arch_orders_order ord ON ((ord.id = pt.order_id)))
     JOIN public.technologies_technology technologyprototype ON ((technologyprototype.id = ord.technology_id)))
     JOIN public.technologies_technology technology ON ((technology.id = ord.technology_id)))
     LEFT JOIN public.technologiesgenerator_generatorcontext tcontext ON ((tcontext.id = technologyprototype.generatorcontext_id)))
     LEFT JOIN public.arch_orders_order parentorder ON ((ord.parent_id = parentorder.id)))
     LEFT JOIN public.technologies_technology parenttechnology ON ((parenttechnology.id = parentorder.technology_id)))
     LEFT JOIN public.basic_shift shift ON ((pt.shift_id = shift.id)))
     LEFT JOIN public.productionlines_productionline pl ON ((ord.productionline_id = pl.id)))
     LEFT JOIN public.basic_company c ON ((c.id = ord.company_id)))
     JOIN public.arch_productioncounting_trackingoperationproductoutcomponent topoc ON ((pt.id = topoc.productiontracking_id)))
     JOIN public.basic_product product ON ((topoc.product_id = product.id)))
     LEFT JOIN public.basic_assortment assortment ON ((product.assortment_id = assortment.id)))
     LEFT JOIN public.basic_size size ON ((size.id = product.size_id)))
  WHERE ((technology.additionalactions = false) AND ((parenttechnology.additionalactions = true) OR (ord.parent_id IS NULL)) AND ((product.id = ord.product_id) OR ((pt.technologyoperationcomponent_id IS NOT NULL) AND ((topoc.typeofmaterial)::text = '02intermediate'::text))))
  GROUP BY ord.number, shift.name, (date_trunc('day'::text, pt.timerangefrom)), (date_trunc('day'::text, pt.timerangeto)), pl.number, c.number, assortment.name, product.number, product.name, product.unit, size.number, tcontext.number;


--
-- Name: productioncounting_beforeadditionalactionsanalysisentry_id_seq; Type: SEQUENCE; Schema: public; Owner: -
--

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


--
-- Name: productioncounting_employeepieceworksettlementdto; Type: VIEW; Schema: public; Owner: -
--

CREATE VIEW public.productioncounting_employeepieceworksettlementdto AS
 SELECT (((staff.name)::text || ' '::text) || (staff.surname)::text) AS worker,
    COALESCE(productiontracking.shiftstartday, (productiontracking.createdate)::date) AS date,
    shift.name AS shiftname,
    ordersorder.number AS ordernumber,
    NULL::text AS operationnumber,
    product.number AS productnumber,
    product.name AS productname,
    COALESCE(sum(trackingoperationproductoutcomponent.usedquantity), (0)::numeric) AS producedquantity,
    COALESCE(max(piecerateitem.rate), (0)::numeric) AS rate,
    (COALESCE(sum(trackingoperationproductoutcomponent.usedquantity), (0)::numeric) * COALESCE(max(piecerateitem.rate), (0)::numeric)) AS cost
   FROM ((((((((public.productioncounting_productiontracking productiontracking
     LEFT JOIN public.productioncounting_trackingoperationproductoutcomponent trackingoperationproductoutcomponent ON (((trackingoperationproductoutcomponent.productiontracking_id = productiontracking.id) AND ((trackingoperationproductoutcomponent.typeofmaterial)::text = '03finalProduct'::text))))
     JOIN public.orders_order ordersorder ON ((ordersorder.id = productiontracking.order_id)))
     JOIN public.technologies_technology technology ON ((technology.id = ordersorder.technology_id)))
     JOIN public.basic_product product ON ((product.id = trackingoperationproductoutcomponent.product_id)))
     LEFT JOIN public.basic_shift shift ON ((shift.id = productiontracking.shift_id)))
     LEFT JOIN public.basic_staff staff ON ((staff.id = productiontracking.staff_id)))
     LEFT JOIN public.basic_piecerate piecerate ON ((piecerate.id = technology.piecerate_id)))
     LEFT JOIN LATERAL ( SELECT piecerateitem_1.actualrate AS rate
           FROM public.basic_piecerateitem piecerateitem_1
          WHERE ((piecerateitem_1.piecerate_id = piecerate.id) AND (piecerateitem_1.datefrom <= COALESCE(productiontracking.shiftstartday, (productiontracking.createdate)::date)))
          ORDER BY piecerateitem_1.datefrom DESC
         LIMIT 1) piecerateitem ON ((1 = 1)))
  WHERE (((productiontracking.state)::text = '02accepted'::text) AND ((ordersorder.typeofproductionrecording)::text = '02cumulated'::text) AND (technology.pieceworkproduction = true))
  GROUP BY (((staff.name)::text || ' '::text) || (staff.surname)::text), COALESCE(productiontracking.shiftstartday, (productiontracking.createdate)::date), shift.name, ordersorder.number, NULL::text, product.number, product.name
UNION ALL
 SELECT (((staff.name)::text || ' '::text) || (staff.surname)::text) AS worker,
    COALESCE(productiontracking.shiftstartday, (productiontracking.createdate)::date) AS date,
    shift.name AS shiftname,
    ordersorder.number AS ordernumber,
    operation.number AS operationnumber,
    product.number AS productnumber,
    product.name AS productname,
    COALESCE(sum(trackingoperationproductoutcomponent.usedquantity), (0)::numeric) AS producedquantity,
    COALESCE(max(piecerateitem.rate), (0)::numeric) AS rate,
    (COALESCE(sum(trackingoperationproductoutcomponent.usedquantity), (0)::numeric) * COALESCE(max(piecerateitem.rate), (0)::numeric)) AS cost
   FROM (((((((((public.productioncounting_productiontracking productiontracking
     LEFT JOIN public.productioncounting_trackingoperationproductoutcomponent trackingoperationproductoutcomponent ON (((trackingoperationproductoutcomponent.productiontracking_id = productiontracking.id) AND (((trackingoperationproductoutcomponent.typeofmaterial)::text = '02intermediate'::text) OR ((trackingoperationproductoutcomponent.typeofmaterial)::text = '03finalProduct'::text)))))
     JOIN public.orders_order ordersorder ON ((ordersorder.id = productiontracking.order_id)))
     JOIN public.technologies_technologyoperationcomponent technologyoperationcomponent ON ((technologyoperationcomponent.id = productiontracking.technologyoperationcomponent_id)))
     JOIN public.technologies_operation operation ON ((operation.id = technologyoperationcomponent.operation_id)))
     JOIN public.basic_product product ON ((product.id = trackingoperationproductoutcomponent.product_id)))
     LEFT JOIN public.basic_shift shift ON ((shift.id = productiontracking.shift_id)))
     LEFT JOIN public.basic_staff staff ON ((staff.id = productiontracking.staff_id)))
     LEFT JOIN public.basic_piecerate piecerate ON ((piecerate.id = technologyoperationcomponent.piecerate_id)))
     LEFT JOIN LATERAL ( SELECT piecerateitem_1.actualrate AS rate
           FROM public.basic_piecerateitem piecerateitem_1
          WHERE ((piecerateitem_1.piecerate_id = piecerate.id) AND (piecerateitem_1.datefrom <= COALESCE(productiontracking.shiftstartday, (productiontracking.createdate)::date)))
          ORDER BY piecerateitem_1.datefrom DESC
         LIMIT 1) piecerateitem ON ((1 = 1)))
  WHERE (((productiontracking.state)::text = '02accepted'::text) AND ((ordersorder.typeofproductionrecording)::text = '03forEach'::text) AND (technologyoperationcomponent.pieceworkproduction = true))
  GROUP BY (((staff.name)::text || ' '::text) || (staff.surname)::text), COALESCE(productiontracking.shiftstartday, (productiontracking.createdate)::date), shift.name, ordersorder.number, operation.number, product.number, product.name;


--
-- Name: productioncounting_finalproductanalysisentry; Type: VIEW; Schema: public; Owner: -
--

CREATE VIEW public.productioncounting_finalproductanalysisentry AS
 SELECT row_number() OVER () AS id,
    pl.number AS productionlinenumber,
    ord.number AS ordernumber,
    c.number AS companynumber,
    assortment.name AS assortmentname,
    product.number AS productnumber,
    product.name AS productname,
    product.unit AS productunit,
    size.number AS sizenumber,
    sum(COALESCE(topoc.usedquantity, (0)::numeric)) AS quantity,
    sum(COALESCE(topoc.wastesquantity, (0)::numeric)) AS wastes,
    (sum(COALESCE(topoc.usedquantity, (0)::numeric)) + sum(COALESCE(topoc.wastesquantity, (0)::numeric))) AS donequantity,
    date(date_trunc('day'::text, pt.timerangefrom)) AS timerangefrom,
    date(date_trunc('day'::text, pt.timerangeto)) AS timerangeto,
    shift.name AS shiftname,
    tcontext.number AS technologygeneratornumber
   FROM ((((((((((public.productioncounting_trackingoperationproductoutcomponent topoc
     JOIN public.productioncounting_productiontracking pt ON ((pt.id = topoc.productiontracking_id)))
     JOIN public.orders_order ord ON ((ord.id = pt.order_id)))
     JOIN public.basic_product product ON ((topoc.product_id = product.id)))
     JOIN public.technologies_technology technology ON ((technology.id = ord.technology_id)))
     LEFT JOIN public.basic_shift shift ON ((pt.shift_id = shift.id)))
     LEFT JOIN public.basic_assortment assortment ON ((product.assortment_id = assortment.id)))
     LEFT JOIN public.basic_size size ON ((size.id = product.size_id)))
     LEFT JOIN public.productionlines_productionline pl ON ((ord.productionline_id = pl.id)))
     LEFT JOIN public.basic_company c ON ((c.id = ord.company_id)))
     LEFT JOIN public.technologiesgenerator_generatorcontext tcontext ON ((tcontext.id = technology.generatorcontext_id)))
  WHERE ((ord.parent_id IS NULL) AND ((product.id = ord.product_id) OR ((pt.technologyoperationcomponent_id IS NOT NULL) AND ((topoc.typeofmaterial)::text = '02intermediate'::text)) OR ((topoc.typeofmaterial)::text = '05additionalFinalProduct'::text)))
  GROUP BY ord.number, shift.name, (date_trunc('day'::text, pt.timerangefrom)), (date_trunc('day'::text, pt.timerangeto)), pl.number, c.number, assortment.name, product.number, product.name, product.unit, size.number, tcontext.number
UNION ALL
 SELECT row_number() OVER () AS id,
    pl.number AS productionlinenumber,
    ord.number AS ordernumber,
    c.number AS companynumber,
    assortment.name AS assortmentname,
    product.number AS productnumber,
    product.name AS productname,
    product.unit AS productunit,
    size.number AS sizenumber,
    sum(COALESCE(topoc.usedquantity, (0)::numeric)) AS quantity,
    sum(COALESCE(topoc.wastesquantity, (0)::numeric)) AS wastes,
    (sum(COALESCE(topoc.usedquantity, (0)::numeric)) + sum(COALESCE(topoc.wastesquantity, (0)::numeric))) AS donequantity,
    date(date_trunc('day'::text, pt.timerangefrom)) AS timerangefrom,
    date(date_trunc('day'::text, pt.timerangeto)) AS timerangeto,
    shift.name AS shiftname,
    tcontext.number AS technologygeneratornumber
   FROM ((((((((((public.arch_productioncounting_trackingoperationproductoutcomponent topoc
     JOIN public.arch_productioncounting_productiontracking pt ON ((pt.id = topoc.productiontracking_id)))
     JOIN public.arch_orders_order ord ON ((ord.id = pt.order_id)))
     JOIN public.basic_product product ON ((topoc.product_id = product.id)))
     JOIN public.technologies_technology technology ON ((technology.id = ord.technology_id)))
     LEFT JOIN public.basic_shift shift ON ((pt.shift_id = shift.id)))
     LEFT JOIN public.basic_assortment assortment ON ((product.assortment_id = assortment.id)))
     LEFT JOIN public.basic_size size ON ((size.id = product.size_id)))
     LEFT JOIN public.productionlines_productionline pl ON ((ord.productionline_id = pl.id)))
     LEFT JOIN public.basic_company c ON ((c.id = ord.company_id)))
     LEFT JOIN public.technologiesgenerator_generatorcontext tcontext ON ((tcontext.id = technology.generatorcontext_id)))
  WHERE ((ord.parent_id IS NULL) AND ((product.id = ord.product_id) OR ((pt.technologyoperationcomponent_id IS NOT NULL) AND ((topoc.typeofmaterial)::text = '02intermediate'::text)) OR ((topoc.typeofmaterial)::text = '05additionalFinalProduct'::text)))
  GROUP BY ord.number, shift.name, (date_trunc('day'::text, pt.timerangefrom)), (date_trunc('day'::text, pt.timerangeto)), pl.number, c.number, assortment.name, product.number, product.name, product.unit, size.number, tcontext.number;


--
-- Name: productioncounting_finalproductanalysisentry_id_seq; Type: SEQUENCE; Schema: public; Owner: -
--

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


--
-- Name: productioncounting_lack; Type: TABLE; Schema: public; Owner: -
--

CREATE TABLE public.productioncounting_lack (
    id bigint NOT NULL,
    trackingoperationproductoutcomponent_id bigint,
    lackquantity numeric(14,5),
    createdate timestamp without time zone,
    updatedate timestamp without time zone,
    createuser character varying(255),
    updateuser character varying(255)
);


--
-- Name: productioncounting_lack_id_seq; Type: SEQUENCE; Schema: public; Owner: -
--

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


--
-- Name: productioncounting_lack_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: -
--

ALTER SEQUENCE public.productioncounting_lack_id_seq OWNED BY public.productioncounting_lack.id;


--
-- Name: productioncounting_lackreason; Type: TABLE; Schema: public; Owner: -
--

CREATE TABLE public.productioncounting_lackreason (
    id bigint NOT NULL,
    lack_id bigint,
    causeofwastes character varying(255),
    description character varying(1024),
    createdate timestamp without time zone,
    updatedate timestamp without time zone,
    createuser character varying(255),
    updateuser character varying(255)
);


--
-- Name: productioncounting_lackdto; Type: VIEW; Schema: public; Owner: -
--

CREATE VIEW public.productioncounting_lackdto AS
 SELECT lack.id,
    (lack.trackingoperationproductoutcomponent_id)::integer AS trackingoperationproductoutcomponentid,
    lack.lackquantity,
    product.unit AS productunit,
    array_to_string(ARRAY( SELECT (((lackreason.causeofwastes)::text || ' - '::text) || (COALESCE(lackreason.description, ''::character varying))::text)
           FROM (public.productioncounting_lackreason lackreason
             LEFT JOIN public.productioncounting_lack l ON ((lackreason.lack_id = l.id)))
          WHERE (lackreason.lack_id = lack.id)), '</br>'::text) AS reasons
   FROM ((public.productioncounting_lack lack
     LEFT JOIN public.productioncounting_trackingoperationproductoutcomponent tooc ON ((tooc.id = lack.trackingoperationproductoutcomponent_id)))
     LEFT JOIN public.basic_product product ON ((product.id = tooc.product_id)));


--
-- Name: productioncounting_lackdto_id_seq; Type: SEQUENCE; Schema: public; Owner: -
--

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


--
-- Name: productioncounting_lackreason_id_seq; Type: SEQUENCE; Schema: public; Owner: -
--

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


--
-- Name: productioncounting_lackreason_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: -
--

ALTER SEQUENCE public.productioncounting_lackreason_id_seq OWNED BY public.productioncounting_lackreason.id;


--
-- Name: productioncounting_orderbalance; Type: TABLE; Schema: public; Owner: -
--

CREATE TABLE public.productioncounting_orderbalance (
    id bigint NOT NULL,
    productionbalance_id bigint,
    ordernumber character varying(255),
    productnumber character varying(255),
    productname character varying(255),
    plannedquantity numeric(12,5),
    producedquantity numeric(12,5),
    deviation numeric(12,5),
    productunit character varying(255),
    plannedmaterialcosts numeric(12,5),
    materialcosts numeric(12,5),
    materialcostsdeviation numeric(12,5),
    plannedproductioncosts numeric(12,5),
    productioncosts numeric(12,5),
    productioncostsdeviation numeric(12,5),
    technicalproductioncosts numeric(12,5),
    materialcostmargin numeric(12,5),
    materialcostmarginvalue numeric(12,5),
    productioncostmargin numeric(12,5),
    productioncostmarginvalue numeric(12,5),
    additionaloverhead numeric(12,5),
    directadditionalcost numeric(12,5),
    totalcosts numeric(12,5),
    registrationprice numeric(12,5),
    registrationpriceoverhead numeric(12,5),
    registrationpriceoverheadvalue numeric(12,5),
    realproductioncosts numeric(12,5),
    technicalproductioncostoverhead numeric(12,5),
    technicalproductioncostoverheadvalue numeric(12,5),
    totalmanufacturingcost numeric(12,5),
    profit numeric(12,5),
    profitvalue numeric(12,5),
    sellprice numeric(12,5),
    externalservicescost numeric(12,5)
);


--
-- Name: productioncounting_orderbalance_id_seq; Type: SEQUENCE; Schema: public; Owner: -
--

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


--
-- Name: productioncounting_orderbalance_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: -
--

ALTER SEQUENCE public.productioncounting_orderbalance_id_seq OWNED BY public.productioncounting_orderbalance.id;


--
-- Name: productioncounting_performanceanalysisdetaildto_id_seq; Type: SEQUENCE; Schema: public; Owner: -
--

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


--
-- Name: productioncounting_performanceanalysisdto; Type: VIEW; Schema: public; Owner: -
--

CREATE VIEW public.productioncounting_performanceanalysisdto AS
 SELECT row_number() OVER () AS id,
    bool_or(performanceanalysisdetaildto.active) AS active,
    performanceanalysisdetaildto.productionline_id,
    performanceanalysisdetaildto.productionlinenumber,
    performanceanalysisdetaildto.staff_id,
    performanceanalysisdetaildto.staffname,
    COALESCE((sum(performanceanalysisdetaildto.timebasedonnorms))::integer, 0) AS timebasedonnormssum,
        CASE
            WHEN (min(performanceanalysisdetaildto.labortimesum) <> max(performanceanalysisdetaildto.labortimesum)) THEN 0
            ELSE (min(performanceanalysisdetaildto.labortimesum))::integer
        END AS labortimesum,
        CASE
            WHEN (min(performanceanalysisdetaildto.labortimesum) <> max(performanceanalysisdetaildto.labortimesum)) THEN (COALESCE(sum(performanceanalysisdetaildto.timebasedonnorms), (0)::bigint))::integer
            ELSE (((COALESCE((sum(performanceanalysisdetaildto.timebasedonnorms))::integer, 0))::double precision - min(performanceanalysisdetaildto.labortimesum)))::integer
        END AS timedeviation,
        CASE
            WHEN (min(performanceanalysisdetaildto.labortimesum) <> max(performanceanalysisdetaildto.labortimesum)) THEN (0)::numeric
            ELSE (((((100)::numeric * (sum(performanceanalysisdetaildto.timebasedonnorms))::numeric))::double precision / min(performanceanalysisdetaildto.labortimesum)))::numeric(14,2)
        END AS performance,
    performanceanalysisdetaildto.shift_id,
    performanceanalysisdetaildto.shiftname,
    performanceanalysisdetaildto.timerangefromwithouttime AS timerangefrom,
    performanceanalysisdetaildto.timerangetowithouttime AS timerangeto,
    sum(performanceanalysisdetaildto.donequantity) AS donequantity,
    (min(helper.productionlinequantity))::integer AS productionlinequantity,
    (count(DISTINCT performanceanalysisdetaildto.assortment_id))::integer AS assortmentquantity,
    (min(helper.dailyperformance))::numeric(14,2) AS dailyperformance
   FROM (public.productioncounting_performanceanalysisdetaildto performanceanalysisdetaildto
     LEFT JOIN public.productioncounting_performanceanalysisdto_helper helper ON (((performanceanalysisdetaildto.staff_id = helper.staff_id) AND (performanceanalysisdetaildto.timerangefromwithouttime = helper.timerangefromwithouttime))))
  GROUP BY performanceanalysisdetaildto.productionline_id, performanceanalysisdetaildto.productionlinenumber, performanceanalysisdetaildto.staff_id, performanceanalysisdetaildto.staffname, performanceanalysisdetaildto.shift_id, performanceanalysisdetaildto.shiftname, performanceanalysisdetaildto.timerangefromwithouttime, performanceanalysisdetaildto.timerangetowithouttime;


--
-- Name: productioncounting_performanceanalysisdto_id_seq; Type: SEQUENCE; Schema: public; Owner: -
--

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


--
-- Name: productioncounting_performanceanalysismv; Type: VIEW; Schema: public; Owner: -
--

CREATE VIEW public.productioncounting_performanceanalysismv AS
 SELECT mv_productioncounting_performanceanalysisdto.id,
    mv_productioncounting_performanceanalysisdto.active,
    mv_productioncounting_performanceanalysisdto.productionline_id,
    mv_productioncounting_performanceanalysisdto.productionlinenumber,
    mv_productioncounting_performanceanalysisdto.staff_id,
    mv_productioncounting_performanceanalysisdto.staffname,
    public.duration_to_string(mv_productioncounting_performanceanalysisdto.timebasedonnormssum) AS timebasedonnormssum,
    public.duration_to_string(mv_productioncounting_performanceanalysisdto.labortimesum) AS labortimesum,
    public.duration_to_string(mv_productioncounting_performanceanalysisdto.timedeviation) AS timedeviation,
    mv_productioncounting_performanceanalysisdto.performance,
    mv_productioncounting_performanceanalysisdto.shift_id,
    mv_productioncounting_performanceanalysisdto.shiftname,
    mv_productioncounting_performanceanalysisdto.timerangefrom,
    mv_productioncounting_performanceanalysisdto.timerangeto,
    mv_productioncounting_performanceanalysisdto.donequantity,
    mv_productioncounting_performanceanalysisdto.productionlinequantity,
    mv_productioncounting_performanceanalysisdto.assortmentquantity,
    mv_productioncounting_performanceanalysisdto.dailyperformance
   FROM public.mv_productioncounting_performanceanalysisdto;


--
-- Name: productioncounting_performanceanalysismv_id_seq; Type: SEQUENCE; Schema: public; Owner: -
--

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


--
-- Name: productioncounting_prodoutresourceattrval; Type: TABLE; Schema: public; Owner: -
--

CREATE TABLE public.productioncounting_prodoutresourceattrval (
    id bigint NOT NULL,
    trackingoperationproductoutcomponent_id bigint,
    attribute_id bigint,
    attributevalue_id bigint,
    value character varying(255)
);


--
-- Name: productioncounting_prodoutresourceattrval_id_seq; Type: SEQUENCE; Schema: public; Owner: -
--

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


--
-- Name: productioncounting_prodoutresourceattrval_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: -
--

ALTER SEQUENCE public.productioncounting_prodoutresourceattrval_id_seq OWNED BY public.productioncounting_prodoutresourceattrval.id;


--
-- Name: productioncounting_productionanalysisdto; Type: VIEW; Schema: public; Owner: -
--

CREATE VIEW public.productioncounting_productionanalysisdto AS
SELECT
    NULL::bigint AS id,
    NULL::boolean AS active,
    NULL::integer AS productionline_id,
    NULL::character varying(255) AS productionlinenumber,
    NULL::integer AS company_id,
    NULL::character varying(255) AS companynumber,
    NULL::integer AS staff_id,
    NULL::text AS staffname,
    NULL::integer AS assortment_id,
    NULL::character varying(255) AS assortmentname,
    NULL::integer AS product_id,
    NULL::character varying(255) AS productnumber,
    NULL::character varying(1024) AS productname,
    NULL::character varying(255) AS productunit,
    NULL::character varying(255) AS sizenumber,
    NULL::numeric AS usedquantity,
    NULL::numeric AS wastesquantity,
    NULL::numeric AS donequantity,
    NULL::character varying(255) AS causeofwastes,
    NULL::integer AS shift_id,
    NULL::character varying(1024) AS shiftname,
    NULL::date AS timerangefrom,
    NULL::date AS timerangeto,
    NULL::integer AS generator_id,
    NULL::character varying(255) AS generatorname,
    NULL::integer AS order_id,
    NULL::character varying(255) AS ordernumber,
    NULL::character varying(255) AS obtainedmasterordernumber,
    NULL::character varying(255) AS technologygroupnumber,
    NULL::character varying(255) AS typeofmaterial;


--
-- Name: productioncounting_productionanalysisdto_id_seq; Type: SEQUENCE; Schema: public; Owner: -
--

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


--
-- Name: productioncounting_productionbalance; Type: TABLE; Schema: public; Owner: -
--

CREATE TABLE public.productioncounting_productionbalance (
    id bigint NOT NULL,
    generated boolean,
    name character varying(1024),
    date timestamp without time zone,
    worker character varying(255),
    description character varying(255),
    filename character varying(1024),
    includetpz boolean DEFAULT true,
    includeadditionaltime boolean DEFAULT false,
    materialcostmargin numeric(12,5) DEFAULT (0)::numeric,
    materialcostsused character varying(255) DEFAULT '01nominal'::character varying,
    productioncostmargin numeric(12,5) DEFAULT (0)::numeric,
    active boolean DEFAULT true,
    entityversion bigint DEFAULT 0,
    sourceofoperationcosts character varying(255) DEFAULT '01technologyOperation'::character varying,
    registrationpriceoverhead numeric,
    profit numeric,
    number character varying(255),
    additionaloverhead numeric(12,5) DEFAULT (0)::numeric,
    includewagegroups boolean DEFAULT false,
    technicalproductioncostoverhead numeric(12,5) DEFAULT 0
);


--
-- Name: productioncounting_productionbalance_id_seq; Type: SEQUENCE; Schema: public; Owner: -
--

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


--
-- Name: productioncounting_productionbalance_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: -
--

ALTER SEQUENCE public.productioncounting_productionbalance_id_seq OWNED BY public.productioncounting_productionbalance.id;


--
-- Name: productioncounting_productiontracking_id_seq; Type: SEQUENCE; Schema: public; Owner: -
--

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


--
-- Name: productioncounting_productiontracking_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: -
--

ALTER SEQUENCE public.productioncounting_productiontracking_id_seq OWNED BY public.productioncounting_productiontracking.id;


--
-- Name: productioncounting_productiontracking_number_seq; Type: SEQUENCE; Schema: public; Owner: -
--

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


--
-- Name: productioncounting_productiontrackingattachment; Type: TABLE; Schema: public; Owner: -
--

CREATE TABLE public.productioncounting_productiontrackingattachment (
    id bigint NOT NULL,
    productiontracking_id bigint,
    attachment character varying(255),
    name character varying(255),
    size numeric(12,5),
    ext character varying(255)
);


--
-- Name: productioncounting_productiontrackingattachment_id_seq; Type: SEQUENCE; Schema: public; Owner: -
--

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


--
-- Name: productioncounting_productiontrackingattachment_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: -
--

ALTER SEQUENCE public.productioncounting_productiontrackingattachment_id_seq OWNED BY public.productioncounting_productiontrackingattachment.id;


--
-- Name: productioncounting_productiontrackingdraftdto; Type: VIEW; Schema: public; Owner: -
--

CREATE VIEW public.productioncounting_productiontrackingdraftdto AS
 SELECT productiontracking.id,
    productiontracking.number,
    productiontracking.state,
    productiontracking.createdate,
    productiontracking.lasttracking,
    productiontracking.timerangefrom,
    productiontracking.timerangeto,
    productiontracking.active,
    (ordersorder.id)::integer AS order_id,
    ordersorder.number AS ordernumber,
    ordersorder.state AS orderstate,
    (technologyoperationcomponent.id)::integer AS technologyoperationcomponent_id,
    COALESCE((((technologyoperationcomponent.nodenumber)::text || ' '::text) || (operation.name)::text), ''::text) AS technologyoperationcomponentnumber,
    (operation.id)::integer AS operation_id,
    (shift.id)::integer AS shift_id,
    shift.name AS shiftname,
    (staff.id)::integer AS staff_id,
    (((staff.surname)::text || ' '::text) || (staff.name)::text) AS staffname,
    (division.id)::integer AS division_id,
    division.number AS divisionnumber,
    (subcontractor.id)::integer AS subcontractor_id,
    subcontractor.name AS subcontractorname,
    (repairorder.id)::integer AS repairorder_id,
    repairorder.number AS repairordernumber,
    productiontrackingcorrection.number AS correctionnumber,
    (productionline.id)::integer AS productionline_id,
    productionline.number AS productionlinenumber,
    ordersgroup.number AS ordersgroup,
    concat(product.number, ' - ', product.name) AS productnumber,
    product.unit AS productunit,
    outcomponent.usedquantity,
    company.number AS companynumber,
    COALESCE((((outproduct.number)::text || ' - '::text) || (outproduct.name)::text), (((product.number)::text || ' - '::text) || (product.name)::text)) AS outproductnumber
   FROM ((((((((((((((((public.productioncounting_productiontracking productiontracking
     JOIN public.orders_order ordersorder ON ((ordersorder.id = productiontracking.order_id)))
     JOIN public.basic_product product ON ((ordersorder.product_id = product.id)))
     JOIN public.productionlines_productionline productionline ON ((productionline.id = ordersorder.productionline_id)))
     LEFT JOIN public.technologies_technologyoperationcomponent technologyoperationcomponent ON ((technologyoperationcomponent.id = productiontracking.technologyoperationcomponent_id)))
     LEFT JOIN public.technologies_operation operation ON ((operation.id = technologyoperationcomponent.operation_id)))
     LEFT JOIN public.basic_shift shift ON ((shift.id = productiontracking.shift_id)))
     LEFT JOIN public.basic_staff staff ON ((staff.id = productiontracking.staff_id)))
     LEFT JOIN public.basic_division division ON ((division.id = productiontracking.division_id)))
     LEFT JOIN public.basic_company subcontractor ON ((subcontractor.id = productiontracking.subcontractor_id)))
     LEFT JOIN public.productioncounting_productiontracking productiontrackingcorrection ON ((productiontrackingcorrection.id = productiontracking.correction_id)))
     LEFT JOIN public.repairs_repairorder repairorder ON ((repairorder.id = productiontracking.repairorder_id)))
     LEFT JOIN public.ordersgroups_ordersgroup ordersgroup ON ((ordersgroup.id = ordersorder.ordersgroup_id)))
     LEFT JOIN public.basic_company company ON ((company.id = ordersorder.company_id)))
     LEFT JOIN public.basicproductioncounting_productioncountingquantity pcq ON (((pcq.order_id = ordersorder.id) AND (pcq.technologyoperationcomponent_id = technologyoperationcomponent.id) AND ((pcq.typeofmaterial)::text = ANY (ARRAY[('02intermediate'::character varying)::text, ('03finalProduct'::character varying)::text])) AND ((pcq.role)::text = '02produced'::text))))
     LEFT JOIN public.basic_product outproduct ON ((pcq.product_id = outproduct.id)))
     LEFT JOIN public.productioncounting_trackingoperationproductoutcomponent outcomponent ON ((((outcomponent.product_id = outproduct.id) OR (outcomponent.product_id = product.id)) AND (productiontracking.id = outcomponent.productiontracking_id))))
  WHERE ((productiontracking.state)::text = '01draft'::text);


--
-- Name: productioncounting_productiontrackingdraftdto_id_seq; Type: SEQUENCE; Schema: public; Owner: -
--

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


--
-- Name: productioncounting_productiontrackingdto; Type: VIEW; Schema: public; Owner: -
--

CREATE VIEW public.productioncounting_productiontrackingdto AS
 SELECT productiontracking.id,
    productiontracking.number,
    productiontracking.state,
    productiontracking.createdate,
    productiontracking.lasttracking,
    productiontracking.timerangefrom,
    productiontracking.timerangeto,
        CASE
            WHEN (productiontracking.shiftstartday IS NULL) THEN (productiontracking.createdate)::date
            ELSE productiontracking.shiftstartday
        END AS datefromforoee,
        CASE
            WHEN (productiontracking.shiftstartday IS NULL) THEN (productiontracking.createdate)::date
            ELSE productiontracking.shiftstartday
        END AS datetoforoee,
    productiontracking.active,
    (ordersorder.id)::integer AS order_id,
    ordersorder.number AS ordernumber,
    ordersorder.state AS orderstate,
    ordersorder.startdate AS orderstartdate,
    (technologyoperationcomponent.id)::integer AS technologyoperationcomponent_id,
    COALESCE((((technologyoperationcomponent.nodenumber)::text || ' '::text) || (operation.name)::text), ''::text) AS technologyoperationcomponentnumber,
    (operation.id)::integer AS operation_id,
    (shift.id)::integer AS shift_id,
    shift.name AS shiftname,
    (staff.id)::integer AS staff_id,
    (((staff.surname)::text || ' '::text) || (staff.name)::text) AS staffname,
    (division.id)::integer AS division_id,
    division.number AS divisionnumber,
    (subcontractor.id)::integer AS subcontractor_id,
    subcontractor.name AS subcontractorname,
    (repairorder.id)::integer AS repairorder_id,
    repairorder.number AS repairordernumber,
    productiontrackingcorrection.number AS correctionnumber,
    (productionline.id)::integer AS productionline_id,
    productionline.number AS productionlinenumber,
    ordersgroup.number AS ordersgroup,
    concat(product.number, ' - ', product.name) AS productnumber,
    product.unit AS productunit,
    outcomponent.usedquantity,
    company.number AS companynumber,
    COALESCE((((outproduct.number)::text || ' - '::text) || (outproduct.name)::text), (((product.number)::text || ' - '::text) || (product.name)::text)) AS outproductnumber,
    productiontracking.shiftstartday,
    productiontracking.createuser,
    workstation.number AS workstationnumber,
    productiontracking.comments
   FROM (((((((((((((((((public.productioncounting_productiontracking productiontracking
     JOIN public.orders_order ordersorder ON ((ordersorder.id = productiontracking.order_id)))
     JOIN public.basic_product product ON ((ordersorder.product_id = product.id)))
     JOIN public.productionlines_productionline productionline ON ((productionline.id = ordersorder.productionline_id)))
     LEFT JOIN public.technologies_technologyoperationcomponent technologyoperationcomponent ON ((technologyoperationcomponent.id = productiontracking.technologyoperationcomponent_id)))
     LEFT JOIN public.technologies_operation operation ON ((operation.id = technologyoperationcomponent.operation_id)))
     LEFT JOIN public.basic_shift shift ON ((shift.id = productiontracking.shift_id)))
     LEFT JOIN public.basic_staff staff ON ((staff.id = productiontracking.staff_id)))
     LEFT JOIN public.basic_division division ON ((division.id = productiontracking.division_id)))
     LEFT JOIN public.basic_company subcontractor ON ((subcontractor.id = productiontracking.subcontractor_id)))
     LEFT JOIN public.basic_workstation workstation ON ((workstation.id = productiontracking.workstation_id)))
     LEFT JOIN public.productioncounting_productiontracking productiontrackingcorrection ON ((productiontrackingcorrection.id = productiontracking.correction_id)))
     LEFT JOIN public.repairs_repairorder repairorder ON ((repairorder.id = productiontracking.repairorder_id)))
     LEFT JOIN public.ordersgroups_ordersgroup ordersgroup ON ((ordersgroup.id = ordersorder.ordersgroup_id)))
     LEFT JOIN public.basic_company company ON ((company.id = ordersorder.company_id)))
     LEFT JOIN public.basicproductioncounting_productioncountingquantity pcq ON (((pcq.order_id = ordersorder.id) AND (pcq.technologyoperationcomponent_id = technologyoperationcomponent.id) AND ((pcq.typeofmaterial)::text = ANY (ARRAY[('02intermediate'::character varying)::text, ('03finalProduct'::character varying)::text])) AND ((pcq.role)::text = '02produced'::text))))
     LEFT JOIN public.basic_product outproduct ON ((pcq.product_id = outproduct.id)))
     LEFT JOIN public.productioncounting_trackingoperationproductoutcomponent outcomponent ON ((((outcomponent.product_id = outproduct.id) OR (outcomponent.product_id = product.id)) AND (productiontracking.id = outcomponent.productiontracking_id))));


--
-- Name: productioncounting_productiontrackingdto_id_seq; Type: SEQUENCE; Schema: public; Owner: -
--

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


--
-- Name: productioncounting_trackingoperationproductincomponenthelper; Type: VIEW; Schema: public; Owner: -
--

CREATE VIEW public.productioncounting_trackingoperationproductincomponenthelper AS
SELECT
    NULL::bigint AS id,
    NULL::integer AS productiontracking_id,
    NULL::integer AS product_id,
    NULL::character varying(255) AS productnumber,
    NULL::character varying(1024) AS productname,
    NULL::character varying(255) AS productunit,
    NULL::numeric AS plannedquantity,
    NULL::numeric(14,5) AS usedquantity,
    NULL::character varying(255) AS batchnumber,
    NULL::character varying(255) AS producedbatchnumber;


--
-- Name: productioncounting_trackingoperationproductoutcomponenthelper; Type: VIEW; Schema: public; Owner: -
--

CREATE VIEW public.productioncounting_trackingoperationproductoutcomponenthelper AS
SELECT
    NULL::bigint AS id,
    NULL::integer AS productiontracking_id,
    NULL::integer AS product_id,
    NULL::character varying(255) AS productnumber,
    NULL::character varying(1024) AS productname,
    NULL::character varying(255) AS productunit,
    NULL::numeric AS plannedquantity,
    NULL::numeric(14,5) AS usedquantity,
    NULL::character varying(255) AS batchnumber,
    NULL::character varying(255) AS producedbatchnumber;


--
-- Name: productioncounting_trackingoperationproductcomponentdto; Type: VIEW; Schema: public; Owner: -
--

CREATE VIEW public.productioncounting_trackingoperationproductcomponentdto AS
 SELECT row_number() OVER () AS id,
    trackingoperationproductcomponentdto.productiontracking_id,
    trackingoperationproductcomponentdto.product_id,
    trackingoperationproductcomponentdto.productnumber,
    trackingoperationproductcomponentdto.productname,
    trackingoperationproductcomponentdto.productunit,
    trackingoperationproductcomponentdto.plannedquantity,
    trackingoperationproductcomponentdto.usedquantity,
    trackingoperationproductcomponentdto.batchnumber,
    trackingoperationproductcomponentdto.typeofrecord,
    trackingoperationproductcomponentdto.producedbatchnumber
   FROM ( SELECT trackingoperationproductincomponentdto.productiontracking_id,
            trackingoperationproductincomponentdto.product_id,
            trackingoperationproductincomponentdto.productnumber,
            trackingoperationproductincomponentdto.productname,
            trackingoperationproductincomponentdto.productunit,
            trackingoperationproductincomponentdto.plannedquantity,
            trackingoperationproductincomponentdto.usedquantity,
            trackingoperationproductincomponentdto.batchnumber,
            '01in'::text AS typeofrecord,
            COALESCE(outtracking.producedbatchnumber, outtracking.batchnumber) AS producedbatchnumber
           FROM (public.productioncounting_trackingoperationproductincomponenthelper trackingoperationproductincomponentdto
             LEFT JOIN public.productioncounting_trackingoperationproductoutcomponenthelper outtracking ON ((outtracking.productiontracking_id = trackingoperationproductincomponentdto.productiontracking_id)))
        UNION
         SELECT trackingoperationproductoutcomponentdto.productiontracking_id,
            trackingoperationproductoutcomponentdto.product_id,
            trackingoperationproductoutcomponentdto.productnumber,
            trackingoperationproductoutcomponentdto.productname,
            trackingoperationproductoutcomponentdto.productunit,
            trackingoperationproductoutcomponentdto.plannedquantity,
            trackingoperationproductoutcomponentdto.usedquantity,
            ''::text AS batchnumber,
            '02out'::text AS typeofrecord,
            COALESCE(trackingoperationproductoutcomponentdto.producedbatchnumber, trackingoperationproductoutcomponentdto.batchnumber) AS producedbatchnumber
           FROM public.productioncounting_trackingoperationproductoutcomponenthelper trackingoperationproductoutcomponentdto) trackingoperationproductcomponentdto;


--
-- Name: productioncounting_productiontrackingforproductdto; Type: VIEW; Schema: public; Owner: -
--

CREATE VIEW public.productioncounting_productiontrackingforproductdto AS
 SELECT row_number() OVER () AS id,
    productiontrackingdto.number,
    productiontrackingdto.state,
    productiontrackingdto.createdate,
    productiontrackingdto.lasttracking,
    productiontrackingdto.timerangefrom,
    productiontrackingdto.timerangeto,
    productiontrackingdto.active,
    productiontrackingdto.order_id,
    productiontrackingdto.ordernumber,
    productiontrackingdto.orderstate,
    productiontrackingdto.orderstartdate,
    productiontrackingdto.technologyoperationcomponent_id,
    productiontrackingdto.technologyoperationcomponentnumber,
    productiontrackingdto.operation_id,
    productiontrackingdto.shift_id,
    productiontrackingdto.shiftname,
    productiontrackingdto.staff_id,
    productiontrackingdto.staffname,
    productiontrackingdto.division_id,
    productiontrackingdto.divisionnumber,
    productiontrackingdto.subcontractor_id,
    productiontrackingdto.subcontractorname,
    trackingoperationproductcomponentdto.product_id,
    trackingoperationproductcomponentdto.productnumber,
    trackingoperationproductcomponentdto.productname,
    trackingoperationproductcomponentdto.productunit,
    trackingoperationproductcomponentdto.plannedquantity,
    COALESCE(trackingoperationproductcomponentdto.usedquantity, (0)::numeric(14,5)) AS usedquantity,
    (productiontrackingdto.id)::integer AS productiontracking_id,
    trackingoperationproductcomponentdto.batchnumber,
    trackingoperationproductcomponentdto.typeofrecord,
    trackingoperationproductcomponentdto.producedbatchnumber
   FROM (public.productioncounting_trackingoperationproductcomponentdto trackingoperationproductcomponentdto
     LEFT JOIN public.productioncounting_productiontrackingdto productiontrackingdto ON ((productiontrackingdto.id = trackingoperationproductcomponentdto.productiontracking_id)));


--
-- Name: productioncounting_productiontrackingforproductdto_id_seq; Type: SEQUENCE; Schema: public; Owner: -
--

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


--
-- Name: productioncounting_productiontrackingforproductgroupeddto; Type: VIEW; Schema: public; Owner: -
--

CREATE VIEW public.productioncounting_productiontrackingforproductgroupeddto AS
 SELECT row_number() OVER () AS id,
    productiontrackingforproductdto.active,
    productiontrackingforproductdto.order_id,
    productiontrackingforproductdto.ordernumber,
    (productiontrackingforproductdto.orderstartdate)::date AS orderstartdate,
    productiontrackingforproductdto.technologyoperationcomponent_id,
    productiontrackingforproductdto.technologyoperationcomponentnumber,
    productiontrackingforproductdto.operation_id,
    productiontrackingforproductdto.product_id,
    productiontrackingforproductdto.productnumber,
    productiontrackingforproductdto.productname,
    productiontrackingforproductdto.productunit,
    productiontrackingforproductdto.plannedquantity,
    sum(productiontrackingforproductdto.usedquantity) AS usedquantity,
    (sum(productiontrackingforproductdto.usedquantity) - productiontrackingforproductdto.plannedquantity) AS quantitydeviation,
    productiontrackingforproductdto.typeofrecord
   FROM public.productioncounting_productiontrackingforproductdto productiontrackingforproductdto
  GROUP BY productiontrackingforproductdto.active, productiontrackingforproductdto.order_id, productiontrackingforproductdto.ordernumber, productiontrackingforproductdto.orderstartdate, productiontrackingforproductdto.technologyoperationcomponent_id, productiontrackingforproductdto.technologyoperationcomponentnumber, productiontrackingforproductdto.operation_id, productiontrackingforproductdto.product_id, productiontrackingforproductdto.productnumber, productiontrackingforproductdto.productname, productiontrackingforproductdto.productunit, productiontrackingforproductdto.plannedquantity, productiontrackingforproductdto.typeofrecord;


--
-- Name: productioncounting_productiontrackingforproductgroupeddto_id_se; Type: SEQUENCE; Schema: public; Owner: -
--

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


--
-- Name: productioncounting_productiontrackingstatechange; Type: TABLE; Schema: public; Owner: -
--

CREATE TABLE public.productioncounting_productiontrackingstatechange (
    id bigint NOT NULL,
    dateandtime timestamp without time zone,
    sourcestate character varying(255),
    targetstate character varying(255),
    status character varying(255) DEFAULT '01inProgress'::character varying,
    phase integer,
    worker character varying(255),
    productiontracking_id bigint,
    shift_id bigint,
    entityversion bigint DEFAULT 0
);


--
-- Name: productioncounting_productiontrackingstatechange_id_seq; Type: SEQUENCE; Schema: public; Owner: -
--

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


--
-- Name: productioncounting_productiontrackingstatechange_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: -
--

ALTER SEQUENCE public.productioncounting_productiontrackingstatechange_id_seq OWNED BY public.productioncounting_productiontrackingstatechange.id;


--
-- Name: productioncounting_staffworktime; Type: TABLE; Schema: public; Owner: -
--

CREATE TABLE public.productioncounting_staffworktime (
    id bigint NOT NULL,
    productionrecord_id bigint,
    worker_id bigint,
    labortime integer DEFAULT 0,
    effectiveexecutiontimestart timestamp without time zone,
    effectiveexecutiontimeend timestamp without time zone,
    entityversion bigint DEFAULT 0
);


--
-- Name: productioncounting_staffworktime_id_seq; Type: SEQUENCE; Schema: public; Owner: -
--

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


--
-- Name: productioncounting_staffworktime_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: -
--

ALTER SEQUENCE public.productioncounting_staffworktime_id_seq OWNED BY public.productioncounting_staffworktime.id;


--
-- Name: productioncounting_trackinginproductreplacementhelper; Type: TABLE; Schema: public; Owner: -
--

CREATE TABLE public.productioncounting_trackinginproductreplacementhelper (
    id bigint NOT NULL,
    productiontracking_id bigint,
    product_id bigint,
    quantity numeric(14,5),
    basicproduct_id bigint
);


--
-- Name: productioncounting_trackinginproductreplacementhelper_id_seq; Type: SEQUENCE; Schema: public; Owner: -
--

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


--
-- Name: productioncounting_trackinginproductreplacementhelper_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: -
--

ALTER SEQUENCE public.productioncounting_trackinginproductreplacementhelper_id_seq OWNED BY public.productioncounting_trackinginproductreplacementhelper.id;


--
-- Name: productioncounting_trackingoperationproductcomponentdto_id_seq; Type: SEQUENCE; Schema: public; Owner: -
--

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


--
-- Name: productioncounting_trackingoperationproductincomponent_id_seq; Type: SEQUENCE; Schema: public; Owner: -
--

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


--
-- Name: productioncounting_trackingoperationproductincomponent_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: -
--

ALTER SEQUENCE public.productioncounting_trackingoperationproductincomponent_id_seq OWNED BY public.productioncounting_trackingoperationproductincomponent.id;


--
-- Name: productioncounting_usedbatch; Type: TABLE; Schema: public; Owner: -
--

CREATE TABLE public.productioncounting_usedbatch (
    id bigint NOT NULL,
    trackingoperationproductincomponent_id bigint,
    batch_id bigint,
    quantity numeric(14,5)
);


--
-- Name: productioncounting_trackingoperationproductincomponentdto; Type: VIEW; Schema: public; Owner: -
--

CREATE VIEW public.productioncounting_trackingoperationproductincomponentdto AS
 SELECT trackingoperationproductincomponent.id,
    (productiontracking.id)::integer AS productiontrackingid,
    product.number AS productnumber,
    product.name AS productname,
    product.unit AS productunit,
    (product.id)::integer AS productid,
    COALESCE(sum(productioncountingquantity.plannedquantity), (0)::numeric) AS plannedquantity,
    trackingoperationproductincomponent.usedquantity,
    trackingoperationproductincomponent.obtainedquantity,
    trackingoperationproductincomponent.remainedquantity,
    trackingoperationproductincomponent.effectiveusedquantity,
    (string_agg((batch.number)::text, ', '::text))::character varying(255) AS batchnumber,
        CASE
            WHEN (( SELECT count(*) AS count
               FROM public.basic_substitutecomponent
              WHERE (basic_substitutecomponent.baseproduct_id = product.id)) > 0) THEN true
            ELSE false
        END AS replacement,
    productreplacement.number AS productreplacementnumber,
    (productreplacement.id)::integer AS productreplacementid
   FROM ((((((public.productioncounting_trackingoperationproductincomponent trackingoperationproductincomponent
     LEFT JOIN public.productioncounting_productiontracking productiontracking ON ((productiontracking.id = trackingoperationproductincomponent.productiontracking_id)))
     LEFT JOIN public.basic_product product ON ((product.id = trackingoperationproductincomponent.product_id)))
     LEFT JOIN public.basic_product productreplacement ON ((productreplacement.id = trackingoperationproductincomponent.replacementto_id)))
     LEFT JOIN public.productioncounting_usedbatch usedbatch ON ((usedbatch.trackingoperationproductincomponent_id = trackingoperationproductincomponent.id)))
     LEFT JOIN public.advancedgenealogy_batch batch ON ((batch.id = usedbatch.batch_id)))
     LEFT JOIN public.basicproductioncounting_productioncountingquantity productioncountingquantity ON (((productioncountingquantity.order_id = productiontracking.order_id) AND (productioncountingquantity.product_id = trackingoperationproductincomponent.product_id) AND ((productioncountingquantity.role)::text = '01used'::text))))
  WHERE (productiontracking.technologyoperationcomponent_id IS NULL)
  GROUP BY trackingoperationproductincomponent.id, productiontracking.id, product.number, product.name, product.unit, product.id, trackingoperationproductincomponent.usedquantity, trackingoperationproductincomponent.obtainedquantity, trackingoperationproductincomponent.remainedquantity, trackingoperationproductincomponent.effectiveusedquantity, productreplacement.number, productreplacement.id
UNION
 SELECT trackingoperationproductincomponent.id,
    (productiontracking.id)::integer AS productiontrackingid,
    product.number AS productnumber,
    product.name AS productname,
    product.unit AS productunit,
    (product.id)::integer AS productid,
    COALESCE(sum(productioncountingquantity.plannedquantity), (0)::numeric) AS plannedquantity,
    trackingoperationproductincomponent.usedquantity,
    trackingoperationproductincomponent.obtainedquantity,
    trackingoperationproductincomponent.remainedquantity,
    trackingoperationproductincomponent.effectiveusedquantity,
    (string_agg((batch.number)::text, ', '::text))::character varying(255) AS batchnumber,
        CASE
            WHEN (( SELECT count(*) AS count
               FROM public.basic_substitutecomponent
              WHERE (basic_substitutecomponent.baseproduct_id = product.id)) > 0) THEN true
            ELSE false
        END AS replacement,
    productreplacement.number AS productreplacementnumber,
    (productreplacement.id)::integer AS productreplacementid
   FROM ((((((public.productioncounting_trackingoperationproductincomponent trackingoperationproductincomponent
     LEFT JOIN public.productioncounting_productiontracking productiontracking ON ((productiontracking.id = trackingoperationproductincomponent.productiontracking_id)))
     LEFT JOIN public.basic_product product ON ((product.id = trackingoperationproductincomponent.product_id)))
     LEFT JOIN public.basic_product productreplacement ON ((productreplacement.id = trackingoperationproductincomponent.replacementto_id)))
     LEFT JOIN public.productioncounting_usedbatch usedbatch ON ((usedbatch.trackingoperationproductincomponent_id = trackingoperationproductincomponent.id)))
     LEFT JOIN public.advancedgenealogy_batch batch ON ((batch.id = usedbatch.batch_id)))
     LEFT JOIN public.basicproductioncounting_productioncountingquantity productioncountingquantity ON (((productioncountingquantity.order_id = productiontracking.order_id) AND (productioncountingquantity.technologyoperationcomponent_id = productiontracking.technologyoperationcomponent_id) AND (productioncountingquantity.product_id = trackingoperationproductincomponent.product_id) AND ((productioncountingquantity.role)::text = '01used'::text))))
  WHERE (productiontracking.technologyoperationcomponent_id IS NOT NULL)
  GROUP BY trackingoperationproductincomponent.id, productiontracking.id, product.number, product.name, product.unit, product.id, trackingoperationproductincomponent.usedquantity, trackingoperationproductincomponent.obtainedquantity, trackingoperationproductincomponent.remainedquantity, trackingoperationproductincomponent.effectiveusedquantity, productiontracking.technologyoperationcomponent_id, productreplacement.number, productreplacement.id;


--
-- Name: productioncounting_trackingoperationproductincomponentdto_id_se; Type: SEQUENCE; Schema: public; Owner: -
--

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


--
-- Name: productioncounting_trackingoperationproductincomponenthelper_id; Type: SEQUENCE; Schema: public; Owner: -
--

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


--
-- Name: productioncounting_trackingoperationproductoutcomponent_id_seq; Type: SEQUENCE; Schema: public; Owner: -
--

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


--
-- Name: productioncounting_trackingoperationproductoutcomponent_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: -
--

ALTER SEQUENCE public.productioncounting_trackingoperationproductoutcomponent_id_seq OWNED BY public.productioncounting_trackingoperationproductoutcomponent.id;


--
-- Name: productioncounting_trackingoperationproductoutcomponentdto; Type: VIEW; Schema: public; Owner: -
--

CREATE VIEW public.productioncounting_trackingoperationproductoutcomponentdto AS
SELECT
    NULL::bigint AS id,
    NULL::integer AS productiontrackingid,
    NULL::character varying(255) AS productnumber,
    NULL::character varying(1024) AS productname,
    NULL::character varying(255) AS productunit,
    NULL::numeric AS plannedquantity,
    NULL::numeric AS producedsum,
    NULL::numeric AS wastessum,
    NULL::numeric AS remainingquantity,
    NULL::numeric(14,5) AS wastesquantity,
    NULL::numeric(14,5) AS usedquantity,
    NULL::numeric(14,5) AS wastedquantity,
    NULL::character varying(255) AS batchnumber,
    NULL::character varying(255) AS typeofmaterial;


--
-- Name: productioncounting_trackingoperationproductoutcomponentdto_id_s; Type: SEQUENCE; Schema: public; Owner: -
--

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


--
-- Name: productioncounting_trackingoperationproductoutcomponenthelper_i; Type: SEQUENCE; Schema: public; Owner: -
--

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


--
-- Name: productioncounting_usedbatch_id_seq; Type: SEQUENCE; Schema: public; Owner: -
--

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


--
-- Name: productioncounting_usedbatch_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: -
--

ALTER SEQUENCE public.productioncounting_usedbatch_id_seq OWNED BY public.productioncounting_usedbatch.id;


--
-- Name: productionlines_factorystructureelement; Type: TABLE; Schema: public; Owner: -
--

CREATE TABLE public.productionlines_factorystructureelement (
    id bigint NOT NULL,
    number character varying(255),
    name character varying(255),
    parent_id bigint,
    priority integer,
    nodenumber character varying(255),
    entitytype character varying(255) DEFAULT 'factory'::character varying,
    current boolean DEFAULT false,
    subassembly_id bigint,
    workstation_id bigint,
    entityid integer,
    maintenanceevent_id bigint,
    entityversion bigint DEFAULT 0,
    productionline_id bigint
);


--
-- Name: productionlines_factorystructureelement_id_seq; Type: SEQUENCE; Schema: public; Owner: -
--

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


--
-- Name: productionlines_factorystructureelement_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: -
--

ALTER SEQUENCE public.productionlines_factorystructureelement_id_seq OWNED BY public.productionlines_factorystructureelement.id;


--
-- Name: productionlines_productionline_id_seq; Type: SEQUENCE; Schema: public; Owner: -
--

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


--
-- Name: productionlines_productionline_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: -
--

ALTER SEQUENCE public.productionlines_productionline_id_seq OWNED BY public.productionlines_productionline.id;


--
-- Name: productionlines_workstationtypecomponent; Type: TABLE; Schema: public; Owner: -
--

CREATE TABLE public.productionlines_workstationtypecomponent (
    id bigint NOT NULL,
    productionline_id bigint,
    workstationtype_id bigint,
    quantity integer DEFAULT 1,
    entityversion bigint DEFAULT 0,
    datefrom timestamp without time zone,
    dateto timestamp without time zone
);


--
-- Name: productionlines_workstationtypecomponent_id_seq; Type: SEQUENCE; Schema: public; Owner: -
--

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


--
-- Name: productionlines_workstationtypecomponent_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: -
--

ALTER SEQUENCE public.productionlines_workstationtypecomponent_id_seq OWNED BY public.productionlines_workstationtypecomponent.id;


--
-- Name: productionpershift_balance; Type: TABLE; Schema: public; Owner: -
--

CREATE TABLE public.productionpershift_balance (
    id bigint NOT NULL,
    context_id bigint,
    day date,
    shiftname character varying(255),
    ordernumber character varying(255),
    productnumber character varying(255),
    productunit character varying(255),
    registeredquantity numeric(14,5),
    plannedquantity numeric(12,5),
    difference numeric(14,5),
    percentagedeviation numeric(16,5),
    entityversion bigint DEFAULT 0
);


--
-- Name: productionpershift_balance_id_seq; Type: SEQUENCE; Schema: public; Owner: -
--

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


--
-- Name: productionpershift_balance_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: -
--

ALTER SEQUENCE public.productionpershift_balance_id_seq OWNED BY public.productionpershift_balance.id;


--
-- Name: productionpershift_balancecontext; Type: TABLE; Schema: public; Owner: -
--

CREATE TABLE public.productionpershift_balancecontext (
    id bigint NOT NULL,
    fromdate date,
    todate date,
    viewisinitialized boolean,
    plannedquantityrequired boolean,
    deviationrequired boolean,
    deviationthreshold numeric(16,5),
    entityversion bigint DEFAULT 0
);


--
-- Name: productionpershift_balancecontext_id_seq; Type: SEQUENCE; Schema: public; Owner: -
--

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


--
-- Name: productionpershift_balancecontext_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: -
--

ALTER SEQUENCE public.productionpershift_balancecontext_id_seq OWNED BY public.productionpershift_balancecontext.id;


--
-- Name: productionpershift_dailyprogress; Type: TABLE; Schema: public; Owner: -
--

CREATE TABLE public.productionpershift_dailyprogress (
    id bigint NOT NULL,
    progressforday_id bigint,
    shift_id bigint,
    quantity numeric(12,5),
    locked boolean DEFAULT false,
    entityversion bigint DEFAULT 0,
    efficiencytime integer
);


--
-- Name: productionpershift_dailyprogress_id_seq; Type: SEQUENCE; Schema: public; Owner: -
--

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


--
-- Name: productionpershift_dailyprogress_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: -
--

ALTER SEQUENCE public.productionpershift_dailyprogress_id_seq OWNED BY public.productionpershift_dailyprogress.id;


--
-- Name: productionpershift_plandailyprogress; Type: TABLE; Schema: public; Owner: -
--

CREATE TABLE public.productionpershift_plandailyprogress (
    id bigint NOT NULL,
    progressforday_id bigint,
    shift_id bigint,
    quantity numeric(12,5),
    efficiencytime integer
);


--
-- Name: productionpershift_plandailyprogress_id_seq; Type: SEQUENCE; Schema: public; Owner: -
--

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


--
-- Name: productionpershift_plandailyprogress_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: -
--

ALTER SEQUENCE public.productionpershift_plandailyprogress_id_seq OWNED BY public.productionpershift_plandailyprogress.id;


--
-- Name: productionpershift_planproductionpershift; Type: TABLE; Schema: public; Owner: -
--

CREATE TABLE public.productionpershift_planproductionpershift (
    id bigint NOT NULL,
    order_id bigint,
    productionlineschedule_id bigint,
    productionline_id bigint
);


--
-- Name: productionpershift_planproductionpershift_id_seq; Type: SEQUENCE; Schema: public; Owner: -
--

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


--
-- Name: productionpershift_planproductionpershift_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: -
--

ALTER SEQUENCE public.productionpershift_planproductionpershift_id_seq OWNED BY public.productionpershift_planproductionpershift.id;


--
-- Name: productionpershift_planprogressforday; Type: TABLE; Schema: public; Owner: -
--

CREATE TABLE public.productionpershift_planprogressforday (
    id bigint NOT NULL,
    day integer,
    dateofday date,
    actualdateofday date,
    productionpershift_id bigint
);


--
-- Name: productionpershift_planprogressforday_id_seq; Type: SEQUENCE; Schema: public; Owner: -
--

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


--
-- Name: productionpershift_planprogressforday_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: -
--

ALTER SEQUENCE public.productionpershift_planprogressforday_id_seq OWNED BY public.productionpershift_planprogressforday.id;


--
-- Name: productionpershift_ppsreport; Type: TABLE; Schema: public; Owner: -
--

CREATE TABLE public.productionpershift_ppsreport (
    id bigint NOT NULL,
    number character varying(1024),
    name character varying(1024),
    datefrom date,
    dateto date,
    filename character varying(255),
    generated boolean DEFAULT false,
    createdate timestamp without time zone,
    updatedate timestamp without time zone,
    createuser character varying(255),
    updateuser character varying(255)
);


--
-- Name: productionpershift_ppsreport_id_seq; Type: SEQUENCE; Schema: public; Owner: -
--

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


--
-- Name: productionpershift_ppsreport_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: -
--

ALTER SEQUENCE public.productionpershift_ppsreport_id_seq OWNED BY public.productionpershift_ppsreport.id;


--
-- Name: productionpershift_productionpershift; Type: TABLE; Schema: public; Owner: -
--

CREATE TABLE public.productionpershift_productionpershift (
    id bigint NOT NULL,
    order_id bigint,
    plannedprogresscorrectioncomment text,
    orderfinishdate timestamp without time zone,
    entityversion bigint DEFAULT 0
);


--
-- Name: productionpershift_productionpershift_id_seq; Type: SEQUENCE; Schema: public; Owner: -
--

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


--
-- Name: productionpershift_productionpershift_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: -
--

ALTER SEQUENCE public.productionpershift_productionpershift_id_seq OWNED BY public.productionpershift_productionpershift.id;


--
-- Name: productionpershift_progressforday; Type: TABLE; Schema: public; Owner: -
--

CREATE TABLE public.productionpershift_progressforday (
    id bigint NOT NULL,
    day integer,
    corrected boolean DEFAULT false,
    dateofday date,
    actualdateofday date,
    entityversion bigint DEFAULT 0,
    productionpershift_id bigint
);


--
-- Name: productionpershift_progressforday_id_seq; Type: SEQUENCE; Schema: public; Owner: -
--

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


--
-- Name: productionpershift_progressforday_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: -
--

ALTER SEQUENCE public.productionpershift_progressforday_id_seq OWNED BY public.productionpershift_progressforday.id;


--
-- Name: productionpershift_reasontypeofcorrectionplan; Type: TABLE; Schema: public; Owner: -
--

CREATE TABLE public.productionpershift_reasontypeofcorrectionplan (
    id bigint NOT NULL,
    productionpershift_id bigint,
    reasontype character varying(255),
    date timestamp without time zone,
    entityversion bigint DEFAULT 0
);


--
-- Name: productionpershift_reasontypeofcorrectionplan_id_seq; Type: SEQUENCE; Schema: public; Owner: -
--

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


--
-- Name: productionpershift_reasontypeofcorrectionplan_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: -
--

ALTER SEQUENCE public.productionpershift_reasontypeofcorrectionplan_id_seq OWNED BY public.productionpershift_reasontypeofcorrectionplan.id;


--
-- Name: productionplans_dimensioncontrolattribute; Type: TABLE; Schema: public; Owner: -
--

CREATE TABLE public.productionplans_dimensioncontrolattribute (
    id bigint NOT NULL,
    parameter_id bigint,
    attribute_id bigint
);


--
-- Name: productionplans_dimensioncontrolattribute_id_seq; Type: SEQUENCE; Schema: public; Owner: -
--

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


--
-- Name: productionplans_dimensioncontrolattribute_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: -
--

ALTER SEQUENCE public.productionplans_dimensioncontrolattribute_id_seq OWNED BY public.productionplans_dimensioncontrolattribute.id;


--
-- Name: productionscheduling_opercomptimecalculation; Type: TABLE; Schema: public; Owner: -
--

CREATE TABLE public.productionscheduling_opercomptimecalculation (
    id bigint NOT NULL,
    ordertimecalculation_id bigint,
    technologyoperationcomponent_id bigint,
    operationoffset integer,
    effectiveoperationrealizationtime integer,
    effectivedatefrom timestamp without time zone,
    effectivedateto timestamp without time zone,
    duration integer DEFAULT 0,
    machineworktime integer DEFAULT 0,
    laborworktime integer DEFAULT 0
);


--
-- Name: productionscheduling_opercomptimecalculation_id_seq; Type: SEQUENCE; Schema: public; Owner: -
--

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


--
-- Name: productionscheduling_opercomptimecalculation_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: -
--

ALTER SEQUENCE public.productionscheduling_opercomptimecalculation_id_seq OWNED BY public.productionscheduling_opercomptimecalculation.id;


--
-- Name: productionscheduling_ordertimecalculation; Type: TABLE; Schema: public; Owner: -
--

CREATE TABLE public.productionscheduling_ordertimecalculation (
    id bigint NOT NULL,
    order_id bigint,
    effectivedatefrom timestamp without time zone,
    effectivedateto timestamp without time zone
);


--
-- Name: productionscheduling_ordertimecalculation_id_seq; Type: SEQUENCE; Schema: public; Owner: -
--

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


--
-- Name: productionscheduling_ordertimecalculation_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: -
--

ALTER SEQUENCE public.productionscheduling_ordertimecalculation_id_seq OWNED BY public.productionscheduling_ordertimecalculation.id;


--
-- Name: productionscheduling_planopercomptimecalculation; Type: TABLE; Schema: public; Owner: -
--

CREATE TABLE public.productionscheduling_planopercomptimecalculation (
    id bigint NOT NULL,
    ordertimecalculation_id bigint,
    technologyoperationcomponent_id bigint,
    operationoffset integer,
    effectiveoperationrealizationtime integer,
    effectivedatefrom timestamp without time zone,
    effectivedateto timestamp without time zone
);


--
-- Name: productionscheduling_planopercomptimecalculation_id_seq; Type: SEQUENCE; Schema: public; Owner: -
--

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


--
-- Name: productionscheduling_planopercomptimecalculation_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: -
--

ALTER SEQUENCE public.productionscheduling_planopercomptimecalculation_id_seq OWNED BY public.productionscheduling_planopercomptimecalculation.id;


--
-- Name: productionscheduling_planordertimecalculation; Type: TABLE; Schema: public; Owner: -
--

CREATE TABLE public.productionscheduling_planordertimecalculation (
    id bigint NOT NULL,
    order_id bigint,
    productionlineschedule_id bigint,
    productionline_id bigint,
    effectivedatefrom timestamp without time zone,
    effectivedateto timestamp without time zone
);


--
-- Name: productionscheduling_planordertimecalculation_id_seq; Type: SEQUENCE; Schema: public; Owner: -
--

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


--
-- Name: productionscheduling_planordertimecalculation_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: -
--

ALTER SEQUENCE public.productionscheduling_planordertimecalculation_id_seq OWNED BY public.productionscheduling_planordertimecalculation.id;


--
-- Name: qcadoocustomtranslation_customtranslation; Type: TABLE; Schema: public; Owner: -
--

CREATE TABLE public.qcadoocustomtranslation_customtranslation (
    id bigint NOT NULL,
    pluginidentifier character varying(255),
    key character varying(1024),
    propertiestranslation character varying(1024),
    customtranslation character varying(1024),
    active boolean DEFAULT false,
    locale character varying(255),
    entityversion bigint DEFAULT 0
);


--
-- Name: qcadoocustomtranslation_customtranslation_id_seq; Type: SEQUENCE; Schema: public; Owner: -
--

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


--
-- Name: qcadoocustomtranslation_customtranslation_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: -
--

ALTER SEQUENCE public.qcadoocustomtranslation_customtranslation_id_seq OWNED BY public.qcadoocustomtranslation_customtranslation.id;


--
-- Name: qcadoomodel_dictionary; Type: TABLE; Schema: public; Owner: -
--

CREATE TABLE public.qcadoomodel_dictionary (
    id bigint NOT NULL,
    name character varying(255),
    pluginidentifier character varying(255),
    active boolean,
    entityversion bigint DEFAULT 0
);


--
-- Name: qcadoomodel_dictionary_id_seq; Type: SEQUENCE; Schema: public; Owner: -
--

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


--
-- Name: qcadoomodel_dictionary_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: -
--

ALTER SEQUENCE public.qcadoomodel_dictionary_id_seq OWNED BY public.qcadoomodel_dictionary.id;


--
-- Name: qcadoomodel_dictionaryitem; Type: TABLE; Schema: public; Owner: -
--

CREATE TABLE public.qcadoomodel_dictionaryitem (
    id bigint NOT NULL,
    name character varying(255),
    externalnumber character varying(255),
    description character varying(2048),
    technicalcode character varying(255),
    dictionary_id bigint,
    active boolean DEFAULT true,
    entityversion bigint DEFAULT 0,
    isinteger boolean DEFAULT false,
    priority integer
);


--
-- Name: qcadoomodel_dictionaryitem_id_seq; Type: SEQUENCE; Schema: public; Owner: -
--

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


--
-- Name: qcadoomodel_dictionaryitem_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: -
--

ALTER SEQUENCE public.qcadoomodel_dictionaryitem_id_seq OWNED BY public.qcadoomodel_dictionaryitem.id;


--
-- Name: qcadoomodel_globalunitconversionsaggregate; Type: TABLE; Schema: public; Owner: -
--

CREATE TABLE public.qcadoomodel_globalunitconversionsaggregate (
    id bigint NOT NULL,
    entityversion bigint DEFAULT 0
);


--
-- Name: qcadoomodel_globalunitconversionsaggregate_id_seq; Type: SEQUENCE; Schema: public; Owner: -
--

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


--
-- Name: qcadoomodel_globalunitconversionsaggregate_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: -
--

ALTER SEQUENCE public.qcadoomodel_globalunitconversionsaggregate_id_seq OWNED BY public.qcadoomodel_globalunitconversionsaggregate.id;


--
-- Name: qcadoomodel_unitconversionitem_id_seq; Type: SEQUENCE; Schema: public; Owner: -
--

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


--
-- Name: qcadoomodel_unitconversionitem_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: -
--

ALTER SEQUENCE public.qcadoomodel_unitconversionitem_id_seq OWNED BY public.qcadoomodel_unitconversionitem.id;


--
-- Name: qcadooplugin_plugin_id_seq; Type: SEQUENCE; Schema: public; Owner: -
--

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


--
-- Name: qcadooplugin_plugin_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: -
--

ALTER SEQUENCE public.qcadooplugin_plugin_id_seq OWNED BY public.qcadooplugin_plugin.id;


--
-- Name: qcadoosecurity_group; Type: TABLE; Schema: public; Owner: -
--

CREATE TABLE public.qcadoosecurity_group (
    id bigint NOT NULL,
    name character varying(255),
    description text,
    identifier character varying(255),
    entityversion bigint DEFAULT 0,
    permissiontype character varying(255) DEFAULT '02officeLicense'::character varying
);


--
-- Name: qcadoosecurity_group_id_seq; Type: SEQUENCE; Schema: public; Owner: -
--

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


--
-- Name: qcadoosecurity_group_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: -
--

ALTER SEQUENCE public.qcadoosecurity_group_id_seq OWNED BY public.qcadoosecurity_group.id;


--
-- Name: qcadoosecurity_passwordresettoken; Type: TABLE; Schema: public; Owner: -
--

CREATE TABLE public.qcadoosecurity_passwordresettoken (
    id bigint NOT NULL,
    user_id bigint NOT NULL,
    token character varying(36) NOT NULL,
    active boolean DEFAULT true,
    expirationtime timestamp without time zone NOT NULL
);


--
-- Name: qcadoosecurity_passwordresettoken_id_seq; Type: SEQUENCE; Schema: public; Owner: -
--

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


--
-- Name: qcadoosecurity_passwordresettoken_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: -
--

ALTER SEQUENCE public.qcadoosecurity_passwordresettoken_id_seq OWNED BY public.qcadoosecurity_passwordresettoken.id;


--
-- Name: qcadoosecurity_persistenttoken; Type: TABLE; Schema: public; Owner: -
--

CREATE TABLE public.qcadoosecurity_persistenttoken (
    id bigint NOT NULL,
    username character varying(255),
    series character varying(255),
    token character varying(255),
    lastused timestamp without time zone,
    entityversion bigint DEFAULT 0
);


--
-- Name: qcadoosecurity_persistenttoken_id_seq; Type: SEQUENCE; Schema: public; Owner: -
--

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


--
-- Name: qcadoosecurity_persistenttoken_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: -
--

ALTER SEQUENCE public.qcadoosecurity_persistenttoken_id_seq OWNED BY public.qcadoosecurity_persistenttoken.id;


--
-- Name: qcadoosecurity_role; Type: TABLE; Schema: public; Owner: -
--

CREATE TABLE public.qcadoosecurity_role (
    id bigint NOT NULL,
    identifier character varying(255),
    description text,
    entityversion bigint DEFAULT 0
);


--
-- Name: qcadoosecurity_role_id_seq; Type: SEQUENCE; Schema: public; Owner: -
--

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


--
-- Name: qcadoosecurity_role_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: -
--

ALTER SEQUENCE public.qcadoosecurity_role_id_seq OWNED BY public.qcadoosecurity_role.id;


--
-- Name: qcadoosecurity_user_id_seq; Type: SEQUENCE; Schema: public; Owner: -
--

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


--
-- Name: qcadoosecurity_user_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: -
--

ALTER SEQUENCE public.qcadoosecurity_user_id_seq OWNED BY public.qcadoosecurity_user.id;


--
-- Name: qcadooview_alert; Type: TABLE; Schema: public; Owner: -
--

CREATE TABLE public.qcadooview_alert (
    id bigint NOT NULL,
    message text,
    type character varying(255) DEFAULT 'information'::character varying,
    expirationdate timestamp without time zone,
    sound boolean DEFAULT false
);


--
-- Name: qcadooview_alert_id_seq; Type: SEQUENCE; Schema: public; Owner: -
--

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


--
-- Name: qcadooview_alert_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: -
--

ALTER SEQUENCE public.qcadooview_alert_id_seq OWNED BY public.qcadooview_alert.id;


--
-- Name: qcadooview_category; Type: TABLE; Schema: public; Owner: -
--

CREATE TABLE public.qcadooview_category (
    id bigint NOT NULL,
    pluginidentifier character varying(255),
    name character varying(255),
    succession integer,
    authrole character varying(255),
    entityversion bigint DEFAULT 0
);


--
-- Name: qcadooview_category_id_seq; Type: SEQUENCE; Schema: public; Owner: -
--

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


--
-- Name: qcadooview_category_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: -
--

ALTER SEQUENCE public.qcadooview_category_id_seq OWNED BY public.qcadooview_category.id;


--
-- Name: qcadooview_item; Type: TABLE; Schema: public; Owner: -
--

CREATE TABLE public.qcadooview_item (
    id bigint NOT NULL,
    pluginidentifier character varying(255),
    name character varying(255),
    active boolean DEFAULT true,
    category_id bigint,
    view_id bigint,
    succession integer,
    authrole character varying(255),
    entityversion bigint DEFAULT 0
);


--
-- Name: qcadooview_item_id_seq; Type: SEQUENCE; Schema: public; Owner: -
--

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


--
-- Name: qcadooview_item_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: -
--

ALTER SEQUENCE public.qcadooview_item_id_seq OWNED BY public.qcadooview_item.id;


--
-- Name: qcadooview_systeminfo; Type: TABLE; Schema: public; Owner: -
--

CREATE TABLE public.qcadooview_systeminfo (
    id bigint NOT NULL,
    nextupdatetime timestamp without time zone
);


--
-- Name: qcadooview_systeminfo_id_seq; Type: SEQUENCE; Schema: public; Owner: -
--

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


--
-- Name: qcadooview_systeminfo_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: -
--

ALTER SEQUENCE public.qcadooview_systeminfo_id_seq OWNED BY public.qcadooview_systeminfo.id;


--
-- Name: qcadooview_view; Type: TABLE; Schema: public; Owner: -
--

CREATE TABLE public.qcadooview_view (
    id bigint NOT NULL,
    pluginidentifier character varying(255),
    name character varying(255),
    view character varying(255),
    url character varying(255),
    entityversion bigint DEFAULT 0
);


--
-- Name: qcadooview_view_id_seq; Type: SEQUENCE; Schema: public; Owner: -
--

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


--
-- Name: qcadooview_view_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: -
--

ALTER SEQUENCE public.qcadooview_view_id_seq OWNED BY public.qcadooview_view.id;


--
-- Name: qcadooview_viewedalert; Type: TABLE; Schema: public; Owner: -
--

CREATE TABLE public.qcadooview_viewedalert (
    id bigint NOT NULL,
    user_id bigint,
    alert_id bigint
);


--
-- Name: qcadooview_viewedalert_id_seq; Type: SEQUENCE; Schema: public; Owner: -
--

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


--
-- Name: qcadooview_viewedalert_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: -
--

ALTER SEQUENCE public.qcadooview_viewedalert_id_seq OWNED BY public.qcadooview_viewedalert.id;


--
-- Name: qualitycontrol_changequalitycards; Type: TABLE; Schema: public; Owner: -
--

CREATE TABLE public.qualitycontrol_changequalitycards (
    id bigint NOT NULL,
    cleanqualitycard boolean DEFAULT false,
    qualitycard_id bigint,
    createdate timestamp without time zone,
    updatedate timestamp without time zone,
    createuser character varying(255),
    updateuser character varying(255)
);


--
-- Name: qualitycontrol_changequalitycards_id_seq; Type: SEQUENCE; Schema: public; Owner: -
--

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


--
-- Name: qualitycontrol_changequalitycards_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: -
--

ALTER SEQUENCE public.qualitycontrol_changequalitycards_id_seq OWNED BY public.qualitycontrol_changequalitycards.id;


--
-- Name: qualitycontrol_deliveryqualitycontrol; Type: TABLE; Schema: public; Owner: -
--

CREATE TABLE public.qualitycontrol_deliveryqualitycontrol (
    id bigint NOT NULL,
    createdate timestamp without time zone,
    updatedate timestamp without time zone,
    createuser character varying(255),
    updateuser character varying(255),
    delivery_id bigint
);


--
-- Name: qualitycontrol_deliveryqualitycontrol_id_seq; Type: SEQUENCE; Schema: public; Owner: -
--

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


--
-- Name: qualitycontrol_deliveryqualitycontrol_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: -
--

ALTER SEQUENCE public.qualitycontrol_deliveryqualitycontrol_id_seq OWNED BY public.qualitycontrol_deliveryqualitycontrol.id;


--
-- Name: qualitycontrol_qualitycardattachment_id_seq; Type: SEQUENCE; Schema: public; Owner: -
--

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


--
-- Name: qualitycontrol_qualitycardattachment_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: -
--

ALTER SEQUENCE public.qualitycontrol_qualitycardattachment_id_seq OWNED BY public.qualitycontrol_qualitycardattachment.id;


--
-- Name: qualitycontrol_qualitycarddto; Type: VIEW; Schema: public; Owner: -
--

CREATE VIEW public.qualitycontrol_qualitycarddto AS
 SELECT qc.id,
    qc.number,
    qc.name,
    qc.description,
    qc.state,
    (count(qualitycardattachment.id) <> 0) AS attachmentsexists
   FROM (public.basic_qualitycard qc
     LEFT JOIN public.qualitycontrol_qualitycardattachment qualitycardattachment ON ((qualitycardattachment.qualitycard_id = qc.id)))
  GROUP BY qc.id, qc.number, qc.name, qc.description, qc.state;


--
-- Name: qualitycontrol_qualitycarddto_id_seq; Type: SEQUENCE; Schema: public; Owner: -
--

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


--
-- Name: qualitycontrol_qualitycontrol_id_seq; Type: SEQUENCE; Schema: public; Owner: -
--

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


--
-- Name: qualitycontrol_qualitycontrol_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: -
--

ALTER SEQUENCE public.qualitycontrol_qualitycontrol_id_seq OWNED BY public.qualitycontrol_qualitycontrol.id;


--
-- Name: qualitycontrol_qualitycontrol_number_seq; Type: SEQUENCE; Schema: public; Owner: -
--

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


--
-- Name: qualitycontrol_qualitycontrolattachment_id_seq; Type: SEQUENCE; Schema: public; Owner: -
--

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


--
-- Name: qualitycontrol_qualitycontrolattachment_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: -
--

ALTER SEQUENCE public.qualitycontrol_qualitycontrolattachment_id_seq OWNED BY public.qualitycontrol_qualitycontrolattachment.id;


--
-- Name: qualitycontrol_qualitycontrolattribute; Type: TABLE; Schema: public; Owner: -
--

CREATE TABLE public.qualitycontrol_qualitycontrolattribute (
    id bigint NOT NULL,
    qualitycard_id bigint,
    attribute_id bigint,
    priority integer,
    attributenumber character varying(255)
);


--
-- Name: qualitycontrol_qualitycontrolattribute_id_seq; Type: SEQUENCE; Schema: public; Owner: -
--

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


--
-- Name: qualitycontrol_qualitycontrolattribute_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: -
--

ALTER SEQUENCE public.qualitycontrol_qualitycontrolattribute_id_seq OWNED BY public.qualitycontrol_qualitycontrolattribute.id;


--
-- Name: qualitycontrol_qualitycontrolattributedeliveredprod; Type: TABLE; Schema: public; Owner: -
--

CREATE TABLE public.qualitycontrol_qualitycontrolattributedeliveredprod (
    id bigint NOT NULL,
    qualitydeliveredproduct_id bigint,
    attribute_id bigint,
    attributevalue_id bigint,
    value character varying(255)
);


--
-- Name: qualitycontrol_qualitycontrolattributedeliveredprod_id_seq; Type: SEQUENCE; Schema: public; Owner: -
--

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


--
-- Name: qualitycontrol_qualitycontrolattributedeliveredprod_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: -
--

ALTER SEQUENCE public.qualitycontrol_qualitycontrolattributedeliveredprod_id_seq OWNED BY public.qualitycontrol_qualitycontrolattributedeliveredprod.id;


--
-- Name: qualitycontrol_qualitycontrolattributeprodtracking; Type: TABLE; Schema: public; Owner: -
--

CREATE TABLE public.qualitycontrol_qualitycontrolattributeprodtracking (
    id bigint NOT NULL,
    productiontracking_id bigint,
    attribute_id bigint,
    attributevalue_id bigint,
    value character varying(255),
    fromtechnology boolean DEFAULT false,
    moment character varying(255),
    adddate timestamp without time zone
);


--
-- Name: qualitycontrol_qualitycontrolattributeprodtracking_id_seq; Type: SEQUENCE; Schema: public; Owner: -
--

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


--
-- Name: qualitycontrol_qualitycontrolattributeprodtracking_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: -
--

ALTER SEQUENCE public.qualitycontrol_qualitycontrolattributeprodtracking_id_seq OWNED BY public.qualitycontrol_qualitycontrolattributeprodtracking.id;


--
-- Name: qualitycontrol_qualitycontrolattributetoc; Type: TABLE; Schema: public; Owner: -
--

CREATE TABLE public.qualitycontrol_qualitycontrolattributetoc (
    id bigint NOT NULL,
    qualitycontrolattribute_id bigint,
    technologyoperationcomponent_id bigint,
    moment character varying(255)
);


--
-- Name: qualitycontrol_qualitycontrolattributetoc_id_seq; Type: SEQUENCE; Schema: public; Owner: -
--

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


--
-- Name: qualitycontrol_qualitycontrolattributetoc_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: -
--

ALTER SEQUENCE public.qualitycontrol_qualitycontrolattributetoc_id_seq OWNED BY public.qualitycontrol_qualitycontrolattributetoc.id;


--
-- Name: qualitycontrol_qualitycontrolattributetocdto; Type: VIEW; Schema: public; Owner: -
--

CREATE VIEW public.qualitycontrol_qualitycontrolattributetocdto AS
 SELECT qcatoc.id,
    (qcatoc.technologyoperationcomponent_id)::integer AS technologyoperationcomponentid,
    qcatoc.technologyoperationcomponent_id,
    qcatoc.qualitycontrolattribute_id,
    qcatoc.moment,
    qca.priority,
    a.number AS attributenumber,
    a.name AS attributename,
    a.datatype AS attributedatatype,
    a.valuetype AS attributevaluetype
   FROM ((public.qualitycontrol_qualitycontrolattributetoc qcatoc
     JOIN public.qualitycontrol_qualitycontrolattribute qca ON ((qcatoc.qualitycontrolattribute_id = qca.id)))
     JOIN public.basic_attribute a ON ((qca.attribute_id = a.id)));


--
-- Name: qualitycontrol_qualitycontrolattributetocdto_id_seq; Type: SEQUENCE; Schema: public; Owner: -
--

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


--
-- Name: qualitycontrol_qualitycontrolattributevalue; Type: TABLE; Schema: public; Owner: -
--

CREATE TABLE public.qualitycontrol_qualitycontrolattributevalue (
    id bigint NOT NULL,
    qualitycontrol_id bigint,
    attribute_id bigint,
    attributevalue_id bigint,
    value character varying(255),
    productiontracking_id bigint,
    fromqualitycard boolean DEFAULT false,
    priority integer
);


--
-- Name: qualitycontrol_qualitycontrolattributevalue_id_seq; Type: SEQUENCE; Schema: public; Owner: -
--

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


--
-- Name: qualitycontrol_qualitycontrolattributevalue_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: -
--

ALTER SEQUENCE public.qualitycontrol_qualitycontrolattributevalue_id_seq OWNED BY public.qualitycontrol_qualitycontrolattributevalue.id;


--
-- Name: qualitycontrol_qualitycontroldto; Type: VIEW; Schema: public; Owner: -
--

CREATE VIEW public.qualitycontrol_qualitycontroldto AS
 SELECT qc.id,
    qc.number,
    qc.date,
    qc.controltype,
    qc.state,
    qc.qualityrating,
    p.number AS product,
    b.number AS batch,
    o.number AS ordernumber,
    (((stf.name)::text || ' '::text) || (stf.surname)::text) AS staff,
    (count(qualitycontrolattachment.id) <> 0) AS attachmentsexists,
    qc.description,
    d.number AS delivery
   FROM ((((((public.qualitycontrol_qualitycontrol qc
     JOIN public.basic_product p ON ((p.id = qc.product_id)))
     LEFT JOIN public.qualitycontrol_qualitycontrolattachment qualitycontrolattachment ON ((qualitycontrolattachment.qualitycontrol_id = qc.id)))
     LEFT JOIN public.advancedgenealogy_batch b ON ((b.id = qc.batch_id)))
     LEFT JOIN public.orders_order o ON ((o.id = qc.order_id)))
     LEFT JOIN public.deliveries_delivery d ON ((d.id = qc.delivery_id)))
     LEFT JOIN public.basic_staff stf ON ((stf.id = qc.staff_id)))
  GROUP BY qc.id, qc.number, qc.date, qc.controltype, qc.state, qc.qualityrating, p.number, b.number, o.number, (((stf.name)::text || ' '::text) || (stf.surname)::text), qc.description, d.number;


--
-- Name: qualitycontrol_qualitycontroldto_id_seq; Type: SEQUENCE; Schema: public; Owner: -
--

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


--
-- Name: qualitycontrol_qualitycontrolresource; Type: TABLE; Schema: public; Owner: -
--

CREATE TABLE public.qualitycontrol_qualitycontrolresource (
    id bigint NOT NULL,
    resourcenumber character varying(255),
    qualitycontrol_id bigint,
    resource_id bigint
);


--
-- Name: qualitycontrol_qualitycontrolresource_id_seq; Type: SEQUENCE; Schema: public; Owner: -
--

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


--
-- Name: qualitycontrol_qualitycontrolresource_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: -
--

ALTER SEQUENCE public.qualitycontrol_qualitycontrolresource_id_seq OWNED BY public.qualitycontrol_qualitycontrolresource.id;


--
-- Name: qualitycontrol_qualitycontrolstatechange; Type: TABLE; Schema: public; Owner: -
--

CREATE TABLE public.qualitycontrol_qualitycontrolstatechange (
    id bigint NOT NULL,
    dateandtime timestamp without time zone,
    sourcestate character varying(255),
    targetstate character varying(255),
    status character varying(255),
    phase integer,
    worker character varying(255),
    qualitycontrol_id bigint,
    shift_id bigint
);


--
-- Name: qualitycontrol_qualitycontrolstatechange_id_seq; Type: SEQUENCE; Schema: public; Owner: -
--

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


--
-- Name: qualitycontrol_qualitycontrolstatechange_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: -
--

ALTER SEQUENCE public.qualitycontrol_qualitycontrolstatechange_id_seq OWNED BY public.qualitycontrol_qualitycontrolstatechange.id;


--
-- Name: qualitycontrol_qualitydeliveredproduct; Type: TABLE; Schema: public; Owner: -
--

CREATE TABLE public.qualitycontrol_qualitydeliveredproduct (
    id bigint NOT NULL,
    deliveryqualitycontrol_id bigint,
    qualitycard_id bigint,
    qualityrating character varying(255),
    product_id bigint,
    batch_id bigint,
    batchnumber character varying(255),
    deliveredquantity numeric(12,5),
    priceperunit numeric(12,5),
    storagelocation_id bigint,
    orderedproduct_id bigint,
    productiondate date,
    expirationdate date
);


--
-- Name: qualitycontrol_qualitydeliveredproduct_id_seq; Type: SEQUENCE; Schema: public; Owner: -
--

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


--
-- Name: qualitycontrol_qualitydeliveredproduct_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: -
--

ALTER SEQUENCE public.qualitycontrol_qualitydeliveredproduct_id_seq OWNED BY public.qualitycontrol_qualitydeliveredproduct.id;


--
-- Name: repairs_repairorder_id_seq; Type: SEQUENCE; Schema: public; Owner: -
--

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


--
-- Name: repairs_repairorder_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: -
--

ALTER SEQUENCE public.repairs_repairorder_id_seq OWNED BY public.repairs_repairorder.id;


--
-- Name: repairs_repairorder_number_seq; Type: SEQUENCE; Schema: public; Owner: -
--

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


--
-- Name: repairs_repairorderdto; Type: VIEW; Schema: public; Owner: -
--

CREATE VIEW public.repairs_repairorderdto AS
 SELECT repairorder.id,
    repairorder.number,
    repairorder.state,
    repairorder.createdate,
    repairorder.startdate,
    repairorder.enddate,
    repairorder.quantitytorepair,
    repairorder.quantityrepaired,
    repairorder.lack,
    repairorder.active,
    (orderdto.id)::integer AS order_id,
    orderdto.number AS ordernumber,
    (division.id)::integer AS division_id,
    division.number AS divisionnumber,
    (shift.id)::integer AS shift_id,
    shift.name AS shiftname,
    (product.id)::integer AS product_id,
    product.number AS productnumber,
    product.name AS productname,
    product.unit AS productunit,
    (productiontrackingdto.id)::integer AS productiontracking_id,
    productiontrackingdto.number AS productiontrackingnumber,
    ft.name AS faulttype
   FROM ((((((public.repairs_repairorder repairorder
     JOIN public.basic_faulttype ft ON ((ft.id = repairorder.faulttype_id)))
     LEFT JOIN public.orders_orderdto orderdto ON ((orderdto.id = repairorder.order_id)))
     LEFT JOIN public.basic_division division ON ((division.id = repairorder.division_id)))
     LEFT JOIN public.basic_shift shift ON ((shift.id = repairorder.shift_id)))
     LEFT JOIN public.basic_product product ON ((product.id = repairorder.product_id)))
     LEFT JOIN public.productioncounting_productiontracking productiontrackingdto ON ((productiontrackingdto.id = repairorder.productiontracking_id)));


--
-- Name: repairs_repairorderdto_id_seq; Type: SEQUENCE; Schema: public; Owner: -
--

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


--
-- Name: repairs_repairorderproduct; Type: TABLE; Schema: public; Owner: -
--

CREATE TABLE public.repairs_repairorderproduct (
    id bigint NOT NULL,
    trackingoperationproductincomponent_id bigint,
    division_id bigint,
    location_id bigint,
    product_id bigint,
    faulttype_id bigint,
    description character varying(2048),
    givenquantity numeric(12,5),
    givenunit character varying(255),
    entityversion bigint DEFAULT 0
);


--
-- Name: repairs_repairorderproduct_id_seq; Type: SEQUENCE; Schema: public; Owner: -
--

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


--
-- Name: repairs_repairorderproduct_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: -
--

ALTER SEQUENCE public.repairs_repairorderproduct_id_seq OWNED BY public.repairs_repairorderproduct.id;


--
-- Name: repairs_repairorderstatechange; Type: TABLE; Schema: public; Owner: -
--

CREATE TABLE public.repairs_repairorderstatechange (
    id bigint NOT NULL,
    dateandtime timestamp without time zone,
    sourcestate character varying(255),
    targetstate character varying(255),
    phase integer,
    worker character varying(255),
    repairorder_id bigint,
    shift_id bigint,
    status character varying
);


--
-- Name: repairs_repairorderstatechange_id_seq; Type: SEQUENCE; Schema: public; Owner: -
--

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


--
-- Name: repairs_repairorderstatechange_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: -
--

ALTER SEQUENCE public.repairs_repairorderstatechange_id_seq OWNED BY public.repairs_repairorderstatechange.id;


--
-- Name: repairs_repairorderworktime; Type: TABLE; Schema: public; Owner: -
--

CREATE TABLE public.repairs_repairorderworktime (
    id bigint NOT NULL,
    repairorder_id bigint,
    staff_id bigint,
    labortime integer DEFAULT 0,
    effectiveexecutiontimestart timestamp without time zone,
    effectiveexecutiontimeend timestamp without time zone
);


--
-- Name: repairs_repairorderworktime_id_seq; Type: SEQUENCE; Schema: public; Owner: -
--

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


--
-- Name: repairs_repairorderworktime_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: -
--

ALTER SEQUENCE public.repairs_repairorderworktime_id_seq OWNED BY public.repairs_repairorderworktime.id;


--
-- Name: states_message; Type: TABLE; Schema: public; Owner: -
--

CREATE TABLE public.states_message (
    id bigint NOT NULL,
    type character varying(255),
    translationkey character varying(255),
    translationargs character varying(255),
    correspondfieldname character varying(255),
    autoclose boolean DEFAULT true,
    productiontrackingstatechange_id bigint,
    deliverystatechange_id bigint,
    assignmenttoshiftstatechange_id bigint,
    technologystatechange_id bigint,
    orderstatechange_id bigint,
    extrusionprotocolstatechange_id bigint,
    confectionprotocolstatechange_id bigint,
    palletstatechange_id bigint,
    batchstatechange_id bigint,
    trackingrecordstatechange_id bigint,
    requestforquotationstatechange_id bigint,
    offerstatechange_id bigint,
    negotiationstatechange_id bigint,
    warehouseissuestatechange_id bigint,
    palletlabelstatechange_id bigint,
    maintenanceeventstatechange_id bigint,
    entityversion bigint DEFAULT 0,
    plannedeventstatechange_id bigint,
    recurringeventstatechange_id bigint
);


--
-- Name: states_message_id_seq; Type: SEQUENCE; Schema: public; Owner: -
--

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


--
-- Name: states_message_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: -
--

ALTER SEQUENCE public.states_message_id_seq OWNED BY public.states_message.id;


--
-- Name: stoppage_stoppage; Type: TABLE; Schema: public; Owner: -
--

CREATE TABLE public.stoppage_stoppage (
    id bigint NOT NULL,
    order_id bigint,
    duration integer,
    entityversion bigint DEFAULT 0,
    productiontracking_id bigint,
    reason_id bigint,
    description character varying(1024),
    datefrom timestamp without time zone,
    dateto timestamp without time zone
);


--
-- Name: stoppage_stoppage_id_seq; Type: SEQUENCE; Schema: public; Owner: -
--

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


--
-- Name: stoppage_stoppage_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: -
--

ALTER SEQUENCE public.stoppage_stoppage_id_seq OWNED BY public.stoppage_stoppage.id;


--
-- Name: stoppage_stoppagereason; Type: TABLE; Schema: public; Owner: -
--

CREATE TABLE public.stoppage_stoppagereason (
    id bigint NOT NULL,
    name character varying(255),
    description character varying(1024),
    type character varying(255) DEFAULT '02other'::character varying
);


--
-- Name: stoppage_stoppagedto; Type: VIEW; Schema: public; Owner: -
--

CREATE VIEW public.stoppage_stoppagedto AS
 SELECT stoppage.id,
    ordersorder.number AS ordernumber,
    ordersorder.state AS orderstate,
    productiontracking.number AS productiontrackingnumber,
    productiontracking.state AS productiontrackingstate,
    stoppagereason.name AS reasonname,
    stoppage.description,
    public.duration_to_string(stoppage.duration) AS duration,
    stoppage.datefrom,
    stoppage.dateto,
    productionline.number AS productionlinenumber,
    workstation.number AS workstationnumber,
    (((staff.name)::text || ' '::text) || (staff.surname)::text) AS staffname,
    COALESCE(productiontrackingdivision.number, orderdivision.number) AS divisionnumber
   FROM ((((((((public.stoppage_stoppage stoppage
     JOIN public.orders_order ordersorder ON ((ordersorder.id = stoppage.order_id)))
     JOIN public.stoppage_stoppagereason stoppagereason ON ((stoppagereason.id = stoppage.reason_id)))
     LEFT JOIN public.productioncounting_productiontracking productiontracking ON ((productiontracking.id = stoppage.productiontracking_id)))
     LEFT JOIN public.productionlines_productionline productionline ON ((productionline.id = ordersorder.productionline_id)))
     LEFT JOIN public.basic_workstation workstation ON ((workstation.id = productiontracking.workstation_id)))
     LEFT JOIN public.basic_staff staff ON ((staff.id = productiontracking.staff_id)))
     LEFT JOIN public.basic_division productiontrackingdivision ON ((productiontrackingdivision.id = productiontracking.division_id)))
     LEFT JOIN public.basic_division orderdivision ON ((orderdivision.id = ordersorder.division_id)));


--
-- Name: stoppage_stoppagedto_id_seq; Type: SEQUENCE; Schema: public; Owner: -
--

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


--
-- Name: stoppage_stoppagereason_id_seq; Type: SEQUENCE; Schema: public; Owner: -
--

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


--
-- Name: stoppage_stoppagereason_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: -
--

ALTER SEQUENCE public.stoppage_stoppagereason_id_seq OWNED BY public.stoppage_stoppagereason.id;


--
-- Name: sub_order_number_seq; Type: SEQUENCE; Schema: public; Owner: -
--

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


--
-- Name: subcontractorportal_subordercost; Type: TABLE; Schema: public; Owner: -
--

CREATE TABLE public.subcontractorportal_subordercost (
    id bigint NOT NULL,
    deliveredquantity numeric(14,5) DEFAULT (0)::numeric,
    unitprice numeric(14,5) DEFAULT (0)::numeric,
    totalprice numeric(14,5) DEFAULT (0)::numeric,
    suborder_id bigint,
    product_id bigint,
    active boolean DEFAULT true,
    entityversion bigint DEFAULT 0,
    operationaltask_id bigint,
    order_id bigint
);


--
-- Name: subcontractorportal_cost_id_seq; Type: SEQUENCE; Schema: public; Owner: -
--

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


--
-- Name: subcontractorportal_cost_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: -
--

ALTER SEQUENCE public.subcontractorportal_cost_id_seq OWNED BY public.subcontractorportal_subordercost.id;


--
-- Name: subcontractorportal_suborderevent; Type: TABLE; Schema: public; Owner: -
--

CREATE TABLE public.subcontractorportal_suborderevent (
    id bigint NOT NULL,
    date timestamp without time zone,
    prevvalue character varying(255),
    currvalue character varying(255),
    type character varying(255),
    action character varying(255),
    staff_id bigint,
    suborder_id bigint,
    active boolean DEFAULT true,
    entityversion bigint DEFAULT 0
);


--
-- Name: subcontractorportal_event_id_seq; Type: SEQUENCE; Schema: public; Owner: -
--

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


--
-- Name: subcontractorportal_event_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: -
--

ALTER SEQUENCE public.subcontractorportal_event_id_seq OWNED BY public.subcontractorportal_suborderevent.id;


--
-- Name: subcontractorportal_subordermessage; Type: TABLE; Schema: public; Owner: -
--

CREATE TABLE public.subcontractorportal_subordermessage (
    id bigint NOT NULL,
    date date,
    createdat timestamp without time zone,
    description character varying(255),
    staff_id bigint,
    company_id bigint,
    suborder_id bigint,
    active boolean DEFAULT true,
    entityversion bigint DEFAULT 0
);


--
-- Name: subcontractorportal_message_id_seq; Type: SEQUENCE; Schema: public; Owner: -
--

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


--
-- Name: subcontractorportal_message_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: -
--

ALTER SEQUENCE public.subcontractorportal_message_id_seq OWNED BY public.subcontractorportal_subordermessage.id;


--
-- Name: subcontractorportal_operation; Type: TABLE; Schema: public; Owner: -
--

CREATE TABLE public.subcontractorportal_operation (
    id bigint NOT NULL,
    orderid integer,
    operationid integer,
    cost integer,
    number character varying(255),
    operation character varying(255),
    ordernumber character varying(255),
    ordername character varying(255),
    datefrom timestamp without time zone,
    dateto timestamp without time zone,
    status character varying(255),
    company_id bigint,
    operationcomponent_id bigint,
    active boolean DEFAULT true,
    entityversion bigint DEFAULT 0
);


--
-- Name: subcontractorportal_operation_id_seq; Type: SEQUENCE; Schema: public; Owner: -
--

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


--
-- Name: subcontractorportal_operation_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: -
--

ALTER SEQUENCE public.subcontractorportal_operation_id_seq OWNED BY public.subcontractorportal_operation.id;


--
-- Name: subcontractorportal_suborderrealisation; Type: TABLE; Schema: public; Owner: -
--

CREATE TABLE public.subcontractorportal_suborderrealisation (
    id bigint NOT NULL,
    date date,
    producedquantity numeric(12,5),
    remainingquantity numeric(12,5),
    product_id bigint,
    suborder_id bigint,
    active boolean DEFAULT true,
    entityversion bigint DEFAULT 0
);


--
-- Name: subcontractorportal_realisation_id_seq; Type: SEQUENCE; Schema: public; Owner: -
--

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


--
-- Name: subcontractorportal_realisation_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: -
--

ALTER SEQUENCE public.subcontractorportal_realisation_id_seq OWNED BY public.subcontractorportal_suborderrealisation.id;


--
-- Name: subcontractorportal_suborder_id_seq; Type: SEQUENCE; Schema: public; Owner: -
--

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


--
-- Name: subcontractorportal_suborder_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: -
--

ALTER SEQUENCE public.subcontractorportal_suborder_id_seq OWNED BY public.subcontractorportal_suborder.id;


--
-- Name: subcontractorportal_suborderattachment; Type: TABLE; Schema: public; Owner: -
--

CREATE TABLE public.subcontractorportal_suborderattachment (
    id bigint NOT NULL,
    attachment character varying(255),
    name character varying(255),
    ext character varying(255),
    size numeric(12,5),
    suborder_id bigint,
    active boolean DEFAULT true,
    entityversion bigint DEFAULT 0
);


--
-- Name: subcontractorportal_suborderattachment_id_seq; Type: SEQUENCE; Schema: public; Owner: -
--

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


--
-- Name: subcontractorportal_suborderattachment_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: -
--

ALTER SEQUENCE public.subcontractorportal_suborderattachment_id_seq OWNED BY public.subcontractorportal_suborderattachment.id;


--
-- Name: subcontractorportal_subordercost_id_seq; Type: SEQUENCE; Schema: public; Owner: -
--

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


--
-- Name: subcontractorportal_subordercost_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: -
--

ALTER SEQUENCE public.subcontractorportal_subordercost_id_seq OWNED BY public.subcontractorportal_subordercost.id;


--
-- Name: subcontractorportal_suborderinput; Type: TABLE; Schema: public; Owner: -
--

CREATE TABLE public.subcontractorportal_suborderinput (
    id bigint NOT NULL,
    unit character varying(20),
    plannedquantity numeric(14,5),
    deliveredquantity numeric(14,5),
    remainingquantity numeric(14,5),
    product_id bigint,
    location_id bigint,
    suborder_id bigint,
    active boolean DEFAULT true,
    operations character varying(20),
    entityversion bigint DEFAULT 0
);


--
-- Name: subcontractorportal_suborderoutput; Type: TABLE; Schema: public; Owner: -
--

CREATE TABLE public.subcontractorportal_suborderoutput (
    id bigint NOT NULL,
    unit character varying(20),
    plannedquantity numeric(14,5) DEFAULT (0)::numeric,
    deliveredquantity numeric(14,5) DEFAULT (0)::numeric,
    producedquantity numeric(14,5) DEFAULT (0)::numeric,
    remainingquantity numeric(14,5) DEFAULT (0)::numeric,
    unitprice numeric(14,5) DEFAULT (0)::numeric,
    createdmanually boolean DEFAULT false,
    product_id bigint,
    location_id bigint,
    suborder_id bigint,
    active boolean DEFAULT true,
    operations character varying(20),
    entityversion bigint DEFAULT 0
);


--
-- Name: subcontractorportal_suborderdto; Type: VIEW; Schema: public; Owner: -
--

CREATE VIEW public.subcontractorportal_suborderdto AS
 WITH suborderinputsum AS (
         SELECT subcontractorportal_suborderinput.suborder_id,
            sum(subcontractorportal_suborderinput.plannedquantity) AS plannedreleasequantity,
            sum(subcontractorportal_suborderinput.deliveredquantity) AS releasequantity
           FROM public.subcontractorportal_suborderinput
          GROUP BY subcontractorportal_suborderinput.suborder_id
        ), suborderoutputsum AS (
         SELECT subcontractorportal_suborderoutput.suborder_id,
            sum(subcontractorportal_suborderoutput.plannedquantity) AS plannedreceiptquantity,
            sum(subcontractorportal_suborderoutput.deliveredquantity) AS receiptquantity
           FROM public.subcontractorportal_suborderoutput
          GROUP BY subcontractorportal_suborderoutput.suborder_id
        )
 SELECT suborder.id,
    suborder.active,
    suborder.number,
    (company.id)::integer AS companyid,
    company.name AS companyname,
    suborder.datefrom,
    suborder.dateto,
    suborder.description,
    suborder.state,
    COALESCE(suborderinputsum.plannedreleasequantity, (0)::numeric) AS plannedreleasequantity,
    COALESCE(suborderinputsum.releasequantity, (0)::numeric) AS releasequantity,
    COALESCE(suborderoutputsum.plannedreceiptquantity, (0)::numeric) AS plannedreceiptquantity,
    COALESCE(suborderoutputsum.receiptquantity, (0)::numeric) AS receiptquantity
   FROM (((public.subcontractorportal_suborder suborder
     LEFT JOIN public.basic_company company ON ((company.id = suborder.company_id)))
     LEFT JOIN suborderinputsum suborderinputsum ON ((suborderinputsum.suborder_id = suborder.id)))
     LEFT JOIN suborderoutputsum suborderoutputsum ON ((suborderoutputsum.suborder_id = suborder.id)));


--
-- Name: subcontractorportal_suborderdto_id_seq; Type: SEQUENCE; Schema: public; Owner: -
--

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


--
-- Name: subcontractorportal_suborderevent_id_seq; Type: SEQUENCE; Schema: public; Owner: -
--

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


--
-- Name: subcontractorportal_suborderevent_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: -
--

ALTER SEQUENCE public.subcontractorportal_suborderevent_id_seq OWNED BY public.subcontractorportal_suborderevent.id;


--
-- Name: subcontractorportal_suborderinput_id_seq; Type: SEQUENCE; Schema: public; Owner: -
--

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


--
-- Name: subcontractorportal_suborderinput_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: -
--

ALTER SEQUENCE public.subcontractorportal_suborderinput_id_seq OWNED BY public.subcontractorportal_suborderinput.id;


--
-- Name: subcontractorportal_suborderissuedproductsreport; Type: TABLE; Schema: public; Owner: -
--

CREATE TABLE public.subcontractorportal_suborderissuedproductsreport (
    id bigint NOT NULL,
    number character varying(256),
    name character varying(1024),
    datefrom date,
    dateto date,
    company_id bigint,
    withoutfinishedsuborders boolean DEFAULT false,
    withoutfullyreceivedsuborders boolean DEFAULT false,
    generated boolean,
    worker character varying(255),
    date timestamp without time zone,
    filename character varying(255)
);


--
-- Name: subcontractorportal_suborderissuedproductsreport_id_seq; Type: SEQUENCE; Schema: public; Owner: -
--

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


--
-- Name: subcontractorportal_suborderissuedproductsreport_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: -
--

ALTER SEQUENCE public.subcontractorportal_suborderissuedproductsreport_id_seq OWNED BY public.subcontractorportal_suborderissuedproductsreport.id;


--
-- Name: subcontractorportal_suborderissuedproductsreport_number_seq; Type: SEQUENCE; Schema: public; Owner: -
--

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


--
-- Name: subcontractorportal_subordermessage_id_seq; Type: SEQUENCE; Schema: public; Owner: -
--

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


--
-- Name: subcontractorportal_subordermessage_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: -
--

ALTER SEQUENCE public.subcontractorportal_subordermessage_id_seq OWNED BY public.subcontractorportal_subordermessage.id;


--
-- Name: subcontractorportal_suborderoperation; Type: TABLE; Schema: public; Owner: -
--

CREATE TABLE public.subcontractorportal_suborderoperation (
    id bigint NOT NULL,
    orderid integer,
    operationid integer,
    cost numeric(14,5),
    number character varying(255),
    operation character varying(255),
    ordernumber character varying(255),
    ordername character varying(255),
    datefrom timestamp without time zone,
    dateto timestamp without time zone,
    status character varying(255),
    company_id bigint,
    suborder_id bigint,
    operationcomponent_id bigint,
    active boolean DEFAULT true,
    entityversion bigint DEFAULT 0
);


--
-- Name: subcontractorportal_suborderoperation_id_seq; Type: SEQUENCE; Schema: public; Owner: -
--

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


--
-- Name: subcontractorportal_suborderoperation_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: -
--

ALTER SEQUENCE public.subcontractorportal_suborderoperation_id_seq OWNED BY public.subcontractorportal_suborderoperation.id;


--
-- Name: subcontractorportal_suborderoutput_id_seq; Type: SEQUENCE; Schema: public; Owner: -
--

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


--
-- Name: subcontractorportal_suborderoutput_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: -
--

ALTER SEQUENCE public.subcontractorportal_suborderoutput_id_seq OWNED BY public.subcontractorportal_suborderoutput.id;


--
-- Name: subcontractorportal_suborderrealisation_id_seq; Type: SEQUENCE; Schema: public; Owner: -
--

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


--
-- Name: subcontractorportal_suborderrealisation_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: -
--

ALTER SEQUENCE public.subcontractorportal_suborderrealisation_id_seq OWNED BY public.subcontractorportal_suborderrealisation.id;


--
-- Name: subcontractorportal_suborderstatechange; Type: TABLE; Schema: public; Owner: -
--

CREATE TABLE public.subcontractorportal_suborderstatechange (
    id bigint NOT NULL,
    dateandtime timestamp without time zone,
    sourcestate character varying(255),
    targetstate character varying(255),
    status character varying(255),
    phase integer,
    worker character varying(255),
    suborder_id bigint,
    shift_id bigint
);


--
-- Name: subcontractorportal_suborderstatechange_id_seq; Type: SEQUENCE; Schema: public; Owner: -
--

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


--
-- Name: subcontractorportal_suborderstatechange_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: -
--

ALTER SEQUENCE public.subcontractorportal_suborderstatechange_id_seq OWNED BY public.subcontractorportal_suborderstatechange.id;


--
-- Name: subcontractorportal_subordertmp; Type: TABLE; Schema: public; Owner: -
--

CREATE TABLE public.subcontractorportal_subordertmp (
    id bigint NOT NULL,
    number character varying(255),
    ordernumber character varying(255),
    datefrom timestamp without time zone,
    dateto timestamp without time zone,
    planneddatefrom timestamp without time zone,
    planneddateto timestamp without time zone,
    status character varying(255),
    company_id bigint,
    active boolean DEFAULT true,
    entityversion bigint DEFAULT 0
);


--
-- Name: subcontractorportal_subordertmp_id_seq; Type: SEQUENCE; Schema: public; Owner: -
--

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


--
-- Name: subcontractorportal_subordertmp_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: -
--

ALTER SEQUENCE public.subcontractorportal_subordertmp_id_seq OWNED BY public.subcontractorportal_subordertmp.id;


--
-- Name: supplynegotiations_columnforoffers; Type: TABLE; Schema: public; Owner: -
--

CREATE TABLE public.supplynegotiations_columnforoffers (
    id bigint NOT NULL,
    identifier character varying(255),
    name character varying(1024),
    description character varying(1024),
    columnfiller character varying(255),
    alignment character varying(255) DEFAULT '01left'::character varying,
    parameter_id bigint,
    succession integer,
    entityversion bigint DEFAULT 0
);


--
-- Name: supplynegotiations_columnforoffers_id_seq; Type: SEQUENCE; Schema: public; Owner: -
--

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


--
-- Name: supplynegotiations_columnforoffers_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: -
--

ALTER SEQUENCE public.supplynegotiations_columnforoffers_id_seq OWNED BY public.supplynegotiations_columnforoffers.id;


--
-- Name: supplynegotiations_columnforrequests; Type: TABLE; Schema: public; Owner: -
--

CREATE TABLE public.supplynegotiations_columnforrequests (
    id bigint NOT NULL,
    identifier character varying(255),
    name character varying(1024),
    description character varying(1024),
    columnfiller character varying(255),
    alignment character varying(255) DEFAULT '01left'::character varying,
    parameter_id bigint,
    succession integer,
    entityversion bigint DEFAULT 0
);


--
-- Name: supplynegotiations_columnforrequests_id_seq; Type: SEQUENCE; Schema: public; Owner: -
--

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


--
-- Name: supplynegotiations_columnforrequests_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: -
--

ALTER SEQUENCE public.supplynegotiations_columnforrequests_id_seq OWNED BY public.supplynegotiations_columnforrequests.id;


--
-- Name: supplynegotiations_negotiation_id_seq; Type: SEQUENCE; Schema: public; Owner: -
--

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


--
-- Name: supplynegotiations_negotiation_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: -
--

ALTER SEQUENCE public.supplynegotiations_negotiation_id_seq OWNED BY public.supplynegotiations_negotiation.id;


--
-- Name: supplynegotiations_negotiationproduct; Type: TABLE; Schema: public; Owner: -
--

CREATE TABLE public.supplynegotiations_negotiationproduct (
    id bigint NOT NULL,
    negotiation_id bigint,
    product_id bigint,
    neededquantity numeric(12,5),
    approveddeliveredquantity numeric(12,5),
    draftdeliveredquantity numeric(12,5),
    leftquantity numeric(12,5),
    duedate timestamp without time zone,
    operation_id bigint,
    requestforquotationsnumber integer,
    entityversion bigint DEFAULT 0
);


--
-- Name: supplynegotiations_negotiationproduct_id_seq; Type: SEQUENCE; Schema: public; Owner: -
--

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


--
-- Name: supplynegotiations_negotiationproduct_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: -
--

ALTER SEQUENCE public.supplynegotiations_negotiationproduct_id_seq OWNED BY public.supplynegotiations_negotiationproduct.id;


--
-- Name: supplynegotiations_negotiationstatechange; Type: TABLE; Schema: public; Owner: -
--

CREATE TABLE public.supplynegotiations_negotiationstatechange (
    id bigint NOT NULL,
    dateandtime timestamp without time zone,
    sourcestate character varying(255),
    targetstate character varying(255),
    status character varying(255),
    phase integer,
    worker character varying(255),
    negotiation_id bigint,
    shift_id bigint,
    entityversion bigint DEFAULT 0
);


--
-- Name: supplynegotiations_negotiationstatechange_id_seq; Type: SEQUENCE; Schema: public; Owner: -
--

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


--
-- Name: supplynegotiations_negotiationstatechange_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: -
--

ALTER SEQUENCE public.supplynegotiations_negotiationstatechange_id_seq OWNED BY public.supplynegotiations_negotiationstatechange.id;


--
-- Name: supplynegotiations_offer_id_seq; Type: SEQUENCE; Schema: public; Owner: -
--

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


--
-- Name: supplynegotiations_offer_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: -
--

ALTER SEQUENCE public.supplynegotiations_offer_id_seq OWNED BY public.supplynegotiations_offer.id;


--
-- Name: supplynegotiations_offerproduct; Type: TABLE; Schema: public; Owner: -
--

CREATE TABLE public.supplynegotiations_offerproduct (
    id bigint NOT NULL,
    offer_id bigint,
    product_id bigint,
    quantity numeric(12,5),
    priceperunit numeric(12,5),
    totalprice numeric(12,5),
    operation_id bigint,
    succession integer,
    actualversion character varying(255),
    entityversion bigint DEFAULT 0
);


--
-- Name: supplynegotiations_offerproduct_id_seq; Type: SEQUENCE; Schema: public; Owner: -
--

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


--
-- Name: supplynegotiations_offerproduct_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: -
--

ALTER SEQUENCE public.supplynegotiations_offerproduct_id_seq OWNED BY public.supplynegotiations_offerproduct.id;


--
-- Name: supplynegotiations_offerstatechange; Type: TABLE; Schema: public; Owner: -
--

CREATE TABLE public.supplynegotiations_offerstatechange (
    id bigint NOT NULL,
    dateandtime timestamp without time zone,
    sourcestate character varying(255),
    targetstate character varying(255),
    status character varying(255),
    phase integer,
    worker character varying(255),
    offer_id bigint,
    shift_id bigint,
    entityversion bigint DEFAULT 0
);


--
-- Name: supplynegotiations_offerstatechange_id_seq; Type: SEQUENCE; Schema: public; Owner: -
--

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


--
-- Name: supplynegotiations_offerstatechange_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: -
--

ALTER SEQUENCE public.supplynegotiations_offerstatechange_id_seq OWNED BY public.supplynegotiations_offerstatechange.id;


--
-- Name: supplynegotiations_parametercolumnforoffers; Type: TABLE; Schema: public; Owner: -
--

CREATE TABLE public.supplynegotiations_parametercolumnforoffers (
    id bigint NOT NULL,
    parameter_id bigint,
    columnforoffers_id bigint,
    succession integer,
    entityversion bigint DEFAULT 0
);


--
-- Name: supplynegotiations_parametercolumnforoffers_id_seq; Type: SEQUENCE; Schema: public; Owner: -
--

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


--
-- Name: supplynegotiations_parametercolumnforoffers_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: -
--

ALTER SEQUENCE public.supplynegotiations_parametercolumnforoffers_id_seq OWNED BY public.supplynegotiations_parametercolumnforoffers.id;


--
-- Name: supplynegotiations_parametercolumnforrequests; Type: TABLE; Schema: public; Owner: -
--

CREATE TABLE public.supplynegotiations_parametercolumnforrequests (
    id bigint NOT NULL,
    parameter_id bigint,
    columnforrequests_id bigint,
    succession integer,
    entityversion bigint DEFAULT 0
);


--
-- Name: supplynegotiations_parametercolumnforrequests_id_seq; Type: SEQUENCE; Schema: public; Owner: -
--

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


--
-- Name: supplynegotiations_parametercolumnforrequests_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: -
--

ALTER SEQUENCE public.supplynegotiations_parametercolumnforrequests_id_seq OWNED BY public.supplynegotiations_parametercolumnforrequests.id;


--
-- Name: supplynegotiations_requestforquotation; Type: TABLE; Schema: public; Owner: -
--

CREATE TABLE public.supplynegotiations_requestforquotation (
    id bigint NOT NULL,
    number character varying(255),
    name character varying(1024),
    description character varying(2048),
    supplier_id bigint,
    desireddate timestamp without time zone,
    active boolean DEFAULT true,
    createdate timestamp without time zone,
    updatedate timestamp without time zone,
    createuser character varying(255),
    updateuser character varying(255),
    state character varying(255) DEFAULT '01draft'::character varying,
    workingdaysafterorder integer,
    negotiation_id bigint,
    entityversion bigint DEFAULT 0
);


--
-- Name: supplynegotiations_requestforquotation_id_seq; Type: SEQUENCE; Schema: public; Owner: -
--

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


--
-- Name: supplynegotiations_requestforquotation_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: -
--

ALTER SEQUENCE public.supplynegotiations_requestforquotation_id_seq OWNED BY public.supplynegotiations_requestforquotation.id;


--
-- Name: supplynegotiations_requestforquotationproduct; Type: TABLE; Schema: public; Owner: -
--

CREATE TABLE public.supplynegotiations_requestforquotationproduct (
    id bigint NOT NULL,
    requestforquotation_id bigint,
    product_id bigint,
    orderedquantity numeric(12,5),
    annualvolume numeric(12,5),
    operation_id bigint,
    succession integer,
    entityversion bigint DEFAULT 0
);


--
-- Name: supplynegotiations_requestforquotationproduct_id_seq; Type: SEQUENCE; Schema: public; Owner: -
--

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


--
-- Name: supplynegotiations_requestforquotationproduct_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: -
--

ALTER SEQUENCE public.supplynegotiations_requestforquotationproduct_id_seq OWNED BY public.supplynegotiations_requestforquotationproduct.id;


--
-- Name: supplynegotiations_requestforquotationstatechange; Type: TABLE; Schema: public; Owner: -
--

CREATE TABLE public.supplynegotiations_requestforquotationstatechange (
    id bigint NOT NULL,
    dateandtime timestamp without time zone,
    sourcestate character varying(255),
    targetstate character varying(255),
    status character varying(255),
    phase integer,
    worker character varying(255),
    requestforquotation_id bigint,
    shift_id bigint,
    entityversion bigint DEFAULT 0
);


--
-- Name: supplynegotiations_requestforquotationstatechange_id_seq; Type: SEQUENCE; Schema: public; Owner: -
--

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


--
-- Name: supplynegotiations_requestforquotationstatechange_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: -
--

ALTER SEQUENCE public.supplynegotiations_requestforquotationstatechange_id_seq OWNED BY public.supplynegotiations_requestforquotationstatechange.id;


--
-- Name: technologies_barcodeoperationcomponent; Type: TABLE; Schema: public; Owner: -
--

CREATE TABLE public.technologies_barcodeoperationcomponent (
    id bigint NOT NULL,
    operationcomponent_id bigint,
    code character varying(20),
    active boolean DEFAULT true,
    entityversion bigint DEFAULT 0,
    order_id bigint
);


--
-- Name: technologies_barcodeoperationcomponent_id_seq; Type: SEQUENCE; Schema: public; Owner: -
--

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


--
-- Name: technologies_barcodeoperationcomponent_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: -
--

ALTER SEQUENCE public.technologies_barcodeoperationcomponent_id_seq OWNED BY public.technologies_barcodeoperationcomponent.id;


--
-- Name: technologies_barcodeoperationcomponent_number_seq; Type: SEQUENCE; Schema: public; Owner: -
--

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


--
-- Name: technologies_changetechnologyparameters; Type: TABLE; Schema: public; Owner: -
--

CREATE TABLE public.technologies_changetechnologyparameters (
    id bigint NOT NULL,
    changeperformancenorm boolean DEFAULT false,
    standardperformance numeric(12,5),
    changegroup boolean DEFAULT false,
    technologygroup_id bigint,
    createdate timestamp without time zone,
    updatedate timestamp without time zone,
    createuser character varying(255),
    updateuser character varying(255),
    updateoperationtimenorms boolean DEFAULT false,
    updateoperationworkstations boolean DEFAULT false,
    updateoperationcostnorms boolean DEFAULT false
);


--
-- Name: technologies_changetechnologyparameters_id_seq; Type: SEQUENCE; Schema: public; Owner: -
--

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


--
-- Name: technologies_changetechnologyparameters_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: -
--

ALTER SEQUENCE public.technologies_changetechnologyparameters_id_seq OWNED BY public.technologies_changetechnologyparameters.id;


--
-- Name: technologies_dimensioncontrolattribute; Type: TABLE; Schema: public; Owner: -
--

CREATE TABLE public.technologies_dimensioncontrolattribute (
    id bigint NOT NULL,
    parameter_id bigint,
    attribute_id bigint
);


--
-- Name: technologies_dimensioncontrolattribute_id_seq; Type: SEQUENCE; Schema: public; Owner: -
--

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


--
-- Name: technologies_dimensioncontrolattribute_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: -
--

ALTER SEQUENCE public.technologies_dimensioncontrolattribute_id_seq OWNED BY public.technologies_dimensioncontrolattribute.id;


--
-- Name: technologies_modifytechnologyaddproducthelper; Type: TABLE; Schema: public; Owner: -
--

CREATE TABLE public.technologies_modifytechnologyaddproducthelper (
    id bigint NOT NULL,
    modifytechnologyhelper_id bigint,
    product_id bigint,
    quantity numeric(14,5)
);


--
-- Name: technologies_modifytechnologyaddproducthelper_id_seq; Type: SEQUENCE; Schema: public; Owner: -
--

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


--
-- Name: technologies_modifytechnologyaddproducthelper_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: -
--

ALTER SEQUENCE public.technologies_modifytechnologyaddproducthelper_id_seq OWNED BY public.technologies_modifytechnologyaddproducthelper.id;


--
-- Name: technologies_modifytechnologyhelper; Type: TABLE; Schema: public; Owner: -
--

CREATE TABLE public.technologies_modifytechnologyhelper (
    id bigint NOT NULL,
    remove boolean DEFAULT false,
    addnew boolean DEFAULT false,
    replace boolean DEFAULT false,
    selectedentities character varying(4096),
    product_id bigint,
    replaceproduct_id bigint,
    replaceproductquantity numeric(14,5),
    createdate timestamp without time zone,
    updatedate timestamp without time zone,
    createuser character varying(255),
    updateuser character varying(255),
    sizeproduct boolean DEFAULT false
);


--
-- Name: technologies_modifytechnologyhelper_id_seq; Type: SEQUENCE; Schema: public; Owner: -
--

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


--
-- Name: technologies_modifytechnologyhelper_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: -
--

ALTER SEQUENCE public.technologies_modifytechnologyhelper_id_seq OWNED BY public.technologies_modifytechnologyhelper.id;


--
-- Name: technologies_operation_id_seq; Type: SEQUENCE; Schema: public; Owner: -
--

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


--
-- Name: technologies_operation_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: -
--

ALTER SEQUENCE public.technologies_operation_id_seq OWNED BY public.technologies_operation.id;


--
-- Name: technologies_operationgroup; Type: TABLE; Schema: public; Owner: -
--

CREATE TABLE public.technologies_operationgroup (
    id bigint NOT NULL,
    number character varying(255),
    name character varying(1024),
    active boolean DEFAULT true,
    entityversion bigint DEFAULT 0
);


--
-- Name: technologies_operationgroup_id_seq; Type: SEQUENCE; Schema: public; Owner: -
--

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


--
-- Name: technologies_operationgroup_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: -
--

ALTER SEQUENCE public.technologies_operationgroup_id_seq OWNED BY public.technologies_operationgroup.id;


--
-- Name: technologies_operationproductincomponent; Type: TABLE; Schema: public; Owner: -
--

CREATE TABLE public.technologies_operationproductincomponent (
    id bigint NOT NULL,
    operationcomponent_id bigint,
    product_id bigint,
    quantity numeric(14,5),
    itemnumberintheexplodedview character varying(255),
    componentslocation_id bigint,
    componentsoutputlocation_id bigint,
    priority integer,
    showinproductdata boolean,
    productdatanumber numeric(12,5) DEFAULT (0)::numeric,
    productsflowlocation_id bigint,
    productionflow character varying(255) DEFAULT '02withinTheProcess'::character varying,
    givenquantity numeric(14,5),
    givenunit character varying(255),
    entityversion bigint DEFAULT 0,
    showmaterialcomponent boolean,
    quantityformula character varying(255),
    technologyinputproducttype_id bigint,
    differentproductsindifferentsizes boolean DEFAULT false,
    description character varying(2048),
    variousquantitiesinproductsbysize boolean DEFAULT false,
    attribute_id bigint
);


--
-- Name: technologies_operationproductincomponent_id_seq; Type: SEQUENCE; Schema: public; Owner: -
--

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


--
-- Name: technologies_operationproductincomponent_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: -
--

ALTER SEQUENCE public.technologies_operationproductincomponent_id_seq OWNED BY public.technologies_operationproductincomponent.id;


--
-- Name: technologies_operationproductincomponentdto; Type: VIEW; Schema: public; Owner: -
--

CREATE VIEW public.technologies_operationproductincomponentdto AS
SELECT
    NULL::bigint AS id,
    NULL::integer AS operationcomponentid,
    NULL::bigint AS product_id,
    NULL::integer AS productid,
    NULL::character varying(255) AS productnumber,
    NULL::character varying(1024) AS productname,
    NULL::character varying(255) AS productunit,
    NULL::numeric(14,5) AS quantity,
    NULL::integer AS priority,
    NULL::character varying(255) AS itemnumberintheexplodedview,
    NULL::character varying(1024) AS operationname,
    NULL::character varying(255) AS nodenumber,
    NULL::integer AS technologyid,
    NULL::character varying(2048) AS technologyname,
    NULL::character varying(255) AS technologystate,
    NULL::character varying(255) AS technologynumber,
    NULL::boolean AS mastertechnology,
    NULL::boolean AS activetechnology,
    NULL::boolean AS hasacceptedtechnology,
    NULL::boolean AS hascheckedtechnology,
    NULL::character varying(255) AS technologyinputproducttypename,
    NULL::boolean AS differentproductsindifferentsizes,
    NULL::character varying(1024) AS modelname,
    NULL::character varying(255) AS assortmentname,
    NULL::character varying(255) AS technologyproductnumber;


--
-- Name: technologies_operationproductincomponentdto_id_seq; Type: SEQUENCE; Schema: public; Owner: -
--

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


--
-- Name: technologies_operationproductinproductdto; Type: VIEW; Schema: public; Owner: -
--

CREATE VIEW public.technologies_operationproductinproductdto AS
SELECT
    NULL::bigint AS id,
    NULL::integer AS operationproductincomponentid,
    NULL::bigint AS product_id,
    NULL::integer AS productid,
    NULL::character varying(255) AS nodenumber,
    NULL::integer AS technologyid,
    NULL::character varying(2048) AS technologyname,
    NULL::character varying(255) AS technologystate,
    NULL::character varying(255) AS technologynumber,
    NULL::character varying(1024) AS operationname,
    NULL::numeric(14,5) AS quantity,
    NULL::boolean AS mastertechnology,
    NULL::integer AS operationcomponentid,
    NULL::boolean AS activetechnology,
    NULL::boolean AS sizeproduct,
    NULL::integer AS productbysizegroupid,
    NULL::character varying(1024) AS modelname,
    NULL::character varying(255) AS assortmentname,
    NULL::character varying(255) AS productnumber,
    NULL::character varying(255) AS technologyproductnumber;


--
-- Name: technologies_operationproductinproductdto_id_seq; Type: SEQUENCE; Schema: public; Owner: -
--

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


--
-- Name: technologies_operationproductoutcomponent; Type: TABLE; Schema: public; Owner: -
--

CREATE TABLE public.technologies_operationproductoutcomponent (
    id bigint NOT NULL,
    operationcomponent_id bigint,
    product_id bigint,
    quantity numeric(14,5),
    productsinputlocation_id bigint,
    productsflowlocation_id bigint,
    productionflow character varying(255) DEFAULT '02withinTheProcess'::character varying,
    automaticmove boolean DEFAULT false,
    entityversion bigint DEFAULT 0,
    waste boolean DEFAULT false,
    wastereceptionwarehouse_id bigint
);


--
-- Name: technologies_operationproductoutcomponent_id_seq; Type: SEQUENCE; Schema: public; Owner: -
--

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


--
-- Name: technologies_operationproductoutcomponent_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: -
--

ALTER SEQUENCE public.technologies_operationproductoutcomponent_id_seq OWNED BY public.technologies_operationproductoutcomponent.id;


--
-- Name: technologies_operationskill_id_seq; Type: SEQUENCE; Schema: public; Owner: -
--

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


--
-- Name: technologies_operationskill; Type: TABLE; Schema: public; Owner: -
--

CREATE TABLE public.technologies_operationskill (
    id bigint DEFAULT nextval('public.technologies_operationskill_id_seq'::regclass) NOT NULL,
    operation_id bigint,
    skill_id bigint,
    requiredlevel integer,
    active boolean DEFAULT true
);


--
-- Name: technologies_operationtechnologydto; Type: VIEW; Schema: public; Owner: -
--

CREATE VIEW public.technologies_operationtechnologydto AS
 SELECT toc.id,
    (toc.technology_id)::integer AS technologyid,
    toc.nodenumber,
    toc.comment,
    t.number AS technologynumber,
    t.name AS technologyname,
    t.state AS technologystate,
    t.master AS mastertechnology,
    t.active AS activetechnology,
    p.number AS technologyproductnumber,
    (toc.operation_id)::integer AS operationid,
    toc.operation_id
   FROM ((public.technologies_technologyoperationcomponent toc
     JOIN public.technologies_technology t ON ((toc.technology_id = t.id)))
     JOIN public.basic_product p ON ((p.id = t.product_id)));


--
-- Name: technologies_operationtechnologydto_id_seq; Type: SEQUENCE; Schema: public; Owner: -
--

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


--
-- Name: technologies_pieceratetechnologydto; Type: VIEW; Schema: public; Owner: -
--

CREATE VIEW public.technologies_pieceratetechnologydto AS
 SELECT toc.technology_id AS id,
    t.number AS technologynumber,
    t.name AS technologyname,
    t.state AS technologystate,
    t.master AS mastertechnology,
    t.active AS activetechnology,
    p.number AS technologyproductnumber,
    toc.piecerate_id
   FROM ((public.technologies_technologyoperationcomponent toc
     JOIN public.technologies_technology t ON ((toc.technology_id = t.id)))
     JOIN public.basic_product p ON ((p.id = t.product_id)))
  GROUP BY toc.technology_id, t.number, t.name, t.state, t.master, t.active, p.number, toc.piecerate_id
UNION
 SELECT t.id,
    t.number AS technologynumber,
    t.name AS technologyname,
    t.state AS technologystate,
    t.master AS mastertechnology,
    t.active AS activetechnology,
    p.number AS technologyproductnumber,
    t.piecerate_id
   FROM (public.technologies_technology t
     JOIN public.basic_product p ON ((p.id = t.product_id)));


--
-- Name: technologies_pieceratetechnologydto_id_seq; Type: SEQUENCE; Schema: public; Owner: -
--

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


--
-- Name: technologies_productbysizegroup; Type: TABLE; Schema: public; Owner: -
--

CREATE TABLE public.technologies_productbysizegroup (
    id bigint NOT NULL,
    operationproductincomponent_id bigint,
    sizegroup_id bigint,
    product_id bigint,
    quantity numeric(14,5),
    givenquantity numeric(14,5),
    givenunit character varying(255)
);


--
-- Name: technologies_productbysizegroup_id_seq; Type: SEQUENCE; Schema: public; Owner: -
--

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


--
-- Name: technologies_productbysizegroup_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: -
--

ALTER SEQUENCE public.technologies_productbysizegroup_id_seq OWNED BY public.technologies_productbysizegroup.id;


--
-- Name: technologies_productcomponent; Type: TABLE; Schema: public; Owner: -
--

CREATE TABLE public.technologies_productcomponent (
    id bigint NOT NULL,
    product_id bigint,
    operationin_id bigint,
    operationout_id bigint,
    active boolean DEFAULT true,
    entityversion bigint DEFAULT 0
);


--
-- Name: technologies_productcomponent_id_seq; Type: SEQUENCE; Schema: public; Owner: -
--

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


--
-- Name: technologies_productcomponent_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: -
--

ALTER SEQUENCE public.technologies_productcomponent_id_seq OWNED BY public.technologies_productcomponent.id;


--
-- Name: technologies_productdata; Type: TABLE; Schema: public; Owner: -
--

CREATE TABLE public.technologies_productdata (
    id bigint NOT NULL,
    number character varying(255),
    filename character varying(255),
    generated boolean DEFAULT false,
    loaded boolean DEFAULT false,
    saved boolean DEFAULT false,
    dategenerated timestamp without time zone,
    staff_id bigint,
    product_id bigint,
    technology_id bigint,
    active boolean DEFAULT true,
    description character varying(2048),
    entityversion bigint DEFAULT 0
);


--
-- Name: technologies_productdata_id_seq; Type: SEQUENCE; Schema: public; Owner: -
--

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


--
-- Name: technologies_productdata_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: -
--

ALTER SEQUENCE public.technologies_productdata_id_seq OWNED BY public.technologies_productdata.id;


--
-- Name: technologies_productdataattachment; Type: TABLE; Schema: public; Owner: -
--

CREATE TABLE public.technologies_productdataattachment (
    id bigint NOT NULL,
    attachment character varying(255),
    name character varying(255),
    ext character varying(255),
    size numeric(12,5),
    productdata_id bigint,
    active boolean DEFAULT true,
    entityversion bigint DEFAULT 0
);


--
-- Name: technologies_productdataattachment_id_seq; Type: SEQUENCE; Schema: public; Owner: -
--

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


--
-- Name: technologies_productdataattachment_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: -
--

ALTER SEQUENCE public.technologies_productdataattachment_id_seq OWNED BY public.technologies_productdataattachment.id;


--
-- Name: technologies_productdatainput; Type: TABLE; Schema: public; Owner: -
--

CREATE TABLE public.technologies_productdatainput (
    id bigint NOT NULL,
    name character varying(255),
    number character varying(255),
    productdata_id bigint,
    succession integer,
    active boolean DEFAULT true,
    quantity numeric(12,5),
    entityversion bigint DEFAULT 0,
    unit character varying(255),
    operationproductincomponent_id bigint
);


--
-- Name: technologies_productdatainput_id_seq; Type: SEQUENCE; Schema: public; Owner: -
--

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


--
-- Name: technologies_productdatainput_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: -
--

ALTER SEQUENCE public.technologies_productdatainput_id_seq OWNED BY public.technologies_productdatainput.id;


--
-- Name: technologies_productdataoperation; Type: TABLE; Schema: public; Owner: -
--

CREATE TABLE public.technologies_productdataoperation (
    id bigint NOT NULL,
    number character varying(255),
    name character varying(255),
    description character varying(255),
    productdata_id bigint,
    technologyoperationcomponent_id bigint,
    succession integer,
    active boolean DEFAULT true,
    entityversion bigint DEFAULT 0
);


--
-- Name: technologies_productdataoperation_id_seq; Type: SEQUENCE; Schema: public; Owner: -
--

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


--
-- Name: technologies_productdataoperation_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: -
--

ALTER SEQUENCE public.technologies_productdataoperation_id_seq OWNED BY public.technologies_productdataoperation.id;


--
-- Name: technologies_productionlinetechnologygroup_id_seq; Type: SEQUENCE; Schema: public; Owner: -
--

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


--
-- Name: technologies_productionlinetechnologygroup_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: -
--

ALTER SEQUENCE public.technologies_productionlinetechnologygroup_id_seq OWNED BY public.technologies_productionlinetechnologygroup.id;


--
-- Name: technologies_productstructuretreenode; Type: TABLE; Schema: public; Owner: -
--

CREATE TABLE public.technologies_productstructuretreenode (
    id bigint NOT NULL,
    priority integer,
    technology_id bigint,
    parent_id bigint,
    nodenumber character varying(255),
    number character varying(255),
    product_id bigint,
    createdate timestamp without time zone,
    updatedate timestamp without time zone,
    createuser character varying(255),
    updateuser character varying(255),
    entityversion bigint DEFAULT 0,
    standardperformance numeric,
    technologygroup_id bigint,
    maintechnology_id bigint,
    operation_id bigint,
    quantity numeric(12,5),
    division_id bigint,
    entitytype character varying(255) DEFAULT 'material'::character varying,
    unit character varying(255),
    technologyinputproducttype_id bigint,
    differentproductsindifferentsizes boolean DEFAULT false,
    sizegroup_id bigint,
    variousquantitiesinproductsbysize boolean DEFAULT false
);


--
-- Name: technologies_productstructuretreenode_id_seq; Type: SEQUENCE; Schema: public; Owner: -
--

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


--
-- Name: technologies_productstructuretreenode_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: -
--

ALTER SEQUENCE public.technologies_productstructuretreenode_id_seq OWNED BY public.technologies_productstructuretreenode.id;


--
-- Name: technologies_producttoproductgrouptechnology; Type: TABLE; Schema: public; Owner: -
--

CREATE TABLE public.technologies_producttoproductgrouptechnology (
    id bigint NOT NULL,
    finalproduct_id bigint NOT NULL,
    productfamily_id bigint NOT NULL,
    orderproduct_id bigint NOT NULL
);


--
-- Name: technologies_producttoproductgrouptechnology_id_seq; Type: SEQUENCE; Schema: public; Owner: -
--

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


--
-- Name: technologies_producttoproductgrouptechnology_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: -
--

ALTER SEQUENCE public.technologies_producttoproductgrouptechnology_id_seq OWNED BY public.technologies_producttoproductgrouptechnology.id;


--
-- Name: technologies_section; Type: TABLE; Schema: public; Owner: -
--

CREATE TABLE public.technologies_section (
    id bigint NOT NULL,
    operationproductincomponent_id bigint,
    length numeric(14,5),
    quantity integer,
    unit character varying(255)
);


--
-- Name: technologies_section_id_seq; Type: SEQUENCE; Schema: public; Owner: -
--

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


--
-- Name: technologies_section_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: -
--

ALTER SEQUENCE public.technologies_section_id_seq OWNED BY public.technologies_section.id;


--
-- Name: technologies_technological_process_list_number_seq; Type: SEQUENCE; Schema: public; Owner: -
--

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


--
-- Name: technologies_technologicalprocess_id_seq; Type: SEQUENCE; Schema: public; Owner: -
--

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


--
-- Name: technologies_technologicalprocess_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: -
--

ALTER SEQUENCE public.technologies_technologicalprocess_id_seq OWNED BY public.technologies_technologicalprocess.id;


--
-- Name: technologies_technologicalprocesscomponent; Type: TABLE; Schema: public; Owner: -
--

CREATE TABLE public.technologies_technologicalprocesscomponent (
    id bigint NOT NULL,
    tj integer DEFAULT 0,
    extendedtimeforsizegroup boolean DEFAULT false,
    increasepercent integer,
    sizegroup_id bigint,
    succession integer,
    technologicalprocesslist_id bigint,
    technologicalprocess_id bigint,
    tpz integer DEFAULT 0,
    additionaltime integer DEFAULT 0,
    remarks character varying(2048)
);


--
-- Name: technologies_technologicalprocesscomponent_id_seq; Type: SEQUENCE; Schema: public; Owner: -
--

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


--
-- Name: technologies_technologicalprocesscomponent_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: -
--

ALTER SEQUENCE public.technologies_technologicalprocesscomponent_id_seq OWNED BY public.technologies_technologicalprocesscomponent.id;


--
-- Name: technologies_technologicalprocesslist; Type: TABLE; Schema: public; Owner: -
--

CREATE TABLE public.technologies_technologicalprocesslist (
    id bigint NOT NULL,
    number character varying(255),
    name character varying(1024),
    operation_id bigint
);


--
-- Name: technologies_technologicalprocesslist_id_seq; Type: SEQUENCE; Schema: public; Owner: -
--

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


--
-- Name: technologies_technologicalprocesslist_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: -
--

ALTER SEQUENCE public.technologies_technologicalprocesslist_id_seq OWNED BY public.technologies_technologicalprocesslist.id;


--
-- Name: technologies_technology_id_seq; Type: SEQUENCE; Schema: public; Owner: -
--

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


--
-- Name: technologies_technology_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: -
--

ALTER SEQUENCE public.technologies_technology_id_seq OWNED BY public.technologies_technology.id;


--
-- Name: technologies_technologyattachment_id_seq; Type: SEQUENCE; Schema: public; Owner: -
--

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


--
-- Name: technologies_technologyattachment_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: -
--

ALTER SEQUENCE public.technologies_technologyattachment_id_seq OWNED BY public.technologies_technologyattachment.id;


--
-- Name: technologies_technologydto; Type: VIEW; Schema: public; Owner: -
--

CREATE VIEW public.technologies_technologydto AS
SELECT
    NULL::bigint AS id,
    NULL::character varying(2048) AS name,
    NULL::character varying(255) AS number,
    NULL::character varying(2048) AS description,
    NULL::boolean AS externalsynchronized,
    NULL::boolean AS master,
    NULL::character varying(255) AS state,
    NULL::character varying(255) AS productnumber,
    NULL::character varying(255) AS productglobaltypeofmaterial,
    NULL::character varying(255) AS technologygroupnumber,
    NULL::character varying(1024) AS divisionname,
    NULL::character varying(1024) AS productname,
    NULL::boolean AS active,
    NULL::numeric(12,5) AS standardperformance,
    NULL::character varying(255) AS generatorname,
    NULL::boolean AS attachmentsexists,
    NULL::timestamp without time zone AS dateandtime,
    NULL::character varying(255) AS productionlinenumber,
    NULL::character varying(255) AS assortmentname,
    NULL::character varying(255) AS qualitycardnumber,
    NULL::boolean AS istemplateaccepted;


--
-- Name: technologies_technologydto_id_seq; Type: SEQUENCE; Schema: public; Owner: -
--

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


--
-- Name: technologies_technologygroup_id_seq; Type: SEQUENCE; Schema: public; Owner: -
--

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


--
-- Name: technologies_technologygroup_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: -
--

ALTER SEQUENCE public.technologies_technologygroup_id_seq OWNED BY public.technologies_technologygroup.id;


--
-- Name: technologies_technologyinputproducttype_id_seq; Type: SEQUENCE; Schema: public; Owner: -
--

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


--
-- Name: technologies_technologyinputproducttype_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: -
--

ALTER SEQUENCE public.technologies_technologyinputproducttype_id_seq OWNED BY public.technologies_technologyinputproducttype.id;


--
-- Name: technologies_technologyoperationcomponent_id_seq; Type: SEQUENCE; Schema: public; Owner: -
--

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


--
-- Name: technologies_technologyoperationcomponent_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: -
--

ALTER SEQUENCE public.technologies_technologyoperationcomponent_id_seq OWNED BY public.technologies_technologyoperationcomponent.id;


--
-- Name: technologies_technologyoperationcomponentdto; Type: VIEW; Schema: public; Owner: -
--

CREATE VIEW public.technologies_technologyoperationcomponentdto AS
 SELECT toc.id,
    (toc.technology_id)::integer AS technologyid,
    toc.nodenumber,
    op.number AS operationnumber,
    op.name AS operationname,
    (count(qca.technologyoperationcomponent_id) > 0) AS qualitycontrol
   FROM ((public.technologies_technologyoperationcomponent toc
     JOIN public.technologies_operation op ON ((toc.operation_id = op.id)))
     LEFT JOIN public.qualitycontrol_qualitycontrolattributetoc qca ON ((qca.technologyoperationcomponent_id = toc.id)))
  GROUP BY toc.id, toc.technology_id, toc.nodenumber, op.number, op.name;


--
-- Name: technologies_technologyoperationcomponentdto_id_seq; Type: SEQUENCE; Schema: public; Owner: -
--

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


--
-- Name: technologies_technologyproductionline_id_seq; Type: SEQUENCE; Schema: public; Owner: -
--

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


--
-- Name: technologies_technologyproductionline_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: -
--

ALTER SEQUENCE public.technologies_technologyproductionline_id_seq OWNED BY public.technologies_technologyproductionline.id;


--
-- Name: technologies_technologystatechange; Type: TABLE; Schema: public; Owner: -
--

CREATE TABLE public.technologies_technologystatechange (
    id bigint NOT NULL,
    dateandtime timestamp without time zone,
    sourcestate character varying(255),
    targetstate character varying(255),
    status character varying(255) DEFAULT '01inProgress'::character varying,
    phase integer,
    worker character varying(255),
    technology_id bigint,
    shift_id bigint,
    entityversion bigint DEFAULT 0
);


--
-- Name: technologies_technologystatechange_id_seq; Type: SEQUENCE; Schema: public; Owner: -
--

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


--
-- Name: technologies_technologystatechange_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: -
--

ALTER SEQUENCE public.technologies_technologystatechange_id_seq OWNED BY public.technologies_technologystatechange.id;


--
-- Name: technologies_technologytocreationhelper; Type: TABLE; Schema: public; Owner: -
--

CREATE TABLE public.technologies_technologytocreationhelper (
    id bigint NOT NULL,
    number character varying(255),
    reprocessed boolean DEFAULT false,
    active boolean DEFAULT true
);


--
-- Name: technologies_technologytocreationhelper_id_seq; Type: SEQUENCE; Schema: public; Owner: -
--

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


--
-- Name: technologies_technologytocreationhelper_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: -
--

ALTER SEQUENCE public.technologies_technologytocreationhelper_id_seq OWNED BY public.technologies_technologytocreationhelper.id;


--
-- Name: technologies_workstationchangeovernorm; Type: TABLE; Schema: public; Owner: -
--

CREATE TABLE public.technologies_workstationchangeovernorm (
    id bigint NOT NULL,
    name character varying(1024),
    description character varying(2048),
    workstationtype_id bigint,
    workstation_id bigint,
    attribute_id bigint,
    changeovertype character varying(255) DEFAULT '01anyChange'::character varying,
    fromattributevalue_id bigint,
    toattributevalue_id bigint,
    duration integer,
    isparallel boolean DEFAULT false,
    active boolean DEFAULT true
);


--
-- Name: technologies_workstationchangeovernorm_id_seq; Type: SEQUENCE; Schema: public; Owner: -
--

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


--
-- Name: technologies_workstationchangeovernorm_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: -
--

ALTER SEQUENCE public.technologies_workstationchangeovernorm_id_seq OWNED BY public.technologies_workstationchangeovernorm.id;


--
-- Name: technologies_workstationchangeovernormdto; Type: VIEW; Schema: public; Owner: -
--

CREATE VIEW public.technologies_workstationchangeovernormdto AS
 SELECT workstationchangeovernorm.id,
    workstationchangeovernorm.name,
    workstationchangeovernorm.description,
    (workstationtype.id)::integer AS workstationtype_id,
    workstationtype.number AS workstationtypenumber,
    (workstation.id)::integer AS workstation_id,
    workstation.number AS workstationnumber,
    workstationchangeovernorm.changeovertype,
    (attribute.id)::integer AS attribute_id,
    attribute.number AS attributenumber,
    fromattributevalue.value AS fromattributevaluevalue,
    toattributevalue.value AS toattributevaluevalue,
    workstationchangeovernorm.duration,
    workstationchangeovernorm.isparallel,
    workstationchangeovernorm.active
   FROM (((((public.technologies_workstationchangeovernorm workstationchangeovernorm
     LEFT JOIN public.basic_workstationtype workstationtype ON ((workstationtype.id = workstationchangeovernorm.workstationtype_id)))
     LEFT JOIN public.basic_workstation workstation ON ((workstation.id = workstationchangeovernorm.workstation_id)))
     LEFT JOIN public.basic_attribute attribute ON ((attribute.id = workstationchangeovernorm.attribute_id)))
     LEFT JOIN public.basic_attributevalue fromattributevalue ON ((fromattributevalue.id = workstationchangeovernorm.fromattributevalue_id)))
     LEFT JOIN public.basic_attributevalue toattributevalue ON ((toattributevalue.id = workstationchangeovernorm.toattributevalue_id)));


--
-- Name: technologies_workstationchangeovernormdto_id_seq; Type: SEQUENCE; Schema: public; Owner: -
--

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


--
-- Name: technologies_workstationstatechange; Type: TABLE; Schema: public; Owner: -
--

CREATE TABLE public.technologies_workstationstatechange (
    id bigint NOT NULL,
    dateandtime timestamp without time zone,
    sourcestate character varying(255),
    targetstate character varying(255),
    status character varying(255),
    phase integer,
    worker character varying(255),
    workstation_id bigint,
    shift_id bigint
);


--
-- Name: technologies_workstationstatechange_id_seq; Type: SEQUENCE; Schema: public; Owner: -
--

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


--
-- Name: technologies_workstationstatechange_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: -
--

ALTER SEQUENCE public.technologies_workstationstatechange_id_seq OWNED BY public.technologies_workstationstatechange.id;


--
-- Name: technologiesgenerator_generatorcontext_id_seq; Type: SEQUENCE; Schema: public; Owner: -
--

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


--
-- Name: technologiesgenerator_generatorcontext_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: -
--

ALTER SEQUENCE public.technologiesgenerator_generatorcontext_id_seq OWNED BY public.technologiesgenerator_generatorcontext.id;


--
-- Name: technologiesgenerator_generatorcontext_number_seq; Type: SEQUENCE; Schema: public; Owner: -
--

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


--
-- Name: technologiesgenerator_generatortechnologiesforproduct; Type: TABLE; Schema: public; Owner: -
--

CREATE TABLE public.technologiesgenerator_generatortechnologiesforproduct (
    id bigint NOT NULL,
    technology_id bigint,
    product_id bigint,
    generatorcontext_id bigint,
    createdate timestamp without time zone,
    updatedate timestamp without time zone,
    createuser character varying(255),
    updateuser character varying(255)
);


--
-- Name: technologiesgenerator_generatortechnologiesforproduct_id_seq; Type: SEQUENCE; Schema: public; Owner: -
--

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


--
-- Name: technologiesgenerator_generatortechnologiesforproduct_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: -
--

ALTER SEQUENCE public.technologiesgenerator_generatortechnologiesforproduct_id_seq OWNED BY public.technologiesgenerator_generatortechnologiesforproduct.id;


--
-- Name: technologiesgenerator_generatortreenode; Type: TABLE; Schema: public; Owner: -
--

CREATE TABLE public.technologiesgenerator_generatortreenode (
    id bigint NOT NULL,
    parent_id bigint,
    generatorcontext_id bigint,
    entitytype character varying(255) DEFAULT 'material'::character varying,
    priority integer,
    nodenumber character varying(255),
    quantity numeric(12,5),
    product_id bigint,
    operation_id bigint,
    producttechnology_id bigint,
    originaltechnology_id bigint,
    division_id bigint,
    entityversion bigint DEFAULT 0,
    standardperformance numeric,
    technologygroup_id bigint,
    unit character varying(255),
    technologyinputproducttype_id bigint,
    differentproductsindifferentsizes boolean DEFAULT false,
    sizegroup_id bigint,
    variousquantitiesinproductsbysize boolean DEFAULT false
);


--
-- Name: technologiesgenerator_generatortreenode_id_seq; Type: SEQUENCE; Schema: public; Owner: -
--

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


--
-- Name: technologiesgenerator_generatortreenode_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: -
--

ALTER SEQUENCE public.technologiesgenerator_generatortreenode_id_seq OWNED BY public.technologiesgenerator_generatortreenode.id;


--
-- Name: techsubcontracting_companyoperation; Type: TABLE; Schema: public; Owner: -
--

CREATE TABLE public.techsubcontracting_companyoperation (
    id bigint NOT NULL,
    company_id bigint,
    operation_id bigint,
    isdefault boolean DEFAULT false
);


--
-- Name: techsubcontracting_companyoperation_id_seq; Type: SEQUENCE; Schema: public; Owner: -
--

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


--
-- Name: techsubcontracting_companyoperation_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: -
--

ALTER SEQUENCE public.techsubcontracting_companyoperation_id_seq OWNED BY public.techsubcontracting_companyoperation.id;


--
-- Name: techsubcontracting_companyoperationgroup; Type: TABLE; Schema: public; Owner: -
--

CREATE TABLE public.techsubcontracting_companyoperationgroup (
    id bigint NOT NULL,
    company_id bigint,
    operationgroup_id bigint,
    isdefault boolean DEFAULT false
);


--
-- Name: techsubcontracting_companyoperationgroup_id_seq; Type: SEQUENCE; Schema: public; Owner: -
--

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


--
-- Name: techsubcontracting_companyoperationgroup_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: -
--

ALTER SEQUENCE public.techsubcontracting_companyoperationgroup_id_seq OWNED BY public.techsubcontracting_companyoperationgroup.id;


--
-- Name: techsubcontracting_orderexternalservicecost; Type: TABLE; Schema: public; Owner: -
--

CREATE TABLE public.techsubcontracting_orderexternalservicecost (
    id bigint NOT NULL,
    order_id bigint,
    technologyoperationcomponent_id bigint,
    product_id bigint,
    quantity numeric(12,5),
    unitcost numeric(12,5),
    totalcost numeric(12,5),
    isaddedmanually boolean DEFAULT true
);


--
-- Name: techsubcontracting_orderexternalservicecost_id_seq; Type: SEQUENCE; Schema: public; Owner: -
--

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


--
-- Name: techsubcontracting_orderexternalservicecost_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: -
--

ALTER SEQUENCE public.techsubcontracting_orderexternalservicecost_id_seq OWNED BY public.techsubcontracting_orderexternalservicecost.id;


--
-- Name: timegapspreview_timegap; Type: TABLE; Schema: public; Owner: -
--

CREATE TABLE public.timegapspreview_timegap (
    id bigint NOT NULL,
    productionline_id bigint,
    fromdate timestamp without time zone,
    todate timestamp without time zone,
    duration integer,
    context_id bigint,
    entityversion bigint DEFAULT 0
);


--
-- Name: timegapspreview_timegap_id_seq; Type: SEQUENCE; Schema: public; Owner: -
--

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


--
-- Name: timegapspreview_timegap_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: -
--

ALTER SEQUENCE public.timegapspreview_timegap_id_seq OWNED BY public.timegapspreview_timegap.id;


--
-- Name: timegapspreview_timegapscontext; Type: TABLE; Schema: public; Owner: -
--

CREATE TABLE public.timegapspreview_timegapscontext (
    id bigint NOT NULL,
    fromdate timestamp without time zone,
    todate timestamp without time zone,
    supportedtechnology_id bigint,
    supportedtechnologygroup_id bigint,
    totalduration integer,
    longestduration integer,
    longestdurationline_id bigint,
    viewisinitialized boolean,
    durationfilter integer DEFAULT 900,
    entityversion bigint DEFAULT 0
);


--
-- Name: timegapspreview_timegapscontext_id_seq; Type: SEQUENCE; Schema: public; Owner: -
--

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


--
-- Name: timegapspreview_timegapscontext_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: -
--

ALTER SEQUENCE public.timegapspreview_timegapscontext_id_seq OWNED BY public.timegapspreview_timegapscontext.id;


--
-- Name: timenormsforoperations_operationworkstationtime; Type: TABLE; Schema: public; Owner: -
--

CREATE TABLE public.timenormsforoperations_operationworkstationtime (
    id bigint NOT NULL,
    operation_id bigint,
    workstation_id bigint,
    tj integer DEFAULT 0,
    tpz integer DEFAULT 0,
    timenextoperation integer DEFAULT 0
);


--
-- Name: timenormsforoperations_operationworkstationtime_id_seq; Type: SEQUENCE; Schema: public; Owner: -
--

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


--
-- Name: timenormsforoperations_operationworkstationtime_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: -
--

ALTER SEQUENCE public.timenormsforoperations_operationworkstationtime_id_seq OWNED BY public.timenormsforoperations_operationworkstationtime.id;


--
-- Name: timenormsforoperations_techopercomptimecalculation; Type: TABLE; Schema: public; Owner: -
--

CREATE TABLE public.timenormsforoperations_techopercomptimecalculation (
    id bigint NOT NULL,
    operationoffset integer,
    effectiveoperationrealizationtime integer,
    effectivedatefrom timestamp without time zone,
    effectivedateto timestamp without time zone,
    duration integer DEFAULT 0,
    machineworktime integer DEFAULT 0,
    laborworktime integer DEFAULT 0,
    entityversion bigint DEFAULT 0
);


--
-- Name: timenormsforoperations_techopercomptimecalculation_id_seq; Type: SEQUENCE; Schema: public; Owner: -
--

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


--
-- Name: timenormsforoperations_techopercomptimecalculation_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: -
--

ALTER SEQUENCE public.timenormsforoperations_techopercomptimecalculation_id_seq OWNED BY public.timenormsforoperations_techopercomptimecalculation.id;


--
-- Name: timenormsforoperations_techopercompworkstationtime; Type: TABLE; Schema: public; Owner: -
--

CREATE TABLE public.timenormsforoperations_techopercompworkstationtime (
    id bigint NOT NULL,
    technologyoperationcomponent_id bigint,
    workstation_id bigint,
    tj integer DEFAULT 0,
    tpz integer DEFAULT 0,
    timenextoperation integer DEFAULT 0
);


--
-- Name: timenormsforoperations_techopercompworkstationtime_id_seq; Type: SEQUENCE; Schema: public; Owner: -
--

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


--
-- Name: timenormsforoperations_techopercompworkstationtime_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: -
--

ALTER SEQUENCE public.timenormsforoperations_techopercompworkstationtime_id_seq OWNED BY public.timenormsforoperations_techopercompworkstationtime.id;


--
-- Name: urccore_lastsynchronizationdate; Type: TABLE; Schema: public; Owner: -
--

CREATE TABLE public.urccore_lastsynchronizationdate (
    id bigint NOT NULL,
    lastsynchronizationdate timestamp without time zone,
    entityversion bigint DEFAULT 0
);


--
-- Name: urccore_lastsynchronizationdate_id_seq; Type: SEQUENCE; Schema: public; Owner: -
--

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


--
-- Name: urccore_lastsynchronizationdate_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: -
--

ALTER SEQUENCE public.urccore_lastsynchronizationdate_id_seq OWNED BY public.urccore_lastsynchronizationdate.id;


--
-- Name: urccore_synchronizationstatus; Type: TABLE; Schema: public; Owner: -
--

CREATE TABLE public.urccore_synchronizationstatus (
    id bigint NOT NULL,
    syncphase character varying(255),
    syncfinishedat timestamp without time zone,
    successful boolean,
    entityversion bigint DEFAULT 0
);


--
-- Name: urccore_synchronizationstatus_id_seq; Type: SEQUENCE; Schema: public; Owner: -
--

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


--
-- Name: urccore_synchronizationstatus_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: -
--

ALTER SEQUENCE public.urccore_synchronizationstatus_id_seq OWNED BY public.urccore_synchronizationstatus.id;


--
-- Name: urcmaterialavailability_requiredcomponent; Type: TABLE; Schema: public; Owner: -
--

CREATE TABLE public.urcmaterialavailability_requiredcomponent (
    id bigint NOT NULL,
    order_id bigint,
    technology_id bigint,
    product_id bigint,
    availablequantity numeric(19,5),
    reservedquantity numeric(19,5),
    requiredquantity numeric(19,5),
    unit character varying(255),
    availability character varying(255),
    createdate timestamp without time zone,
    updatedate timestamp without time zone,
    createuser character varying(255),
    updateuser character varying(255),
    entityversion bigint DEFAULT 0
);


--
-- Name: urcmaterialavailability_requiredcomponent_id_seq; Type: SEQUENCE; Schema: public; Owner: -
--

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


--
-- Name: urcmaterialavailability_requiredcomponent_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: -
--

ALTER SEQUENCE public.urcmaterialavailability_requiredcomponent_id_seq OWNED BY public.urcmaterialavailability_requiredcomponent.id;


--
-- Name: urcproductioncounting_requestrepair; Type: TABLE; Schema: public; Owner: -
--

CREATE TABLE public.urcproductioncounting_requestrepair (
    id bigint NOT NULL,
    division_id bigint,
    quantitytorepair numeric(12,5),
    faulttype_id bigint,
    description character varying(2048),
    location_id bigint
);


--
-- Name: urcproductioncounting_requestrepair_id_seq; Type: SEQUENCE; Schema: public; Owner: -
--

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


--
-- Name: urcproductioncounting_requestrepair_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: -
--

ALTER SEQUENCE public.urcproductioncounting_requestrepair_id_seq OWNED BY public.urcproductioncounting_requestrepair.id;


--
-- Name: wagegroups_wagegroup_id_seq; Type: SEQUENCE; Schema: public; Owner: -
--

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


--
-- Name: wagegroups_wagegroup_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: -
--

ALTER SEQUENCE public.wagegroups_wagegroup_id_seq OWNED BY public.wagegroups_wagegroup.id;


--
-- Name: walusiak_exportdocumenthistory; Type: TABLE; Schema: public; Owner: -
--

CREATE TABLE public.walusiak_exportdocumenthistory (
    id bigint NOT NULL,
    dateexported timestamp without time zone,
    datefrom timestamp without time zone,
    dateto timestamp without time zone,
    entityversion bigint DEFAULT 0
);


--
-- Name: walusiak_exportdocumenthistory_id_seq; Type: SEQUENCE; Schema: public; Owner: -
--

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


--
-- Name: walusiak_exportdocumenthistory_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: -
--

ALTER SEQUENCE public.walusiak_exportdocumenthistory_id_seq OWNED BY public.walusiak_exportdocumenthistory.id;


--
-- Name: warehouseminimalstate_warehouseminimumstate_id_seq; Type: SEQUENCE; Schema: public; Owner: -
--

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


--
-- Name: warehouseminimalstate_warehouseminimumstate_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: -
--

ALTER SEQUENCE public.warehouseminimalstate_warehouseminimumstate_id_seq OWNED BY public.warehouseminimalstate_warehouseminimumstate.id;


--
-- Name: warehouseminimalstate_warehouseminimumstatemulti; Type: TABLE; Schema: public; Owner: -
--

CREATE TABLE public.warehouseminimalstate_warehouseminimumstatemulti (
    id bigint NOT NULL,
    location_id bigint,
    minimumstate numeric(12,5),
    optimalorderquantity numeric(12,5),
    createdate timestamp without time zone,
    updatedate timestamp without time zone,
    createuser character varying(255),
    updateuser character varying(255),
    entityversion bigint DEFAULT 0
);


--
-- Name: warehouseminimalstate_warehouseminimumstatemulti_id_seq; Type: SEQUENCE; Schema: public; Owner: -
--

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


--
-- Name: warehouseminimalstate_warehouseminimumstatemulti_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: -
--

ALTER SEQUENCE public.warehouseminimalstate_warehouseminimumstatemulti_id_seq OWNED BY public.warehouseminimalstate_warehouseminimumstatemulti.id;


--
-- Name: workplans_columnforinputproducts; Type: TABLE; Schema: public; Owner: -
--

CREATE TABLE public.workplans_columnforinputproducts (
    id bigint NOT NULL,
    identifier character varying(255),
    name character varying(1024),
    description character varying(1024),
    columnfiller character varying(255),
    alignment character varying(255) DEFAULT '01left'::character varying,
    entityversion bigint DEFAULT 0
);


--
-- Name: workplans_columnforinputproducts_id_seq; Type: SEQUENCE; Schema: public; Owner: -
--

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


--
-- Name: workplans_columnforinputproducts_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: -
--

ALTER SEQUENCE public.workplans_columnforinputproducts_id_seq OWNED BY public.workplans_columnforinputproducts.id;


--
-- Name: workplans_columnfororders; Type: TABLE; Schema: public; Owner: -
--

CREATE TABLE public.workplans_columnfororders (
    id bigint NOT NULL,
    identifier character varying(255),
    name character varying(1024),
    description character varying(1024),
    columnfiller character varying(255),
    alignment character varying(255) DEFAULT '01left'::character varying,
    entityversion bigint DEFAULT 0
);


--
-- Name: workplans_columnfororders_id_seq; Type: SEQUENCE; Schema: public; Owner: -
--

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


--
-- Name: workplans_columnfororders_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: -
--

ALTER SEQUENCE public.workplans_columnfororders_id_seq OWNED BY public.workplans_columnfororders.id;


--
-- Name: workplans_columnforoutputproducts; Type: TABLE; Schema: public; Owner: -
--

CREATE TABLE public.workplans_columnforoutputproducts (
    id bigint NOT NULL,
    identifier character varying(255),
    name character varying(1024),
    description character varying(1024),
    columnfiller character varying(255),
    alignment character varying(255) DEFAULT '01left'::character varying,
    entityversion bigint DEFAULT 0
);


--
-- Name: workplans_columnforoutputproducts_id_seq; Type: SEQUENCE; Schema: public; Owner: -
--

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


--
-- Name: workplans_columnforoutputproducts_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: -
--

ALTER SEQUENCE public.workplans_columnforoutputproducts_id_seq OWNED BY public.workplans_columnforoutputproducts.id;


--
-- Name: workplans_parameterinputcolumn; Type: TABLE; Schema: public; Owner: -
--

CREATE TABLE public.workplans_parameterinputcolumn (
    id bigint NOT NULL,
    parameter_id bigint,
    columnforinputproducts_id bigint,
    succession integer,
    entityversion bigint DEFAULT 0
);


--
-- Name: workplans_parameterinputcolumn_id_seq; Type: SEQUENCE; Schema: public; Owner: -
--

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


--
-- Name: workplans_parameterinputcolumn_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: -
--

ALTER SEQUENCE public.workplans_parameterinputcolumn_id_seq OWNED BY public.workplans_parameterinputcolumn.id;


--
-- Name: workplans_parameterordercolumn; Type: TABLE; Schema: public; Owner: -
--

CREATE TABLE public.workplans_parameterordercolumn (
    id bigint NOT NULL,
    parameter_id bigint,
    columnfororders_id bigint,
    succession integer,
    entityversion bigint DEFAULT 0
);


--
-- Name: workplans_parameterordercolumn_id_seq; Type: SEQUENCE; Schema: public; Owner: -
--

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


--
-- Name: workplans_parameterordercolumn_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: -
--

ALTER SEQUENCE public.workplans_parameterordercolumn_id_seq OWNED BY public.workplans_parameterordercolumn.id;


--
-- Name: workplans_parameteroutputcolumn; Type: TABLE; Schema: public; Owner: -
--

CREATE TABLE public.workplans_parameteroutputcolumn (
    id bigint NOT NULL,
    parameter_id bigint,
    columnforoutputproducts_id bigint,
    succession integer,
    entityversion bigint DEFAULT 0
);


--
-- Name: workplans_parameteroutputcolumn_id_seq; Type: SEQUENCE; Schema: public; Owner: -
--

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


--
-- Name: workplans_parameteroutputcolumn_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: -
--

ALTER SEQUENCE public.workplans_parameteroutputcolumn_id_seq OWNED BY public.workplans_parameteroutputcolumn.id;


--
-- Name: workplans_workplan; Type: TABLE; Schema: public; Owner: -
--

CREATE TABLE public.workplans_workplan (
    id bigint NOT NULL,
    name character varying(1024),
    date timestamp without time zone,
    worker character varying(255),
    generated boolean,
    filename character varying(1024),
    type character varying(255) DEFAULT '01allOperations'::character varying,
    dontprintordersinworkplans boolean,
    active boolean DEFAULT true,
    ordersorting character varying(255),
    inputproductcolumntosortby_id bigint,
    entityversion bigint DEFAULT 0
);


--
-- Name: workplans_workplan_id_seq; Type: SEQUENCE; Schema: public; Owner: -
--

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


--
-- Name: workplans_workplan_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: -
--

ALTER SEQUENCE public.workplans_workplan_id_seq OWNED BY public.workplans_workplan.id;


--
-- Name: workplans_workplanordercolumn; Type: TABLE; Schema: public; Owner: -
--

CREATE TABLE public.workplans_workplanordercolumn (
    id bigint NOT NULL,
    workplan_id bigint,
    columnfororders_id bigint,
    succession integer,
    entityversion bigint DEFAULT 0
);


--
-- Name: workplans_workplanordercolumn_id_seq; Type: SEQUENCE; Schema: public; Owner: -
--

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


--
-- Name: workplans_workplanordercolumn_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: -
--

ALTER SEQUENCE public.workplans_workplanordercolumn_id_seq OWNED BY public.workplans_workplanordercolumn.id;


--
-- Name: workstation_changeover_for_operational_task_number_seq; Type: SEQUENCE; Schema: public; Owner: -
--

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


--
-- Name: advancedgenealogy_batch id; Type: DEFAULT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.advancedgenealogy_batch ALTER COLUMN id SET DEFAULT nextval('public.advancedgenealogy_batch_id_seq'::regclass);


--
-- Name: advancedgenealogy_batchattachment id; Type: DEFAULT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.advancedgenealogy_batchattachment ALTER COLUMN id SET DEFAULT nextval('public.advancedgenealogy_batchattachment_id_seq'::regclass);


--
-- Name: advancedgenealogy_batchstatechange id; Type: DEFAULT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.advancedgenealogy_batchstatechange ALTER COLUMN id SET DEFAULT nextval('public.advancedgenealogy_batchstatechange_id_seq'::regclass);


--
-- Name: advancedgenealogy_genealogyreport id; Type: DEFAULT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.advancedgenealogy_genealogyreport ALTER COLUMN id SET DEFAULT nextval('public.advancedgenealogy_genealogyreport_id_seq'::regclass);


--
-- Name: advancedgenealogy_trackingrecord id; Type: DEFAULT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.advancedgenealogy_trackingrecord ALTER COLUMN id SET DEFAULT nextval('public.advancedgenealogy_trackingrecord_id_seq'::regclass);


--
-- Name: advancedgenealogy_trackingrecordstatechange id; Type: DEFAULT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.advancedgenealogy_trackingrecordstatechange ALTER COLUMN id SET DEFAULT nextval('public.advancedgenealogy_trackingrecordstatechange_id_seq'::regclass);


--
-- Name: advancedgenealogy_usedbatchsimple id; Type: DEFAULT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.advancedgenealogy_usedbatchsimple ALTER COLUMN id SET DEFAULT nextval('public.advancedgenealogy_usedbatchsimple_id_seq'::regclass);


--
-- Name: advancedgenealogyfororders_genealogyproductinbatch id; Type: DEFAULT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.advancedgenealogyfororders_genealogyproductinbatch ALTER COLUMN id SET DEFAULT nextval('public.advancedgenealogyfororders_genealogyproductinbatch_id_seq'::regclass);


--
-- Name: advancedgenealogyfororders_genealogyproductincomponent id; Type: DEFAULT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.advancedgenealogyfororders_genealogyproductincomponent ALTER COLUMN id SET DEFAULT nextval('public.advancedgenealogyfororders_genealogyproductincomponent_id_seq'::regclass);


--
-- Name: arch_advancedgenealogy_trackingrecord id; Type: DEFAULT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.arch_advancedgenealogy_trackingrecord ALTER COLUMN id SET DEFAULT nextval('public.arch_advancedgenealogy_trackingrecord_id_seq'::regclass);


--
-- Name: arch_advancedgenealogy_trackingrecordstatechange id; Type: DEFAULT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.arch_advancedgenealogy_trackingrecordstatechange ALTER COLUMN id SET DEFAULT nextval('public.arch_advancedgenealogy_trackingrecordstatechange_id_seq'::regclass);


--
-- Name: arch_advancedgenealogy_usedbatchsimple id; Type: DEFAULT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.arch_advancedgenealogy_usedbatchsimple ALTER COLUMN id SET DEFAULT nextval('public.arch_advancedgenealogy_usedbatchsimple_id_seq'::regclass);


--
-- Name: arch_advancedgenealogyfororders_genealogyproductinbatch id; Type: DEFAULT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.arch_advancedgenealogyfororders_genealogyproductinbatch ALTER COLUMN id SET DEFAULT nextval('public.arch_advancedgenealogyfororders_genealogyproductinbatch_id_seq'::regclass);


--
-- Name: arch_advancedgenealogyfororders_genealogyproductincomponent id; Type: DEFAULT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.arch_advancedgenealogyfororders_genealogyproductincomponent ALTER COLUMN id SET DEFAULT nextval('public.arch_advancedgenealogyfororders_genealogyproductincomponent_id_'::regclass);


--
-- Name: arch_archiving id; Type: DEFAULT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.arch_archiving ALTER COLUMN id SET DEFAULT nextval('public.arch_archiving_id_seq'::regclass);


--
-- Name: arch_assignmenttoshift_multiassignmenttoshift id; Type: DEFAULT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.arch_assignmenttoshift_multiassignmenttoshift ALTER COLUMN id SET DEFAULT nextval('public.arch_assignmenttoshift_multiassignmenttoshift_id_seq'::regclass);


--
-- Name: arch_assignmenttoshift_staffassignmenttoshift id; Type: DEFAULT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.arch_assignmenttoshift_staffassignmenttoshift ALTER COLUMN id SET DEFAULT nextval('public.arch_assignmenttoshift_staffassignmenttoshift_id_seq'::regclass);


--
-- Name: arch_avglaborcostcalcfororder_assignmentworkertoshift id; Type: DEFAULT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.arch_avglaborcostcalcfororder_assignmentworkertoshift ALTER COLUMN id SET DEFAULT nextval('public.arch_avglaborcostcalcfororder_assignmentworkertoshift_id_seq'::regclass);


--
-- Name: arch_avglaborcostcalcfororder_avglaborcostcalcfororder id; Type: DEFAULT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.arch_avglaborcostcalcfororder_avglaborcostcalcfororder ALTER COLUMN id SET DEFAULT nextval('public.arch_avglaborcostcalcfororder_avglaborcostcalcfororder_id_seq'::regclass);


--
-- Name: arch_basicproductioncounting_basicproductioncounting id; Type: DEFAULT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.arch_basicproductioncounting_basicproductioncounting ALTER COLUMN id SET DEFAULT nextval('public.arch_basicproductioncounting_basicproductioncounting_id_seq'::regclass);


--
-- Name: arch_basicproductioncounting_productioncountingattributevalue id; Type: DEFAULT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.arch_basicproductioncounting_productioncountingattributevalue ALTER COLUMN id SET DEFAULT nextval('public.arch_basicproductioncounting_productioncountingattributevalue_i'::regclass);


--
-- Name: arch_basicproductioncounting_productioncountingoperationrun id; Type: DEFAULT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.arch_basicproductioncounting_productioncountingoperationrun ALTER COLUMN id SET DEFAULT nextval('public.arch_basicproductioncounting_productioncountingoperationrun_id_'::regclass);


--
-- Name: arch_basicproductioncounting_productioncountingquantity id; Type: DEFAULT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.arch_basicproductioncounting_productioncountingquantity ALTER COLUMN id SET DEFAULT nextval('public.arch_basicproductioncounting_productioncountingquantity_id_seq'::regclass);


--
-- Name: arch_cdnrcgoodfood_cancelprotocol id; Type: DEFAULT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.arch_cdnrcgoodfood_cancelprotocol ALTER COLUMN id SET DEFAULT nextval('public.arch_cdnrcgoodfood_cancelprotocol_id_seq'::regclass);


--
-- Name: arch_costnormsformaterials_technologyinstoperproductincomp id; Type: DEFAULT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.arch_costnormsformaterials_technologyinstoperproductincomp ALTER COLUMN id SET DEFAULT nextval('public.arch_costnormsformaterials_technologyinstoperproductincomp_id_s'::regclass);


--
-- Name: arch_goodfood_confectionadditionalinputproduct id; Type: DEFAULT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.arch_goodfood_confectionadditionalinputproduct ALTER COLUMN id SET DEFAULT nextval('public.arch_goodfood_confectionadditionalinputproduct_id_seq'::regclass);


--
-- Name: arch_goodfood_confectionfilmproduct id; Type: DEFAULT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.arch_goodfood_confectionfilmproduct ALTER COLUMN id SET DEFAULT nextval('public.arch_goodfood_confectionfilmproduct_id_seq'::regclass);


--
-- Name: arch_goodfood_confectionfilmproductentry id; Type: DEFAULT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.arch_goodfood_confectionfilmproductentry ALTER COLUMN id SET DEFAULT nextval('public.arch_goodfood_confectionfilmproductentry_id_seq'::regclass);


--
-- Name: arch_goodfood_confectioninputproduct id; Type: DEFAULT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.arch_goodfood_confectioninputproduct ALTER COLUMN id SET DEFAULT nextval('public.arch_goodfood_confectioninputproduct_id_seq'::regclass);


--
-- Name: arch_goodfood_confectionprotocol id; Type: DEFAULT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.arch_goodfood_confectionprotocol ALTER COLUMN id SET DEFAULT nextval('public.arch_goodfood_confectionprotocol_id_seq'::regclass);


--
-- Name: arch_goodfood_confectionprotocolcorrect id; Type: DEFAULT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.arch_goodfood_confectionprotocolcorrect ALTER COLUMN id SET DEFAULT nextval('public.arch_goodfood_confectionprotocolcorrect_id_seq'::regclass);


--
-- Name: arch_goodfood_confectionprotocolstatechange id; Type: DEFAULT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.arch_goodfood_confectionprotocolstatechange ALTER COLUMN id SET DEFAULT nextval('public.arch_goodfood_confectionprotocolstatechange_id_seq'::regclass);


--
-- Name: arch_goodfood_confectionremainderinputproduct id; Type: DEFAULT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.arch_goodfood_confectionremainderinputproduct ALTER COLUMN id SET DEFAULT nextval('public.arch_goodfood_confectionremainderinputproduct_id_seq'::regclass);


--
-- Name: arch_goodfood_confectionstaff id; Type: DEFAULT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.arch_goodfood_confectionstaff ALTER COLUMN id SET DEFAULT nextval('public.arch_goodfood_confectionstaff_id_seq'::regclass);


--
-- Name: arch_goodfood_extrusionaddedmixentry id; Type: DEFAULT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.arch_goodfood_extrusionaddedmixentry ALTER COLUMN id SET DEFAULT nextval('public.arch_goodfood_extrusionaddedmixentry_id_seq'::regclass);


--
-- Name: arch_goodfood_extrusionaddedmixingredient id; Type: DEFAULT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.arch_goodfood_extrusionaddedmixingredient ALTER COLUMN id SET DEFAULT nextval('public.arch_goodfood_extrusionaddedmixingredient_id_seq'::regclass);


--
-- Name: arch_goodfood_extrusionpouring id; Type: DEFAULT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.arch_goodfood_extrusionpouring ALTER COLUMN id SET DEFAULT nextval('public.arch_goodfood_extrusionpouring_id_seq'::regclass);


--
-- Name: arch_goodfood_extrusionpouringingredient id; Type: DEFAULT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.arch_goodfood_extrusionpouringingredient ALTER COLUMN id SET DEFAULT nextval('public.arch_goodfood_extrusionpouringingredient_id_seq'::regclass);


--
-- Name: arch_goodfood_extrusionpouringmix id; Type: DEFAULT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.arch_goodfood_extrusionpouringmix ALTER COLUMN id SET DEFAULT nextval('public.arch_goodfood_extrusionpouringmix_id_seq'::regclass);


--
-- Name: arch_goodfood_extrusionprotocol id; Type: DEFAULT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.arch_goodfood_extrusionprotocol ALTER COLUMN id SET DEFAULT nextval('public.arch_goodfood_extrusionprotocol_id_seq'::regclass);


--
-- Name: arch_goodfood_extrusionprotocolcorrect id; Type: DEFAULT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.arch_goodfood_extrusionprotocolcorrect ALTER COLUMN id SET DEFAULT nextval('public.arch_goodfood_extrusionprotocolcorrect_id_seq'::regclass);


--
-- Name: arch_goodfood_extrusionprotocolstatechange id; Type: DEFAULT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.arch_goodfood_extrusionprotocolstatechange ALTER COLUMN id SET DEFAULT nextval('public.arch_goodfood_extrusionprotocolstatechange_id_seq'::regclass);


--
-- Name: arch_goodfood_extrusionsouse id; Type: DEFAULT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.arch_goodfood_extrusionsouse ALTER COLUMN id SET DEFAULT nextval('public.arch_goodfood_extrusionsouse_id_seq'::regclass);


--
-- Name: arch_goodfood_extrusiontakenoffmixentry id; Type: DEFAULT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.arch_goodfood_extrusiontakenoffmixentry ALTER COLUMN id SET DEFAULT nextval('public.arch_goodfood_extrusiontakenoffmixentry_id_seq'::regclass);


--
-- Name: arch_goodfood_extrusiontakenoffmixingredient id; Type: DEFAULT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.arch_goodfood_extrusiontakenoffmixingredient ALTER COLUMN id SET DEFAULT nextval('public.arch_goodfood_extrusiontakenoffmixingredient_id_seq'::regclass);


--
-- Name: arch_goodfood_pallet id; Type: DEFAULT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.arch_goodfood_pallet ALTER COLUMN id SET DEFAULT nextval('public.arch_goodfood_pallet_id_seq'::regclass);


--
-- Name: arch_goodfood_palletlabel id; Type: DEFAULT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.arch_goodfood_palletlabel ALTER COLUMN id SET DEFAULT nextval('public.arch_goodfood_palletlabel_id_seq'::regclass);


--
-- Name: arch_goodfood_palletlabelstatechange id; Type: DEFAULT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.arch_goodfood_palletlabelstatechange ALTER COLUMN id SET DEFAULT nextval('public.arch_goodfood_palletlabelstatechange_id_seq'::regclass);


--
-- Name: arch_goodfood_palletstatechange id; Type: DEFAULT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.arch_goodfood_palletstatechange ALTER COLUMN id SET DEFAULT nextval('public.arch_goodfood_palletstatechange_id_seq'::regclass);


--
-- Name: arch_goodfood_printedlabel id; Type: DEFAULT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.arch_goodfood_printedlabel ALTER COLUMN id SET DEFAULT nextval('public.arch_goodfood_printedlabel_id_seq'::regclass);


--
-- Name: arch_integrationbartender_printlabelshelper id; Type: DEFAULT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.arch_integrationbartender_printlabelshelper ALTER COLUMN id SET DEFAULT nextval('public.arch_integrationbartender_printlabelshelper_id_seq'::regclass);


--
-- Name: arch_integrationbartender_sendtoprint id; Type: DEFAULT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.arch_integrationbartender_sendtoprint ALTER COLUMN id SET DEFAULT nextval('public.arch_integrationbartender_sendtoprint_id_seq'::regclass);


--
-- Name: arch_masterorders_masterorder id; Type: DEFAULT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.arch_masterorders_masterorder ALTER COLUMN id SET DEFAULT nextval('public.arch_masterorders_masterorder_id_seq'::regclass);


--
-- Name: arch_masterorders_masterorderproduct id; Type: DEFAULT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.arch_masterorders_masterorderproduct ALTER COLUMN id SET DEFAULT nextval('public.arch_masterorders_masterorderproduct_id_seq'::regclass);


--
-- Name: arch_masterorders_masterorderproductattrvalue id; Type: DEFAULT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.arch_masterorders_masterorderproductattrvalue ALTER COLUMN id SET DEFAULT nextval('public.arch_masterorders_masterorderproductattrvalue_id_seq'::regclass);


--
-- Name: arch_masterorders_productsbysizeentryhelper id; Type: DEFAULT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.arch_masterorders_productsbysizeentryhelper ALTER COLUMN id SET DEFAULT nextval('public.arch_masterorders_productsbysizeentryhelper_id_seq'::regclass);


--
-- Name: arch_masterorders_productsbysizehelper id; Type: DEFAULT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.arch_masterorders_productsbysizehelper ALTER COLUMN id SET DEFAULT nextval('public.arch_masterorders_productsbysizehelper_id_seq'::regclass);


--
-- Name: arch_materialflowresources_document id; Type: DEFAULT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.arch_materialflowresources_document ALTER COLUMN id SET DEFAULT nextval('public.arch_materialflowresources_document_id_seq'::regclass);


--
-- Name: arch_materialflowresources_documentstatechange id; Type: DEFAULT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.arch_materialflowresources_documentstatechange ALTER COLUMN id SET DEFAULT nextval('public.arch_materialflowresources_documentstatechange_id_seq'::regclass);


--
-- Name: arch_materialflowresources_position id; Type: DEFAULT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.arch_materialflowresources_position ALTER COLUMN id SET DEFAULT nextval('public.arch_materialflowresources_position_id_seq'::regclass);


--
-- Name: arch_materialflowresources_positionattributevalue id; Type: DEFAULT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.arch_materialflowresources_positionattributevalue ALTER COLUMN id SET DEFAULT nextval('public.arch_materialflowresources_positionattributevalue_id_seq'::regclass);


--
-- Name: arch_materialflowresources_reservation id; Type: DEFAULT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.arch_materialflowresources_reservation ALTER COLUMN id SET DEFAULT nextval('public.arch_materialflowresources_reservation_id_seq'::regclass);


--
-- Name: arch_materialrequirementcoveragefororder_coveragefororder id; Type: DEFAULT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.arch_materialrequirementcoveragefororder_coveragefororder ALTER COLUMN id SET DEFAULT nextval('public.arch_materialrequirementcoveragefororder_coveragefororder_id_se'::regclass);


--
-- Name: arch_materialrequirementcoveragefororder_coveragelocation id; Type: DEFAULT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.arch_materialrequirementcoveragefororder_coveragelocation ALTER COLUMN id SET DEFAULT nextval('public.arch_materialrequirementcoveragefororder_coveragelocation_id_se'::regclass);


--
-- Name: arch_materialrequirementcoveragefororder_coverageproduct id; Type: DEFAULT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.arch_materialrequirementcoveragefororder_coverageproduct ALTER COLUMN id SET DEFAULT nextval('public.arch_materialrequirementcoveragefororder_coverageproduct_id_seq'::regclass);


--
-- Name: arch_orders_operationaltask id; Type: DEFAULT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.arch_orders_operationaltask ALTER COLUMN id SET DEFAULT nextval('public.arch_orders_operationaltask_id_seq'::regclass);


--
-- Name: arch_orders_operationaltaskstatechange id; Type: DEFAULT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.arch_orders_operationaltaskstatechange ALTER COLUMN id SET DEFAULT nextval('public.arch_orders_operationaltaskstatechange_id_seq'::regclass);


--
-- Name: arch_orders_order id; Type: DEFAULT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.arch_orders_order ALTER COLUMN id SET DEFAULT nextval('public.arch_orders_order_id_seq'::regclass);


--
-- Name: arch_orders_orderpack id; Type: DEFAULT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.arch_orders_orderpack ALTER COLUMN id SET DEFAULT nextval('public.arch_orders_orderpack_id_seq'::regclass);


--
-- Name: arch_orders_orderpackstatechange id; Type: DEFAULT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.arch_orders_orderpackstatechange ALTER COLUMN id SET DEFAULT nextval('public.arch_orders_orderpackstatechange_id_seq'::regclass);


--
-- Name: arch_orders_orderstatechange id; Type: DEFAULT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.arch_orders_orderstatechange ALTER COLUMN id SET DEFAULT nextval('public.arch_orders_orderstatechange_id_seq'::regclass);


--
-- Name: arch_orders_ordertechnologicalprocess id; Type: DEFAULT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.arch_orders_ordertechnologicalprocess ALTER COLUMN id SET DEFAULT nextval('public.arch_orders_ordertechnologicalprocess_id_seq'::regclass);


--
-- Name: arch_orders_ordertechnologicalprocesspart id; Type: DEFAULT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.arch_orders_ordertechnologicalprocesspart ALTER COLUMN id SET DEFAULT nextval('public.arch_orders_ordertechnologicalprocesspart_id_seq'::regclass);


--
-- Name: arch_orders_ordertechnologicalprocesswaste id; Type: DEFAULT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.arch_orders_ordertechnologicalprocesswaste ALTER COLUMN id SET DEFAULT nextval('public.arch_orders_ordertechnologicalprocesswaste_id_seq'::regclass);


--
-- Name: arch_orders_productionlinescheduleposition id; Type: DEFAULT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.arch_orders_productionlinescheduleposition ALTER COLUMN id SET DEFAULT nextval('public.arch_orders_productionlinescheduleposition_id_seq'::regclass);


--
-- Name: arch_orders_reasontypecorrectiondatefrom id; Type: DEFAULT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.arch_orders_reasontypecorrectiondatefrom ALTER COLUMN id SET DEFAULT nextval('public.arch_orders_reasontypecorrectiondatefrom_id_seq'::regclass);


--
-- Name: arch_orders_reasontypecorrectiondateto id; Type: DEFAULT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.arch_orders_reasontypecorrectiondateto ALTER COLUMN id SET DEFAULT nextval('public.arch_orders_reasontypecorrectiondateto_id_seq'::regclass);


--
-- Name: arch_orders_reasontypedeviationeffectiveend id; Type: DEFAULT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.arch_orders_reasontypedeviationeffectiveend ALTER COLUMN id SET DEFAULT nextval('public.arch_orders_reasontypedeviationeffectiveend_id_seq'::regclass);


--
-- Name: arch_orders_reasontypedeviationeffectivestart id; Type: DEFAULT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.arch_orders_reasontypedeviationeffectivestart ALTER COLUMN id SET DEFAULT nextval('public.arch_orders_reasontypedeviationeffectivestart_id_seq'::regclass);


--
-- Name: arch_orders_reasontypeofchangingorderstate id; Type: DEFAULT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.arch_orders_reasontypeofchangingorderstate ALTER COLUMN id SET DEFAULT nextval('public.arch_orders_reasontypeofchangingorderstate_id_seq'::regclass);


--
-- Name: arch_orders_scheduleposition id; Type: DEFAULT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.arch_orders_scheduleposition ALTER COLUMN id SET DEFAULT nextval('public.arch_orders_scheduleposition_id_seq'::regclass);


--
-- Name: arch_orders_typeofcorrectioncauses id; Type: DEFAULT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.arch_orders_typeofcorrectioncauses ALTER COLUMN id SET DEFAULT nextval('public.arch_orders_typeofcorrectioncauses_id_seq'::regclass);


--
-- Name: arch_ordersforsubproductsgeneration_suborders id; Type: DEFAULT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.arch_ordersforsubproductsgeneration_suborders ALTER COLUMN id SET DEFAULT nextval('public.arch_ordersforsubproductsgeneration_suborders_id_seq'::regclass);


--
-- Name: arch_ordersgroups_ordersgroup id; Type: DEFAULT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.arch_ordersgroups_ordersgroup ALTER COLUMN id SET DEFAULT nextval('public.arch_ordersgroups_ordersgroup_id_seq'::regclass);


--
-- Name: arch_ordersgroups_ordersgroupissuedmaterial id; Type: DEFAULT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.arch_ordersgroups_ordersgroupissuedmaterial ALTER COLUMN id SET DEFAULT nextval('public.arch_ordersgroups_ordersgroupissuedmaterial_id_seq'::regclass);


--
-- Name: arch_ordersgroups_ordersgroupissuedmaterialposition id; Type: DEFAULT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.arch_ordersgroups_ordersgroupissuedmaterialposition ALTER COLUMN id SET DEFAULT nextval('public.arch_ordersgroups_ordersgroupissuedmaterialposition_id_seq'::regclass);


--
-- Name: arch_ordersgroups_ordersgroupmaterialrequirement id; Type: DEFAULT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.arch_ordersgroups_ordersgroupmaterialrequirement ALTER COLUMN id SET DEFAULT nextval('public.arch_ordersgroups_ordersgroupmaterialrequirement_id_seq'::regclass);


--
-- Name: arch_ordersgroups_ordersgroupmaterialrequirementproduct id; Type: DEFAULT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.arch_ordersgroups_ordersgroupmaterialrequirementproduct ALTER COLUMN id SET DEFAULT nextval('public.arch_ordersgroups_ordersgroupmaterialrequirementproduct_id_seq'::regclass);


--
-- Name: arch_ordersgroups_ordersgroupproducedproduct id; Type: DEFAULT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.arch_ordersgroups_ordersgroupproducedproduct ALTER COLUMN id SET DEFAULT nextval('public.arch_ordersgroups_ordersgroupproducedproduct_id_seq'::regclass);


--
-- Name: arch_ordersgroups_ordersgroupproductstoissueentryhelper id; Type: DEFAULT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.arch_ordersgroups_ordersgroupproductstoissueentryhelper ALTER COLUMN id SET DEFAULT nextval('public.arch_ordersgroups_ordersgroupproductstoissueentryhelper_id_seq'::regclass);


--
-- Name: arch_ordersgroups_ordersgroupproductstoissuehelper id; Type: DEFAULT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.arch_ordersgroups_ordersgroupproductstoissuehelper ALTER COLUMN id SET DEFAULT nextval('public.arch_ordersgroups_ordersgroupproductstoissuehelper_id_seq'::regclass);


--
-- Name: arch_ordersgroups_productionbalance id; Type: DEFAULT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.arch_ordersgroups_productionbalance ALTER COLUMN id SET DEFAULT nextval('public.arch_ordersgroups_productionbalance_id_seq'::regclass);


--
-- Name: arch_ordersupplies_coverageanalysisfororder id; Type: DEFAULT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.arch_ordersupplies_coverageanalysisfororder ALTER COLUMN id SET DEFAULT nextval('public.arch_ordersupplies_coverageanalysisfororder_id_seq'::regclass);


--
-- Name: arch_ordersupplies_coveragelocation id; Type: DEFAULT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.arch_ordersupplies_coveragelocation ALTER COLUMN id SET DEFAULT nextval('public.arch_ordersupplies_coveragelocation_id_seq'::regclass);


--
-- Name: arch_ordersupplies_coverageorderstate id; Type: DEFAULT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.arch_ordersupplies_coverageorderstate ALTER COLUMN id SET DEFAULT nextval('public.arch_ordersupplies_coverageorderstate_id_seq'::regclass);


--
-- Name: arch_ordersupplies_coverageproduct id; Type: DEFAULT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.arch_ordersupplies_coverageproduct ALTER COLUMN id SET DEFAULT nextval('public.arch_ordersupplies_coverageproduct_id_seq'::regclass);


--
-- Name: arch_ordersupplies_coverageproductlogging id; Type: DEFAULT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.arch_ordersupplies_coverageproductlogging ALTER COLUMN id SET DEFAULT nextval('public.arch_ordersupplies_coverageproductlogging_id_seq'::regclass);


--
-- Name: arch_ordersupplies_coverageproductselected id; Type: DEFAULT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.arch_ordersupplies_coverageproductselected ALTER COLUMN id SET DEFAULT nextval('public.arch_ordersupplies_coverageproductselected_id_seq'::regclass);


--
-- Name: arch_ordersupplies_materialrequirementcoverage id; Type: DEFAULT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.arch_ordersupplies_materialrequirementcoverage ALTER COLUMN id SET DEFAULT nextval('public.arch_ordersupplies_materialrequirementcoverage_id_seq'::regclass);


--
-- Name: arch_productflowthrudivision_issue id; Type: DEFAULT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.arch_productflowthrudivision_issue ALTER COLUMN id SET DEFAULT nextval('public.arch_productflowthrudivision_issue_id_seq'::regclass);


--
-- Name: arch_productflowthrudivision_materialavailability id; Type: DEFAULT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.arch_productflowthrudivision_materialavailability ALTER COLUMN id SET DEFAULT nextval('public.arch_productflowthrudivision_materialavailability_id_seq'::regclass);


--
-- Name: arch_productflowthrudivision_productstoissue id; Type: DEFAULT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.arch_productflowthrudivision_productstoissue ALTER COLUMN id SET DEFAULT nextval('public.arch_productflowthrudivision_productstoissue_id_seq'::regclass);


--
-- Name: arch_productflowthrudivision_producttoissuecorrection id; Type: DEFAULT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.arch_productflowthrudivision_producttoissuecorrection ALTER COLUMN id SET DEFAULT nextval('public.arch_productflowthrudivision_producttoissuecorrection_id_seq'::regclass);


--
-- Name: arch_productflowthrudivision_warehouseissue id; Type: DEFAULT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.arch_productflowthrudivision_warehouseissue ALTER COLUMN id SET DEFAULT nextval('public.arch_productflowthrudivision_warehouseissue_id_seq'::regclass);


--
-- Name: arch_productflowthrudivision_warehouseissuestatechange id; Type: DEFAULT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.arch_productflowthrudivision_warehouseissuestatechange ALTER COLUMN id SET DEFAULT nextval('public.arch_productflowthrudivision_warehouseissuestatechange_id_seq'::regclass);


--
-- Name: arch_productioncounting_anomaly id; Type: DEFAULT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.arch_productioncounting_anomaly ALTER COLUMN id SET DEFAULT nextval('public.arch_productioncounting_anomaly_id_seq'::regclass);


--
-- Name: arch_productioncounting_anomalyexplanation id; Type: DEFAULT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.arch_productioncounting_anomalyexplanation ALTER COLUMN id SET DEFAULT nextval('public.arch_productioncounting_anomalyexplanation_id_seq'::regclass);


--
-- Name: arch_productioncounting_anomalyproductiontrackingentryhelper id; Type: DEFAULT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.arch_productioncounting_anomalyproductiontrackingentryhelper ALTER COLUMN id SET DEFAULT nextval('public.arch_productioncounting_anomalyproductiontrackingentryhelper_id'::regclass);


--
-- Name: arch_productioncounting_anomalyreasoncontainer id; Type: DEFAULT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.arch_productioncounting_anomalyreasoncontainer ALTER COLUMN id SET DEFAULT nextval('public.arch_productioncounting_anomalyreasoncontainer_id_seq'::regclass);


--
-- Name: arch_productioncounting_lack id; Type: DEFAULT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.arch_productioncounting_lack ALTER COLUMN id SET DEFAULT nextval('public.arch_productioncounting_lack_id_seq'::regclass);


--
-- Name: arch_productioncounting_prodoutresourceattrval id; Type: DEFAULT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.arch_productioncounting_prodoutresourceattrval ALTER COLUMN id SET DEFAULT nextval('public.arch_productioncounting_prodoutresourceattrval_id_seq'::regclass);


--
-- Name: arch_productioncounting_productiontracking id; Type: DEFAULT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.arch_productioncounting_productiontracking ALTER COLUMN id SET DEFAULT nextval('public.arch_productioncounting_productiontracking_id_seq'::regclass);


--
-- Name: arch_productioncounting_productiontrackingattachment id; Type: DEFAULT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.arch_productioncounting_productiontrackingattachment ALTER COLUMN id SET DEFAULT nextval('public.arch_productioncounting_productiontrackingattachment_id_seq'::regclass);


--
-- Name: arch_productioncounting_productiontrackingstatechange id; Type: DEFAULT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.arch_productioncounting_productiontrackingstatechange ALTER COLUMN id SET DEFAULT nextval('public.arch_productioncounting_productiontrackingstatechange_id_seq'::regclass);


--
-- Name: arch_productioncounting_staffworktime id; Type: DEFAULT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.arch_productioncounting_staffworktime ALTER COLUMN id SET DEFAULT nextval('public.arch_productioncounting_staffworktime_id_seq'::regclass);


--
-- Name: arch_productioncounting_trackinginproductreplacementhelper id; Type: DEFAULT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.arch_productioncounting_trackinginproductreplacementhelper ALTER COLUMN id SET DEFAULT nextval('public.arch_productioncounting_trackinginproductreplacementhelper_id_s'::regclass);


--
-- Name: arch_productioncounting_trackingoperationproductincomponent id; Type: DEFAULT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.arch_productioncounting_trackingoperationproductincomponent ALTER COLUMN id SET DEFAULT nextval('public.arch_productioncounting_trackingoperationproductincomponent_id_'::regclass);


--
-- Name: arch_productioncounting_trackingoperationproductoutcomponent id; Type: DEFAULT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.arch_productioncounting_trackingoperationproductoutcomponent ALTER COLUMN id SET DEFAULT nextval('public.arch_productioncounting_trackingoperationproductoutcomponent_id'::regclass);


--
-- Name: arch_productioncounting_usedbatch id; Type: DEFAULT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.arch_productioncounting_usedbatch ALTER COLUMN id SET DEFAULT nextval('public.arch_productioncounting_usedbatch_id_seq'::regclass);


--
-- Name: arch_productionpershift_dailyprogress id; Type: DEFAULT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.arch_productionpershift_dailyprogress ALTER COLUMN id SET DEFAULT nextval('public.arch_productionpershift_dailyprogress_id_seq'::regclass);


--
-- Name: arch_productionpershift_productionpershift id; Type: DEFAULT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.arch_productionpershift_productionpershift ALTER COLUMN id SET DEFAULT nextval('public.arch_productionpershift_productionpershift_id_seq'::regclass);


--
-- Name: arch_productionpershift_progressforday id; Type: DEFAULT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.arch_productionpershift_progressforday ALTER COLUMN id SET DEFAULT nextval('public.arch_productionpershift_progressforday_id_seq'::regclass);


--
-- Name: arch_productionpershift_reasontypeofcorrectionplan id; Type: DEFAULT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.arch_productionpershift_reasontypeofcorrectionplan ALTER COLUMN id SET DEFAULT nextval('public.arch_productionpershift_reasontypeofcorrectionplan_id_seq'::regclass);


--
-- Name: arch_productionscheduling_opercomptimecalculation id; Type: DEFAULT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.arch_productionscheduling_opercomptimecalculation ALTER COLUMN id SET DEFAULT nextval('public.arch_productionscheduling_opercomptimecalculation_id_seq'::regclass);


--
-- Name: arch_productionscheduling_ordertimecalculation id; Type: DEFAULT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.arch_productionscheduling_ordertimecalculation ALTER COLUMN id SET DEFAULT nextval('public.arch_productionscheduling_ordertimecalculation_id_seq'::regclass);


--
-- Name: arch_qualitycontrol_qualitycontrol id; Type: DEFAULT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.arch_qualitycontrol_qualitycontrol ALTER COLUMN id SET DEFAULT nextval('public.arch_qualitycontrol_qualitycontrol_id_seq'::regclass);


--
-- Name: arch_qualitycontrol_qualitycontrolattachment id; Type: DEFAULT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.arch_qualitycontrol_qualitycontrolattachment ALTER COLUMN id SET DEFAULT nextval('public.arch_qualitycontrol_qualitycontrolattachment_id_seq'::regclass);


--
-- Name: arch_qualitycontrol_qualitycontrolattributeprodtracking id; Type: DEFAULT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.arch_qualitycontrol_qualitycontrolattributeprodtracking ALTER COLUMN id SET DEFAULT nextval('public.arch_qualitycontrol_qualitycontrolattributeprodtracking_id_seq'::regclass);


--
-- Name: arch_qualitycontrol_qualitycontrolattributevalue id; Type: DEFAULT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.arch_qualitycontrol_qualitycontrolattributevalue ALTER COLUMN id SET DEFAULT nextval('public.arch_qualitycontrol_qualitycontrolattributevalue_id_seq'::regclass);


--
-- Name: arch_qualitycontrol_qualitycontrolresource id; Type: DEFAULT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.arch_qualitycontrol_qualitycontrolresource ALTER COLUMN id SET DEFAULT nextval('public.arch_qualitycontrol_qualitycontrolresource_id_seq'::regclass);


--
-- Name: arch_qualitycontrol_qualitycontrolstatechange id; Type: DEFAULT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.arch_qualitycontrol_qualitycontrolstatechange ALTER COLUMN id SET DEFAULT nextval('public.arch_qualitycontrol_qualitycontrolstatechange_id_seq'::regclass);


--
-- Name: arch_repairs_repairorder id; Type: DEFAULT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.arch_repairs_repairorder ALTER COLUMN id SET DEFAULT nextval('public.arch_repairs_repairorder_id_seq'::regclass);


--
-- Name: arch_repairs_repairorderproduct id; Type: DEFAULT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.arch_repairs_repairorderproduct ALTER COLUMN id SET DEFAULT nextval('public.arch_repairs_repairorderproduct_id_seq'::regclass);


--
-- Name: arch_repairs_repairorderstatechange id; Type: DEFAULT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.arch_repairs_repairorderstatechange ALTER COLUMN id SET DEFAULT nextval('public.arch_repairs_repairorderstatechange_id_seq'::regclass);


--
-- Name: arch_repairs_repairorderworktime id; Type: DEFAULT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.arch_repairs_repairorderworktime ALTER COLUMN id SET DEFAULT nextval('public.arch_repairs_repairorderworktime_id_seq'::regclass);


--
-- Name: arch_states_message id; Type: DEFAULT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.arch_states_message ALTER COLUMN id SET DEFAULT nextval('public.arch_states_message_id_seq'::regclass);


--
-- Name: arch_stoppage_stoppage id; Type: DEFAULT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.arch_stoppage_stoppage ALTER COLUMN id SET DEFAULT nextval('public.arch_stoppage_stoppage_id_seq'::regclass);


--
-- Name: arch_technologies_barcodeoperationcomponent id; Type: DEFAULT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.arch_technologies_barcodeoperationcomponent ALTER COLUMN id SET DEFAULT nextval('public.arch_technologies_barcodeoperationcomponent_id_seq'::regclass);


--
-- Name: arch_urcmaterialavailability_requiredcomponent id; Type: DEFAULT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.arch_urcmaterialavailability_requiredcomponent ALTER COLUMN id SET DEFAULT nextval('public.arch_urcmaterialavailability_requiredcomponent_id_seq'::regclass);


--
-- Name: assignmenttoshift_assignmenttoshift id; Type: DEFAULT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.assignmenttoshift_assignmenttoshift ALTER COLUMN id SET DEFAULT nextval('public.assignmenttoshift_assignmenttoshift_id_seq'::regclass);


--
-- Name: assignmenttoshift_assignmenttoshiftreport id; Type: DEFAULT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.assignmenttoshift_assignmenttoshiftreport ALTER COLUMN id SET DEFAULT nextval('public.assignmenttoshift_assignmenttoshiftreport_id_seq'::regclass);


--
-- Name: assignmenttoshift_assignmenttoshiftstatechange id; Type: DEFAULT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.assignmenttoshift_assignmenttoshiftstatechange ALTER COLUMN id SET DEFAULT nextval('public.assignmenttoshift_assignmenttoshiftstatechange_id_seq'::regclass);


--
-- Name: assignmenttoshift_multiassignmenttoshift id; Type: DEFAULT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.assignmenttoshift_multiassignmenttoshift ALTER COLUMN id SET DEFAULT nextval('public.assignmenttoshift_multiassignmenttoshift_id_seq'::regclass);


--
-- Name: assignmenttoshift_staffassignmenttoshift id; Type: DEFAULT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.assignmenttoshift_staffassignmenttoshift ALTER COLUMN id SET DEFAULT nextval('public.assignmenttoshift_staffassignmenttoshift_id_seq'::regclass);


--
-- Name: avglaborcostcalcfororder_assignmentworkertoshift id; Type: DEFAULT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.avglaborcostcalcfororder_assignmentworkertoshift ALTER COLUMN id SET DEFAULT nextval('public.avglaborcostcalcfororder_assignmentworkertoshift_id_seq'::regclass);


--
-- Name: avglaborcostcalcfororder_avglaborcostcalcfororder id; Type: DEFAULT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.avglaborcostcalcfororder_avglaborcostcalcfororder ALTER COLUMN id SET DEFAULT nextval('public.avglaborcostcalcfororder_avglaborcostcalcfororder_id_seq'::regclass);


--
-- Name: basic_address id; Type: DEFAULT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.basic_address ALTER COLUMN id SET DEFAULT nextval('public.basic_address_id_seq'::regclass);


--
-- Name: basic_assortment id; Type: DEFAULT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.basic_assortment ALTER COLUMN id SET DEFAULT nextval('public.basic_assortment_id_seq'::regclass);


--
-- Name: basic_assortmentelement id; Type: DEFAULT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.basic_assortmentelement ALTER COLUMN id SET DEFAULT nextval('public.basic_assortmentelement_id_seq'::regclass);


--
-- Name: basic_attribute id; Type: DEFAULT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.basic_attribute ALTER COLUMN id SET DEFAULT nextval('public.basic_attribute_id_seq'::regclass);


--
-- Name: basic_attributevalue id; Type: DEFAULT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.basic_attributevalue ALTER COLUMN id SET DEFAULT nextval('public.basic_attributevalue_id_seq'::regclass);


--
-- Name: basic_company id; Type: DEFAULT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.basic_company ALTER COLUMN id SET DEFAULT nextval('public.basic_company_id_seq'::regclass);


--
-- Name: basic_country id; Type: DEFAULT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.basic_country ALTER COLUMN id SET DEFAULT nextval('public.basic_country_id_seq'::regclass);


--
-- Name: basic_crew id; Type: DEFAULT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.basic_crew ALTER COLUMN id SET DEFAULT nextval('public.basic_crew_id_seq'::regclass);


--
-- Name: basic_currency id; Type: DEFAULT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.basic_currency ALTER COLUMN id SET DEFAULT nextval('public.basic_currency_id_seq'::regclass);


--
-- Name: basic_dashboardbutton id; Type: DEFAULT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.basic_dashboardbutton ALTER COLUMN id SET DEFAULT nextval('public.basic_dashboardbutton_id_seq'::regclass);


--
-- Name: basic_division id; Type: DEFAULT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.basic_division ALTER COLUMN id SET DEFAULT nextval('public.basic_division_id_seq'::regclass);


--
-- Name: basic_factory id; Type: DEFAULT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.basic_factory ALTER COLUMN id SET DEFAULT nextval('public.basic_factory_id_seq'::regclass);


--
-- Name: basic_faulttype id; Type: DEFAULT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.basic_faulttype ALTER COLUMN id SET DEFAULT nextval('public.basic_faulttype_id_seq'::regclass);


--
-- Name: basic_forms id; Type: DEFAULT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.basic_forms ALTER COLUMN id SET DEFAULT nextval('public.basic_forms_id_seq'::regclass);


--
-- Name: basic_label id; Type: DEFAULT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.basic_label ALTER COLUMN id SET DEFAULT nextval('public.basic_label_id_seq'::regclass);


--
-- Name: basic_licenseusage id; Type: DEFAULT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.basic_licenseusage ALTER COLUMN id SET DEFAULT nextval('public.basic_licenseusage_id_seq'::regclass);


--
-- Name: basic_log id; Type: DEFAULT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.basic_log ALTER COLUMN id SET DEFAULT nextval('public.basic_log_id_seq'::regclass);


--
-- Name: basic_machineworkingperiod id; Type: DEFAULT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.basic_machineworkingperiod ALTER COLUMN id SET DEFAULT nextval('public.basic_machineworkingperiod_id_seq'::regclass);


--
-- Name: basic_model id; Type: DEFAULT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.basic_model ALTER COLUMN id SET DEFAULT nextval('public.basic_model_id_seq'::regclass);


--
-- Name: basic_numberpattern id; Type: DEFAULT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.basic_numberpattern ALTER COLUMN id SET DEFAULT nextval('public.basic_numberpattern_id_seq'::regclass);


--
-- Name: basic_numberpatternelement id; Type: DEFAULT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.basic_numberpatternelement ALTER COLUMN id SET DEFAULT nextval('public.basic_numberpatternelement_id_seq'::regclass);


--
-- Name: basic_palletnumber id; Type: DEFAULT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.basic_palletnumber ALTER COLUMN id SET DEFAULT nextval('public.basic_palletnumber_id_seq'::regclass);


--
-- Name: basic_palletnumberhelper id; Type: DEFAULT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.basic_palletnumberhelper ALTER COLUMN id SET DEFAULT nextval('public.basic_palletnumberhelper_id_seq'::regclass);


--
-- Name: basic_parameter id; Type: DEFAULT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.basic_parameter ALTER COLUMN id SET DEFAULT nextval('public.basic_parameter_id_seq'::regclass);


--
-- Name: basic_piecerate id; Type: DEFAULT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.basic_piecerate ALTER COLUMN id SET DEFAULT nextval('public.basic_piecerate_id_seq'::regclass);


--
-- Name: basic_piecerateitem id; Type: DEFAULT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.basic_piecerateitem ALTER COLUMN id SET DEFAULT nextval('public.basic_piecerateitem_id_seq'::regclass);


--
-- Name: basic_product id; Type: DEFAULT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.basic_product ALTER COLUMN id SET DEFAULT nextval('public.basic_product_id_seq'::regclass);


--
-- Name: basic_productattachment id; Type: DEFAULT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.basic_productattachment ALTER COLUMN id SET DEFAULT nextval('public.basic_productattachment_id_seq'::regclass);


--
-- Name: basic_productattributevalue id; Type: DEFAULT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.basic_productattributevalue ALTER COLUMN id SET DEFAULT nextval('public.basic_productattributevalue_id_seq'::regclass);


--
-- Name: basic_qualitycard id; Type: DEFAULT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.basic_qualitycard ALTER COLUMN id SET DEFAULT nextval('public.basic_qualitycard_id_seq'::regclass);


--
-- Name: basic_qualitycardstatechange id; Type: DEFAULT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.basic_qualitycardstatechange ALTER COLUMN id SET DEFAULT nextval('public.basic_qualitycardstatechange_id_seq'::regclass);


--
-- Name: basic_reportcolumnwidth id; Type: DEFAULT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.basic_reportcolumnwidth ALTER COLUMN id SET DEFAULT nextval('public.basic_reportcolumnwidth_id_seq'::regclass);


--
-- Name: basic_shift id; Type: DEFAULT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.basic_shift ALTER COLUMN id SET DEFAULT nextval('public.basic_shift_id_seq'::regclass);


--
-- Name: basic_shifttimetableexception id; Type: DEFAULT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.basic_shifttimetableexception ALTER COLUMN id SET DEFAULT nextval('public.basic_shifttimetableexception_id_seq'::regclass);


--
-- Name: basic_size id; Type: DEFAULT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.basic_size ALTER COLUMN id SET DEFAULT nextval('public.basic_size_id_seq'::regclass);


--
-- Name: basic_sizegroup id; Type: DEFAULT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.basic_sizegroup ALTER COLUMN id SET DEFAULT nextval('public.basic_sizegroup_id_seq'::regclass);


--
-- Name: basic_staff id; Type: DEFAULT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.basic_staff ALTER COLUMN id SET DEFAULT nextval('public.basic_staff_id_seq'::regclass);


--
-- Name: basic_subassembly id; Type: DEFAULT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.basic_subassembly ALTER COLUMN id SET DEFAULT nextval('public.basic_subassembly_id_seq'::regclass);


--
-- Name: basic_subassemblyattachment id; Type: DEFAULT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.basic_subassemblyattachment ALTER COLUMN id SET DEFAULT nextval('public.basic_subassemblyattachment_id_seq'::regclass);


--
-- Name: basic_subassemblytoworkstationhelper id; Type: DEFAULT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.basic_subassemblytoworkstationhelper ALTER COLUMN id SET DEFAULT nextval('public.basic_subassemblytoworkstationhelper_id_seq'::regclass);


--
-- Name: basic_substitutecomponent id; Type: DEFAULT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.basic_substitutecomponent ALTER COLUMN id SET DEFAULT nextval('public.basic_substitutecomponent_id_seq'::regclass);


--
-- Name: basic_technologicalprocessrate id; Type: DEFAULT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.basic_technologicalprocessrate ALTER COLUMN id SET DEFAULT nextval('public.basic_technologicalprocessrate_id_seq'::regclass);


--
-- Name: basic_technologicalprocessrateitem id; Type: DEFAULT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.basic_technologicalprocessrateitem ALTER COLUMN id SET DEFAULT nextval('public.basic_technologicalprocessrateitem_id_seq'::regclass);


--
-- Name: basic_viewedactivity id; Type: DEFAULT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.basic_viewedactivity ALTER COLUMN id SET DEFAULT nextval('public.basic_viewedactivity_id_seq'::regclass);


--
-- Name: basic_workstation id; Type: DEFAULT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.basic_workstation ALTER COLUMN id SET DEFAULT nextval('public.basic_workstation_id_seq'::regclass);


--
-- Name: basic_workstationattachment id; Type: DEFAULT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.basic_workstationattachment ALTER COLUMN id SET DEFAULT nextval('public.basic_workstationattachment_id_seq'::regclass);


--
-- Name: basic_workstationtype id; Type: DEFAULT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.basic_workstationtype ALTER COLUMN id SET DEFAULT nextval('public.basic_workstationtype_id_seq'::regclass);


--
-- Name: basicproductioncounting_basicproductioncounting id; Type: DEFAULT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.basicproductioncounting_basicproductioncounting ALTER COLUMN id SET DEFAULT nextval('public.basicproductioncounting_basicproductioncounting_id_seq'::regclass);


--
-- Name: basicproductioncounting_productioncountingattributevalue id; Type: DEFAULT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.basicproductioncounting_productioncountingattributevalue ALTER COLUMN id SET DEFAULT nextval('public.basicproductioncounting_productioncountingattributevalue_id_seq'::regclass);


--
-- Name: basicproductioncounting_productioncountingoperationrun id; Type: DEFAULT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.basicproductioncounting_productioncountingoperationrun ALTER COLUMN id SET DEFAULT nextval('public.basicproductioncounting_productioncountingoperationrun_id_seq'::regclass);


--
-- Name: basicproductioncounting_productioncountingquantity id; Type: DEFAULT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.basicproductioncounting_productioncountingquantity ALTER COLUMN id SET DEFAULT nextval('public.basicproductioncounting_productioncountingquantity_id_seq'::regclass);


--
-- Name: basicproductioncounting_productioncountingquantitychange id; Type: DEFAULT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.basicproductioncounting_productioncountingquantitychange ALTER COLUMN id SET DEFAULT nextval('public.basicproductioncounting_productioncountingquantitychange_id_seq'::regclass);


--
-- Name: basicproductioncounting_productioncountingreplacementhelper id; Type: DEFAULT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.basicproductioncounting_productioncountingreplacementhelper ALTER COLUMN id SET DEFAULT nextval('public.basicproductioncounting_productioncountingreplacementhelper_id_'::regclass);


--
-- Name: basicproductioncounting_section id; Type: DEFAULT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.basicproductioncounting_section ALTER COLUMN id SET DEFAULT nextval('public.basicproductioncounting_section_id_seq'::regclass);


--
-- Name: cdnrcgoodfood_cancelprotocol id; Type: DEFAULT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.cdnrcgoodfood_cancelprotocol ALTER COLUMN id SET DEFAULT nextval('public.cdnrcgoodfood_cancelprotocol_id_seq'::regclass);


--
-- Name: cdnrcgoodfood_highestmasterordernum id; Type: DEFAULT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.cdnrcgoodfood_highestmasterordernum ALTER COLUMN id SET DEFAULT nextval('public.cdnrcgoodfood_highestmasterordernum_id_seq'::regclass);


--
-- Name: cmmsmachineparts_action id; Type: DEFAULT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.cmmsmachineparts_action ALTER COLUMN id SET DEFAULT nextval('public.cmmsmachineparts_action_id_seq'::regclass);


--
-- Name: cmmsmachineparts_actionforplannedevent id; Type: DEFAULT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.cmmsmachineparts_actionforplannedevent ALTER COLUMN id SET DEFAULT nextval('public.cmmsmachineparts_actionforplannedevent_id_seq'::regclass);


--
-- Name: cmmsmachineparts_eventattachment id; Type: DEFAULT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.cmmsmachineparts_eventattachment ALTER COLUMN id SET DEFAULT nextval('public.cmmsmachineparts_eventattachment_id_seq'::regclass);


--
-- Name: cmmsmachineparts_machinepartattachment id; Type: DEFAULT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.cmmsmachineparts_machinepartattachment ALTER COLUMN id SET DEFAULT nextval('public.cmmsmachineparts_machinepartattachment_id_seq'::regclass);


--
-- Name: cmmsmachineparts_machinepartforevent id; Type: DEFAULT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.cmmsmachineparts_machinepartforevent ALTER COLUMN id SET DEFAULT nextval('public.cmmsmachineparts_machinepartforevent_id_seq'::regclass);


--
-- Name: cmmsmachineparts_maintenanceevent id; Type: DEFAULT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.cmmsmachineparts_maintenanceevent ALTER COLUMN id SET DEFAULT nextval('public.cmmsmachineparts_maintenanceevent_id_seq'::regclass);


--
-- Name: cmmsmachineparts_maintenanceeventcontext id; Type: DEFAULT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.cmmsmachineparts_maintenanceeventcontext ALTER COLUMN id SET DEFAULT nextval('public.cmmsmachineparts_maintenanceeventcontext_id_seq'::regclass);


--
-- Name: cmmsmachineparts_maintenanceeventstatechange id; Type: DEFAULT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.cmmsmachineparts_maintenanceeventstatechange ALTER COLUMN id SET DEFAULT nextval('public.cmmsmachineparts_maintenanceeventstatechange_id_seq'::regclass);


--
-- Name: cmmsmachineparts_operationtool id; Type: DEFAULT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.cmmsmachineparts_operationtool ALTER COLUMN id SET DEFAULT nextval('public.cmmsmachineparts_operationtool_id_seq'::regclass);


--
-- Name: cmmsmachineparts_orderstoolrequirement id; Type: DEFAULT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.cmmsmachineparts_orderstoolrequirement ALTER COLUMN id SET DEFAULT nextval('public.cmmsmachineparts_orderstoolrequirement_id_seq'::regclass);


--
-- Name: cmmsmachineparts_orderstoolrequirementtool id; Type: DEFAULT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.cmmsmachineparts_orderstoolrequirementtool ALTER COLUMN id SET DEFAULT nextval('public.cmmsmachineparts_orderstoolrequirementtool_id_seq'::regclass);


--
-- Name: cmmsmachineparts_plannedevent id; Type: DEFAULT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.cmmsmachineparts_plannedevent ALTER COLUMN id SET DEFAULT nextval('public.cmmsmachineparts_plannedevent_id_seq'::regclass);


--
-- Name: cmmsmachineparts_plannedeventattachment id; Type: DEFAULT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.cmmsmachineparts_plannedeventattachment ALTER COLUMN id SET DEFAULT nextval('public.cmmsmachineparts_plannedeventattachment_id_seq'::regclass);


--
-- Name: cmmsmachineparts_plannedeventcontext id; Type: DEFAULT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.cmmsmachineparts_plannedeventcontext ALTER COLUMN id SET DEFAULT nextval('public.cmmsmachineparts_plannedeventcontext_id_seq'::regclass);


--
-- Name: cmmsmachineparts_plannedeventrealization id; Type: DEFAULT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.cmmsmachineparts_plannedeventrealization ALTER COLUMN id SET DEFAULT nextval('public.cmmsmachineparts_plannedeventrealization_id_seq'::regclass);


--
-- Name: cmmsmachineparts_plannedeventstatechange id; Type: DEFAULT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.cmmsmachineparts_plannedeventstatechange ALTER COLUMN id SET DEFAULT nextval('public.cmmsmachineparts_plannedeventstatechange_id_seq'::regclass);


--
-- Name: cmmsmachineparts_plannedeventxlshelper id; Type: DEFAULT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.cmmsmachineparts_plannedeventxlshelper ALTER COLUMN id SET DEFAULT nextval('public.cmmsmachineparts_plannedeventxlshelper_id_seq'::regclass);


--
-- Name: cmmsmachineparts_sourcecost id; Type: DEFAULT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.cmmsmachineparts_sourcecost ALTER COLUMN id SET DEFAULT nextval('public.cmmsmachineparts_sourcecost_id_seq'::regclass);


--
-- Name: cmmsmachineparts_sourcecostreportfilter id; Type: DEFAULT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.cmmsmachineparts_sourcecostreportfilter ALTER COLUMN id SET DEFAULT nextval('public.cmmsmachineparts_sourcecostreportfilter_id_seq'::regclass);


--
-- Name: cmmsmachineparts_staffworktime id; Type: DEFAULT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.cmmsmachineparts_staffworktime ALTER COLUMN id SET DEFAULT nextval('public.cmmsmachineparts_staffworktime_id_seq'::regclass);


--
-- Name: cmmsmachineparts_technologyoperationtool id; Type: DEFAULT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.cmmsmachineparts_technologyoperationtool ALTER COLUMN id SET DEFAULT nextval('public.cmmsmachineparts_technologyoperationtool_id_seq'::regclass);


--
-- Name: cmmsmachineparts_timeusagereportfilter id; Type: DEFAULT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.cmmsmachineparts_timeusagereportfilter ALTER COLUMN id SET DEFAULT nextval('public.cmmsmachineparts_timeusagereportfilter_id_seq'::regclass);


--
-- Name: cmmsmachineparts_tool id; Type: DEFAULT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.cmmsmachineparts_tool ALTER COLUMN id SET DEFAULT nextval('public.cmmsmachineparts_tool_id_seq'::regclass);


--
-- Name: cmmsmachineparts_toolattachment id; Type: DEFAULT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.cmmsmachineparts_toolattachment ALTER COLUMN id SET DEFAULT nextval('public.cmmsmachineparts_toolattachment_id_seq'::regclass);


--
-- Name: cmmsscheduler_actionforrecurringevent id; Type: DEFAULT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.cmmsscheduler_actionforrecurringevent ALTER COLUMN id SET DEFAULT nextval('public.cmmsscheduler_actionforrecurringevent_id_seq'::regclass);


--
-- Name: cmmsscheduler_recurringevent id; Type: DEFAULT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.cmmsscheduler_recurringevent ALTER COLUMN id SET DEFAULT nextval('public.cmmsscheduler_recurringevent_id_seq'::regclass);


--
-- Name: cmmsscheduler_recurringeventattachment id; Type: DEFAULT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.cmmsscheduler_recurringeventattachment ALTER COLUMN id SET DEFAULT nextval('public.cmmsscheduler_recurringeventattachment_id_seq'::regclass);


--
-- Name: cmmsscheduler_recurringeventcontext id; Type: DEFAULT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.cmmsscheduler_recurringeventcontext ALTER COLUMN id SET DEFAULT nextval('public.cmmsscheduler_recurringeventcontext_id_seq'::regclass);


--
-- Name: cmmsscheduler_recurringeventstatechange id; Type: DEFAULT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.cmmsscheduler_recurringeventstatechange ALTER COLUMN id SET DEFAULT nextval('public.cmmsscheduler_recurringeventstatechange_id_seq'::regclass);


--
-- Name: costcalculation_additionaldirectcost id; Type: DEFAULT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.costcalculation_additionaldirectcost ALTER COLUMN id SET DEFAULT nextval('public.costcalculation_additionaldirectcost_id_seq'::regclass);


--
-- Name: costcalculation_additionaldirectcostitem id; Type: DEFAULT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.costcalculation_additionaldirectcostitem ALTER COLUMN id SET DEFAULT nextval('public.costcalculation_additionaldirectcostitem_id_seq'::regclass);


--
-- Name: costcalculation_calculationresult id; Type: DEFAULT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.costcalculation_calculationresult ALTER COLUMN id SET DEFAULT nextval('public.costcalculation_calculationresult_id_seq'::regclass);


--
-- Name: costcalculation_componentcost id; Type: DEFAULT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.costcalculation_componentcost ALTER COLUMN id SET DEFAULT nextval('public.costcalculation_componentcost_id_seq'::regclass);


--
-- Name: costcalculation_costcalculation id; Type: DEFAULT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.costcalculation_costcalculation ALTER COLUMN id SET DEFAULT nextval('public.costcalculation_costcalculation_id_seq'::regclass);


--
-- Name: costcalculation_orderadditionaldirectcost id; Type: DEFAULT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.costcalculation_orderadditionaldirectcost ALTER COLUMN id SET DEFAULT nextval('public.costcalculation_orderadditionaldirectcost_id_seq'::regclass);


--
-- Name: costcalculation_standardlaborcost id; Type: DEFAULT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.costcalculation_standardlaborcost ALTER COLUMN id SET DEFAULT nextval('public.costcalculation_standardlaborcost_id_seq'::regclass);


--
-- Name: costnormsformaterials_technologyinstoperproductincomp id; Type: DEFAULT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.costnormsformaterials_technologyinstoperproductincomp ALTER COLUMN id SET DEFAULT nextval('public.costnormsformaterials_technologyinstoperproductincomp_id_seq'::regclass);


--
-- Name: costnormsforoperation_calculationoperationcomponent id; Type: DEFAULT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.costnormsforoperation_calculationoperationcomponent ALTER COLUMN id SET DEFAULT nextval('public.costnormsforoperation_calculationoperationcomponent_id_seq'::regclass);


--
-- Name: deliveries_columnfordeliveries id; Type: DEFAULT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.deliveries_columnfordeliveries ALTER COLUMN id SET DEFAULT nextval('public.deliveries_columnfordeliveries_id_seq'::regclass);


--
-- Name: deliveries_columnfororders id; Type: DEFAULT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.deliveries_columnfororders ALTER COLUMN id SET DEFAULT nextval('public.deliveries_columnfororders_id_seq'::regclass);


--
-- Name: deliveries_companyproduct id; Type: DEFAULT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.deliveries_companyproduct ALTER COLUMN id SET DEFAULT nextval('public.deliveries_companyproduct_id_seq'::regclass);


--
-- Name: deliveries_deliveredpackage id; Type: DEFAULT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.deliveries_deliveredpackage ALTER COLUMN id SET DEFAULT nextval('public.deliveries_deliveredpackage_id_seq'::regclass);


--
-- Name: deliveries_deliveredproduct id; Type: DEFAULT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.deliveries_deliveredproduct ALTER COLUMN id SET DEFAULT nextval('public.deliveries_deliveredproduct_id_seq'::regclass);


--
-- Name: deliveries_deliveredproductattributeval id; Type: DEFAULT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.deliveries_deliveredproductattributeval ALTER COLUMN id SET DEFAULT nextval('public.deliveries_deliveredproductattributeval_id_seq'::regclass);


--
-- Name: deliveries_deliveredproductmulti id; Type: DEFAULT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.deliveries_deliveredproductmulti ALTER COLUMN id SET DEFAULT nextval('public.deliveries_deliveredproductmulti_id_seq'::regclass);


--
-- Name: deliveries_deliveredproductmultiposition id; Type: DEFAULT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.deliveries_deliveredproductmultiposition ALTER COLUMN id SET DEFAULT nextval('public.deliveries_deliveredproductmultiposition_id_seq'::regclass);


--
-- Name: deliveries_delivery id; Type: DEFAULT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.deliveries_delivery ALTER COLUMN id SET DEFAULT nextval('public.deliveries_delivery_id_seq'::regclass);


--
-- Name: deliveries_deliveryattachment id; Type: DEFAULT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.deliveries_deliveryattachment ALTER COLUMN id SET DEFAULT nextval('public.deliveries_deliveryattachment_id_seq'::regclass);


--
-- Name: deliveries_deliverybypallettypereport id; Type: DEFAULT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.deliveries_deliverybypallettypereport ALTER COLUMN id SET DEFAULT nextval('public.deliveries_deliverybypallettypereport_id_seq'::regclass);


--
-- Name: deliveries_deliverystatechange id; Type: DEFAULT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.deliveries_deliverystatechange ALTER COLUMN id SET DEFAULT nextval('public.deliveries_deliverystatechange_id_seq'::regclass);


--
-- Name: deliveries_orderedproduct id; Type: DEFAULT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.deliveries_orderedproduct ALTER COLUMN id SET DEFAULT nextval('public.deliveries_orderedproduct_id_seq'::regclass);


--
-- Name: deliveries_parameterdeliveryordercolumn id; Type: DEFAULT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.deliveries_parameterdeliveryordercolumn ALTER COLUMN id SET DEFAULT nextval('public.deliveries_parameterdeliveryordercolumn_id_seq'::regclass);


--
-- Name: emailnotifications_staffnotification id; Type: DEFAULT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.emailnotifications_staffnotification ALTER COLUMN id SET DEFAULT nextval('public.emailnotifications_staffnotification_id_seq'::regclass);


--
-- Name: goodfood_confectionadditionalinputproduct id; Type: DEFAULT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.goodfood_confectionadditionalinputproduct ALTER COLUMN id SET DEFAULT nextval('public.goodfood_confectionadditionalinputproduct_id_seq'::regclass);


--
-- Name: goodfood_confectioncontext id; Type: DEFAULT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.goodfood_confectioncontext ALTER COLUMN id SET DEFAULT nextval('public.goodfood_confectioncontext_id_seq'::regclass);


--
-- Name: goodfood_confectionfilmproduct id; Type: DEFAULT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.goodfood_confectionfilmproduct ALTER COLUMN id SET DEFAULT nextval('public.goodfood_confectionfilmproduct_id_seq'::regclass);


--
-- Name: goodfood_confectionfilmproductentry id; Type: DEFAULT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.goodfood_confectionfilmproductentry ALTER COLUMN id SET DEFAULT nextval('public.goodfood_confectionfilmproductentry_id_seq'::regclass);


--
-- Name: goodfood_confectioninputproduct id; Type: DEFAULT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.goodfood_confectioninputproduct ALTER COLUMN id SET DEFAULT nextval('public.goodfood_confectioninputproduct_id_seq'::regclass);


--
-- Name: goodfood_confectionprotocol id; Type: DEFAULT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.goodfood_confectionprotocol ALTER COLUMN id SET DEFAULT nextval('public.goodfood_confectionprotocol_id_seq'::regclass);


--
-- Name: goodfood_confectionprotocolcorrect id; Type: DEFAULT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.goodfood_confectionprotocolcorrect ALTER COLUMN id SET DEFAULT nextval('public.goodfood_confectionprotocolcorrect_id_seq'::regclass);


--
-- Name: goodfood_confectionprotocolstatechange id; Type: DEFAULT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.goodfood_confectionprotocolstatechange ALTER COLUMN id SET DEFAULT nextval('public.goodfood_confectionprotocolstatechange_id_seq'::regclass);


--
-- Name: goodfood_confectionremainderinputproduct id; Type: DEFAULT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.goodfood_confectionremainderinputproduct ALTER COLUMN id SET DEFAULT nextval('public.goodfood_confectionremainderinputproduct_id_seq'::regclass);


--
-- Name: goodfood_confectionstaff id; Type: DEFAULT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.goodfood_confectionstaff ALTER COLUMN id SET DEFAULT nextval('public.goodfood_confectionstaff_id_seq'::regclass);


--
-- Name: goodfood_eventlog id; Type: DEFAULT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.goodfood_eventlog ALTER COLUMN id SET DEFAULT nextval('public.goodfood_eventlog_id_seq'::regclass);


--
-- Name: goodfood_extrusionaddedmixentry id; Type: DEFAULT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.goodfood_extrusionaddedmixentry ALTER COLUMN id SET DEFAULT nextval('public.goodfood_extrusionaddedmixentry_id_seq'::regclass);


--
-- Name: goodfood_extrusionaddedmixingredient id; Type: DEFAULT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.goodfood_extrusionaddedmixingredient ALTER COLUMN id SET DEFAULT nextval('public.goodfood_extrusionaddedmixingredient_id_seq'::regclass);


--
-- Name: goodfood_extrusioncontext id; Type: DEFAULT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.goodfood_extrusioncontext ALTER COLUMN id SET DEFAULT nextval('public.goodfood_extrusioncontext_id_seq'::regclass);


--
-- Name: goodfood_extrusionmix id; Type: DEFAULT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.goodfood_extrusionmix ALTER COLUMN id SET DEFAULT nextval('public.goodfood_extrusionmix_id_seq'::regclass);


--
-- Name: goodfood_extrusionmixingredient id; Type: DEFAULT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.goodfood_extrusionmixingredient ALTER COLUMN id SET DEFAULT nextval('public.goodfood_extrusionmixingredient_id_seq'::regclass);


--
-- Name: goodfood_extrusionpouring id; Type: DEFAULT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.goodfood_extrusionpouring ALTER COLUMN id SET DEFAULT nextval('public.goodfood_extrusionpouring_id_seq'::regclass);


--
-- Name: goodfood_extrusionpouringingredient id; Type: DEFAULT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.goodfood_extrusionpouringingredient ALTER COLUMN id SET DEFAULT nextval('public.goodfood_extrusionpouringingredient_id_seq'::regclass);


--
-- Name: goodfood_extrusionpouringmix id; Type: DEFAULT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.goodfood_extrusionpouringmix ALTER COLUMN id SET DEFAULT nextval('public.goodfood_extrusionpouringmix_id_seq'::regclass);


--
-- Name: goodfood_extrusionprotocol id; Type: DEFAULT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.goodfood_extrusionprotocol ALTER COLUMN id SET DEFAULT nextval('public.goodfood_extrusionprotocol_id_seq'::regclass);


--
-- Name: goodfood_extrusionprotocolcorrect id; Type: DEFAULT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.goodfood_extrusionprotocolcorrect ALTER COLUMN id SET DEFAULT nextval('public.goodfood_extrusionprotocolcorrect_id_seq'::regclass);


--
-- Name: goodfood_extrusionprotocolstatechange id; Type: DEFAULT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.goodfood_extrusionprotocolstatechange ALTER COLUMN id SET DEFAULT nextval('public.goodfood_extrusionprotocolstatechange_id_seq'::regclass);


--
-- Name: goodfood_extrusionsouse id; Type: DEFAULT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.goodfood_extrusionsouse ALTER COLUMN id SET DEFAULT nextval('public.goodfood_extrusionsouse_id_seq'::regclass);


--
-- Name: goodfood_extrusiontakenoffmixentry id; Type: DEFAULT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.goodfood_extrusiontakenoffmixentry ALTER COLUMN id SET DEFAULT nextval('public.goodfood_extrusiontakenoffmixentry_id_seq'::regclass);


--
-- Name: goodfood_extrusiontakenoffmixingredient id; Type: DEFAULT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.goodfood_extrusiontakenoffmixingredient ALTER COLUMN id SET DEFAULT nextval('public.goodfood_extrusiontakenoffmixingredient_id_seq'::regclass);


--
-- Name: goodfood_goodfoodreport id; Type: DEFAULT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.goodfood_goodfoodreport ALTER COLUMN id SET DEFAULT nextval('public.goodfood_goodfoodreport_id_seq'::regclass);


--
-- Name: goodfood_pallet id; Type: DEFAULT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.goodfood_pallet ALTER COLUMN id SET DEFAULT nextval('public.goodfood_pallet_id_seq'::regclass);


--
-- Name: goodfood_palletcontext id; Type: DEFAULT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.goodfood_palletcontext ALTER COLUMN id SET DEFAULT nextval('public.goodfood_palletcontext_id_seq'::regclass);


--
-- Name: goodfood_palletlabel id; Type: DEFAULT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.goodfood_palletlabel ALTER COLUMN id SET DEFAULT nextval('public.goodfood_palletlabel_id_seq'::regclass);


--
-- Name: goodfood_palletlabelstatechange id; Type: DEFAULT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.goodfood_palletlabelstatechange ALTER COLUMN id SET DEFAULT nextval('public.goodfood_palletlabelstatechange_id_seq'::regclass);


--
-- Name: goodfood_palletstatechange id; Type: DEFAULT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.goodfood_palletstatechange ALTER COLUMN id SET DEFAULT nextval('public.goodfood_palletstatechange_id_seq'::regclass);


--
-- Name: goodfood_palnumber id; Type: DEFAULT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.goodfood_palnumber ALTER COLUMN id SET DEFAULT nextval('public.goodfood_palnumber_id_seq'::regclass);


--
-- Name: goodfood_printedlabel id; Type: DEFAULT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.goodfood_printedlabel ALTER COLUMN id SET DEFAULT nextval('public.goodfood_printedlabel_id_seq'::regclass);


--
-- Name: goodfood_ssccnumber id; Type: DEFAULT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.goodfood_ssccnumber ALTER COLUMN id SET DEFAULT nextval('public.goodfood_ssccnumber_id_seq'::regclass);


--
-- Name: integrationbartender_printlabelshelper id; Type: DEFAULT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.integrationbartender_printlabelshelper ALTER COLUMN id SET DEFAULT nextval('public.integrationbartender_printlabelshelper_id_seq'::regclass);


--
-- Name: integrationbartender_sendtoprint id; Type: DEFAULT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.integrationbartender_sendtoprint ALTER COLUMN id SET DEFAULT nextval('public.integrationbartender_sendtoprint_id_seq'::regclass);


--
-- Name: integrationbaselinker_baselinkerparameters id; Type: DEFAULT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.integrationbaselinker_baselinkerparameters ALTER COLUMN id SET DEFAULT nextval('public.integrationbaselinker_baselinkerparameters_id_seq'::regclass);


--
-- Name: integrationbaselinker_statusesfordocument id; Type: DEFAULT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.integrationbaselinker_statusesfordocument ALTER COLUMN id SET DEFAULT nextval('public.integrationbaselinker_statusesfordocument_id_seq'::regclass);


--
-- Name: integrationbaselinker_statusesformasterorder id; Type: DEFAULT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.integrationbaselinker_statusesformasterorder ALTER COLUMN id SET DEFAULT nextval('public.integrationbaselinker_statusesformasterorder_id_seq'::regclass);


--
-- Name: integrationscales_productionlineforscale id; Type: DEFAULT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.integrationscales_productionlineforscale ALTER COLUMN id SET DEFAULT nextval('public.integrationscales_productionlineforscale_id_seq'::regclass);


--
-- Name: integrationscales_scale id; Type: DEFAULT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.integrationscales_scale ALTER COLUMN id SET DEFAULT nextval('public.integrationscales_scale_id_seq'::regclass);


--
-- Name: linechangeovernorms_linechangeovernorms id; Type: DEFAULT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.linechangeovernorms_linechangeovernorms ALTER COLUMN id SET DEFAULT nextval('public.linechangeovernorms_linechangeovernorms_id_seq'::regclass);


--
-- Name: masterorders_generatingordershelper id; Type: DEFAULT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.masterorders_generatingordershelper ALTER COLUMN id SET DEFAULT nextval('public.masterorders_generatingordershelper_id_seq'::regclass);


--
-- Name: masterorders_masterorder id; Type: DEFAULT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.masterorders_masterorder ALTER COLUMN id SET DEFAULT nextval('public.masterorders_masterorder_id_seq'::regclass);


--
-- Name: masterorders_masterorderdefinition id; Type: DEFAULT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.masterorders_masterorderdefinition ALTER COLUMN id SET DEFAULT nextval('public.masterorders_masterorderdefinition_id_seq'::regclass);


--
-- Name: masterorders_masterorderproduct id; Type: DEFAULT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.masterorders_masterorderproduct ALTER COLUMN id SET DEFAULT nextval('public.masterorders_masterorderproduct_id_seq'::regclass);


--
-- Name: masterorders_masterorderproductattrvalue id; Type: DEFAULT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.masterorders_masterorderproductattrvalue ALTER COLUMN id SET DEFAULT nextval('public.masterorders_masterorderproductattrvalue_id_seq'::regclass);


--
-- Name: masterorders_masterordersmaterialrequirement id; Type: DEFAULT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.masterorders_masterordersmaterialrequirement ALTER COLUMN id SET DEFAULT nextval('public.masterorders_masterordersmaterialrequirement_id_seq'::regclass);


--
-- Name: masterorders_masterordersmaterialrequirementproduct id; Type: DEFAULT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.masterorders_masterordersmaterialrequirementproduct ALTER COLUMN id SET DEFAULT nextval('public.masterorders_masterordersmaterialrequirementproduct_id_seq'::regclass);


--
-- Name: masterorders_orderedproductconfigurator id; Type: DEFAULT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.masterorders_orderedproductconfigurator ALTER COLUMN id SET DEFAULT nextval('public.masterorders_orderedproductconfigurator_id_seq'::regclass);


--
-- Name: masterorders_orderedproductconfiguratorattribute id; Type: DEFAULT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.masterorders_orderedproductconfiguratorattribute ALTER COLUMN id SET DEFAULT nextval('public.masterorders_orderedproductconfiguratorattribute_id_seq'::regclass);


--
-- Name: masterorders_ordersgenerationhelper id; Type: DEFAULT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.masterorders_ordersgenerationhelper ALTER COLUMN id SET DEFAULT nextval('public.masterorders_ordersgenerationhelper_id_seq'::regclass);


--
-- Name: masterorders_outsourceprocessingcomponenthelper id; Type: DEFAULT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.masterorders_outsourceprocessingcomponenthelper ALTER COLUMN id SET DEFAULT nextval('public.masterorders_outsourceprocessingcomponenthelper_id_seq'::regclass);


--
-- Name: masterorders_position_deliveryproductquantityhelper id; Type: DEFAULT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.masterorders_position_deliveryproductquantityhelper ALTER COLUMN id SET DEFAULT nextval('public.masterorders_position_deliveryproductquantityhelper_id_seq'::regclass);


--
-- Name: masterorders_position_warehousestatehelper id; Type: DEFAULT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.masterorders_position_warehousestatehelper ALTER COLUMN id SET DEFAULT nextval('public.masterorders_position_warehousestatehelper_id_seq'::regclass);


--
-- Name: masterorders_priceslist id; Type: DEFAULT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.masterorders_priceslist ALTER COLUMN id SET DEFAULT nextval('public.masterorders_priceslist_id_seq'::regclass);


--
-- Name: masterorders_productsbyattributeentryhelper id; Type: DEFAULT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.masterorders_productsbyattributeentryhelper ALTER COLUMN id SET DEFAULT nextval('public.masterorders_productsbyattributeentryhelper_id_seq'::regclass);


--
-- Name: masterorders_productsbyattributehelper id; Type: DEFAULT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.masterorders_productsbyattributehelper ALTER COLUMN id SET DEFAULT nextval('public.masterorders_productsbyattributehelper_id_seq'::regclass);


--
-- Name: masterorders_productsbysizeentryhelper id; Type: DEFAULT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.masterorders_productsbysizeentryhelper ALTER COLUMN id SET DEFAULT nextval('public.masterorders_productsbysizeentryhelper_id_seq'::regclass);


--
-- Name: masterorders_productsbysizehelper id; Type: DEFAULT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.masterorders_productsbysizehelper ALTER COLUMN id SET DEFAULT nextval('public.masterorders_productsbysizehelper_id_seq'::regclass);


--
-- Name: masterorders_salesplan id; Type: DEFAULT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.masterorders_salesplan ALTER COLUMN id SET DEFAULT nextval('public.masterorders_salesplan_id_seq'::regclass);


--
-- Name: masterorders_salesplanmaterialrequirement id; Type: DEFAULT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.masterorders_salesplanmaterialrequirement ALTER COLUMN id SET DEFAULT nextval('public.masterorders_salesplanmaterialrequirement_id_seq'::regclass);


--
-- Name: masterorders_salesplanmaterialrequirementproduct id; Type: DEFAULT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.masterorders_salesplanmaterialrequirementproduct ALTER COLUMN id SET DEFAULT nextval('public.masterorders_salesplanmaterialrequirementproduct_id_seq'::regclass);


--
-- Name: masterorders_salesplanordersgroupentryhelper id; Type: DEFAULT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.masterorders_salesplanordersgroupentryhelper ALTER COLUMN id SET DEFAULT nextval('public.masterorders_salesplanordersgroupentryhelper_id_seq'::regclass);


--
-- Name: masterorders_salesplanordersgrouphelper id; Type: DEFAULT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.masterorders_salesplanordersgrouphelper ALTER COLUMN id SET DEFAULT nextval('public.masterorders_salesplanordersgrouphelper_id_seq'::regclass);


--
-- Name: masterorders_salesplanproduct id; Type: DEFAULT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.masterorders_salesplanproduct ALTER COLUMN id SET DEFAULT nextval('public.masterorders_salesplanproduct_id_seq'::regclass);


--
-- Name: masterorders_salesplanstatechange id; Type: DEFAULT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.masterorders_salesplanstatechange ALTER COLUMN id SET DEFAULT nextval('public.masterorders_salesplanstatechange_id_seq'::regclass);


--
-- Name: masterorders_salesvolume id; Type: DEFAULT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.masterorders_salesvolume ALTER COLUMN id SET DEFAULT nextval('public.masterorders_salesvolume_id_seq'::regclass);


--
-- Name: masterorders_salesvolumemulti id; Type: DEFAULT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.masterorders_salesvolumemulti ALTER COLUMN id SET DEFAULT nextval('public.masterorders_salesvolumemulti_id_seq'::regclass);


--
-- Name: materialflow_location id; Type: DEFAULT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.materialflow_location ALTER COLUMN id SET DEFAULT nextval('public.materialflow_location_id_seq'::regclass);


--
-- Name: materialflow_userlocation id; Type: DEFAULT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.materialflow_userlocation ALTER COLUMN id SET DEFAULT nextval('public.materialflow_userlocation_id_seq'::regclass);


--
-- Name: materialflowresources_costnormsgenerator id; Type: DEFAULT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.materialflowresources_costnormsgenerator ALTER COLUMN id SET DEFAULT nextval('public.materialflowresources_costnormsgenerator_id_seq'::regclass);


--
-- Name: materialflowresources_costnormslocation id; Type: DEFAULT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.materialflowresources_costnormslocation ALTER COLUMN id SET DEFAULT nextval('public.materialflowresources_costnormslocation_id_seq'::regclass);


--
-- Name: materialflowresources_document id; Type: DEFAULT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.materialflowresources_document ALTER COLUMN id SET DEFAULT nextval('public.materialflowresources_document_id_seq'::regclass);


--
-- Name: materialflowresources_documentpositionparameters id; Type: DEFAULT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.materialflowresources_documentpositionparameters ALTER COLUMN id SET DEFAULT nextval('public.materialflowresources_documentpositionparameters_id_seq'::regclass);


--
-- Name: materialflowresources_documentpositionparametersitem id; Type: DEFAULT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.materialflowresources_documentpositionparametersitem ALTER COLUMN id SET DEFAULT nextval('public.materialflowresources_documentpositionparametersitem_id_seq'::regclass);


--
-- Name: materialflowresources_documentstatechange id; Type: DEFAULT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.materialflowresources_documentstatechange ALTER COLUMN id SET DEFAULT nextval('public.materialflowresources_documentstatechange_id_seq'::regclass);


--
-- Name: materialflowresources_importstoragelocation id; Type: DEFAULT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.materialflowresources_importstoragelocation ALTER COLUMN id SET DEFAULT nextval('public.materialflowresources_importstoragelocation_id_seq'::regclass);


--
-- Name: materialflowresources_palletbalance id; Type: DEFAULT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.materialflowresources_palletbalance ALTER COLUMN id SET DEFAULT nextval('public.materialflowresources_palletbalance_id_seq'::regclass);


--
-- Name: materialflowresources_palletmovehelper id; Type: DEFAULT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.materialflowresources_palletmovehelper ALTER COLUMN id SET DEFAULT nextval('public.materialflowresources_palletmovehelper_id_seq'::regclass);


--
-- Name: materialflowresources_position id; Type: DEFAULT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.materialflowresources_position ALTER COLUMN id SET DEFAULT nextval('public.materialflowresources_position_id_seq'::regclass);


--
-- Name: materialflowresources_positionaddmultihelper id; Type: DEFAULT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.materialflowresources_positionaddmultihelper ALTER COLUMN id SET DEFAULT nextval('public.materialflowresources_positionaddmultihelper_id_seq'::regclass);


--
-- Name: materialflowresources_positionattributevalue id; Type: DEFAULT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.materialflowresources_positionattributevalue ALTER COLUMN id SET DEFAULT nextval('public.materialflowresources_positionattributevalue_id_seq'::regclass);


--
-- Name: materialflowresources_reservation id; Type: DEFAULT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.materialflowresources_reservation ALTER COLUMN id SET DEFAULT nextval('public.materialflowresources_reservation_id_seq'::regclass);


--
-- Name: materialflowresources_resource id; Type: DEFAULT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.materialflowresources_resource ALTER COLUMN id SET DEFAULT nextval('public.materialflowresources_resource_id_seq'::regclass);


--
-- Name: materialflowresources_resourceattributevalue id; Type: DEFAULT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.materialflowresources_resourceattributevalue ALTER COLUMN id SET DEFAULT nextval('public.materialflowresources_resourceattributevalue_id_seq'::regclass);


--
-- Name: materialflowresources_resourceattributevalueaftercorrection id; Type: DEFAULT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.materialflowresources_resourceattributevalueaftercorrection ALTER COLUMN id SET DEFAULT nextval('public.materialflowresources_resourceattributevalueaftercorrection_id_'::regclass);


--
-- Name: materialflowresources_resourceattributevaluebeforecorrection id; Type: DEFAULT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.materialflowresources_resourceattributevaluebeforecorrection ALTER COLUMN id SET DEFAULT nextval('public.materialflowresources_resourceattributevaluebeforecorrection_id'::regclass);


--
-- Name: materialflowresources_resourcecorrection id; Type: DEFAULT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.materialflowresources_resourcecorrection ALTER COLUMN id SET DEFAULT nextval('public.materialflowresources_resourcecorrection_id_seq'::regclass);


--
-- Name: materialflowresources_resourcestock id; Type: DEFAULT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.materialflowresources_resourcestock ALTER COLUMN id SET DEFAULT nextval('public.materialflowresources_resourcestock_id_seq'::regclass);


--
-- Name: materialflowresources_stocktaking id; Type: DEFAULT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.materialflowresources_stocktaking ALTER COLUMN id SET DEFAULT nextval('public.materialflowresources_stocktaking_id_seq'::regclass);


--
-- Name: materialflowresources_storagelocation id; Type: DEFAULT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.materialflowresources_storagelocation ALTER COLUMN id SET DEFAULT nextval('public.materialflowresources_storagelocation_id_seq'::regclass);


--
-- Name: materialflowresources_storagelocationhelper id; Type: DEFAULT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.materialflowresources_storagelocationhelper ALTER COLUMN id SET DEFAULT nextval('public.materialflowresources_storagelocationhelper_id_seq'::regclass);


--
-- Name: materialflowresources_storagelocationnumberhelper id; Type: DEFAULT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.materialflowresources_storagelocationnumberhelper ALTER COLUMN id SET DEFAULT nextval('public.materialflowresources_storagelocationnumberhelper_id_seq'::regclass);


--
-- Name: materialflowresources_warehousestockreport id; Type: DEFAULT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.materialflowresources_warehousestockreport ALTER COLUMN id SET DEFAULT nextval('public.materialflowresources_warehousestockreport_id_seq'::regclass);


--
-- Name: materialrequirementcoveragefororder_columnforcoveragesfororder id; Type: DEFAULT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.materialrequirementcoveragefororder_columnforcoveragesfororder ALTER COLUMN id SET DEFAULT nextval('public.materialrequirementcoveragefororder_columnforcoveragesfororder_'::regclass);


--
-- Name: materialrequirementcoveragefororder_coveragefororder id; Type: DEFAULT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.materialrequirementcoveragefororder_coveragefororder ALTER COLUMN id SET DEFAULT nextval('public.materialrequirementcoveragefororder_coveragefororder_id_seq'::regclass);


--
-- Name: materialrequirementcoveragefororder_coveragelocation id; Type: DEFAULT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.materialrequirementcoveragefororder_coveragelocation ALTER COLUMN id SET DEFAULT nextval('public.materialrequirementcoveragefororder_coveragelocation_id_seq'::regclass);


--
-- Name: materialrequirementcoveragefororder_coverageproduct id; Type: DEFAULT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.materialrequirementcoveragefororder_coverageproduct ALTER COLUMN id SET DEFAULT nextval('public.materialrequirementcoveragefororder_coverageproduct_id_seq'::regclass);


--
-- Name: materialrequirementcoveragefororder_coverageproductlogging id; Type: DEFAULT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.materialrequirementcoveragefororder_coverageproductlogging ALTER COLUMN id SET DEFAULT nextval('public.materialrequirementcoveragefororder_coverageproductlogging_id_s'::regclass);


--
-- Name: materialrequirements_materialrequirement id; Type: DEFAULT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.materialrequirements_materialrequirement ALTER COLUMN id SET DEFAULT nextval('public.materialrequirements_materialrequirement_id_seq'::regclass);


--
-- Name: materialrequirements_materialrequirementproduct id; Type: DEFAULT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.materialrequirements_materialrequirementproduct ALTER COLUMN id SET DEFAULT nextval('public.materialrequirements_materialrequirementproduct_id_seq'::regclass);


--
-- Name: mobilewms_wmsdocumentpart id; Type: DEFAULT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.mobilewms_wmsdocumentpart ALTER COLUMN id SET DEFAULT nextval('public.mobilewms_wmsdocumentpart_id_seq'::regclass);


--
-- Name: nutritionfacts_nutrientcalculation id; Type: DEFAULT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.nutritionfacts_nutrientcalculation ALTER COLUMN id SET DEFAULT nextval('public.nutritionfacts_nutrientcalculation_id_seq'::regclass);


--
-- Name: nutritionfacts_nutrition id; Type: DEFAULT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.nutritionfacts_nutrition ALTER COLUMN id SET DEFAULT nextval('public.nutritionfacts_nutrition_id_seq'::regclass);


--
-- Name: nutritionfacts_nutritionelement id; Type: DEFAULT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.nutritionfacts_nutritionelement ALTER COLUMN id SET DEFAULT nextval('public.nutritionfacts_nutritionelement_id_seq'::regclass);


--
-- Name: nutritionfacts_nutritiongroup id; Type: DEFAULT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.nutritionfacts_nutritiongroup ALTER COLUMN id SET DEFAULT nextval('public.nutritionfacts_nutritiongroup_id_seq'::regclass);


--
-- Name: nutritionfacts_prototypeproduct id; Type: DEFAULT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.nutritionfacts_prototypeproduct ALTER COLUMN id SET DEFAULT nextval('public.nutritionfacts_prototypeproduct_id_seq'::regclass);


--
-- Name: nutritionfacts_prototypeproductcomponent id; Type: DEFAULT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.nutritionfacts_prototypeproductcomponent ALTER COLUMN id SET DEFAULT nextval('public.nutritionfacts_prototypeproductcomponent_id_seq'::regclass);


--
-- Name: oee_oee id; Type: DEFAULT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.oee_oee ALTER COLUMN id SET DEFAULT nextval('public.oee_oee_id_seq'::regclass);


--
-- Name: oee_oeevalue id; Type: DEFAULT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.oee_oeevalue ALTER COLUMN id SET DEFAULT nextval('public.oee_oeevalue_id_seq'::regclass);


--
-- Name: orders_changedateshelper id; Type: DEFAULT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.orders_changedateshelper ALTER COLUMN id SET DEFAULT nextval('public.orders_changedateshelper_id_seq'::regclass);


--
-- Name: orders_dimensioncontrolattribute id; Type: DEFAULT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.orders_dimensioncontrolattribute ALTER COLUMN id SET DEFAULT nextval('public.orders_dimensioncontrolattribute_id_seq'::regclass);


--
-- Name: orders_operationaltask id; Type: DEFAULT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.orders_operationaltask ALTER COLUMN id SET DEFAULT nextval('public.orders_operationaltask_id_seq'::regclass);


--
-- Name: orders_operationaltaskstatechange id; Type: DEFAULT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.orders_operationaltaskstatechange ALTER COLUMN id SET DEFAULT nextval('public.orders_operationaltaskstatechange_id_seq'::regclass);


--
-- Name: orders_order id; Type: DEFAULT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.orders_order ALTER COLUMN id SET DEFAULT nextval('public.orders_order_id_seq'::regclass);


--
-- Name: orders_orderattachment id; Type: DEFAULT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.orders_orderattachment ALTER COLUMN id SET DEFAULT nextval('public.orders_orderattachment_id_seq'::regclass);


--
-- Name: orders_ordercategorycolor id; Type: DEFAULT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.orders_ordercategorycolor ALTER COLUMN id SET DEFAULT nextval('public.orders_ordercategorycolor_id_seq'::regclass);


--
-- Name: orders_orderpack id; Type: DEFAULT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.orders_orderpack ALTER COLUMN id SET DEFAULT nextval('public.orders_orderpack_id_seq'::regclass);


--
-- Name: orders_orderpackstatechange id; Type: DEFAULT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.orders_orderpackstatechange ALTER COLUMN id SET DEFAULT nextval('public.orders_orderpackstatechange_id_seq'::regclass);


--
-- Name: orders_orderstatechange id; Type: DEFAULT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.orders_orderstatechange ALTER COLUMN id SET DEFAULT nextval('public.orders_orderstatechange_id_seq'::regclass);


--
-- Name: orders_ordertechnologicalprocess id; Type: DEFAULT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.orders_ordertechnologicalprocess ALTER COLUMN id SET DEFAULT nextval('public.orders_ordertechnologicalprocess_id_seq'::regclass);


--
-- Name: orders_ordertechnologicalprocesspart id; Type: DEFAULT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.orders_ordertechnologicalprocesspart ALTER COLUMN id SET DEFAULT nextval('public.orders_ordertechnologicalprocesspart_id_seq'::regclass);


--
-- Name: orders_ordertechnologicalprocesswaste id; Type: DEFAULT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.orders_ordertechnologicalprocesswaste ALTER COLUMN id SET DEFAULT nextval('public.orders_ordertechnologicalprocesswaste_id_seq'::regclass);


--
-- Name: orders_productionlineschedule id; Type: DEFAULT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.orders_productionlineschedule ALTER COLUMN id SET DEFAULT nextval('public.orders_productionlineschedule_id_seq'::regclass);


--
-- Name: orders_productionlinescheduleposition id; Type: DEFAULT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.orders_productionlinescheduleposition ALTER COLUMN id SET DEFAULT nextval('public.orders_productionlinescheduleposition_id_seq'::regclass);


--
-- Name: orders_productionlineschedulestatechange id; Type: DEFAULT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.orders_productionlineschedulestatechange ALTER COLUMN id SET DEFAULT nextval('public.orders_productionlineschedulestatechange_id_seq'::regclass);


--
-- Name: orders_reasontypecorrectiondatefrom id; Type: DEFAULT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.orders_reasontypecorrectiondatefrom ALTER COLUMN id SET DEFAULT nextval('public.orders_reasontypecorrectiondatefrom_id_seq'::regclass);


--
-- Name: orders_reasontypecorrectiondateto id; Type: DEFAULT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.orders_reasontypecorrectiondateto ALTER COLUMN id SET DEFAULT nextval('public.orders_reasontypecorrectiondateto_id_seq'::regclass);


--
-- Name: orders_reasontypedeviationeffectiveend id; Type: DEFAULT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.orders_reasontypedeviationeffectiveend ALTER COLUMN id SET DEFAULT nextval('public.orders_reasontypedeviationeffectiveend_id_seq'::regclass);


--
-- Name: orders_reasontypedeviationeffectivestart id; Type: DEFAULT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.orders_reasontypedeviationeffectivestart ALTER COLUMN id SET DEFAULT nextval('public.orders_reasontypedeviationeffectivestart_id_seq'::regclass);


--
-- Name: orders_reasontypeofchangingorderstate id; Type: DEFAULT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.orders_reasontypeofchangingorderstate ALTER COLUMN id SET DEFAULT nextval('public.orders_reasontypeofchangingorderstate_id_seq'::regclass);


--
-- Name: orders_schedule id; Type: DEFAULT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.orders_schedule ALTER COLUMN id SET DEFAULT nextval('public.orders_schedule_id_seq'::regclass);


--
-- Name: orders_scheduleposition id; Type: DEFAULT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.orders_scheduleposition ALTER COLUMN id SET DEFAULT nextval('public.orders_scheduleposition_id_seq'::regclass);


--
-- Name: orders_schedulestatechange id; Type: DEFAULT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.orders_schedulestatechange ALTER COLUMN id SET DEFAULT nextval('public.orders_schedulestatechange_id_seq'::regclass);


--
-- Name: orders_setcategory id; Type: DEFAULT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.orders_setcategory ALTER COLUMN id SET DEFAULT nextval('public.orders_setcategory_id_seq'::regclass);


--
-- Name: orders_splitorderchild id; Type: DEFAULT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.orders_splitorderchild ALTER COLUMN id SET DEFAULT nextval('public.orders_splitorderchild_id_seq'::regclass);


--
-- Name: orders_splitorderhelper id; Type: DEFAULT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.orders_splitorderhelper ALTER COLUMN id SET DEFAULT nextval('public.orders_splitorderhelper_id_seq'::regclass);


--
-- Name: orders_splitorderparent id; Type: DEFAULT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.orders_splitorderparent ALTER COLUMN id SET DEFAULT nextval('public.orders_splitorderparent_id_seq'::regclass);


--
-- Name: orders_typeofcorrectioncauses id; Type: DEFAULT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.orders_typeofcorrectioncauses ALTER COLUMN id SET DEFAULT nextval('public.orders_typeofcorrectioncauses_id_seq'::regclass);


--
-- Name: orders_workstationchangeoverforoperationaltask id; Type: DEFAULT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.orders_workstationchangeoverforoperationaltask ALTER COLUMN id SET DEFAULT nextval('public.orders_workstationchangeoverforoperationaltask_id_seq'::regclass);


--
-- Name: orders_workstationchangeoverforscheduleposition id; Type: DEFAULT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.orders_workstationchangeoverforscheduleposition ALTER COLUMN id SET DEFAULT nextval('public.orders_workstationchangeoverforscheduleposition_id_seq'::regclass);


--
-- Name: ordersforsubproductsgeneration_suborders id; Type: DEFAULT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.ordersforsubproductsgeneration_suborders ALTER COLUMN id SET DEFAULT nextval('public.ordersforsubproductsgeneration_suborders_id_seq'::regclass);


--
-- Name: ordersgantt_ordersganttparameters id; Type: DEFAULT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.ordersgantt_ordersganttparameters ALTER COLUMN id SET DEFAULT nextval('public.ordersgantt_ordersganttparameters_id_seq'::regclass);


--
-- Name: ordersgroups_ordersgroup id; Type: DEFAULT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.ordersgroups_ordersgroup ALTER COLUMN id SET DEFAULT nextval('public.ordersgroups_ordersgroup_id_seq'::regclass);


--
-- Name: ordersgroups_ordersgroupissuedmaterial id; Type: DEFAULT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.ordersgroups_ordersgroupissuedmaterial ALTER COLUMN id SET DEFAULT nextval('public.ordersgroups_ordersgroupissuedmaterial_id_seq'::regclass);


--
-- Name: ordersgroups_ordersgroupissuedmaterialposition id; Type: DEFAULT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.ordersgroups_ordersgroupissuedmaterialposition ALTER COLUMN id SET DEFAULT nextval('public.ordersgroups_ordersgroupissuedmaterialposition_id_seq'::regclass);


--
-- Name: ordersgroups_ordersgroupmaterialrequirement id; Type: DEFAULT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.ordersgroups_ordersgroupmaterialrequirement ALTER COLUMN id SET DEFAULT nextval('public.ordersgroups_ordersgroupmaterialrequirement_id_seq'::regclass);


--
-- Name: ordersgroups_ordersgroupmaterialrequirementproduct id; Type: DEFAULT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.ordersgroups_ordersgroupmaterialrequirementproduct ALTER COLUMN id SET DEFAULT nextval('public.ordersgroups_ordersgroupmaterialrequirementproduct_id_seq'::regclass);


--
-- Name: ordersgroups_ordersgroupproducedproduct id; Type: DEFAULT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.ordersgroups_ordersgroupproducedproduct ALTER COLUMN id SET DEFAULT nextval('public.ordersgroups_ordersgroupproducedproduct_id_seq'::regclass);


--
-- Name: ordersgroups_ordersgroupproductstoissueentryhelper id; Type: DEFAULT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.ordersgroups_ordersgroupproductstoissueentryhelper ALTER COLUMN id SET DEFAULT nextval('public.ordersgroups_ordersgroupproductstoissueentryhelper_id_seq'::regclass);


--
-- Name: ordersgroups_ordersgroupproductstoissuehelper id; Type: DEFAULT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.ordersgroups_ordersgroupproductstoissuehelper ALTER COLUMN id SET DEFAULT nextval('public.ordersgroups_ordersgroupproductstoissuehelper_id_seq'::regclass);


--
-- Name: ordersgroups_productionbalance id; Type: DEFAULT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.ordersgroups_productionbalance ALTER COLUMN id SET DEFAULT nextval('public.ordersgroups_productionbalance_id_seq'::regclass);


--
-- Name: ordersgroups_sizegroupcolor id; Type: DEFAULT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.ordersgroups_sizegroupcolor ALTER COLUMN id SET DEFAULT nextval('public.ordersgroups_sizegroupcolor_id_seq'::regclass);


--
-- Name: ordersupplies_columnforcoverages id; Type: DEFAULT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.ordersupplies_columnforcoverages ALTER COLUMN id SET DEFAULT nextval('public.ordersupplies_columnforcoverages_id_seq'::regclass);


--
-- Name: ordersupplies_coverageanalysisfororder id; Type: DEFAULT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.ordersupplies_coverageanalysisfororder ALTER COLUMN id SET DEFAULT nextval('public.ordersupplies_coverageanalysisfororder_id_seq'::regclass);


--
-- Name: ordersupplies_coveragelocation id; Type: DEFAULT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.ordersupplies_coveragelocation ALTER COLUMN id SET DEFAULT nextval('public.ordersupplies_coveragelocation_id_seq'::regclass);


--
-- Name: ordersupplies_coverageorderstate id; Type: DEFAULT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.ordersupplies_coverageorderstate ALTER COLUMN id SET DEFAULT nextval('public.ordersupplies_coverageorderstate_id_seq'::regclass);


--
-- Name: ordersupplies_coverageproductgenerated id; Type: DEFAULT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.ordersupplies_coverageproductgenerated ALTER COLUMN id SET DEFAULT nextval('public.ordersupplies_coverageproductgenerated_id_seq'::regclass);


--
-- Name: ordersupplies_coverageproductselected id; Type: DEFAULT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.ordersupplies_coverageproductselected ALTER COLUMN id SET DEFAULT nextval('public.ordersupplies_coverageproductselected_id_seq'::regclass);


--
-- Name: ordersupplies_materialrequirementcoverage id; Type: DEFAULT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.ordersupplies_materialrequirementcoverage ALTER COLUMN id SET DEFAULT nextval('public.ordersupplies_materialrequirementcoverage_id_seq'::regclass);


--
-- Name: productcatalognumbers_productcatalognumbers id; Type: DEFAULT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.productcatalognumbers_productcatalognumbers ALTER COLUMN id SET DEFAULT nextval('public.productcatalognumbers_productcatalognumbers_id_seq'::regclass);


--
-- Name: productflowthrudivision_issue id; Type: DEFAULT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.productflowthrudivision_issue ALTER COLUMN id SET DEFAULT nextval('public.productflowthrudivision_issue_id_seq'::regclass);


--
-- Name: productflowthrudivision_materialavailability id; Type: DEFAULT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.productflowthrudivision_materialavailability ALTER COLUMN id SET DEFAULT nextval('public.productflowthrudivision_materialavailability_id_seq'::regclass);


--
-- Name: productflowthrudivision_modelcard id; Type: DEFAULT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.productflowthrudivision_modelcard ALTER COLUMN id SET DEFAULT nextval('public.productflowthrudivision_modelcard_id_seq'::regclass);


--
-- Name: productflowthrudivision_modelcardproduct id; Type: DEFAULT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.productflowthrudivision_modelcardproduct ALTER COLUMN id SET DEFAULT nextval('public.productflowthrudivision_modelcardproduct_id_seq'::regclass);


--
-- Name: productflowthrudivision_opertaskmaterialavailability id; Type: DEFAULT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.productflowthrudivision_opertaskmaterialavailability ALTER COLUMN id SET DEFAULT nextval('public.productflowthrudivision_opertaskmaterialavailability_id_seq'::regclass);


--
-- Name: productflowthrudivision_orderproductresourcereservation id; Type: DEFAULT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.productflowthrudivision_orderproductresourcereservation ALTER COLUMN id SET DEFAULT nextval('public.productflowthrudivision_orderproductresourcereservation_id_seq'::regclass);


--
-- Name: productflowthrudivision_productandquantityhelper id; Type: DEFAULT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.productflowthrudivision_productandquantityhelper ALTER COLUMN id SET DEFAULT nextval('public.productflowthrudivision_productandquantityhelper_id_seq'::regclass);


--
-- Name: productflowthrudivision_productstoissue id; Type: DEFAULT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.productflowthrudivision_productstoissue ALTER COLUMN id SET DEFAULT nextval('public.productflowthrudivision_productstoissue_id_seq'::regclass);


--
-- Name: productflowthrudivision_productstoissuehelper id; Type: DEFAULT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.productflowthrudivision_productstoissuehelper ALTER COLUMN id SET DEFAULT nextval('public.productflowthrudivision_productstoissuehelper_id_seq'::regclass);


--
-- Name: productflowthrudivision_producttoissuecorrection id; Type: DEFAULT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.productflowthrudivision_producttoissuecorrection ALTER COLUMN id SET DEFAULT nextval('public.productflowthrudivision_producttoissuecorrection_id_seq'::regclass);


--
-- Name: productflowthrudivision_producttoissuecorrectionhelper id; Type: DEFAULT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.productflowthrudivision_producttoissuecorrectionhelper ALTER COLUMN id SET DEFAULT nextval('public.productflowthrudivision_producttoissuecorrectionhelper_id_seq'::regclass);


--
-- Name: productflowthrudivision_trackingproductresourcereservation id; Type: DEFAULT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.productflowthrudivision_trackingproductresourcereservation ALTER COLUMN id SET DEFAULT nextval('public.productflowthrudivision_trackingproductresourcereservation_id_s'::regclass);


--
-- Name: productflowthrudivision_warehouseissue id; Type: DEFAULT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.productflowthrudivision_warehouseissue ALTER COLUMN id SET DEFAULT nextval('public.productflowthrudivision_warehouseissue_id_seq'::regclass);


--
-- Name: productflowthrudivision_warehouseissuestatechange id; Type: DEFAULT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.productflowthrudivision_warehouseissuestatechange ALTER COLUMN id SET DEFAULT nextval('public.productflowthrudivision_warehouseissuestatechange_id_seq'::regclass);


--
-- Name: productioncounting_anomaly id; Type: DEFAULT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.productioncounting_anomaly ALTER COLUMN id SET DEFAULT nextval('public.productioncounting_anomaly_id_seq'::regclass);


--
-- Name: productioncounting_anomalyexplanation id; Type: DEFAULT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.productioncounting_anomalyexplanation ALTER COLUMN id SET DEFAULT nextval('public.productioncounting_anomalyexplanation_id_seq'::regclass);


--
-- Name: productioncounting_anomalyproductiontrackingentryhelper id; Type: DEFAULT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.productioncounting_anomalyproductiontrackingentryhelper ALTER COLUMN id SET DEFAULT nextval('public.productioncounting_anomalyproductiontrackingentryhelper_id_seq'::regclass);


--
-- Name: productioncounting_anomalyproductiontrackinghelper id; Type: DEFAULT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.productioncounting_anomalyproductiontrackinghelper ALTER COLUMN id SET DEFAULT nextval('public.productioncounting_anomalyproductiontrackinghelper_id_seq'::regclass);


--
-- Name: productioncounting_anomalyreason id; Type: DEFAULT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.productioncounting_anomalyreason ALTER COLUMN id SET DEFAULT nextval('public.productioncounting_anomalyreason_id_seq'::regclass);


--
-- Name: productioncounting_anomalyreasoncontainer id; Type: DEFAULT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.productioncounting_anomalyreasoncontainer ALTER COLUMN id SET DEFAULT nextval('public.productioncounting_anomalyreasoncontainer_id_seq'::regclass);


--
-- Name: productioncounting_lack id; Type: DEFAULT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.productioncounting_lack ALTER COLUMN id SET DEFAULT nextval('public.productioncounting_lack_id_seq'::regclass);


--
-- Name: productioncounting_lackreason id; Type: DEFAULT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.productioncounting_lackreason ALTER COLUMN id SET DEFAULT nextval('public.productioncounting_lackreason_id_seq'::regclass);


--
-- Name: productioncounting_orderbalance id; Type: DEFAULT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.productioncounting_orderbalance ALTER COLUMN id SET DEFAULT nextval('public.productioncounting_orderbalance_id_seq'::regclass);


--
-- Name: productioncounting_prodoutresourceattrval id; Type: DEFAULT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.productioncounting_prodoutresourceattrval ALTER COLUMN id SET DEFAULT nextval('public.productioncounting_prodoutresourceattrval_id_seq'::regclass);


--
-- Name: productioncounting_productionbalance id; Type: DEFAULT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.productioncounting_productionbalance ALTER COLUMN id SET DEFAULT nextval('public.productioncounting_productionbalance_id_seq'::regclass);


--
-- Name: productioncounting_productiontracking id; Type: DEFAULT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.productioncounting_productiontracking ALTER COLUMN id SET DEFAULT nextval('public.productioncounting_productiontracking_id_seq'::regclass);


--
-- Name: productioncounting_productiontrackingattachment id; Type: DEFAULT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.productioncounting_productiontrackingattachment ALTER COLUMN id SET DEFAULT nextval('public.productioncounting_productiontrackingattachment_id_seq'::regclass);


--
-- Name: productioncounting_productiontrackingstatechange id; Type: DEFAULT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.productioncounting_productiontrackingstatechange ALTER COLUMN id SET DEFAULT nextval('public.productioncounting_productiontrackingstatechange_id_seq'::regclass);


--
-- Name: productioncounting_staffworktime id; Type: DEFAULT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.productioncounting_staffworktime ALTER COLUMN id SET DEFAULT nextval('public.productioncounting_staffworktime_id_seq'::regclass);


--
-- Name: productioncounting_trackinginproductreplacementhelper id; Type: DEFAULT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.productioncounting_trackinginproductreplacementhelper ALTER COLUMN id SET DEFAULT nextval('public.productioncounting_trackinginproductreplacementhelper_id_seq'::regclass);


--
-- Name: productioncounting_trackingoperationproductincomponent id; Type: DEFAULT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.productioncounting_trackingoperationproductincomponent ALTER COLUMN id SET DEFAULT nextval('public.productioncounting_trackingoperationproductincomponent_id_seq'::regclass);


--
-- Name: productioncounting_trackingoperationproductoutcomponent id; Type: DEFAULT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.productioncounting_trackingoperationproductoutcomponent ALTER COLUMN id SET DEFAULT nextval('public.productioncounting_trackingoperationproductoutcomponent_id_seq'::regclass);


--
-- Name: productioncounting_usedbatch id; Type: DEFAULT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.productioncounting_usedbatch ALTER COLUMN id SET DEFAULT nextval('public.productioncounting_usedbatch_id_seq'::regclass);


--
-- Name: productionlines_factorystructureelement id; Type: DEFAULT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.productionlines_factorystructureelement ALTER COLUMN id SET DEFAULT nextval('public.productionlines_factorystructureelement_id_seq'::regclass);


--
-- Name: productionlines_productionline id; Type: DEFAULT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.productionlines_productionline ALTER COLUMN id SET DEFAULT nextval('public.productionlines_productionline_id_seq'::regclass);


--
-- Name: productionlines_workstationtypecomponent id; Type: DEFAULT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.productionlines_workstationtypecomponent ALTER COLUMN id SET DEFAULT nextval('public.productionlines_workstationtypecomponent_id_seq'::regclass);


--
-- Name: productionpershift_balance id; Type: DEFAULT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.productionpershift_balance ALTER COLUMN id SET DEFAULT nextval('public.productionpershift_balance_id_seq'::regclass);


--
-- Name: productionpershift_balancecontext id; Type: DEFAULT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.productionpershift_balancecontext ALTER COLUMN id SET DEFAULT nextval('public.productionpershift_balancecontext_id_seq'::regclass);


--
-- Name: productionpershift_dailyprogress id; Type: DEFAULT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.productionpershift_dailyprogress ALTER COLUMN id SET DEFAULT nextval('public.productionpershift_dailyprogress_id_seq'::regclass);


--
-- Name: productionpershift_plandailyprogress id; Type: DEFAULT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.productionpershift_plandailyprogress ALTER COLUMN id SET DEFAULT nextval('public.productionpershift_plandailyprogress_id_seq'::regclass);


--
-- Name: productionpershift_planproductionpershift id; Type: DEFAULT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.productionpershift_planproductionpershift ALTER COLUMN id SET DEFAULT nextval('public.productionpershift_planproductionpershift_id_seq'::regclass);


--
-- Name: productionpershift_planprogressforday id; Type: DEFAULT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.productionpershift_planprogressforday ALTER COLUMN id SET DEFAULT nextval('public.productionpershift_planprogressforday_id_seq'::regclass);


--
-- Name: productionpershift_ppsreport id; Type: DEFAULT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.productionpershift_ppsreport ALTER COLUMN id SET DEFAULT nextval('public.productionpershift_ppsreport_id_seq'::regclass);


--
-- Name: productionpershift_productionpershift id; Type: DEFAULT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.productionpershift_productionpershift ALTER COLUMN id SET DEFAULT nextval('public.productionpershift_productionpershift_id_seq'::regclass);


--
-- Name: productionpershift_progressforday id; Type: DEFAULT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.productionpershift_progressforday ALTER COLUMN id SET DEFAULT nextval('public.productionpershift_progressforday_id_seq'::regclass);


--
-- Name: productionpershift_reasontypeofcorrectionplan id; Type: DEFAULT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.productionpershift_reasontypeofcorrectionplan ALTER COLUMN id SET DEFAULT nextval('public.productionpershift_reasontypeofcorrectionplan_id_seq'::regclass);


--
-- Name: productionplans_dimensioncontrolattribute id; Type: DEFAULT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.productionplans_dimensioncontrolattribute ALTER COLUMN id SET DEFAULT nextval('public.productionplans_dimensioncontrolattribute_id_seq'::regclass);


--
-- Name: productionscheduling_opercomptimecalculation id; Type: DEFAULT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.productionscheduling_opercomptimecalculation ALTER COLUMN id SET DEFAULT nextval('public.productionscheduling_opercomptimecalculation_id_seq'::regclass);


--
-- Name: productionscheduling_ordertimecalculation id; Type: DEFAULT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.productionscheduling_ordertimecalculation ALTER COLUMN id SET DEFAULT nextval('public.productionscheduling_ordertimecalculation_id_seq'::regclass);


--
-- Name: productionscheduling_planopercomptimecalculation id; Type: DEFAULT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.productionscheduling_planopercomptimecalculation ALTER COLUMN id SET DEFAULT nextval('public.productionscheduling_planopercomptimecalculation_id_seq'::regclass);


--
-- Name: productionscheduling_planordertimecalculation id; Type: DEFAULT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.productionscheduling_planordertimecalculation ALTER COLUMN id SET DEFAULT nextval('public.productionscheduling_planordertimecalculation_id_seq'::regclass);


--
-- Name: qcadoocustomtranslation_customtranslation id; Type: DEFAULT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.qcadoocustomtranslation_customtranslation ALTER COLUMN id SET DEFAULT nextval('public.qcadoocustomtranslation_customtranslation_id_seq'::regclass);


--
-- Name: qcadoomodel_dictionary id; Type: DEFAULT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.qcadoomodel_dictionary ALTER COLUMN id SET DEFAULT nextval('public.qcadoomodel_dictionary_id_seq'::regclass);


--
-- Name: qcadoomodel_dictionaryitem id; Type: DEFAULT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.qcadoomodel_dictionaryitem ALTER COLUMN id SET DEFAULT nextval('public.qcadoomodel_dictionaryitem_id_seq'::regclass);


--
-- Name: qcadoomodel_globalunitconversionsaggregate id; Type: DEFAULT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.qcadoomodel_globalunitconversionsaggregate ALTER COLUMN id SET DEFAULT nextval('public.qcadoomodel_globalunitconversionsaggregate_id_seq'::regclass);


--
-- Name: qcadoomodel_unitconversionitem id; Type: DEFAULT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.qcadoomodel_unitconversionitem ALTER COLUMN id SET DEFAULT nextval('public.qcadoomodel_unitconversionitem_id_seq'::regclass);


--
-- Name: qcadooplugin_plugin id; Type: DEFAULT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.qcadooplugin_plugin ALTER COLUMN id SET DEFAULT nextval('public.qcadooplugin_plugin_id_seq'::regclass);


--
-- Name: qcadoosecurity_group id; Type: DEFAULT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.qcadoosecurity_group ALTER COLUMN id SET DEFAULT nextval('public.qcadoosecurity_group_id_seq'::regclass);


--
-- Name: qcadoosecurity_passwordresettoken id; Type: DEFAULT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.qcadoosecurity_passwordresettoken ALTER COLUMN id SET DEFAULT nextval('public.qcadoosecurity_passwordresettoken_id_seq'::regclass);


--
-- Name: qcadoosecurity_persistenttoken id; Type: DEFAULT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.qcadoosecurity_persistenttoken ALTER COLUMN id SET DEFAULT nextval('public.qcadoosecurity_persistenttoken_id_seq'::regclass);


--
-- Name: qcadoosecurity_role id; Type: DEFAULT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.qcadoosecurity_role ALTER COLUMN id SET DEFAULT nextval('public.qcadoosecurity_role_id_seq'::regclass);


--
-- Name: qcadoosecurity_user id; Type: DEFAULT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.qcadoosecurity_user ALTER COLUMN id SET DEFAULT nextval('public.qcadoosecurity_user_id_seq'::regclass);


--
-- Name: qcadooview_alert id; Type: DEFAULT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.qcadooview_alert ALTER COLUMN id SET DEFAULT nextval('public.qcadooview_alert_id_seq'::regclass);


--
-- Name: qcadooview_category id; Type: DEFAULT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.qcadooview_category ALTER COLUMN id SET DEFAULT nextval('public.qcadooview_category_id_seq'::regclass);


--
-- Name: qcadooview_item id; Type: DEFAULT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.qcadooview_item ALTER COLUMN id SET DEFAULT nextval('public.qcadooview_item_id_seq'::regclass);


--
-- Name: qcadooview_systeminfo id; Type: DEFAULT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.qcadooview_systeminfo ALTER COLUMN id SET DEFAULT nextval('public.qcadooview_systeminfo_id_seq'::regclass);


--
-- Name: qcadooview_view id; Type: DEFAULT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.qcadooview_view ALTER COLUMN id SET DEFAULT nextval('public.qcadooview_view_id_seq'::regclass);


--
-- Name: qcadooview_viewedalert id; Type: DEFAULT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.qcadooview_viewedalert ALTER COLUMN id SET DEFAULT nextval('public.qcadooview_viewedalert_id_seq'::regclass);


--
-- Name: qualitycontrol_changequalitycards id; Type: DEFAULT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.qualitycontrol_changequalitycards ALTER COLUMN id SET DEFAULT nextval('public.qualitycontrol_changequalitycards_id_seq'::regclass);


--
-- Name: qualitycontrol_deliveryqualitycontrol id; Type: DEFAULT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.qualitycontrol_deliveryqualitycontrol ALTER COLUMN id SET DEFAULT nextval('public.qualitycontrol_deliveryqualitycontrol_id_seq'::regclass);


--
-- Name: qualitycontrol_qualitycardattachment id; Type: DEFAULT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.qualitycontrol_qualitycardattachment ALTER COLUMN id SET DEFAULT nextval('public.qualitycontrol_qualitycardattachment_id_seq'::regclass);


--
-- Name: qualitycontrol_qualitycontrol id; Type: DEFAULT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.qualitycontrol_qualitycontrol ALTER COLUMN id SET DEFAULT nextval('public.qualitycontrol_qualitycontrol_id_seq'::regclass);


--
-- Name: qualitycontrol_qualitycontrolattachment id; Type: DEFAULT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.qualitycontrol_qualitycontrolattachment ALTER COLUMN id SET DEFAULT nextval('public.qualitycontrol_qualitycontrolattachment_id_seq'::regclass);


--
-- Name: qualitycontrol_qualitycontrolattribute id; Type: DEFAULT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.qualitycontrol_qualitycontrolattribute ALTER COLUMN id SET DEFAULT nextval('public.qualitycontrol_qualitycontrolattribute_id_seq'::regclass);


--
-- Name: qualitycontrol_qualitycontrolattributedeliveredprod id; Type: DEFAULT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.qualitycontrol_qualitycontrolattributedeliveredprod ALTER COLUMN id SET DEFAULT nextval('public.qualitycontrol_qualitycontrolattributedeliveredprod_id_seq'::regclass);


--
-- Name: qualitycontrol_qualitycontrolattributeprodtracking id; Type: DEFAULT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.qualitycontrol_qualitycontrolattributeprodtracking ALTER COLUMN id SET DEFAULT nextval('public.qualitycontrol_qualitycontrolattributeprodtracking_id_seq'::regclass);


--
-- Name: qualitycontrol_qualitycontrolattributetoc id; Type: DEFAULT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.qualitycontrol_qualitycontrolattributetoc ALTER COLUMN id SET DEFAULT nextval('public.qualitycontrol_qualitycontrolattributetoc_id_seq'::regclass);


--
-- Name: qualitycontrol_qualitycontrolattributevalue id; Type: DEFAULT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.qualitycontrol_qualitycontrolattributevalue ALTER COLUMN id SET DEFAULT nextval('public.qualitycontrol_qualitycontrolattributevalue_id_seq'::regclass);


--
-- Name: qualitycontrol_qualitycontrolresource id; Type: DEFAULT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.qualitycontrol_qualitycontrolresource ALTER COLUMN id SET DEFAULT nextval('public.qualitycontrol_qualitycontrolresource_id_seq'::regclass);


--
-- Name: qualitycontrol_qualitycontrolstatechange id; Type: DEFAULT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.qualitycontrol_qualitycontrolstatechange ALTER COLUMN id SET DEFAULT nextval('public.qualitycontrol_qualitycontrolstatechange_id_seq'::regclass);


--
-- Name: qualitycontrol_qualitydeliveredproduct id; Type: DEFAULT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.qualitycontrol_qualitydeliveredproduct ALTER COLUMN id SET DEFAULT nextval('public.qualitycontrol_qualitydeliveredproduct_id_seq'::regclass);


--
-- Name: repairs_repairorder id; Type: DEFAULT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.repairs_repairorder ALTER COLUMN id SET DEFAULT nextval('public.repairs_repairorder_id_seq'::regclass);


--
-- Name: repairs_repairorderproduct id; Type: DEFAULT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.repairs_repairorderproduct ALTER COLUMN id SET DEFAULT nextval('public.repairs_repairorderproduct_id_seq'::regclass);


--
-- Name: repairs_repairorderstatechange id; Type: DEFAULT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.repairs_repairorderstatechange ALTER COLUMN id SET DEFAULT nextval('public.repairs_repairorderstatechange_id_seq'::regclass);


--
-- Name: repairs_repairorderworktime id; Type: DEFAULT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.repairs_repairorderworktime ALTER COLUMN id SET DEFAULT nextval('public.repairs_repairorderworktime_id_seq'::regclass);


--
-- Name: states_message id; Type: DEFAULT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.states_message ALTER COLUMN id SET DEFAULT nextval('public.states_message_id_seq'::regclass);


--
-- Name: stoppage_stoppage id; Type: DEFAULT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.stoppage_stoppage ALTER COLUMN id SET DEFAULT nextval('public.stoppage_stoppage_id_seq'::regclass);


--
-- Name: stoppage_stoppagereason id; Type: DEFAULT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.stoppage_stoppagereason ALTER COLUMN id SET DEFAULT nextval('public.stoppage_stoppagereason_id_seq'::regclass);


--
-- Name: subcontractorportal_operation id; Type: DEFAULT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.subcontractorportal_operation ALTER COLUMN id SET DEFAULT nextval('public.subcontractorportal_operation_id_seq'::regclass);


--
-- Name: subcontractorportal_suborder id; Type: DEFAULT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.subcontractorportal_suborder ALTER COLUMN id SET DEFAULT nextval('public.subcontractorportal_suborder_id_seq'::regclass);


--
-- Name: subcontractorportal_suborderattachment id; Type: DEFAULT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.subcontractorportal_suborderattachment ALTER COLUMN id SET DEFAULT nextval('public.subcontractorportal_suborderattachment_id_seq'::regclass);


--
-- Name: subcontractorportal_subordercost id; Type: DEFAULT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.subcontractorportal_subordercost ALTER COLUMN id SET DEFAULT nextval('public.subcontractorportal_subordercost_id_seq'::regclass);


--
-- Name: subcontractorportal_suborderevent id; Type: DEFAULT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.subcontractorportal_suborderevent ALTER COLUMN id SET DEFAULT nextval('public.subcontractorportal_suborderevent_id_seq'::regclass);


--
-- Name: subcontractorportal_suborderinput id; Type: DEFAULT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.subcontractorportal_suborderinput ALTER COLUMN id SET DEFAULT nextval('public.subcontractorportal_suborderinput_id_seq'::regclass);


--
-- Name: subcontractorportal_suborderissuedproductsreport id; Type: DEFAULT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.subcontractorportal_suborderissuedproductsreport ALTER COLUMN id SET DEFAULT nextval('public.subcontractorportal_suborderissuedproductsreport_id_seq'::regclass);


--
-- Name: subcontractorportal_subordermessage id; Type: DEFAULT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.subcontractorportal_subordermessage ALTER COLUMN id SET DEFAULT nextval('public.subcontractorportal_subordermessage_id_seq'::regclass);


--
-- Name: subcontractorportal_suborderoperation id; Type: DEFAULT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.subcontractorportal_suborderoperation ALTER COLUMN id SET DEFAULT nextval('public.subcontractorportal_suborderoperation_id_seq'::regclass);


--
-- Name: subcontractorportal_suborderoutput id; Type: DEFAULT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.subcontractorportal_suborderoutput ALTER COLUMN id SET DEFAULT nextval('public.subcontractorportal_suborderoutput_id_seq'::regclass);


--
-- Name: subcontractorportal_suborderrealisation id; Type: DEFAULT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.subcontractorportal_suborderrealisation ALTER COLUMN id SET DEFAULT nextval('public.subcontractorportal_suborderrealisation_id_seq'::regclass);


--
-- Name: subcontractorportal_suborderstatechange id; Type: DEFAULT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.subcontractorportal_suborderstatechange ALTER COLUMN id SET DEFAULT nextval('public.subcontractorportal_suborderstatechange_id_seq'::regclass);


--
-- Name: subcontractorportal_subordertmp id; Type: DEFAULT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.subcontractorportal_subordertmp ALTER COLUMN id SET DEFAULT nextval('public.subcontractorportal_subordertmp_id_seq'::regclass);


--
-- Name: supplynegotiations_columnforoffers id; Type: DEFAULT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.supplynegotiations_columnforoffers ALTER COLUMN id SET DEFAULT nextval('public.supplynegotiations_columnforoffers_id_seq'::regclass);


--
-- Name: supplynegotiations_columnforrequests id; Type: DEFAULT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.supplynegotiations_columnforrequests ALTER COLUMN id SET DEFAULT nextval('public.supplynegotiations_columnforrequests_id_seq'::regclass);


--
-- Name: supplynegotiations_negotiation id; Type: DEFAULT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.supplynegotiations_negotiation ALTER COLUMN id SET DEFAULT nextval('public.supplynegotiations_negotiation_id_seq'::regclass);


--
-- Name: supplynegotiations_negotiationproduct id; Type: DEFAULT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.supplynegotiations_negotiationproduct ALTER COLUMN id SET DEFAULT nextval('public.supplynegotiations_negotiationproduct_id_seq'::regclass);


--
-- Name: supplynegotiations_negotiationstatechange id; Type: DEFAULT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.supplynegotiations_negotiationstatechange ALTER COLUMN id SET DEFAULT nextval('public.supplynegotiations_negotiationstatechange_id_seq'::regclass);


--
-- Name: supplynegotiations_offer id; Type: DEFAULT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.supplynegotiations_offer ALTER COLUMN id SET DEFAULT nextval('public.supplynegotiations_offer_id_seq'::regclass);


--
-- Name: supplynegotiations_offerproduct id; Type: DEFAULT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.supplynegotiations_offerproduct ALTER COLUMN id SET DEFAULT nextval('public.supplynegotiations_offerproduct_id_seq'::regclass);


--
-- Name: supplynegotiations_offerstatechange id; Type: DEFAULT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.supplynegotiations_offerstatechange ALTER COLUMN id SET DEFAULT nextval('public.supplynegotiations_offerstatechange_id_seq'::regclass);


--
-- Name: supplynegotiations_parametercolumnforoffers id; Type: DEFAULT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.supplynegotiations_parametercolumnforoffers ALTER COLUMN id SET DEFAULT nextval('public.supplynegotiations_parametercolumnforoffers_id_seq'::regclass);


--
-- Name: supplynegotiations_parametercolumnforrequests id; Type: DEFAULT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.supplynegotiations_parametercolumnforrequests ALTER COLUMN id SET DEFAULT nextval('public.supplynegotiations_parametercolumnforrequests_id_seq'::regclass);


--
-- Name: supplynegotiations_requestforquotation id; Type: DEFAULT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.supplynegotiations_requestforquotation ALTER COLUMN id SET DEFAULT nextval('public.supplynegotiations_requestforquotation_id_seq'::regclass);


--
-- Name: supplynegotiations_requestforquotationproduct id; Type: DEFAULT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.supplynegotiations_requestforquotationproduct ALTER COLUMN id SET DEFAULT nextval('public.supplynegotiations_requestforquotationproduct_id_seq'::regclass);


--
-- Name: supplynegotiations_requestforquotationstatechange id; Type: DEFAULT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.supplynegotiations_requestforquotationstatechange ALTER COLUMN id SET DEFAULT nextval('public.supplynegotiations_requestforquotationstatechange_id_seq'::regclass);


--
-- Name: technologies_barcodeoperationcomponent id; Type: DEFAULT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.technologies_barcodeoperationcomponent ALTER COLUMN id SET DEFAULT nextval('public.technologies_barcodeoperationcomponent_id_seq'::regclass);


--
-- Name: technologies_changetechnologyparameters id; Type: DEFAULT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.technologies_changetechnologyparameters ALTER COLUMN id SET DEFAULT nextval('public.technologies_changetechnologyparameters_id_seq'::regclass);


--
-- Name: technologies_dimensioncontrolattribute id; Type: DEFAULT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.technologies_dimensioncontrolattribute ALTER COLUMN id SET DEFAULT nextval('public.technologies_dimensioncontrolattribute_id_seq'::regclass);


--
-- Name: technologies_modifytechnologyaddproducthelper id; Type: DEFAULT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.technologies_modifytechnologyaddproducthelper ALTER COLUMN id SET DEFAULT nextval('public.technologies_modifytechnologyaddproducthelper_id_seq'::regclass);


--
-- Name: technologies_modifytechnologyhelper id; Type: DEFAULT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.technologies_modifytechnologyhelper ALTER COLUMN id SET DEFAULT nextval('public.technologies_modifytechnologyhelper_id_seq'::regclass);


--
-- Name: technologies_operation id; Type: DEFAULT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.technologies_operation ALTER COLUMN id SET DEFAULT nextval('public.technologies_operation_id_seq'::regclass);


--
-- Name: technologies_operationgroup id; Type: DEFAULT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.technologies_operationgroup ALTER COLUMN id SET DEFAULT nextval('public.technologies_operationgroup_id_seq'::regclass);


--
-- Name: technologies_operationproductincomponent id; Type: DEFAULT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.technologies_operationproductincomponent ALTER COLUMN id SET DEFAULT nextval('public.technologies_operationproductincomponent_id_seq'::regclass);


--
-- Name: technologies_operationproductoutcomponent id; Type: DEFAULT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.technologies_operationproductoutcomponent ALTER COLUMN id SET DEFAULT nextval('public.technologies_operationproductoutcomponent_id_seq'::regclass);


--
-- Name: technologies_productbysizegroup id; Type: DEFAULT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.technologies_productbysizegroup ALTER COLUMN id SET DEFAULT nextval('public.technologies_productbysizegroup_id_seq'::regclass);


--
-- Name: technologies_productcomponent id; Type: DEFAULT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.technologies_productcomponent ALTER COLUMN id SET DEFAULT nextval('public.technologies_productcomponent_id_seq'::regclass);


--
-- Name: technologies_productdata id; Type: DEFAULT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.technologies_productdata ALTER COLUMN id SET DEFAULT nextval('public.technologies_productdata_id_seq'::regclass);


--
-- Name: technologies_productdataattachment id; Type: DEFAULT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.technologies_productdataattachment ALTER COLUMN id SET DEFAULT nextval('public.technologies_productdataattachment_id_seq'::regclass);


--
-- Name: technologies_productdatainput id; Type: DEFAULT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.technologies_productdatainput ALTER COLUMN id SET DEFAULT nextval('public.technologies_productdatainput_id_seq'::regclass);


--
-- Name: technologies_productdataoperation id; Type: DEFAULT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.technologies_productdataoperation ALTER COLUMN id SET DEFAULT nextval('public.technologies_productdataoperation_id_seq'::regclass);


--
-- Name: technologies_productionlinetechnologygroup id; Type: DEFAULT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.technologies_productionlinetechnologygroup ALTER COLUMN id SET DEFAULT nextval('public.technologies_productionlinetechnologygroup_id_seq'::regclass);


--
-- Name: technologies_productstructuretreenode id; Type: DEFAULT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.technologies_productstructuretreenode ALTER COLUMN id SET DEFAULT nextval('public.technologies_productstructuretreenode_id_seq'::regclass);


--
-- Name: technologies_producttoproductgrouptechnology id; Type: DEFAULT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.technologies_producttoproductgrouptechnology ALTER COLUMN id SET DEFAULT nextval('public.technologies_producttoproductgrouptechnology_id_seq'::regclass);


--
-- Name: technologies_section id; Type: DEFAULT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.technologies_section ALTER COLUMN id SET DEFAULT nextval('public.technologies_section_id_seq'::regclass);


--
-- Name: technologies_technologicalprocess id; Type: DEFAULT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.technologies_technologicalprocess ALTER COLUMN id SET DEFAULT nextval('public.technologies_technologicalprocess_id_seq'::regclass);


--
-- Name: technologies_technologicalprocesscomponent id; Type: DEFAULT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.technologies_technologicalprocesscomponent ALTER COLUMN id SET DEFAULT nextval('public.technologies_technologicalprocesscomponent_id_seq'::regclass);


--
-- Name: technologies_technologicalprocesslist id; Type: DEFAULT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.technologies_technologicalprocesslist ALTER COLUMN id SET DEFAULT nextval('public.technologies_technologicalprocesslist_id_seq'::regclass);


--
-- Name: technologies_technology id; Type: DEFAULT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.technologies_technology ALTER COLUMN id SET DEFAULT nextval('public.technologies_technology_id_seq'::regclass);


--
-- Name: technologies_technologyattachment id; Type: DEFAULT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.technologies_technologyattachment ALTER COLUMN id SET DEFAULT nextval('public.technologies_technologyattachment_id_seq'::regclass);


--
-- Name: technologies_technologygroup id; Type: DEFAULT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.technologies_technologygroup ALTER COLUMN id SET DEFAULT nextval('public.technologies_technologygroup_id_seq'::regclass);


--
-- Name: technologies_technologyinputproducttype id; Type: DEFAULT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.technologies_technologyinputproducttype ALTER COLUMN id SET DEFAULT nextval('public.technologies_technologyinputproducttype_id_seq'::regclass);


--
-- Name: technologies_technologyoperationcomponent id; Type: DEFAULT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.technologies_technologyoperationcomponent ALTER COLUMN id SET DEFAULT nextval('public.technologies_technologyoperationcomponent_id_seq'::regclass);


--
-- Name: technologies_technologyproductionline id; Type: DEFAULT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.technologies_technologyproductionline ALTER COLUMN id SET DEFAULT nextval('public.technologies_technologyproductionline_id_seq'::regclass);


--
-- Name: technologies_technologystatechange id; Type: DEFAULT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.technologies_technologystatechange ALTER COLUMN id SET DEFAULT nextval('public.technologies_technologystatechange_id_seq'::regclass);


--
-- Name: technologies_technologytocreationhelper id; Type: DEFAULT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.technologies_technologytocreationhelper ALTER COLUMN id SET DEFAULT nextval('public.technologies_technologytocreationhelper_id_seq'::regclass);


--
-- Name: technologies_workstationchangeovernorm id; Type: DEFAULT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.technologies_workstationchangeovernorm ALTER COLUMN id SET DEFAULT nextval('public.technologies_workstationchangeovernorm_id_seq'::regclass);


--
-- Name: technologies_workstationstatechange id; Type: DEFAULT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.technologies_workstationstatechange ALTER COLUMN id SET DEFAULT nextval('public.technologies_workstationstatechange_id_seq'::regclass);


--
-- Name: technologiesgenerator_generatorcontext id; Type: DEFAULT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.technologiesgenerator_generatorcontext ALTER COLUMN id SET DEFAULT nextval('public.technologiesgenerator_generatorcontext_id_seq'::regclass);


--
-- Name: technologiesgenerator_generatortechnologiesforproduct id; Type: DEFAULT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.technologiesgenerator_generatortechnologiesforproduct ALTER COLUMN id SET DEFAULT nextval('public.technologiesgenerator_generatortechnologiesforproduct_id_seq'::regclass);


--
-- Name: technologiesgenerator_generatortreenode id; Type: DEFAULT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.technologiesgenerator_generatortreenode ALTER COLUMN id SET DEFAULT nextval('public.technologiesgenerator_generatortreenode_id_seq'::regclass);


--
-- Name: techsubcontracting_companyoperation id; Type: DEFAULT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.techsubcontracting_companyoperation ALTER COLUMN id SET DEFAULT nextval('public.techsubcontracting_companyoperation_id_seq'::regclass);


--
-- Name: techsubcontracting_companyoperationgroup id; Type: DEFAULT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.techsubcontracting_companyoperationgroup ALTER COLUMN id SET DEFAULT nextval('public.techsubcontracting_companyoperationgroup_id_seq'::regclass);


--
-- Name: techsubcontracting_orderexternalservicecost id; Type: DEFAULT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.techsubcontracting_orderexternalservicecost ALTER COLUMN id SET DEFAULT nextval('public.techsubcontracting_orderexternalservicecost_id_seq'::regclass);


--
-- Name: timegapspreview_timegap id; Type: DEFAULT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.timegapspreview_timegap ALTER COLUMN id SET DEFAULT nextval('public.timegapspreview_timegap_id_seq'::regclass);


--
-- Name: timegapspreview_timegapscontext id; Type: DEFAULT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.timegapspreview_timegapscontext ALTER COLUMN id SET DEFAULT nextval('public.timegapspreview_timegapscontext_id_seq'::regclass);


--
-- Name: timenormsforoperations_operationworkstationtime id; Type: DEFAULT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.timenormsforoperations_operationworkstationtime ALTER COLUMN id SET DEFAULT nextval('public.timenormsforoperations_operationworkstationtime_id_seq'::regclass);


--
-- Name: timenormsforoperations_techopercomptimecalculation id; Type: DEFAULT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.timenormsforoperations_techopercomptimecalculation ALTER COLUMN id SET DEFAULT nextval('public.timenormsforoperations_techopercomptimecalculation_id_seq'::regclass);


--
-- Name: timenormsforoperations_techopercompworkstationtime id; Type: DEFAULT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.timenormsforoperations_techopercompworkstationtime ALTER COLUMN id SET DEFAULT nextval('public.timenormsforoperations_techopercompworkstationtime_id_seq'::regclass);


--
-- Name: urccore_lastsynchronizationdate id; Type: DEFAULT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.urccore_lastsynchronizationdate ALTER COLUMN id SET DEFAULT nextval('public.urccore_lastsynchronizationdate_id_seq'::regclass);


--
-- Name: urccore_synchronizationstatus id; Type: DEFAULT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.urccore_synchronizationstatus ALTER COLUMN id SET DEFAULT nextval('public.urccore_synchronizationstatus_id_seq'::regclass);


--
-- Name: urcmaterialavailability_requiredcomponent id; Type: DEFAULT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.urcmaterialavailability_requiredcomponent ALTER COLUMN id SET DEFAULT nextval('public.urcmaterialavailability_requiredcomponent_id_seq'::regclass);


--
-- Name: urcproductioncounting_requestrepair id; Type: DEFAULT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.urcproductioncounting_requestrepair ALTER COLUMN id SET DEFAULT nextval('public.urcproductioncounting_requestrepair_id_seq'::regclass);


--
-- Name: wagegroups_wagegroup id; Type: DEFAULT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.wagegroups_wagegroup ALTER COLUMN id SET DEFAULT nextval('public.wagegroups_wagegroup_id_seq'::regclass);


--
-- Name: walusiak_exportdocumenthistory id; Type: DEFAULT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.walusiak_exportdocumenthistory ALTER COLUMN id SET DEFAULT nextval('public.walusiak_exportdocumenthistory_id_seq'::regclass);


--
-- Name: warehouseminimalstate_warehouseminimumstate id; Type: DEFAULT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.warehouseminimalstate_warehouseminimumstate ALTER COLUMN id SET DEFAULT nextval('public.warehouseminimalstate_warehouseminimumstate_id_seq'::regclass);


--
-- Name: warehouseminimalstate_warehouseminimumstatemulti id; Type: DEFAULT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.warehouseminimalstate_warehouseminimumstatemulti ALTER COLUMN id SET DEFAULT nextval('public.warehouseminimalstate_warehouseminimumstatemulti_id_seq'::regclass);


--
-- Name: workplans_columnforinputproducts id; Type: DEFAULT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.workplans_columnforinputproducts ALTER COLUMN id SET DEFAULT nextval('public.workplans_columnforinputproducts_id_seq'::regclass);


--
-- Name: workplans_columnfororders id; Type: DEFAULT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.workplans_columnfororders ALTER COLUMN id SET DEFAULT nextval('public.workplans_columnfororders_id_seq'::regclass);


--
-- Name: workplans_columnforoutputproducts id; Type: DEFAULT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.workplans_columnforoutputproducts ALTER COLUMN id SET DEFAULT nextval('public.workplans_columnforoutputproducts_id_seq'::regclass);


--
-- Name: workplans_parameterinputcolumn id; Type: DEFAULT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.workplans_parameterinputcolumn ALTER COLUMN id SET DEFAULT nextval('public.workplans_parameterinputcolumn_id_seq'::regclass);


--
-- Name: workplans_parameterordercolumn id; Type: DEFAULT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.workplans_parameterordercolumn ALTER COLUMN id SET DEFAULT nextval('public.workplans_parameterordercolumn_id_seq'::regclass);


--
-- Name: workplans_parameteroutputcolumn id; Type: DEFAULT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.workplans_parameteroutputcolumn ALTER COLUMN id SET DEFAULT nextval('public.workplans_parameteroutputcolumn_id_seq'::regclass);


--
-- Name: workplans_workplan id; Type: DEFAULT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.workplans_workplan ALTER COLUMN id SET DEFAULT nextval('public.workplans_workplan_id_seq'::regclass);


--
-- Name: workplans_workplanordercolumn id; Type: DEFAULT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.workplans_workplanordercolumn ALTER COLUMN id SET DEFAULT nextval('public.workplans_workplanordercolumn_id_seq'::regclass);


--
-- Data for Name: advancedgenealogy_batch; Type: TABLE DATA; Schema: public; Owner: -
--

COPY public.advancedgenealogy_batch (id, number, product_id, supplier_id, state, externalnumber, createdate, updatedate, createuser, updateuser, active, entityversion) FROM stdin;
\.


--
-- Data for Name: advancedgenealogy_batchattachment; Type: TABLE DATA; Schema: public; Owner: -
--

COPY public.advancedgenealogy_batchattachment (id, batch_id, attachment, name, size, ext) FROM stdin;
\.


--
-- Data for Name: advancedgenealogy_batchstatechange; Type: TABLE DATA; Schema: public; Owner: -
--

COPY public.advancedgenealogy_batchstatechange (id, dateandtime, sourcestate, targetstate, status, phase, worker, batch_id, shift_id, entityversion) FROM stdin;
\.


--
-- Data for Name: advancedgenealogy_genealogyreport; Type: TABLE DATA; Schema: public; Owner: -
--

COPY public.advancedgenealogy_genealogyreport (id, date, name, type, batch_id, worker, filename, generated, includedraft, directrelatedonly, active, entityversion) FROM stdin;
\.


--
-- Data for Name: advancedgenealogy_trackingrecord; Type: TABLE DATA; Schema: public; Owner: -
--

COPY public.advancedgenealogy_trackingrecord (id, entitytype, state, quantity, producedbatch_id, number, externalnumber, active, createdate, updatedate, createuser, updateuser, order_id, entityversion) FROM stdin;
\.


--
-- Data for Name: advancedgenealogy_trackingrecordstatechange; Type: TABLE DATA; Schema: public; Owner: -
--

COPY public.advancedgenealogy_trackingrecordstatechange (id, dateandtime, sourcestate, targetstate, status, phase, worker, trackingrecord_id, shift_id, entityversion) FROM stdin;
\.


--
-- Data for Name: advancedgenealogy_usedbatchsimple; Type: TABLE DATA; Schema: public; Owner: -
--

COPY public.advancedgenealogy_usedbatchsimple (id, batch_id, trackingrecord_id, worker, dateandtime, quantity, entityversion) FROM stdin;
\.


--
-- Data for Name: advancedgenealogyfororders_genealogyproductinbatch; Type: TABLE DATA; Schema: public; Owner: -
--

COPY public.advancedgenealogyfororders_genealogyproductinbatch (id, worker, dateandtime, batch_id, genealogyproductincomponent_id, entityversion) FROM stdin;
\.


--
-- Data for Name: advancedgenealogyfororders_genealogyproductincomponent; Type: TABLE DATA; Schema: public; Owner: -
--

COPY public.advancedgenealogyfororders_genealogyproductincomponent (id, trackingrecord_id, technologyinstanceoperationcomponent_id, technologyoperationcomponent_id, entityversion, product_id) FROM stdin;
\.


--
-- Data for Name: arch_advancedgenealogy_trackingrecord; Type: TABLE DATA; Schema: public; Owner: -
--

COPY public.arch_advancedgenealogy_trackingrecord (id, entitytype, state, quantity, producedbatch_id, number, externalnumber, active, createdate, updatedate, createuser, updateuser, order_id, entityversion, archived) FROM stdin;
\.


--
-- Data for Name: arch_advancedgenealogy_trackingrecordstatechange; Type: TABLE DATA; Schema: public; Owner: -
--

COPY public.arch_advancedgenealogy_trackingrecordstatechange (id, dateandtime, sourcestate, targetstate, status, phase, worker, trackingrecord_id, shift_id, entityversion, archived) FROM stdin;
\.


--
-- Data for Name: arch_advancedgenealogy_usedbatchsimple; Type: TABLE DATA; Schema: public; Owner: -
--

COPY public.arch_advancedgenealogy_usedbatchsimple (id, batch_id, trackingrecord_id, worker, dateandtime, quantity, entityversion, archived) FROM stdin;
\.


--
-- Data for Name: arch_advancedgenealogyfororders_genealogyproductinbatch; Type: TABLE DATA; Schema: public; Owner: -
--

COPY public.arch_advancedgenealogyfororders_genealogyproductinbatch (id, worker, dateandtime, batch_id, genealogyproductincomponent_id, entityversion, archived) FROM stdin;
\.


--
-- Data for Name: arch_advancedgenealogyfororders_genealogyproductincomponent; Type: TABLE DATA; Schema: public; Owner: -
--

COPY public.arch_advancedgenealogyfororders_genealogyproductincomponent (id, trackingrecord_id, technologyinstanceoperationcomponent_id, technologyoperationcomponent_id, entityversion, product_id, archived) FROM stdin;
\.


--
-- Data for Name: arch_archiving; Type: TABLE DATA; Schema: public; Owner: -
--

COPY public.arch_archiving (id, entityversion, masterordernumber, start, finish, createdate, updatedate, createuser, updateuser) FROM stdin;
\.


--
-- Data for Name: arch_assignmenttoshift_multiassignmenttoshift; Type: TABLE DATA; Schema: public; Owner: -
--

COPY public.arch_assignmenttoshift_multiassignmenttoshift (id, productionline_id, occupationtype, occupationtypename, occupationtypeenum, masterorder_id, assignmenttoshift_id, createdate, updatedate, createuser, updateuser, archived) FROM stdin;
\.


--
-- Data for Name: arch_assignmenttoshift_staffassignmenttoshift; Type: TABLE DATA; Schema: public; Owner: -
--

COPY public.arch_assignmenttoshift_staffassignmenttoshift (id, assignmenttoshift_id, worker_id, productionline_id, occupationtype, occupationtypename, state, occupationtypeenum, occupationtypevalueforgrid, masterorder_id, entityversion, description, archived) FROM stdin;
\.


--
-- Data for Name: arch_avglaborcostcalcfororder_assignmentworkertoshift; Type: TABLE DATA; Schema: public; Owner: -
--

COPY public.arch_avglaborcostcalcfororder_assignmentworkertoshift (id, worker_id, assignmenttoshift_id, workedhours, avglaborcostcalcfororder_id, entityversion, archived) FROM stdin;
\.


--
-- Data for Name: arch_avglaborcostcalcfororder_avglaborcostcalcfororder; Type: TABLE DATA; Schema: public; Owner: -
--

COPY public.arch_avglaborcostcalcfororder_avglaborcostcalcfororder (id, startdate, finishdate, order_id, productionline_id, basedon, averagelaborhourlycost, entityversion, archived) FROM stdin;
\.


--
-- Data for Name: arch_basicproductioncounting_basicproductioncounting; Type: TABLE DATA; Schema: public; Owner: -
--

COPY public.arch_basicproductioncounting_basicproductioncounting (id, order_id, product_id, usedquantity, producedquantity, entityversion, archived) FROM stdin;
\.


--
-- Data for Name: arch_basicproductioncounting_productioncountingattributevalue; Type: TABLE DATA; Schema: public; Owner: -
--

COPY public.arch_basicproductioncounting_productioncountingattributevalue (id, productioncountingquantity_id, attribute_id, attributevalue_id, value, archived) FROM stdin;
\.


--
-- Data for Name: arch_basicproductioncounting_productioncountingoperationrun; Type: TABLE DATA; Schema: public; Owner: -
--

COPY public.arch_basicproductioncounting_productioncountingoperationrun (id, order_id, technologyoperationcomponent_id, runs, entityversion, archived) FROM stdin;
\.


--
-- Data for Name: arch_basicproductioncounting_productioncountingquantity; Type: TABLE DATA; Schema: public; Owner: -
--

COPY public.arch_basicproductioncounting_productioncountingquantity (id, order_id, product_id, plannedquantity, isnoncomponent, technologyoperationcomponent_id, basicproductioncounting_id, typeofmaterial, role, componentsoutputlocation_id, componentslocation_id, productsinputlocation_id, productionflow, productsflowlocation_id, entityversion, replacementto_id, showmaterialcomponentinworkplan, technologyinputproducttype_id, usedquantity, producedquantity, wastereceptionwarehouse_id, attribute_id, archived) FROM stdin;
\.


--
-- Data for Name: arch_cdnrcgoodfood_cancelprotocol; Type: TABLE DATA; Schema: public; Owner: -
--

COPY public.arch_cdnrcgoodfood_cancelprotocol (id, extrusionprotocol_id, confectionprotocol_id, createdate, laststatechangefailcause, iscanceled, archived) FROM stdin;
\.


--
-- Data for Name: arch_costnormsformaterials_technologyinstoperproductincomp; Type: TABLE DATA; Schema: public; Owner: -
--

COPY public.arch_costnormsformaterials_technologyinstoperproductincomp (id, order_id, product_id, costfororder, entityversion, averagepricesubcontractor, archived) FROM stdin;
\.


--
-- Data for Name: arch_goodfood_confectionadditionalinputproduct; Type: TABLE DATA; Schema: public; Owner: -
--

COPY public.arch_goodfood_confectionadditionalinputproduct (id, confectionprotocol_id, batch_id, product_id, takenonquantity, takenofquantity, cullquantity, effectivequantity, entityversion, archived) FROM stdin;
\.


--
-- Data for Name: arch_goodfood_confectionfilmproduct; Type: TABLE DATA; Schema: public; Owner: -
--

COPY public.arch_goodfood_confectionfilmproduct (id, confectionprotocol_id, filmproduct_id, beyondrecipe, archived) FROM stdin;
\.


--
-- Data for Name: arch_goodfood_confectionfilmproductentry; Type: TABLE DATA; Schema: public; Owner: -
--

COPY public.arch_goodfood_confectionfilmproductentry (id, batch_id, confectionfilmproduct_id, takenonquantity, takenofquantity, cullquantity, effectivequantity, archived) FROM stdin;
\.


--
-- Data for Name: arch_goodfood_confectioninputproduct; Type: TABLE DATA; Schema: public; Owner: -
--

COPY public.arch_goodfood_confectioninputproduct (id, confectionprotocol_id, batch_id, product_id, takenonquantity, takenofquantity, cullquantity, effectivequantity, entityversion, archived) FROM stdin;
\.


--
-- Data for Name: arch_goodfood_confectionprotocol; Type: TABLE DATA; Schema: public; Owner: -
--

COPY public.arch_goodfood_confectionprotocol (id, generationdate, state, laststatechangefails, confectioncontext_id, number, dayofshiftstart, productionline_id, toproduce, startdate, finishdate, order_id, ordernumber, productnameandnumber, qcp5code, filmproduct_id, restoneofcartonsquantity, resttwoofcartonsquantity, allpalletquantity, quantityofallcartonsquantity, wastewafers, effectiveproducedquantity, effectiveexecutiontimestart, effectiveexecutiontimeend, externalnumber, externalsynchronized, active, laststatechangefailcause, showlaststatechangeresult, isdoubled, additionalfilmproduct_id, iscorrected, productiondate, entityversion, comments, sendagaintoblackbox, finalprotocol, plannextorderinfo, plannextorderinfoargs, plannextorderstatechangeinfo, archived) FROM stdin;
\.


--
-- Data for Name: arch_goodfood_confectionprotocolcorrect; Type: TABLE DATA; Schema: public; Owner: -
--

COPY public.arch_goodfood_confectionprotocolcorrect (id, confectionprotocol_id, correctdate, correctreason, createdate, updatedate, createuser, updateuser, isconfirmed, entityversion, archived) FROM stdin;
\.


--
-- Data for Name: arch_goodfood_confectionprotocolstatechange; Type: TABLE DATA; Schema: public; Owner: -
--

COPY public.arch_goodfood_confectionprotocolstatechange (id, dateandtime, sourcestate, targetstate, status, phase, shift_id, worker, confectionprotocol_id, entityversion, archived) FROM stdin;
\.


--
-- Data for Name: arch_goodfood_confectionremainderinputproduct; Type: TABLE DATA; Schema: public; Owner: -
--

COPY public.arch_goodfood_confectionremainderinputproduct (id, confectionprotocol_id, product_id, usedquantity, isdoubled, entityversion, usedbatches, beyondrecipe, archived) FROM stdin;
\.


--
-- Data for Name: arch_goodfood_confectionstaff; Type: TABLE DATA; Schema: public; Owner: -
--

COPY public.arch_goodfood_confectionstaff (id, confectionprotocol_id, worker_id, labortime, effectiveexecutiontimestart, effectiveexecutiontimeend, entityversion, archived) FROM stdin;
\.


--
-- Data for Name: arch_goodfood_extrusionaddedmixentry; Type: TABLE DATA; Schema: public; Owner: -
--

COPY public.arch_goodfood_extrusionaddedmixentry (id, extrusionprotocol_id, quantity, entityversion, extrusionmix_id, archived) FROM stdin;
\.


--
-- Data for Name: arch_goodfood_extrusionaddedmixingredient; Type: TABLE DATA; Schema: public; Owner: -
--

COPY public.arch_goodfood_extrusionaddedmixingredient (id, extrusionaddedmixentry_id, extrusionmixingredient_id, product_id, batch_id, quantity, beyondrecipe, archived) FROM stdin;
\.


--
-- Data for Name: arch_goodfood_extrusionpouring; Type: TABLE DATA; Schema: public; Owner: -
--

COPY public.arch_goodfood_extrusionpouring (id, extrusionprotocol_id, finaladdedquantity, addedquantity, totalmixquantity, addedquantitymanual, addedquantityrelatesto, mixwaterquantity, priority, archived) FROM stdin;
\.


--
-- Data for Name: arch_goodfood_extrusionpouringingredient; Type: TABLE DATA; Schema: public; Owner: -
--

COPY public.arch_goodfood_extrusionpouringingredient (id, extrusionpouring_id, product_id, batch_id, quantity, ratio, manual, skip, frommix, requiredquantity, quantityinmix, beyondrecipe, addedbyuser, extrusionpouringmix_id, archived) FROM stdin;
\.


--
-- Data for Name: arch_goodfood_extrusionpouringmix; Type: TABLE DATA; Schema: public; Owner: -
--

COPY public.arch_goodfood_extrusionpouringmix (id, extrusionpouring_id, mixid, requiredscalequantity, scalequantity, scalequantitymanual, totalmixquantity, mixwaterquantity, archived) FROM stdin;
\.


--
-- Data for Name: arch_goodfood_extrusionprotocol; Type: TABLE DATA; Schema: public; Owner: -
--

COPY public.arch_goodfood_extrusionprotocol (id, generationdate, state, laststatechangefails, extrusioncontext_id, number, dayofshiftstart, productionline_id, toproduce, changeover, startdate, finishdate, numberofavailableworkstation, order_id, ordernumber, productnameandnumber, mixproduct, operatorworkstartdate, operatorworkfinishdate, externalnumber, externalsynchronized, active, laststatechangefailcause, showlaststatechangeresult, iscorrected, entityversion, comments, sendagaintoblackbox, archived) FROM stdin;
\.


--
-- Data for Name: arch_goodfood_extrusionprotocolcorrect; Type: TABLE DATA; Schema: public; Owner: -
--

COPY public.arch_goodfood_extrusionprotocolcorrect (id, extrusionprotocol_id, correctdate, correctreason, createdate, updatedate, createuser, updateuser, isconfirmed, entityversion, archived) FROM stdin;
\.


--
-- Data for Name: arch_goodfood_extrusionprotocolstatechange; Type: TABLE DATA; Schema: public; Owner: -
--

COPY public.arch_goodfood_extrusionprotocolstatechange (id, dateandtime, sourcestate, targetstate, status, phase, shift_id, worker, extrusionprotocol_id, entityversion, archived) FROM stdin;
\.


--
-- Data for Name: arch_goodfood_extrusionsouse; Type: TABLE DATA; Schema: public; Owner: -
--

COPY public.arch_goodfood_extrusionsouse (id, extrusionprotocol_id, category, datesouse, datedownload, worker_id, wetness, entityversion, archived) FROM stdin;
\.


--
-- Data for Name: arch_goodfood_extrusiontakenoffmixentry; Type: TABLE DATA; Schema: public; Owner: -
--

COPY public.arch_goodfood_extrusiontakenoffmixentry (id, extrusionprotocol_id, quantity, entityversion, extrusionmix_id, archived) FROM stdin;
\.


--
-- Data for Name: arch_goodfood_extrusiontakenoffmixingredient; Type: TABLE DATA; Schema: public; Owner: -
--

COPY public.arch_goodfood_extrusiontakenoffmixingredient (id, extrusiontakenoffmixentry_id, extrusionmixingredient_id, product_id, batch_id, quantity, beyondrecipe, archived) FROM stdin;
\.


--
-- Data for Name: arch_goodfood_pallet; Type: TABLE DATA; Schema: public; Owner: -
--

COPY public.arch_goodfood_pallet (id, palletcontext_id, palletlabel_id, typeoflogistics, printedcount, ssccnumber, palletnumber, secondpallet_id, state, isstateerror, stateerror, registrationdate, senddate, active, packagescount, laststatechangefails, laststatechangefailcause, externalnumber, externalsynchronized, eurocod, entityversion, sendagaintoblackbox, product_id, archived) FROM stdin;
\.


--
-- Data for Name: arch_goodfood_palletlabel; Type: TABLE DATA; Schema: public; Owner: -
--

COPY public.arch_goodfood_palletlabel (id, palletcontext_id, printedcount, firstssccnumber, firstpalletnumber, lastssccnumber, lastpalletnumber, masterorder_id, productionline_id, batchnumber, bestbefore, registrationdate, active, batch_id, state, entityversion, archived) FROM stdin;
\.


--
-- Data for Name: arch_goodfood_palletlabelstatechange; Type: TABLE DATA; Schema: public; Owner: -
--

COPY public.arch_goodfood_palletlabelstatechange (id, dateandtime, sourcestate, targetstate, status, phase, shift_id, worker, palletlabel_id, entityversion, archived) FROM stdin;
\.


--
-- Data for Name: arch_goodfood_palletstatechange; Type: TABLE DATA; Schema: public; Owner: -
--

COPY public.arch_goodfood_palletstatechange (id, dateandtime, sourcestate, targetstate, status, phase, shift_id, worker, pallet_id, entityversion, archived) FROM stdin;
\.


--
-- Data for Name: arch_goodfood_printedlabel; Type: TABLE DATA; Schema: public; Owner: -
--

COPY public.arch_goodfood_printedlabel (id, cartonlabel, masterorder_id, ssccnumber, palletcontext_id, productionline_id, createdate, updatedate, createuser, updateuser, active, archived) FROM stdin;
\.


--
-- Data for Name: arch_integrationbartender_printlabelshelper; Type: TABLE DATA; Schema: public; Owner: -
--

COPY public.arch_integrationbartender_printlabelshelper (id, createdate, updatedate, createuser, updateuser, quantity, masterorder_id, printer_id, path, ssccnumbers, order_id, barcodeismasterorderid, archived) FROM stdin;
\.


--
-- Data for Name: arch_integrationbartender_sendtoprint; Type: TABLE DATA; Schema: public; Owner: -
--

COPY public.arch_integrationbartender_sendtoprint (id, printlabelshelper_id, createdate, updatedate, createuser, updateuser, archived) FROM stdin;
\.


--
-- Data for Name: arch_masterorders_masterorder; Type: TABLE DATA; Schema: public; Owner: -
--

COPY public.arch_masterorders_masterorder (id, number, name, description, externalnumber, deadline, addmasterprefixtonumber, masterorderstate, company_id, externalsynchronized, generationdateoneec, cancelsynchronizationreason, active, pw2prod, batch_id, masterorderdefinition_id, startdate, finishdate, entityversion, sendagaintoblackbox, dateofreceipt, address_id, externalproductionorderid, ponumber, direction, createdate, updatedate, createuser, updateuser, deliverynotenumber, cancelsynchronizationtype, companypayer_id, productioncode, commissionnumber, machinetype, pipedriveupdate, state, asanataskid, asanatasknameupdated, asanataskcommentadded, sendagaintoasana, sendagaintoasanatries, asanastatecompleteddate, colourral, salesplan_id, materialsissued, warehouseorder, synchronize, synchronizationdate, archived) FROM stdin;
\.


--
-- Data for Name: arch_masterorders_masterorderproduct; Type: TABLE DATA; Schema: public; Owner: -
--

COPY public.arch_masterorders_masterorderproduct (id, product_id, technology_id, masterorder_id, masterorderquantity, cumulatedorderquantity, producedorderquantity, entityversion, lefttorelease, comments, masterorderpositionstatus, quantitytakenfromwarehouse, quantityremainingtoorder, deliverydate, line, vendorinfo, vendorso, price, priceslistprice, archived) FROM stdin;
\.


--
-- Data for Name: arch_masterorders_masterorderproductattrvalue; Type: TABLE DATA; Schema: public; Owner: -
--

COPY public.arch_masterorders_masterorderproductattrvalue (id, masterorderproduct_id, attribute_id, attributevalue_id, value, succession, archived) FROM stdin;
\.


--
-- Data for Name: arch_masterorders_productsbysizeentryhelper; Type: TABLE DATA; Schema: public; Owner: -
--

COPY public.arch_masterorders_productsbysizeentryhelper (id, size_id, productsbysizehelper_id, quantity, product_id, archived) FROM stdin;
\.


--
-- Data for Name: arch_masterorders_productsbysizehelper; Type: TABLE DATA; Schema: public; Owner: -
--

COPY public.arch_masterorders_productsbysizehelper (id, product_id, totalquantity, masterorder_id, salesplan_id, ordersgroup_id, archived) FROM stdin;
\.


--
-- Data for Name: arch_materialflowresources_document; Type: TABLE DATA; Schema: public; Owner: -
--

COPY public.arch_materialflowresources_document (id, number, type, "time", state, locationfrom_id, locationto_id, user_id, delivery_id, active, createdate, updatedate, createuser, updateuser, order_id, description, suborder_id, company_id, maintenanceevent_id, entityversion, plannedevent_id, name, createlinkeddocument, linkeddocumentlocation_id, address_id, dispositionshift_id, positionsfile, printed, generationdate, filename, acceptationinprogress, externalnumber, issend, wms, datesendtowms, stateinwms, pickingworker, dateconfirmationofcompletion, locationchanged, editinwms, staff_id, ordersgroup_id, invoicenumber, archived) FROM stdin;
\.


--
-- Data for Name: arch_materialflowresources_documentstatechange; Type: TABLE DATA; Schema: public; Owner: -
--

COPY public.arch_materialflowresources_documentstatechange (id, dateandtime, document_id, sourcestate, targetstate, status, worker, archived) FROM stdin;
\.


--
-- Data for Name: arch_materialflowresources_position; Type: TABLE DATA; Schema: public; Owner: -
--

COPY public.arch_materialflowresources_position (id, document_id, product_id, quantity, price, productiondate, expirationdate, number, resource_id, givenunit, givenquantity, entityversion, storagelocation_id, conversion, palletnumber_id, typeofpallet, waste, resourcereceiptdocument, lastresource, resourcenumber, externaldocumentnumber, orderid, sellingprice, batch_id, qualityrating, pickingdate, pickingworker_id, documentpart_id, archived) FROM stdin;
\.


--
-- Data for Name: arch_materialflowresources_positionattributevalue; Type: TABLE DATA; Schema: public; Owner: -
--

COPY public.arch_materialflowresources_positionattributevalue (id, position_id, attribute_id, attributevalue_id, value, archived) FROM stdin;
\.


--
-- Data for Name: arch_materialflowresources_reservation; Type: TABLE DATA; Schema: public; Owner: -
--

COPY public.arch_materialflowresources_reservation (id, location_id, product_id, quantity, position_id, productstoissue_id, resource_id, order_id, orderproductresourcereservation_id, date, archived) FROM stdin;
\.


--
-- Data for Name: arch_materialrequirementcoveragefororder_coveragefororder; Type: TABLE DATA; Schema: public; Owner: -
--

COPY public.arch_materialrequirementcoveragefororder_coveragefororder (id, number, coveragetodate, actualdate, generateddate, generatedby, generated, saved, filename, coveragetype, includedraftdeliveries, order_id, createdate, updatedate, createuser, updateuser, generatedorders, entityversion, archived) FROM stdin;
\.


--
-- Data for Name: arch_materialrequirementcoveragefororder_coveragelocation; Type: TABLE DATA; Schema: public; Owner: -
--

COPY public.arch_materialrequirementcoveragefororder_coveragelocation (id, coveragefororder_id, location_id, parameter_id, entityversion, archived) FROM stdin;
\.


--
-- Data for Name: arch_materialrequirementcoveragefororder_coverageproduct; Type: TABLE DATA; Schema: public; Owner: -
--

COPY public.arch_materialrequirementcoveragefororder_coverageproduct (id, coveragefororder_id, product_id, lackfromdate, demandquantity, coveredquantity, reservemissingquantity, deliveredquantity, locationsquantity, state, ispurchased, issubcontracted, producttype, order_id, planedquantity, entityversion, archived) FROM stdin;
\.


--
-- Data for Name: arch_materialrequirementcoveragefororder_coverageproductlogging; Type: TABLE DATA; Schema: public; Owner: -
--

COPY public.arch_materialrequirementcoveragefororder_coverageproductlogging (id, coverageproduct_id, date, delivery_id, order_id, operation_id, reservemissingquantity, changes, eventtype, state, subcontractedoperation_id, entityversion, archived) FROM stdin;
\.


--
-- Data for Name: arch_orders_operationaltask; Type: TABLE DATA; Schema: public; Owner: -
--

COPY public.arch_orders_operationaltask (id, number, name, description, type, startdate, finishdate, order_id, entityversion, staff_id, workstation_id, state, technologyoperationcomponent_id, product_id, scheduleposition_id, division_id, actualstaff, suborder_id, archived) FROM stdin;
\.


--
-- Data for Name: arch_orders_operationaltaskstatechange; Type: TABLE DATA; Schema: public; Owner: -
--

COPY public.arch_orders_operationaltaskstatechange (id, dateandtime, sourcestate, targetstate, status, phase, worker, operationaltask_id, shift_id, archived) FROM stdin;
\.


--
-- Data for Name: arch_orders_order; Type: TABLE DATA; Schema: public; Owner: -
--

COPY public.arch_orders_order (id, number, name, description, commentreasontypecorrectiondatefrom, commentreasontypecorrectiondateto, commentreasondeviationeffectivestart, commentreasondeviationeffectiveend, externalnumber, commentreasontypedeviationsquantity, datefrom, dateto, effectivedatefrom, effectivedateto, deadline, correcteddatefrom, correcteddateto, startdate, finishdate, state, company_id, product_id, technology_id, productionline_id, plannedquantity, donequantity, externalsynchronized, commissionedplannedquantity, commissionedcorrectedquantity, amountofproductproduced, remainingamountofproducttoproduce, ownlinechangeoverduration, registerproductiontime, registerquantityinproduct, laborworktime, includetpz, inputproductsrequiredfortype, generatedenddate, machineworktime, ownlinechangeover, registerquantityoutproduct, operationdurationquantityunit, realizationtime, calculate, includeadditionaltime, typeofproductionrecording, masterorder_id, active, productpriceperunit, failuresyncmessage, targetstate, ignorerequiredcomponents, automaticallymoveoverusage, updatecomponentsavailability, technologyprototype_id, level, parent_id, ignoremissingcomponents, masterorderproduct_id, dateschanged, sourcecorrecteddatefrom, sourcecorrecteddateto, sourcestartdate, sourcefinishdate, batchnumber, root_id, includeordersforcomponent, plannedfinishallorders, plannedstartallorders, calculatedfinishallorders, registerfilled, workplandelivered, calculatedstartallorders, scadacreatedorupdatestate, entityversion, workertochange, masterorderproductcomponent_id, wastesquantity, existsrepairorders, ordercategory, address_id, finalproductiontracking, updatefinishdate, ordersgroup_id, plannedquantityforadditionalunit, division_id, salesplan_id, reportedproductionquantity, expirationdate, additionalfinalproducts, optimizecuttingsolution, vendorinfo, priority, archived) FROM stdin;
\.


--
-- Data for Name: arch_orders_orderpack; Type: TABLE DATA; Schema: public; Owner: -
--

COPY public.arch_orders_orderpack (id, number, order_id, quantity, state, archived) FROM stdin;
\.


--
-- Data for Name: arch_orders_orderpackstatechange; Type: TABLE DATA; Schema: public; Owner: -
--

COPY public.arch_orders_orderpackstatechange (id, dateandtime, sourcestate, targetstate, status, phase, worker, orderpack_id, shift_id, archived) FROM stdin;
\.


--
-- Data for Name: arch_orders_orderstatechange; Type: TABLE DATA; Schema: public; Owner: -
--

COPY public.arch_orders_orderstatechange (id, comment, reasonrequired, dateandtime, sourcestate, targetstate, status, phase, worker, order_id, shift_id, additionalinformation, sourcecorrecteddatefrom, sourcecorrecteddateto, sourcestartdate, sourcefinishdate, targetcorrecteddatefrom, targetcorrecteddateto, targetstartdate, targetfinishdate, dateschanged, entityversion, archived) FROM stdin;
\.


--
-- Data for Name: arch_orders_ordertechnologicalprocess; Type: TABLE DATA; Schema: public; Owner: -
--

COPY public.arch_orders_ordertechnologicalprocess (id, number, orderpack_id, order_id, product_id, operation_id, technologicalprocess_id, quantity, worker_id, date, wastesquantity, technologyoperationcomponent_id, createdate, archived) FROM stdin;
\.


--
-- Data for Name: arch_orders_ordertechnologicalprocesspart; Type: TABLE DATA; Schema: public; Owner: -
--

COPY public.arch_orders_ordertechnologicalprocesspart (id, number, quantity, ordertechnologicalprocess_id, archived) FROM stdin;
\.


--
-- Data for Name: arch_orders_ordertechnologicalprocesswaste; Type: TABLE DATA; Schema: public; Owner: -
--

COPY public.arch_orders_ordertechnologicalprocesswaste (id, number, ordertechnologicalprocess_id, orderpack_id, order_id, product_id, technologicalprocess_id, wastequantity, causeofwaste, worker_id, date, description, archived) FROM stdin;
\.


--
-- Data for Name: arch_orders_productionlinescheduleposition; Type: TABLE DATA; Schema: public; Owner: -
--

COPY public.arch_orders_productionlinescheduleposition (id, productionlineschedule_id, order_id, productionline_id, linechangeovernorm_id, starttime, endtime, additionaltime, archived) FROM stdin;
\.


--
-- Data for Name: arch_orders_reasontypecorrectiondatefrom; Type: TABLE DATA; Schema: public; Owner: -
--

COPY public.arch_orders_reasontypecorrectiondatefrom (id, order_id, reasontypeofchangingorderstate, date, entityversion, changedateshelper_id, archived) FROM stdin;
\.


--
-- Data for Name: arch_orders_reasontypecorrectiondateto; Type: TABLE DATA; Schema: public; Owner: -
--

COPY public.arch_orders_reasontypecorrectiondateto (id, order_id, reasontypeofchangingorderstate, date, entityversion, changedateshelper_id, archived) FROM stdin;
\.


--
-- Data for Name: arch_orders_reasontypedeviationeffectiveend; Type: TABLE DATA; Schema: public; Owner: -
--

COPY public.arch_orders_reasontypedeviationeffectiveend (id, order_id, reasontypeofchangingorderstate, date, entityversion, archived) FROM stdin;
\.


--
-- Data for Name: arch_orders_reasontypedeviationeffectivestart; Type: TABLE DATA; Schema: public; Owner: -
--

COPY public.arch_orders_reasontypedeviationeffectivestart (id, order_id, reasontypeofchangingorderstate, date, entityversion, archived) FROM stdin;
\.


--
-- Data for Name: arch_orders_reasontypeofchangingorderstate; Type: TABLE DATA; Schema: public; Owner: -
--

COPY public.arch_orders_reasontypeofchangingorderstate (id, orderstatechange_id, reasontypeofchangingorderstate, entityversion, archived) FROM stdin;
\.


--
-- Data for Name: arch_orders_scheduleposition; Type: TABLE DATA; Schema: public; Owner: -
--

COPY public.arch_orders_scheduleposition (id, schedule_id, technologyoperationcomponent_id, additionaltime, machineworktime, laborworktime, order_id, product_id, workstation_id, quantity, starttime, endtime, staff_id, operationruns, partialoperationruns, archived) FROM stdin;
\.


--
-- Data for Name: arch_orders_typeofcorrectioncauses; Type: TABLE DATA; Schema: public; Owner: -
--

COPY public.arch_orders_typeofcorrectioncauses (id, order_id, reasontype, date, entityversion, archived) FROM stdin;
\.


--
-- Data for Name: arch_ordersforsubproductsgeneration_suborders; Type: TABLE DATA; Schema: public; Owner: -
--

COPY public.arch_ordersforsubproductsgeneration_suborders (id, order_id, ordersgroup_id, createdate, updatedate, createuser, updateuser, ordersgroupsgenerated, generatedorders, ordergenerationinprogress, archived) FROM stdin;
\.


--
-- Data for Name: arch_ordersgroups_ordersgroup; Type: TABLE DATA; Schema: public; Owner: -
--

COPY public.arch_ordersgroups_ordersgroup (id, number, assortment_id, productionline_id, startdate, finishdate, deadline, quantity, producedquantity, remainingquantity, state, active, masterorder_id, parent_id, remainingquantityinorders, description, salesplan_id, archived) FROM stdin;
\.


--
-- Data for Name: arch_ordersgroups_ordersgroupissuedmaterial; Type: TABLE DATA; Schema: public; Owner: -
--

COPY public.arch_ordersgroups_ordersgroupissuedmaterial (id, ordersgroup_id, product_id, quantity, value, averageprice, archived) FROM stdin;
\.


--
-- Data for Name: arch_ordersgroups_ordersgroupissuedmaterialposition; Type: TABLE DATA; Schema: public; Owner: -
--

COPY public.arch_ordersgroups_ordersgroupissuedmaterialposition (id, ordersgroupissuedmaterial_id, documentnumber, quantity, price, value, externaldocumentid, archived) FROM stdin;
\.


--
-- Data for Name: arch_ordersgroups_ordersgroupmaterialrequirement; Type: TABLE DATA; Schema: public; Owner: -
--

COPY public.arch_ordersgroups_ordersgroupmaterialrequirement (id, number, ordersgroup_id, generated, worker, date, filename, archived) FROM stdin;
\.


--
-- Data for Name: arch_ordersgroups_ordersgroupmaterialrequirementproduct; Type: TABLE DATA; Schema: public; Owner: -
--

COPY public.arch_ordersgroups_ordersgroupmaterialrequirementproduct (id, ordersgroupmaterialrequirement_id, product_id, quantity, currentstock, technologyinputproducttype_id, orderstartdate, division_id, location_id, issuedquantity, supplier_id, archived) FROM stdin;
\.


--
-- Data for Name: arch_ordersgroups_ordersgroupproducedproduct; Type: TABLE DATA; Schema: public; Owner: -
--

COPY public.arch_ordersgroups_ordersgroupproducedproduct (id, ordersgroup_id, product_id, location_id, document_id, quantity, accepted, externaldocumentnumber, batch_id, storagelocation_id, palletnumber_id, typeofpallet, archived) FROM stdin;
\.


--
-- Data for Name: arch_ordersgroups_ordersgroupproductstoissueentryhelper; Type: TABLE DATA; Schema: public; Owner: -
--

COPY public.arch_ordersgroups_ordersgroupproductstoissueentryhelper (id, ordersgroupmaterialrequirementproduct_id, ordersgroupproductstoissuehelper_id, quantity, archived) FROM stdin;
\.


--
-- Data for Name: arch_ordersgroups_ordersgroupproductstoissuehelper; Type: TABLE DATA; Schema: public; Owner: -
--

COPY public.arch_ordersgroups_ordersgroupproductstoissuehelper (id, ordersgroupmaterialrequirement_id, archived) FROM stdin;
\.


--
-- Data for Name: arch_ordersgroups_productionbalance; Type: TABLE DATA; Schema: public; Owner: -
--

COPY public.arch_ordersgroups_productionbalance (id, number, name, generated, worker, date, filename, ordersgroup_id, plannedmaterialcost, usenominalcostpricenotspecified, realmaterialcost, orderedquantity, producedquantity, quantitydeviation, plannedcost, realcost, costdeviation, active, archived) FROM stdin;
\.


--
-- Data for Name: arch_ordersupplies_coverageanalysisfororder; Type: TABLE DATA; Schema: public; Owner: -
--

COPY public.arch_ordersupplies_coverageanalysisfororder (id, order_id, orderedproduct_id, plannedquantity, coveragedegree, coveredfromtheday, deliverytime, componentsproductiondate, materialrequirementcoverage_id, archived) FROM stdin;
\.


--
-- Data for Name: arch_ordersupplies_coveragelocation; Type: TABLE DATA; Schema: public; Owner: -
--

COPY public.arch_ordersupplies_coveragelocation (id, materialrequirementcoverage_id, location_id, parameter_id, entityversion, archived) FROM stdin;
\.


--
-- Data for Name: arch_ordersupplies_coverageorderstate; Type: TABLE DATA; Schema: public; Owner: -
--

COPY public.arch_ordersupplies_coverageorderstate (id, materialrequirementcoverage_id, parameter_id, state, archived) FROM stdin;
\.


--
-- Data for Name: arch_ordersupplies_coverageproduct; Type: TABLE DATA; Schema: public; Owner: -
--

COPY public.arch_ordersupplies_coverageproduct (id, materialrequirementcoverage_id, product_id, lackfromdate, demandquantity, coveredquantity, reservemissingquantity, deliveredquantity, locationsquantity, state, issubcontracted, ispurchased, productnumber, productname, productunit, producttype, planedquantity, producequantity, fromselectedorder, entityversion, company_id, price, archived) FROM stdin;
\.


--
-- Data for Name: arch_ordersupplies_coverageproductlogging; Type: TABLE DATA; Schema: public; Owner: -
--

COPY public.arch_ordersupplies_coverageproductlogging (id, coverageproduct_id, date, delivery_id, order_id, operation_id, reservemissingquantity, changes, eventtype, state, subcontractedoperation_id, deliverynumberexternal, warehousenumber, entityversion, archived) FROM stdin;
\.


--
-- Data for Name: arch_ordersupplies_coverageproductselected; Type: TABLE DATA; Schema: public; Owner: -
--

COPY public.arch_ordersupplies_coverageproductselected (id, coverageproduct_id, entityversion, archived) FROM stdin;
\.


--
-- Data for Name: arch_ordersupplies_materialrequirementcoverage; Type: TABLE DATA; Schema: public; Owner: -
--

COPY public.arch_ordersupplies_materialrequirementcoverage (id, number, coveragetodate, actualdate, generateddate, generatedby, generated, saved, coveragetype, includedraftdeliveries, createdate, updatedate, createuser, updateuser, filename, automaticsavecoverage, order_id, entityversion, ordergenerationinprogress, forordersgroup_id, ordersgroupsgenerated, includeincalculationdeliveries, archived) FROM stdin;
\.


--
-- Data for Name: arch_productflowthrudivision_issue; Type: TABLE DATA; Schema: public; Owner: -
--

COPY public.arch_productflowthrudivision_issue (id, warehouseissue_id, product_id, productincomponent_id, demandquantity, locationsquantity, issuequantity, location_id, entityversion, locationtoquantity, quantityperunit, issued, storagelocation_id, additionaldemandquantity, conversion, dateofissued, document_id, archived) FROM stdin;
\.


--
-- Data for Name: arch_productflowthrudivision_materialavailability; Type: TABLE DATA; Schema: public; Owner: -
--

COPY public.arch_productflowthrudivision_materialavailability (id, order_id, product_id, availablequantity, requiredquantity, unit, entityversion, location_id, availability, replacement, batchesid, batches, batchesquantity, archived) FROM stdin;
\.


--
-- Data for Name: arch_productflowthrudivision_productstoissue; Type: TABLE DATA; Schema: public; Owner: -
--

COPY public.arch_productflowthrudivision_productstoissue (id, warehouseissue_id, product_id, productincomponent_id, demandquantity, locationsquantity, placeofissuequantity, issuequantity, location_id, entityversion, issued, storagelocation_id, additionaldemandquantity, conversion, correction, archived) FROM stdin;
\.


--
-- Data for Name: arch_productflowthrudivision_producttoissuecorrection; Type: TABLE DATA; Schema: public; Owner: -
--

COPY public.arch_productflowthrudivision_producttoissuecorrection (id, producttoissuecorrectionhelper_id, warehouseissue_id, product_id, correctionquantity, correctionquantityinadditionalunit, quantitytoissue, demandquantity, conversion, location_id, description, createdate, updatedate, createuser, updateuser, productstoissue_id, archived) FROM stdin;
\.


--
-- Data for Name: arch_productflowthrudivision_warehouseissue; Type: TABLE DATA; Schema: public; Owner: -
--

COPY public.arch_productflowthrudivision_warehouseissue (id, number, description, order_id, placeofissue_id, division_id, workerwhoissued_id, workerwhocollected_id, dateofissued, dateofcreation, technologyoperationcomponent_id, collectionproducts, state, createdate, updatedate, createuser, updateuser, entityversion, productstoissuemode, archived) FROM stdin;
\.


--
-- Data for Name: arch_productflowthrudivision_warehouseissuestatechange; Type: TABLE DATA; Schema: public; Owner: -
--

COPY public.arch_productflowthrudivision_warehouseissuestatechange (id, dateandtime, sourcestate, targetstate, status, phase, worker, warehouseissue_id, shift_id, additionalinformation, entityversion, archived) FROM stdin;
\.


--
-- Data for Name: arch_productioncounting_anomaly; Type: TABLE DATA; Schema: public; Owner: -
--

COPY public.arch_productioncounting_anomaly (id, number, productiontracking_id, masterproduct_id, product_id, usedquantity, state, issued, createdate, updatedate, createuser, updateuser, location_id, archived) FROM stdin;
\.


--
-- Data for Name: arch_productioncounting_anomalyexplanation; Type: TABLE DATA; Schema: public; Owner: -
--

COPY public.arch_productioncounting_anomalyexplanation (id, anomaly_id, product_id, location_id, usedquantity, givenquantity, givenunit, usewaste, description, createdate, updatedate, createuser, updateuser, archived) FROM stdin;
\.


--
-- Data for Name: arch_productioncounting_anomalyproductiontrackingentryhelper; Type: TABLE DATA; Schema: public; Owner: -
--

COPY public.arch_productioncounting_anomalyproductiontrackingentryhelper (id, anomalyproductiontracking_id, trackingoperationproductincomponent_id, createdate, updatedate, createuser, updateuser, archived) FROM stdin;
\.


--
-- Data for Name: arch_productioncounting_anomalyreasoncontainer; Type: TABLE DATA; Schema: public; Owner: -
--

COPY public.arch_productioncounting_anomalyreasoncontainer (id, anomalyproductiontrackingentryhelper_id, anomalyreason_id, archived) FROM stdin;
\.


--
-- Data for Name: arch_productioncounting_lack; Type: TABLE DATA; Schema: public; Owner: -
--

COPY public.arch_productioncounting_lack (id, trackingoperationproductoutcomponent_id, lackquantity, createdate, updatedate, createuser, updateuser, archived) FROM stdin;
\.


--
-- Data for Name: arch_productioncounting_prodoutresourceattrval; Type: TABLE DATA; Schema: public; Owner: -
--

COPY public.arch_productioncounting_prodoutresourceattrval (id, trackingoperationproductoutcomponent_id, attribute_id, attributevalue_id, value, archived) FROM stdin;
\.


--
-- Data for Name: arch_productioncounting_productiontracking; Type: TABLE DATA; Schema: public; Owner: -
--

COPY public.arch_productioncounting_productiontracking (id, number, order_id, technologyinstanceoperationcomponent_id, shift_id, state, lasttracking, machinetime, labortime, staff_id, workstationtype_id, division_id, active, createdate, updatedate, createuser, updateuser, laststatechangefails, laststatechangefailcause, isexternalsynchronized, timerangefrom, timerangeto, shiftstartday, changeovertime, subcontractor_id, technologyoperationcomponent_id, entityversion, repairorder_id, correction_id, iscorrection, planforordercompleted, workstation_id, batch_id, expirationdate, qualityrating, iscorrected, comments, archived) FROM stdin;
\.


--
-- Data for Name: arch_productioncounting_productiontrackingattachment; Type: TABLE DATA; Schema: public; Owner: -
--

COPY public.arch_productioncounting_productiontrackingattachment (id, productiontracking_id, attachment, name, size, ext, archived) FROM stdin;
\.


--
-- Data for Name: arch_productioncounting_productiontrackingstatechange; Type: TABLE DATA; Schema: public; Owner: -
--

COPY public.arch_productioncounting_productiontrackingstatechange (id, dateandtime, sourcestate, targetstate, status, phase, worker, productiontracking_id, shift_id, entityversion, archived) FROM stdin;
\.


--
-- Data for Name: arch_productioncounting_staffworktime; Type: TABLE DATA; Schema: public; Owner: -
--

COPY public.arch_productioncounting_staffworktime (id, productionrecord_id, worker_id, labortime, effectiveexecutiontimestart, effectiveexecutiontimeend, entityversion, archived) FROM stdin;
\.


--
-- Data for Name: arch_productioncounting_trackinginproductreplacementhelper; Type: TABLE DATA; Schema: public; Owner: -
--

COPY public.arch_productioncounting_trackinginproductreplacementhelper (id, productiontracking_id, product_id, quantity, basicproduct_id, archived) FROM stdin;
\.


--
-- Data for Name: arch_productioncounting_trackingoperationproductincomponent; Type: TABLE DATA; Schema: public; Owner: -
--

COPY public.arch_productioncounting_trackingoperationproductincomponent (id, productiontracking_id, product_id, usedquantity, balance, obtainedquantity, remainedquantity, effectiveusedquantity, givenunit, givenquantity, entityversion, typeofmaterial, wasteused, wasteusedonly, wasteusedquantity, wasteunit, additionalinformation, replacementto_id, archived) FROM stdin;
\.


--
-- Data for Name: arch_productioncounting_trackingoperationproductoutcomponent; Type: TABLE DATA; Schema: public; Owner: -
--

COPY public.arch_productioncounting_trackingoperationproductoutcomponent (id, productiontracking_id, product_id, usedquantity, balance, batch_id, wastedquantity, givenunit, givenquantity, entityversion, wastesquantity, typeofmaterial, storagelocation_id, causeofwastes, palletnumber_id, manyreasonsforlacks, typeofpallet, archived) FROM stdin;
\.


--
-- Data for Name: arch_productioncounting_usedbatch; Type: TABLE DATA; Schema: public; Owner: -
--

COPY public.arch_productioncounting_usedbatch (id, trackingoperationproductincomponent_id, batch_id, quantity, archived) FROM stdin;
\.


--
-- Data for Name: arch_productionpershift_dailyprogress; Type: TABLE DATA; Schema: public; Owner: -
--

COPY public.arch_productionpershift_dailyprogress (id, progressforday_id, shift_id, quantity, locked, entityversion, efficiencytime, archived) FROM stdin;
\.


--
-- Data for Name: arch_productionpershift_productionpershift; Type: TABLE DATA; Schema: public; Owner: -
--

COPY public.arch_productionpershift_productionpershift (id, order_id, plannedprogresscorrectioncomment, orderfinishdate, entityversion, archived) FROM stdin;
\.


--
-- Data for Name: arch_productionpershift_progressforday; Type: TABLE DATA; Schema: public; Owner: -
--

COPY public.arch_productionpershift_progressforday (id, day, corrected, dateofday, actualdateofday, entityversion, productionpershift_id, archived) FROM stdin;
\.


--
-- Data for Name: arch_productionpershift_reasontypeofcorrectionplan; Type: TABLE DATA; Schema: public; Owner: -
--

COPY public.arch_productionpershift_reasontypeofcorrectionplan (id, productionpershift_id, reasontype, date, entityversion, archived) FROM stdin;
\.


--
-- Data for Name: arch_productionscheduling_opercomptimecalculation; Type: TABLE DATA; Schema: public; Owner: -
--

COPY public.arch_productionscheduling_opercomptimecalculation (id, ordertimecalculation_id, technologyoperationcomponent_id, operationoffset, effectiveoperationrealizationtime, effectivedatefrom, effectivedateto, duration, machineworktime, laborworktime, archived) FROM stdin;
\.


--
-- Data for Name: arch_productionscheduling_ordertimecalculation; Type: TABLE DATA; Schema: public; Owner: -
--

COPY public.arch_productionscheduling_ordertimecalculation (id, order_id, effectivedatefrom, effectivedateto, archived) FROM stdin;
\.


--
-- Data for Name: arch_qualitycontrol_qualitycontrol; Type: TABLE DATA; Schema: public; Owner: -
--

COPY public.arch_qualitycontrol_qualitycontrol (id, number, product_id, qualitycard_id, controltype, batch_id, date, staff_id, order_id, qualityrating, state, delivery_id, description, archived) FROM stdin;
\.


--
-- Data for Name: arch_qualitycontrol_qualitycontrolattachment; Type: TABLE DATA; Schema: public; Owner: -
--

COPY public.arch_qualitycontrol_qualitycontrolattachment (id, qualitycontrol_id, attachment, name, size, ext, archived) FROM stdin;
\.


--
-- Data for Name: arch_qualitycontrol_qualitycontrolattributeprodtracking; Type: TABLE DATA; Schema: public; Owner: -
--

COPY public.arch_qualitycontrol_qualitycontrolattributeprodtracking (id, productiontracking_id, attribute_id, attributevalue_id, value, fromtechnology, moment, adddate, archived) FROM stdin;
\.


--
-- Data for Name: arch_qualitycontrol_qualitycontrolattributevalue; Type: TABLE DATA; Schema: public; Owner: -
--

COPY public.arch_qualitycontrol_qualitycontrolattributevalue (id, qualitycontrol_id, attribute_id, attributevalue_id, value, productiontracking_id, fromqualitycard, priority, archived) FROM stdin;
\.


--
-- Data for Name: arch_qualitycontrol_qualitycontrolresource; Type: TABLE DATA; Schema: public; Owner: -
--

COPY public.arch_qualitycontrol_qualitycontrolresource (id, resourcenumber, qualitycontrol_id, resource_id, archived) FROM stdin;
\.


--
-- Data for Name: arch_qualitycontrol_qualitycontrolstatechange; Type: TABLE DATA; Schema: public; Owner: -
--

COPY public.arch_qualitycontrol_qualitycontrolstatechange (id, dateandtime, sourcestate, targetstate, status, phase, worker, qualitycontrol_id, shift_id, archived) FROM stdin;
\.


--
-- Data for Name: arch_repairs_repairorder; Type: TABLE DATA; Schema: public; Owner: -
--

COPY public.arch_repairs_repairorder (id, number, state, order_id, division_id, createdate, shift_id, startdate, enddate, staff_id, product_id, faulttype_id, description, quantitytorepair, quantityrepaired, lack, active, orderdto_id, entityversion, productiontracking_id, labortime, machinetime, repairorderproduct_id, archived) FROM stdin;
\.


--
-- Data for Name: arch_repairs_repairorderproduct; Type: TABLE DATA; Schema: public; Owner: -
--

COPY public.arch_repairs_repairorderproduct (id, trackingoperationproductincomponent_id, division_id, location_id, product_id, faulttype_id, description, givenquantity, givenunit, entityversion, archived) FROM stdin;
\.


--
-- Data for Name: arch_repairs_repairorderstatechange; Type: TABLE DATA; Schema: public; Owner: -
--

COPY public.arch_repairs_repairorderstatechange (id, dateandtime, sourcestate, targetstate, phase, worker, repairorder_id, shift_id, status, archived) FROM stdin;
\.


--
-- Data for Name: arch_repairs_repairorderworktime; Type: TABLE DATA; Schema: public; Owner: -
--

COPY public.arch_repairs_repairorderworktime (id, repairorder_id, staff_id, labortime, effectiveexecutiontimestart, effectiveexecutiontimeend, archived) FROM stdin;
\.


--
-- Data for Name: arch_states_message; Type: TABLE DATA; Schema: public; Owner: -
--

COPY public.arch_states_message (id, type, translationkey, translationargs, correspondfieldname, autoclose, productiontrackingstatechange_id, deliverystatechange_id, assignmenttoshiftstatechange_id, technologystatechange_id, orderstatechange_id, extrusionprotocolstatechange_id, confectionprotocolstatechange_id, palletstatechange_id, batchstatechange_id, trackingrecordstatechange_id, requestforquotationstatechange_id, offerstatechange_id, negotiationstatechange_id, warehouseissuestatechange_id, palletlabelstatechange_id, maintenanceeventstatechange_id, entityversion, plannedeventstatechange_id, recurringeventstatechange_id, archived) FROM stdin;
\.


--
-- Data for Name: arch_stoppage_stoppage; Type: TABLE DATA; Schema: public; Owner: -
--

COPY public.arch_stoppage_stoppage (id, order_id, duration, entityversion, productiontracking_id, reason_id, description, datefrom, dateto, archived) FROM stdin;
\.


--
-- Data for Name: arch_technologies_barcodeoperationcomponent; Type: TABLE DATA; Schema: public; Owner: -
--

COPY public.arch_technologies_barcodeoperationcomponent (id, operationcomponent_id, code, active, entityversion, order_id, archived) FROM stdin;
\.


--
-- Data for Name: arch_urcmaterialavailability_requiredcomponent; Type: TABLE DATA; Schema: public; Owner: -
--

COPY public.arch_urcmaterialavailability_requiredcomponent (id, order_id, technology_id, product_id, availablequantity, reservedquantity, requiredquantity, unit, availability, createdate, updatedate, createuser, updateuser, entityversion, archived) FROM stdin;
\.


--
-- Data for Name: assignmenttoshift_assignmenttoshift; Type: TABLE DATA; Schema: public; Owner: -
--

COPY public.assignmenttoshift_assignmenttoshift (id, startdate, shift_id, state, approvedattendancelist, active, externalnumber, externalsynchronized, showlaststatechangeresult, laststatechangefails, laststatechangefailcause, factory_id, entityversion, crew_id) FROM stdin;
\.


--
-- Data for Name: assignmenttoshift_assignmenttoshiftreport; Type: TABLE DATA; Schema: public; Owner: -
--

COPY public.assignmenttoshift_assignmenttoshiftreport (id, number, name, datefrom, dateto, shift_id, filename, generated, active, createdate, updatedate, createuser, updateuser, factory_id, entityversion) FROM stdin;
\.


--
-- Data for Name: assignmenttoshift_assignmenttoshiftstatechange; Type: TABLE DATA; Schema: public; Owner: -
--

COPY public.assignmenttoshift_assignmenttoshiftstatechange (id, dateandtime, sourcestate, targetstate, status, phase, worker, assignmenttoshift_id, shift_id, additionalinformation, entityversion) FROM stdin;
\.


--
-- Data for Name: assignmenttoshift_multiassignmenttoshift; Type: TABLE DATA; Schema: public; Owner: -
--

COPY public.assignmenttoshift_multiassignmenttoshift (id, productionline_id, occupationtype, occupationtypename, occupationtypeenum, masterorder_id, assignmenttoshift_id, createdate, updatedate, createuser, updateuser) FROM stdin;
\.


--
-- Data for Name: assignmenttoshift_staffassignmenttoshift; Type: TABLE DATA; Schema: public; Owner: -
--

COPY public.assignmenttoshift_staffassignmenttoshift (id, assignmenttoshift_id, worker_id, productionline_id, occupationtype, occupationtypename, state, occupationtypeenum, occupationtypevalueforgrid, masterorder_id, entityversion, description) FROM stdin;
\.


--
-- Data for Name: avglaborcostcalcfororder_assignmentworkertoshift; Type: TABLE DATA; Schema: public; Owner: -
--

COPY public.avglaborcostcalcfororder_assignmentworkertoshift (id, worker_id, assignmenttoshift_id, workedhours, avglaborcostcalcfororder_id, entityversion) FROM stdin;
\.


--
-- Data for Name: avglaborcostcalcfororder_avglaborcostcalcfororder; Type: TABLE DATA; Schema: public; Owner: -
--

COPY public.avglaborcostcalcfororder_avglaborcostcalcfororder (id, startdate, finishdate, order_id, productionline_id, basedon, averagelaborhourlycost, entityversion) FROM stdin;
\.


--
-- Data for Name: basic_address; Type: TABLE DATA; Schema: public; Owner: -
--

COPY public.basic_address (id, company_id, addresstype, number, name, phone, email, website, street, house, flat, zipcode, city, state, country_id, contactperson, canbedeleted, active, externalnumber) FROM stdin;
1	1	main	1-01	\N	+48 881 501 347	welcome@qcadoo.com	http://www.qcadoo.com/	Walerego Sławka	3A	\N	30-633	Kraków	małopolskie	167	\N	f	t	\N
\.


--
-- Data for Name: basic_assortment; Type: TABLE DATA; Schema: public; Owner: -
--

COPY public.basic_assortment (id, name, active) FROM stdin;
\.


--
-- Data for Name: basic_assortmentelement; Type: TABLE DATA; Schema: public; Owner: -
--

COPY public.basic_assortmentelement (id, descriptiontype, description, assortment_id, main) FROM stdin;
\.


--
-- Data for Name: basic_attribute; Type: TABLE DATA; Schema: public; Owner: -
--

COPY public.basic_attribute (id, number, name, datatype, valuetype, "precision", unit, forproduct, forresource, forqualitycontrol, active) FROM stdin;
\.


--
-- Data for Name: basic_attributevalue; Type: TABLE DATA; Schema: public; Owner: -
--

COPY public.basic_attributevalue (id, attribute_id, value, description) FROM stdin;
\.


--
-- Data for Name: basic_company; Type: TABLE DATA; Schema: public; Owner: -
--

COPY public.basic_company (id, number, name, taxcountrycode_id, tax, street, house, flat, zipcode, city, state, country_id, email, website, phone, externalnumber, buffer, active, paymentform, country, entityversion, contactperson, issupplier, isreceiver, logoimage, currency_id, contractorcategory, abcanalysis) FROM stdin;
1	1	Qcadoo Limited Sp. z o.o.	\N	676-241-35-25	Walerego Sławka	3A	\N	30-633	Kraków	małopolskie	167	welcome@qcadoo.com	http://www.qcadoo.com/	+48 881 501 347	\N	\N	t	\N	\N	0	\N	f	f	\N	5	\N	\N
\.


--
-- Data for Name: basic_country; Type: TABLE DATA; Schema: public; Owner: -
--

COPY public.basic_country (id, country, code, entityversion) FROM stdin;
1	Afghanistan	AF	0
2	Albania	AL	0
3	Algeria	DZ	0
4	Andorra	AD	0
5	Angola	AO	0
6	Anguilla	AI	0
7	Antarctica	AQ	0
8	Antigua and Barbuda	AG	0
9	Saudi Arabia	SA	0
10	Argentina	AR	0
11	Armenia	AM	0
12	Aruba	AW	0
13	Australia	AU	0
14	Austria	AT	0
15	Azerbaijan	AZ	0
16	Bahamas	BS	0
17	Bahrain	BH	0
18	Bangladesh	BD	0
19	Barbados	BB	0
20	Belgium	BE	0
21	Belize	BZ	0
22	Benin	BJ	0
23	Bermuda	BM	0
24	Bhutan	BT	0
25	Belarus	BY	0
26	Bolivia, Plurinational State of	BO	0
27	Bonaire, Sint Eustatius and Saba	BQ	0
28	Bosnia and Herzegovina	BA	0
29	Botswana	BW	0
30	Brazil	BR	0
31	Brunei Darussalam	BN	0
32	British Indian Ocean Territory	IO	0
33	Virgin Islands, British	VG	0
34	Bulgaria	BG	0
35	Burkina Faso	BF	0
36	Burundi	BI	0
37	Chile	CL	0
38	China	CN	0
39	Croatia	HR	0
40	Curaçao	CW	0
41	Cyprus	CY	0
42	Chad	TD	0
43	Montenegro	ME	0
44	Czech Republic	CZ	0
45	United States Minor Outlying Islands	UM	0
46	Denmark	DK	0
47	Congo, the Democratic Republic of the	CD	0
48	Dominica	DM	0
49	Dominican Republic	DO	0
50	Djibouti	DJ	0
51	Egypt	EG	0
52	Ecuador	EC	0
53	Eritrea	ER	0
54	Estonia	EE	0
55	Ethiopia	ET	0
56	Falkland Islands (Malvinas)	FK	0
57	Fiji	FJ	0
58	Philippines	PH	0
59	Finland	FI	0
60	France	FR	0
61	French Southern Territories	TF	0
62	Gabon	GA	0
63	Gambia	GM	0
64	South Georgia and the South Sandwich Islands	GS	0
65	Ghana	GH	0
66	Gibraltar	GI	0
67	Greece	EL	0
68	Grenada	GD	0
69	Greenland	GL	0
70	Georgia	GE	0
71	Guam	GU	0
72	Guernsey	GG	0
73	French Guiana	GF	0
74	Guyana	GY	0
75	Guadeloupe	GP	0
76	Guatemala	GT	0
77	Guinea-Bissau	GW	0
78	Equatorial Guinea	GQ	0
79	Guinea	GN	0
80	Haiti	HT	0
81	Spain	ES	0
82	Netherlands	NL	0
83	Honduras	HN	0
84	Hong Kong	HK	0
85	India	IN	0
86	Indonesia	ID	0
87	Iraq	IQ	0
88	Iran, Islamic Republic of	IR	0
89	Ireland	IE	0
90	Iceland	IS	0
91	Israel	IL	0
92	Jamaica	JM	0
93	Japan	JP	0
94	Yemen	YE	0
95	Jersey	JE	0
96	Jordan	JO	0
97	Cayman Islands	KY	0
98	Cambodia	KH	0
99	Cameroon	CM	0
100	Canada	CA	0
101	Qatar	QA	0
102	Kazakhstan	KZ	0
103	Kenya	KE	0
104	Kyrgyzstan	KG	0
105	Kiribati	KI	0
106	Colombia	CO	0
107	Comoros	KM	0
108	Congo	CG	0
109	Korea, Republic of	KR	0
110	Korea, Democratic People's Republic of	KP	0
111	Costa Rica	CR	0
112	Cuba	CU	0
113	Kuwait	KW	0
114	Lao People's Democratic Republic	LA	0
115	Lesotho	LS	0
116	Lebanon	LB	0
117	Liberia	LR	0
118	Libyan Arab Jamahiriya	LY	0
119	Liechtenstein	LI	0
120	Lithuania	LT	0
121	Luxembourg	LU	0
122	Latvia	LV	0
123	Macedonia, the former Yugoslav Republic of	MK	0
124	Madagascar	MG	0
125	Mayotte	YT	0
126	Macao	MO	0
127	Malawi	MW	0
128	Maldives	MV	0
129	Malaysia	MY	0
130	Mali	ML	0
131	Malta	MT	0
132	Northern Mariana Islands	MP	0
133	Morocco	MA	0
134	Martinique	MQ	0
135	Mauritania	MR	0
136	Mauritius	MU	0
137	Mexico	MX	0
138	Micronesia, Federated States of	FM	0
139	Myanmar	MM	0
140	Moldova, Republic of	MD	0
141	Monaco	MC	0
142	Mongolia	MN	0
143	Montserrat	MS	0
144	Mozambique	MZ	0
145	Namibia	NA	0
146	Nauru	NR	0
147	Nepal	NP	0
148	Germany	DE	0
149	Niger	NE	0
150	Nigeria	NG	0
151	Nicaragua	NI	0
152	Niue	NU	0
153	Norfolk Island	NF	0
154	Norway	NO	0
155	New Caledonia	NC	0
156	New Zealand	NZ	0
157	Oman	OM	0
158	Pakistan	PK	0
159	Palau	PW	0
160	Palestinian Territory, Occupied	PS	0
161	Panama	PA	0
162	Papua New Guinea	PG	0
163	Paraguay	PY	0
164	Peru	PE	0
165	Pitcairn	PN	0
166	French Polynesia	PF	0
167	Poland	PL	0
168	Puerto Rico	PR	0
169	Portugal	PT	0
170	South Africa	ZA	0
171	Central African Republic	CF	0
172	Cape Verde	CV	0
173	Réunion	RE	0
174	Russian Federation	RU	0
175	Romania	RO	0
176	Rwanda	RW	0
177	Western Sahara	EH	0
178	Saint Kitts and Nevis	KN	0
179	Saint Lucia	LC	0
180	Saint Vincent and the Grenadines	VC	0
181	Saint Barthélemy	BL	0
182	Saint Martin (French part)	MF	0
183	Saint Pierre and Miquelon	PM	0
184	El Salvador	SV	0
185	American Samoa	AS	0
186	Samoa	WS	0
187	San Marino	SM	0
188	Senegal	SN	0
189	Serbia	RS	0
190	Seychelles	SC	0
191	Sierra Leone	SL	0
192	Singapore	SG	0
193	Sint Maarten (Dutch part)	SX	0
194	Slovakia	SK	0
195	Slovenia	SI	0
196	Somalia	SO	0
197	Sri Lanka	LK	0
198	United States	US	0
199	Swaziland	SZ	0
200	Sudan	SD	0
201	South Sudan	SS	0
202	Suriname	SR	0
203	Svalbard and Jan Mayen	SJ	0
204	Syrian Arab Republic	SY	0
205	Switzerland	CH	0
206	Sweden	SE	0
207	Tajikistan	TJ	0
208	Thailand	TH	0
209	Taiwan, Province of China	TW	0
210	Tanzania, United Republic of	TZ	0
211	Timor-Leste	TL	0
212	Togo	TG	0
213	Tokelau	TK	0
214	Tonga	TO	0
215	Trinidad and Tobago	TT	0
216	Tunisia	TN	0
217	Turkey	TR	0
218	Turkmenistan	TM	0
219	Turks and Caicos Islands	TC	0
220	Tuvalu	TV	0
221	Uganda	UG	0
222	Ukraine	UA	0
223	Uruguay	UY	0
224	Uzbekistan	UZ	0
225	Vanuatu	VU	0
226	Wallis and Futuna	WF	0
227	Holy See (Vatican City State)	VA	0
228	Venezuela, Bolivarian Republic of	VE	0
229	Hungary	HU	0
230	United Kingdom	UK	0
231	Viet Nam	VN	0
232	Italy	IT	0
233	Côte d'Ivoire	CI	0
234	Bouvet Island	BV	0
235	Christmas Island	CX	0
236	Isle of Man	IM	0
237	Saint Helena, Ascension and Tristan da Cunha	SH	0
238	Aland Islands	AX	0
239	Cook Islands	CK	0
240	Virgin Islands, U.S.	VI	0
241	Heard Island and McDonald Islands	HM	0
242	Cocos (Keeling) Islands	CC	0
243	Marshall Islands	MH	0
244	Faroe Islands	FO	0
245	Solomon Islands	SB	0
246	Sao Tome and Principe	ST	0
247	Zambia	ZM	0
248	Zimbabwe	ZW	0
249	United Arab Emirates	AE	0
\.


--
-- Data for Name: basic_crew; Type: TABLE DATA; Schema: public; Owner: -
--

COPY public.basic_crew (id, number, leader_id, active, eventsscheduler) FROM stdin;
\.


--
-- Data for Name: basic_currency; Type: TABLE DATA; Schema: public; Owner: -
--

COPY public.basic_currency (id, currency, alphabeticcode, isocode, minorunit, exchangerate, entityversion) FROM stdin;
17	Belarussian Ruble	BYR	974	0	1.00000	0
20	Bermudian Dollar	BMD	60	2	1.00000	0
22	Ngultrum	BTN	64	2	1.00000	0
24	Mvdol	BOV	984	2	1.00000	0
36	Cayman Islands Dollar	KYD	136	2	1.00000	0
38	Unidades de fomento	CLF	990	0	1.00000	0
41	Unidad de Valor Real	COU	970	2	1.00000	0
47	Cuban Peso	CUP	192	2	1.00000	0
48	Peso Convertible	CUC	931	2	1.00000	0
58	Falkland Islands Pound	FKP	238	2	1.00000	0
84	North Korean Won	KPW	408	2	1.00000	0
89	Latvian Lats	LVL	428	2	1.00000	0
96	Lithuanian Litas	LTL	440	2	1.00000	0
27	Norwegian Krone	NOK	578	2	0.48960	0
50	Czech Koruna	CZK	203	2	0.16130	0
21	Indian Rupee	INR	356	2	0.06050	0
51	Danish Krone	DKK	208	2	0.58610	0
28	Brazilian Real	BRL	986	2	1.30240	0
30	Bulgarian Lev	BGN	975	2	2.19980	0
37	Chilean Peso	CLP	152	0	0.00630	0
39	Yuan Renminbi	CNY	156	2	0.59020	0
44	New Zealand Dollar	NZD	554	2	2.91130	0
46	Croatian Kuna	HRK	191	2	0.57720	0
66	Pound Sterling	GBP	826	2	5.13590	0
72	Forint	HUF	348	2	0.01410	0
75	SDR (Special Drawing Right)	XDR	960	0	5.55200	0
71	Hong Kong Dollar	HKD	344	2	0.52220	0
80	Yen	JPY	392	0	0.03610	0
73	Iceland Krona	ISK	352	0	0.03600	0
74	Rupiah	IDR	360	2	0.00030	0
95	Swiss Franc	CHF	756	2	4.08710	0
78	New Israeli Sheqel	ILS	376	2	1.08160	0
92	Rand	ZAR	710	2	0.30660	0
1	Afghani	AFN	971	2	0.06070	0
3	Lek	ALL	8	2	0.03170	0
4	Algerian Dinar	DZD	12	2	0.03680	0
6	Kwanza	AOA	973	2	0.02440	0
7	East Caribbean Dollar	XCD	951	2	1.49490	0
8	Argentine Peso	ARS	32	2	0.25810	0
9	Armenian Dram	AMD	51	2	0.00830	0
10	Aruban Florin	AWG	533	2	2.26040	0
12	Azerbaijanian Manat	AZN	944	2	2.21680	0
13	Bahamian Dollar	BSD	44	2	4.05210	0
14	Bahraini Dinar	BHD	48	3	10.65420	0
15	Taka	BDT	50	2	0.05060	0
16	Barbados Dollar	BBD	52	2	2.02080	0
18	Belize Dollar	BZD	84	2	2.01280	0
19	CFA Franc BCEAO	XOF	952	0	0.00660	0
23	Boliviano	BOB	68	2	0.58380	0
25	Convertible Mark	BAM	977	2	2.20510	0
26	Pula	BWP	72	2	0.38390	0
29	Brunei Dollar	BND	96	2	2.85420	0
31	Burundi Franc	BIF	108	0	0.00240	0
32	Riel	KHR	116	2	0.00100	0
35	Cape Verde Escudo	CVE	132	2	0.03890	0
40	Colombian Peso	COP	170	2	0.00140	0
42	Comoro Franc	KMF	174	0	0.00880	0
43	Congolese Franc	CDF	976	2	0.00320	0
45	Costa Rican Colon	CRC	188	2	0.00730	0
49	Netherlands Antillean Guilder	ANG	532	2	2.27290	0
52	Djibouti Franc	DJF	262	0	0.02260	0
53	Dominican Peso	DOP	214	2	0.08650	0
54	Egyptian Pound	EGP	818	2	0.22030	0
55	El Salvador Colon	SVC	222	2	0.46360	0
56	Nakfa	ERN	232	2	0.26040	0
57	Ethiopian Birr	ETB	230	2	0.17880	0
59	Fiji Dollar	FJD	242	2	1.97310	0
60	CFP Franc	XPF	953	0	0.03610	0
61	Dalasi	GMD	270	2	0.09130	0
62	Lari	GEL	981	2	1.52370	0
63	Cedi	GHS	936	2	0.92050	0
64	Gibraltar Pound	GIP	292	2	5.06430	0
65	Quetzal	GTQ	320	2	0.54380	0
68	Guyana Dollar	GYD	328	2	0.01950	0
69	Gourde	HTG	332	2	0.06050	0
70	Lempira	HNL	340	2	0.17220	0
76	Iranian Rial	IRR	364	2	0.00010	0
77	Iraqi Dinar	IQD	368	3	0.00340	0
79	Jamaican Dollar	JMD	388	2	0.03150	0
81	Jordanian Dinar	JOD	400	3	5.70210	0
82	Tenge	KZT	398	2	0.01250	0
83	Kenyan Shilling	KES	404	2	0.03900	0
86	Kuwaiti Dinar	KWD	414	3	13.24570	0
87	Som	KGS	417	2	0.05830	0
88	Kip	LAK	418	2	0.00050	0
90	Lebanese Pound	LBP	422	2	0.00270	0
91	Loti	LSL	426	2	0.30080	0
93	Liberian Dollar	LRD	430	2	0.04300	0
94	Libyan Dinar	LYD	434	3	2.84240	0
97	Pataca	MOP	446	2	0.50630	0
98	Denar	MKD	807	2	0.07000	0
99	Malagasy Ariary	MGA	969	2	0.00130	0
100	Kwacha	MWK	454	2	0.00560	0
5	US Dollar	USD	840	2	4.11130	0
105	ADB Unit of Account	XUA	965	0	1.00000	0
107	Mexican Unidad de Inversion (UDI)	MXV	979	2	1.00000	0
124	Zloty	PLN	985	2	1.00000	0
129	Saint Helena Pound	SHP	654	2	1.00000	0
137	Sucre	XSU	994	0	1.00000	0
140	South Sudanese Pound	SSP	728	2	1.00000	0
146	WIR Euro	CHE	947	2	1.00000	0
147	WIR Franc	CHW	948	2	1.00000	0
157	New Manat	TMT	934	2	1.00000	0
161	US Dollar (Next day)	USN	997	2	1.00000	0
162	US Dollar (Same day)	USS	998	2	1.00000	0
164	Uruguay Peso en Unidades Indexadas (URUIURUI)	UYI	940	0	1.00000	0
170	Zambian Kwacha	ZMK	894	2	1.00000	0
171	Zimbabwe Dollar	ZWL	932	2	1.00000	0
172	Bond Markets Unit European Composite Unit (EURCO)	XBA	955	0	1.00000	0
173	Bond Markets Unit European Monetary Unit (E.M.U.-6)	XBB	956	0	1.00000	0
174	Bond Markets Unit European Unit of Account 9 (E.U.A.-9)	XBC	957	0	1.00000	0
175	Bond Markets Unit European Unit of Account 17 (E.U.A.-17)	XBD	958	0	1.00000	0
176	UIC-Franc	XFU	0	0	1.00000	0
177	Codes specifically reserved for testing purposes	XTS	963	0	1.00000	0
178	Gold	XAU	959	0	1.00000	0
179	Palladium	XPD	964	0	1.00000	0
180	Platinum	XPT	962	0	1.00000	0
181	Silver	XAG	961	0	1.00000	0
182	The codes assigned for transactions where no currency is involved	XXX	999	0	1.00000	0
85	Won	KRW	410	0	0.00360	0
101	Malaysian Ringgit	MYR	458	2	0.91070	0
106	Mexican Peso	MXN	484	2	0.20020	0
123	Philippine Peso	PHP	608	2	0.08130	0
126	Leu	RON	946	2	0.95530	0
127	Russian Ruble	RUB	643	2	0.07030	0
136	Singapore Dollar	SGD	702	2	2.85820	0
152	Baht	THB	764	2	0.11590	0
156	Turkish Lira	TRY	949	2	1.11020	0
159	Hryvnia	UAH	980	2	0.14910	0
33	CFA Franc BEAC	XAF	950	0	0.00660	0
67	Guinea Franc	GNF	324	0	0.00040	0
102	Rufiyaa	MVR	462	2	0.26270	0
103	Ouguiya	MRO	478	2	0.01130	0
104	Mauritius Rupee	MUR	480	2	0.11400	0
108	Moldovan Leu	MDL	498	2	0.20280	0
109	Tugrik	MNT	496	2	0.00160	0
110	Moroccan Dirham	MAD	504	2	0.40340	0
111	Metical	MZN	943	2	0.05770	0
112	Kyat	MMK	104	2	0.00300	0
113	Namibia Dollar	NAD	516	2	0.30070	0
114	Nepalese Rupee	NPR	524	2	0.03760	0
115	Cordoba Oro	NIO	558	2	0.13720	0
116	Naira	NGN	566	2	0.01290	0
117	Rial Omani	OMR	512	3	10.43250	0
118	Pakistan Rupee	PKR	586	2	0.03860	0
119	Balboa	PAB	590	2	4.05210	0
120	Kina	PGK	598	2	1.28700	0
121	Guarani	PYG	600	0	0.00070	0
122	Nuevo Sol	PEN	604	2	1.22780	0
125	Qatari Rial	QAR	634	2	1.11300	0
128	Rwanda Franc	RWF	646	0	0.00480	0
130	Tala	WST	882	2	1.62140	0
131	Dobra	STD	678	2	0.00020	0
132	Saudi Riyal	SAR	682	2	1.07950	0
133	Serbian Dinar	RSD	941	2	0.03480	0
134	Seychelles Rupee	SCR	690	2	0.29970	0
135	Leone	SLL	694	2	0.00050	0
138	Solomon Islands Dollar	SBD	90	2	0.51840	0
139	Somali Shilling	SOS	706	2	0.00700	0
141	Sri Lanka Rupee	LKR	144	2	0.02680	0
142	Sudanese Pound	SDG	938	2	0.63010	0
143	Surinam Dollar	SRD	968	2	0.53750	0
144	Lilangeni	SZL	748	2	0.30080	0
148	Syrian Pound	SYP	760	2	0.00790	0
149	New Taiwan Dollar	TWD	901	2	0.13020	0
150	Somoni	TJS	972	2	0.51040	0
151	Tanzanian Shilling	TZS	834	2	0.00180	0
153	Pa’anga	TOP	776	2	1.86700	0
154	Trinidad and Tobago Dollar	TTD	780	2	0.60120	0
155	Tunisian Dinar	TND	788	3	1.77290	0
158	Uganda Shilling	UGX	800	2	0.00110	0
160	UAE Dirham	AED	784	2	1.10140	0
163	Peso Uruguayo	UYU	858	2	0.14250	0
165	Uzbekistan Sum	UZS	860	2	0.00120	0
166	Vatu	VUV	548	0	0.03710	0
167	Bolivar Fuerte	VEF	937	2	0.40510	0
168	Dong	VND	704	0	0.00020	0
169	Yemeni Rial	YER	886	2	0.01620	0
2	Euro	EUR	978	2	4.35830	0
11	Australian Dollar	AUD	36	2	3.14310	0
34	Canadian Dollar	CAD	124	2	3.14020	0
145	Swedish Krona	SEK	752	2	0.46020	0
\.


--
-- Data for Name: basic_dashboardbutton; Type: TABLE DATA; Schema: public; Owner: -
--

COPY public.basic_dashboardbutton (id, parameter_id, identifier, item_id, icon, succession, active) FROM stdin;
1	1	basic.dashboardButton.identifier.orders.ordersPlanningList	47	/qcadooView/public/css/core/images/dashboard/orders.png	1	t
4	1	basic.dashboardButton.identifier.technology.technologiesList	39	/qcadooView/public/css/core/images/dashboard/technologies.png	4	t
2	1	basic.dashboardButton.identifier.orders.operationalTasksList	46	/qcadooView/public/css/core/images/dashboard/operationalTasks.png	2	t
3	1	basic.dashboardButton.identifier.orders.schedulesList	149	/qcadooView/public/css/core/images/dashboard/schedules.png	3	t
10	1	basic.dashboardButton.identifier.ordersTracking.productionTrackingsList	96	/qcadooView/public/css/core/images/dashboard/productionTrackings.png	9	t
11	1	basic.dashboardButton.identifier.ordersTracking.productionBalancesList	95	/qcadooView/public/css/core/images/dashboard/productionBalances.png	10	f
14	1	basic.dashboardButton.identifier.orders.productionLineSchedulesList	200	/qcadooView/public/css/core/images/dashboard/schedules.png	11	f
15	1	basic.dashboardButton.identifier.orders.salesPlansList	181	/qcadooView/public/css/core/images/dashboard/orders.png	12	f
16	1	basic.dashboardButton.identifier.orders.masterOrdersList	77	/qcadooView/public/css/core/images/dashboard/orders.png	13	f
17	1	basic.dashboardButton.identifier.orders.sgOrdersGantt	202	/qcadooView/public/css/core/images/dashboard/schedules.png	14	f
18	1	basic.dashboardButton.identifier.orders.operationalTasksGantt	154	/qcadooView/public/css/core/images/dashboard/schedules.png	15	t
6	1	basic.dashboardButton.identifier.requirements.deliveriesList	62	/qcadooView/public/css/core/images/dashboard/deliveries.png	5	f
7	1	basic.dashboardButton.identifier.materialFlow.warehouseStocksList	72	/qcadooView/public/css/core/images/dashboard/warehouseStocks.png	6	f
8	1	basic.dashboardButton.identifier.materialFlow.resourcesList	75	/qcadooView/public/css/core/images/dashboard/resources.png	7	f
9	1	basic.dashboardButton.identifier.materialFlow.documentsList	73	/qcadooView/public/css/core/images/dashboard/documents.png	8	f
\.


--
-- Data for Name: basic_division; Type: TABLE DATA; Schema: public; Owner: -
--

COPY public.basic_division (id, number, name, supervisor_id, componentslocation_id, componentsoutputlocation_id, productsinputlocation_id, productionline_id, productsflowlocation_id, productionflow, factory_id, active, comment, entityversion, wastereceptionwarehouse_id) FROM stdin;
\.


--
-- Data for Name: basic_factory; Type: TABLE DATA; Schema: public; Owner: -
--

COPY public.basic_factory (id, number, name, city, active, entityversion, warehouse_id) FROM stdin;
\.


--
-- Data for Name: basic_faulttype; Type: TABLE DATA; Schema: public; Owner: -
--

COPY public.basic_faulttype (id, name, appliesto, entityversion, isdefault, active) FROM stdin;
1	Other	\N	0	t	t
\.


--
-- Data for Name: basic_forms; Type: TABLE DATA; Schema: public; Owner: -
--

COPY public.basic_forms (id, number, name, company_id, size, unit, active) FROM stdin;
\.


--
-- Data for Name: basic_label; Type: TABLE DATA; Schema: public; Owner: -
--

COPY public.basic_label (id, name, description, createdate, updatedate, createuser, updateuser, active) FROM stdin;
\.


--
-- Data for Name: basic_licenseusage; Type: TABLE DATA; Schema: public; Owner: -
--

COPY public.basic_licenseusage (id, createtime, user_id, staff_id) FROM stdin;
\.


--
-- Data for Name: basic_log; Type: TABLE DATA; Schema: public; Owner: -
--

COPY public.basic_log (id, createtime, user_id, message, item1, item2, item3, details, loglevel, logtype, action) FROM stdin;
\.


--
-- Data for Name: basic_machineworkingperiod; Type: TABLE DATA; Schema: public; Owner: -
--

COPY public.basic_machineworkingperiod (id, launchdate, stopdate, workingtime, workstation_id, launchedby_id, stoppedby_id) FROM stdin;
\.


--
-- Data for Name: basic_model; Type: TABLE DATA; Schema: public; Owner: -
--

COPY public.basic_model (id, name, assortment_id, forms_id, typeofproduct, label_id, createdate, updatedate, createuser, updateuser, active) FROM stdin;
\.


--
-- Data for Name: basic_numberpattern; Type: TABLE DATA; Schema: public; Owner: -
--

COPY public.basic_numberpattern (id, number, name, pattern, usedin, used) FROM stdin;
\.


--
-- Data for Name: basic_numberpatternelement; Type: TABLE DATA; Schema: public; Owner: -
--

COPY public.basic_numberpatternelement (id, numberpattern_id, element, value, succession, sequencecycle) FROM stdin;
\.


--
-- Data for Name: basic_palletnumber; Type: TABLE DATA; Schema: public; Owner: -
--

COPY public.basic_palletnumber (id, number, active, createdate, updatedate, createuser, updateuser, issuedatetime) FROM stdin;
\.


--
-- Data for Name: basic_palletnumberhelper; Type: TABLE DATA; Schema: public; Owner: -
--

COPY public.basic_palletnumberhelper (id, quantity, active, createdate, updatedate, createuser, updateuser, temporary) FROM stdin;
\.


--
-- Data for Name: basic_parameter; Type: TABLE DATA; Schema: public; Owner: -
--

COPY public.basic_parameter (id, country_id, currency_id, unit, additionaltextinfooter, company_id, registerproductiontime, reasonneededwhendelayedeffectivedatefrom, earliereffectivedatetotime, reasonneededwhencorrectingtherequestedvolume, reasonneededwhencorrectingdateto, reasonneededwhenchangingstatetodeclined, imageurlinworkplan, hidedescriptioninworkplans, defaultproductionline_id, reasonneededwhenearliereffectivedateto, earliereffectivedatefromtime, defaultaddress, allowquantitychangeinacceptedorder, reasonneededwhendelayedeffectivedateto, justone, registerquantityinproduct, reasonneededwhenchangingstatetointerrupted, registerquantityoutproduct, dontprintordersinworkplans, location_id, typeofproductionrecording, dontprintinputproductsinworkplans, delayedeffectivedatefromtime, hideemptycolumnsfororders, reasonneededwhenchangingstatetoabandoned, autocloseorder, allowtoclose, dontprintoutputproductsinworkplans, inputproductsrequiredfortype, otheraddress, reasonneededwhenearliereffectivedatefrom, defaultdescription, delayedeffectivedatetotime, hidetechnologyandorderinworkplans, reasonneededwhencorrectingdatefrom, ssccnumberprefix, lowerlimit, negativetrend, upperlimit, positivetrend, dueweight, printoperationatfirstpageinworkplans, averagelaborhourlycostpb, materialcostsusedpb, additionaloverheadpb, materialcostmarginpb, includetpzpb, productioncostmarginpb, averagemachinehourlycostpb, includeadditionaltimepb, batchnumberuniqueness, defaultcoveragefromdays, includedraftdeliveries, coveragetype, hideemptycolumnsforoffers, hideemptycolumnsforrequests, validateproductionrecordtimes, workstationsquantityfromproductionline, lockproductionprogress, hidebarcodeoperationcomponentinworkplans, ignoremissingcomponents, additionaloutputrows, additionalinputrows, allowmultipleregisteringtimeforworker, pricebasedon, takeactualprogressinworkplans, confectionplanrequirereasontypethreshold, confectionplancorrectionreasontype, automaticsavecoverage, externaldeliveriesextension, warehouse_id, documentstate, positivepurchaseprice, sameordernumber, automaticdeliveriesminstate, possibleworktimedeviation, ordersincludeperiod, includerequirements, entityversion, labelsbtpath, profitpb, registrationpriceoverheadpb, sourceofoperationcostspb, acceptanceevents, useblackbox, generatewarehouseissuestoorders, daysbeforeorderstart, issuelocation_id, consumptionofrawmaterialsbasedonstandards, documentpositionparameters_id, includecomponents, warehouseissuesreservestates, drawndocuments, issuedquantityuptoneed, documentsstatus, warehouseissueproductssource, productstoissue, trackingcorrectionrecalculatepps, deliveredbiggerthanordered, ordersganttparameters_id, additionalimage, autorecalculateorder, ppsisautomatic, ppsproducedamountrecalculateplan, ppsalgorithm, baselinkerparameters_id, technologiesgeneratorcopyproductsize, cartonlabelsbtpath, maxproductsquantity, allowerrorsinmasterorderpositions, companyname_id, hideassignedstaff, fillorderdescriptionbasedontechnologydescription, allowanomalycreationonacceptancerecord, includelevelandsuffix, orderedproductsunit, allowincompleteunits, acceptrecordsfromterminal, allowchangestousedquantityonterminal, includeadditionaltimeps, includetpzps, ordersgenerationnotcompletedates, canchangeprodlineforacceptedorders, generateeachonseparatepage, includewagegroups, ordersgeneratedbycoverage, automaticallygenerateordersforcomponents, seteffectivedatefromoninprogress, seteffectivedatetooncompleted, copydescription, exporttopdfonlyvisiblecolumns, additionalcartonlabelsquantity, maxcartonlabelsquantity, exporttocsvonlyvisiblecolumns, flagpercentageofexecutionwithcolor, opertaskflagpercentexecutionwithcolor, automaticclosingoforderwithingroups, copynotesfrommasterorderposition, manuallysendwarehousedocuments, realizationfromstock, alwaysorderitemswithpersonalization, selectorder, availabilityofrawmaterials, selectoperationaltask, stoppages, repair, employeeprogress, includeunacceptableproduction, calculateamounttimeemployeesonacceptancerecord, notshowtasksdownloadedbyanotheremployee, createcollectiveorders, completemasterorderafterorderingpositions, hideorderedproductworkplan, selectiontasksbyorderdateinterminal, showprogress, showdelays, requiresupplieridentification, numberpattern_id, generatebatchfororderedproduct, generatebatchoforderedproduct, acceptbatchtrackingwhenclosingorder, completewarehousesflowwhilechecking, qualitycontrol, finalqualitycontrolwithoutresources, terminalproductattribute_id, oeefor, oeeworktimefrom, range, division_id, showqronordersgrouppdf, advisestartdateoftheorder, orderstartdatebasedon, showchartondashboard, whattoshowondashboard, dashboardoperation_id, dashboardcomponentslocation_id, dashboardproductsinputlocation_id, momentofvalidation, moveproductstosubsequentoperations, demandcausesofwastes, wmsapk, wmsversion, applicationconfigured, materialcostsused, usenominalcostpricenotspecified, sourceofoperationcosts, standardlaborcost_id, averagemachinehourlycost, averagelaborhourlycost, includetpz, includeadditionaltime, materialcostmargin, productioncostmargin, additionaloverhead, registrationpriceoverhead, profit, applicationconfigurationfinished, generatepacksfororders, includepacksgeneratingprocessesfororder, optimalpacksize, restfeedinglastpack, deliveryusenominalcostwhenpricenotspecified, deliverypricefillbasedon, allowcheckedtechnologywithoutinproducts, requireassortment, changeorderdatesbasedonchangegroupdates, acceptedtechnologymarkedasdefault, terminalscanning, processsource, showproductdescriptiononordersgrouppdf, attributeonordersgrouppdf_id, copyattributestosizeproducts, materialcostsusedmc, usenominalcostpricenotspecifiedmc, productattribute_id, materialattribute_id, attributeonthelabel_id, requiretypeoffault, workingstationinputtype, allowchangeordeleteordertechnologicalprocess, technicalproductioncostoverhead, technicalproductioncostoverheadpb, synchronizeadditionalproductdata, processterminalplaceofperformance, emptylabelbtpath, schedulesortorder, workstationassigncriterion, workerassigncriterion, additionaltimeextendsoperation, synchronizeproductcategory, completenominalcostinarticleandproducts, copynominalcostfamilyofproductssizes, onlypackagesinproduction, allowtilelengthtobeedited, analyzeavailableresources, analyzeplannedquantity, analyzemaxquantity, numberpatternordergroup_id, otcopydescriptionfromproductionorder, setorderdatesbasedontaskdates, automaticallygeneratetasksfororder, automaticallygenerateprocessesfororder, includeadditionaltimesg, includetpzsg, includetpzs, dashboardshowforproduct, dashboardshowdescription, receivedeliveryinordercurrency, sortbyproducttypepriorityordersgrouppdf, attributeonordersgrouprequirementpdf_id, quantitymadeonthebasisofdashboard, producingmorethanplanned, logo, synchronizemasterorderattributes, synchronizedocumentpositionattributes, dashboardordersorting, completestationandemployeeingeneratedtasks, considerexceptionswhenpromptingcurrentshift, productionorderedquantityclosestheorder, receiptofproducts, releaseofmaterials, considerminimumstocklevelwhencreatingproductionorders, fillorderdescriptionbasedonproductdescription, ganttrunadjusterror, checkfortheexistenceofinputproductprices, automaticupdatecostnorms, costssource, automaticreleaseaftergeneration, analyzeactualstaff, analyzeactualstaffmaxquantity, analyzegetquantityfromshiftassignment, setmasterorderdatebasedonorderdates, notshowtasksblockedbyprevious, promptdefaultlinefromtechnology, numberofficelicenses, numberterminallicenses, typeterminallicenses, notshoworderfilters, notincludedateswhenretrievingorders, requirequalityrating, synchronizeproductsize, masterorderreleaselocation_id, demandworkstation, skipfinishedtasks, onlyonebatchtrackingfororder, producedbatchfromordertrackingrecord, packaginglocation_id, includeworkstationongetrrforot, notincludeworkstationwhensearchingot, generatetransferdocumentsonrepair, howmanydaysrecalculateplan, operationproductindefaultquantity, operationproductoutdefaultquantity, manyarticleswiththesameean, includeincalculationdeliveries, transferordersgrouptoordersforcomponents, automaticallyusethebatchplannedinorder, productdeliverybatchevidence, productdeliverybatchnumberpattern_id, showmachineperiodregistration, mergingordersforcomponents, tasksselectionby, recalculateplantasksorder, numbervisibleorderstasksondashboard, updatetechnologiesonpendingorders, sharingregistrationrecord, noexchangeratedownload, createfailtodowntime, optimizecuttinglengthattribute_id, optimizecuttingfinalwasteunit, optimizecuttingfinalwaste, dimensioncontrolofproducts, showplannedeventsonchart, updateplannedeventfinishdate, copyattributestoproducts, technologiesgeneratorcopyproductattributes, allowtotalregistration, workingtimetotalregistration, wastesconsumerawmaterials, moldrewclient_id, deadlinefororderbasedondeliverydate, deadlinefororderearlierthandeliverydate, operationaltasksrecalculationtoken, plannerworkstationassigncriterion, deadlinesort, operationlevelsort, orderprioritysort, abcanalysissort, allowmasterorderdeadlinechange, scheduleduration, plandimensioncontrolofproducts, orderdimensioncontrolofproducts, pricelistattribute1_id, pricelistattribute2_id, recalculateplanafterfinishtaskinterminal, numberapslicenses, numberwmsmobilelicenses) FROM stdin;
1	\N	5	pc	\N	1	t	f	0	f	f	f	\N	f	1	f	0	\N	t	f	f	t	f	t	f	\N	03forEach	f	0	f	f	f	f	f	01startOrder	\N	f	\N	0	f	f	0005900125	\N	\N	\N	\N	\N	f	\N	03lastPurchase	\N	\N	f	\N	\N	f	01globally	14	f	\N	f	f	f	f	f	f	t	\N	\N	f	01nominalProductCost	f	\N	\N	f	\N	\N	01draft	f	f	f	\N	\N	f	0	\N	\N	\N	02parameters	f	\N	f	\N	\N	t	1	f	f	01transfer	f	01accepted	01order	01allInputProducts	f	t	\N	\N	f	f	f	\N	\N	\N	\N	150	\N	\N	f	t	f	t	\N	f	f	t	f	f	f	t	f	f	f	f	f	f	t	f	50	3000	f	t	t	f	f	f	f	f	t	f	t	t	t	f	t	f	f	f	f	f	f	f	f	f	\N	\N	f	f	t	t	f	\N	01productionLine	01staffWorkTimes	01oneDivision	\N	f	t	03endDateLastOrderOnTheLine	t	02operationalTasks	\N	\N	\N	01orderAcceptance	t	f	\N	\N	t	01nominal	f	01technologyOperation	\N	\N	\N	f	f	0.00000	0.00000	0.00000	0.00000	0.00000	f	f	f	\N	\N	f	01lastPurchasePrice	f	f	f	f	01operationNumber	01orderPackages	f	\N	f	01nominal	f	\N	\N	\N	f	01scanTheNumber	f	0.00000	0.00000	f	01workstation	\N	01desc	01shortestTime	01workstationLastOperatorLatestFinished	t	t	f	f	f	f	f	f	\N	\N	f	f	f	f	\N	\N	t	01number	f	f	t	\N	01approvedProduction	t	\N	f	f	01startDate	f	f	f	04doNotCreateDocuments	04doNotCreateDocuments	f	f	t	f	f	01mes	f	f	\N	f	f	f	t	10000	0	03over51Employees	f	f	t	f	\N	f	f	f	f	\N	f	f	t	7	\N	\N	f	01confirmedDeliveries	f	f	f	\N	f	f	02taskDate	01operationsLevelAndTasksStartDate	50	f	f	f	f	\N	\N	\N	f	f	f	f	f	f	01duplicatedForEachOrder	t	\N	f	0	\N	01minDeadlineForOrder	t	t	f	f	f	90	f	f	\N	\N	f	0	0
\.


--
-- Data for Name: basic_piecerate; Type: TABLE DATA; Schema: public; Owner: -
--

COPY public.basic_piecerate (id, number, name) FROM stdin;
\.


--
-- Data for Name: basic_piecerateitem; Type: TABLE DATA; Schema: public; Owner: -
--

COPY public.basic_piecerateitem (id, piecerate_id, actualrate, datefrom, dateto) FROM stdin;
\.


--
-- Data for Name: basic_product; Type: TABLE DATA; Schema: public; Owner: -
--

COPY public.basic_product (id, number, name, globaltypeofmaterial, ean, category, unit, externalnumber, description, parent_id, entitytype, durabilityinmonths, averageoffercost, costfornumber, lastpurchasecost, lastoffercost, isglutenproduct, symbol, averagecost, goodsgroup, nominalcost, bio, isdoublepallet, technologygroup_id, active, createdate, updatedate, createuser, updateuser, quantityofextrusioningredient, norm, actualversion, hasnutritionelements, quantityfornutritions, quantityfornutritionsunit, showinproductdata, doublequantityfordoublepallet, usedquantitycontrol, automaticusedquantity, nominalweight, countusedquantityforfullpallets, quantityinpackage, synchronize, capacitynormfortwodimensionalmachines, downform_id, upform_id, downshelve_id, upshelve_id, costnormsgenerator_id, producer_id, machinepart, drawingnumber, catalognumber, isproductiondate, entityversion, ispallet, additionalunit, fromgenerator, generatorcontext_id, dateformatinqcp5code, assortment_id, isoil, isaroma, capacitynormforthreedimensionalmachines, recommendednumofheadsfortwodimensionalmachines, recommendednumofheadsforthreedimensionalmachines, iscartonlabel, isactivecartonlabelquantity, batchevidence, expirydatevalidity, productform_id, size_id, model_id, supplier_id, nominalcostcurrency_id, averagecostcurrency_id, lastpurchasecostcurrency_id, expirydatevalidityunit, orderedproductconfigurator_id, batchnumberpattern_id) FROM stdin;
\.


--
-- Data for Name: basic_productattachment; Type: TABLE DATA; Schema: public; Owner: -
--

COPY public.basic_productattachment (id, product_id, attachment, name, size, ext) FROM stdin;
\.


--
-- Data for Name: basic_productattributevalue; Type: TABLE DATA; Schema: public; Owner: -
--

COPY public.basic_productattributevalue (id, product_id, attribute_id, attributevalue_id, value) FROM stdin;
\.


--
-- Data for Name: basic_qualitycard; Type: TABLE DATA; Schema: public; Owner: -
--

COPY public.basic_qualitycard (id, number, name, description, state, sampling) FROM stdin;
\.


--
-- Data for Name: basic_qualitycardstatechange; Type: TABLE DATA; Schema: public; Owner: -
--

COPY public.basic_qualitycardstatechange (id, dateandtime, sourcestate, targetstate, status, phase, worker, qualitycard_id, shift_id) FROM stdin;
\.


--
-- Data for Name: basic_reportcolumnwidth; Type: TABLE DATA; Schema: public; Owner: -
--

COPY public.basic_reportcolumnwidth (id, identifier, name, width, chartype, parameter_id, entityversion) FROM stdin;
1	productUnit	basic.reportColumnWidth.name.value.Unit	\N	01smallChars	1	0
2	currency	basic.reportColumnWidth.name.value.Currency	\N	01smallChars	1	0
3	number	basic.reportColumnWidth.name.value.Number	\N	01smallChars	1	0
4	succession	basic.reportColumnWidth.name.value.Lp	\N	01smallChars	1	0
5	price	basic.reportColumnWidth.name.value.Price	\N	01smallChars	1	0
6	name	basic.reportColumnWidth.name.value.Name	\N	01smallChars	1	0
7	quantity	basic.reportColumnWidth.name.value.Quantity	\N	01smallChars	1	0
8	catalogNumber	basic.reportColumnWidth.name.value.CatalogNumber	\N	01smallChars	1	0
\.


--
-- Data for Name: basic_shift; Type: TABLE DATA; Schema: public; Owner: -
--

COPY public.basic_shift (id, name, mondayworking, mondayhours, tuesdayworking, tuesdayhours, wensdayworking, wensdayhours, thursdayworking, thursdayhours, fridayworking, fridayhours, saturdayworking, saturdayhours, sundayworking, sundayhours, entityversion) FROM stdin;
1	1	t	8:00-16:00	t	8:00-16:00	t	8:00-16:00	t	8:00-16:00	t	8:00-16:00	f	\N	f	\N	0
\.


--
-- Data for Name: basic_shifttimetableexception; Type: TABLE DATA; Schema: public; Owner: -
--

COPY public.basic_shifttimetableexception (id, name, fromdate, todate, type, relatestoprevday, entityversion) FROM stdin;
\.


--
-- Data for Name: basic_size; Type: TABLE DATA; Schema: public; Owner: -
--

COPY public.basic_size (id, number, succession, createdate, updatedate, createuser, updateuser, active) FROM stdin;
\.


--
-- Data for Name: basic_sizegroup; Type: TABLE DATA; Schema: public; Owner: -
--

COPY public.basic_sizegroup (id, number, createdate, updatedate, createuser, updateuser, active) FROM stdin;
\.


--
-- Data for Name: basic_skill; Type: TABLE DATA; Schema: public; Owner: -
--

COPY public.basic_skill (id, name, description, maximumlevel, active) FROM stdin;
\.


--
-- Data for Name: basic_staff; Type: TABLE DATA; Schema: public; Owner: -
--

COPY public.basic_staff (id, number, name, surname, email, phone, workfor_id, post, division_id, individuallaborcost, determinedindividual, laborhourlycost, wagegroup_id, active, parameter_id, entityversion, crew_id, workstation_id, productionline_id) FROM stdin;
\.


--
-- Data for Name: basic_staffskill; Type: TABLE DATA; Schema: public; Owner: -
--

COPY public.basic_staffskill (id, staff_id, skill_id, level, active) FROM stdin;
\.


--
-- Data for Name: basic_subassembly; Type: TABLE DATA; Schema: public; Owner: -
--

COPY public.basic_subassembly (id, number, name, workstationtype_id, workstation_id, serialnumber, series, producer, productiondate, lastrepairsdate, active, type, entityversion) FROM stdin;
\.


--
-- Data for Name: basic_subassemblyattachment; Type: TABLE DATA; Schema: public; Owner: -
--

COPY public.basic_subassemblyattachment (id, subassembly_id, attachment, name, size, ext, entityversion) FROM stdin;
\.


--
-- Data for Name: basic_subassemblytoworkstationhelper; Type: TABLE DATA; Schema: public; Owner: -
--

COPY public.basic_subassemblytoworkstationhelper (id, subassembly_id, type, workstation_id, entityversion) FROM stdin;
\.


--
-- Data for Name: basic_substitutecomponent; Type: TABLE DATA; Schema: public; Owner: -
--

COPY public.basic_substitutecomponent (id, product_id, quantity, baseproduct_id, entityversion) FROM stdin;
\.


--
-- Data for Name: basic_technologicalprocessrate; Type: TABLE DATA; Schema: public; Owner: -
--

COPY public.basic_technologicalprocessrate (id, number, name) FROM stdin;
\.


--
-- Data for Name: basic_technologicalprocessrateitem; Type: TABLE DATA; Schema: public; Owner: -
--

COPY public.basic_technologicalprocessrateitem (id, technologicalprocessrate_id, actualrate, datefrom, dateto) FROM stdin;
\.


--
-- Data for Name: basic_viewedactivity; Type: TABLE DATA; Schema: public; Owner: -
--

COPY public.basic_viewedactivity (id, user_id, log_id) FROM stdin;
\.


--
-- Data for Name: basic_workstation; Type: TABLE DATA; Schema: public; Owner: -
--

COPY public.basic_workstation (id, number, name, description, workstationtype_id, operation_id, active, productionline_id, division_id, serialnumber, udtnumber, series, producer, productiondate, wnknumber, entityversion, staff_id, dateofadmission, dateofwithdrawal, state, minimumdimension, minimumdimensionunit, maximumdimension, maximumdimensionunit, virtual) FROM stdin;
\.


--
-- Data for Name: basic_workstationattachment; Type: TABLE DATA; Schema: public; Owner: -
--

COPY public.basic_workstationattachment (id, workstation_id, attachment, name, size, ext, entityversion) FROM stdin;
\.


--
-- Data for Name: basic_workstationtype; Type: TABLE DATA; Schema: public; Owner: -
--

COPY public.basic_workstationtype (id, name, number, description, active, subassembly, entityversion) FROM stdin;
\.


--
-- Data for Name: basicproductioncounting_basicproductioncounting; Type: TABLE DATA; Schema: public; Owner: -
--

COPY public.basicproductioncounting_basicproductioncounting (id, order_id, product_id, usedquantity, producedquantity, entityversion) FROM stdin;
\.


--
-- Data for Name: basicproductioncounting_productioncountingattributevalue; Type: TABLE DATA; Schema: public; Owner: -
--

COPY public.basicproductioncounting_productioncountingattributevalue (id, productioncountingquantity_id, attribute_id, attributevalue_id, value) FROM stdin;
\.


--
-- Data for Name: basicproductioncounting_productioncountingoperationrun; Type: TABLE DATA; Schema: public; Owner: -
--

COPY public.basicproductioncounting_productioncountingoperationrun (id, order_id, technologyoperationcomponent_id, runs, entityversion) FROM stdin;
\.


--
-- Data for Name: basicproductioncounting_productioncountingquantity; Type: TABLE DATA; Schema: public; Owner: -
--

COPY public.basicproductioncounting_productioncountingquantity (id, order_id, product_id, plannedquantity, isnoncomponent, technologyoperationcomponent_id, basicproductioncounting_id, typeofmaterial, role, componentsoutputlocation_id, componentslocation_id, productsinputlocation_id, productionflow, productsflowlocation_id, entityversion, replacementto_id, showmaterialcomponentinworkplan, technologyinputproducttype_id, usedquantity, producedquantity, wastereceptionwarehouse_id, attribute_id) FROM stdin;
\.


--
-- Data for Name: basicproductioncounting_productioncountingquantitychange; Type: TABLE DATA; Schema: public; Owner: -
--

COPY public.basicproductioncounting_productioncountingquantitychange (id, order_id, product_id, plannedquantitybefore, plannedquantityafter, dateandtime, worker, changetype) FROM stdin;
\.


--
-- Data for Name: basicproductioncounting_productioncountingreplacementhelper; Type: TABLE DATA; Schema: public; Owner: -
--

COPY public.basicproductioncounting_productioncountingreplacementhelper (id, order_id, product_id, basicproduct_id, plannedquantity, replacesquantity, productioncountingquantity_id) FROM stdin;
\.


--
-- Data for Name: basicproductioncounting_section; Type: TABLE DATA; Schema: public; Owner: -
--

COPY public.basicproductioncounting_section (id, productioncountingquantity_id, length, quantity, unit) FROM stdin;
\.


--
-- Data for Name: cdnrcgoodfood_cancelprotocol; Type: TABLE DATA; Schema: public; Owner: -
--

COPY public.cdnrcgoodfood_cancelprotocol (id, extrusionprotocol_id, confectionprotocol_id, createdate, laststatechangefailcause, iscanceled) FROM stdin;
\.


--
-- Data for Name: cdnrcgoodfood_highestmasterordernum; Type: TABLE DATA; Schema: public; Owner: -
--

COPY public.cdnrcgoodfood_highestmasterordernum (id, type, number, entityversion) FROM stdin;
\.


--
-- Data for Name: cmmsmachineparts_action; Type: TABLE DATA; Schema: public; Owner: -
--

COPY public.cmmsmachineparts_action (id, name, appliesto, entityversion, isdefault) FROM stdin;
1	Other	\N	0	t
\.


--
-- Data for Name: cmmsmachineparts_actionforplannedevent; Type: TABLE DATA; Schema: public; Owner: -
--

COPY public.cmmsmachineparts_actionforplannedevent (id, plannedevent_id, description, action_id, responsibleworker_id, responsibleworkername, state, reason, entityversion, actionname) FROM stdin;
\.


--
-- Data for Name: cmmsmachineparts_eventattachment; Type: TABLE DATA; Schema: public; Owner: -
--

COPY public.cmmsmachineparts_eventattachment (id, maintenanceevent_id, attachment, name, size, ext, entityversion) FROM stdin;
\.


--
-- Data for Name: cmmsmachineparts_machinepartattachment; Type: TABLE DATA; Schema: public; Owner: -
--

COPY public.cmmsmachineparts_machinepartattachment (id, product_id, attachment, name, size, ext, entityversion) FROM stdin;
\.


--
-- Data for Name: cmmsmachineparts_machinepartforevent; Type: TABLE DATA; Schema: public; Owner: -
--

COPY public.cmmsmachineparts_machinepartforevent (id, maintenanceevent_id, machinepart_id, warehouse_id, plannedquantity, availablequantity, plannedevent_id, machinepartname, machinepartnumber, machinepartunit, warehousenumber, entityversion, recurringevent_id) FROM stdin;
\.


--
-- Data for Name: cmmsmachineparts_maintenanceevent; Type: TABLE DATA; Schema: public; Owner: -
--

COPY public.cmmsmachineparts_maintenanceevent (id, number, type, description, personreceiving_id, personreceivingname, state, createdate, updatedate, createuser, updateuser, factory_id, division_id, productionline_id, workstation_id, subassembly_id, faulttype_id, solutiondescription, maintenanceeventcontext_id, entityversion, sourcecost_id, soundnotifications, highestpriority, reportingemployee_id) FROM stdin;
\.


--
-- Data for Name: cmmsmachineparts_maintenanceeventcontext; Type: TABLE DATA; Schema: public; Owner: -
--

COPY public.cmmsmachineparts_maintenanceeventcontext (id, factory_id, division_id, generated, confirmed, entityversion, datefrom, dateto) FROM stdin;
\.


--
-- Data for Name: cmmsmachineparts_maintenanceeventstatechange; Type: TABLE DATA; Schema: public; Owner: -
--

COPY public.cmmsmachineparts_maintenanceeventstatechange (id, dateandtime, sourcestate, targetstate, status, phase, worker, maintenanceevent_id, shift_id, comment, commentrequired, entityversion, plannedeventtype, plannedeventtyperequired) FROM stdin;
\.


--
-- Data for Name: cmmsmachineparts_maintenanceeventxlshelper; Type: TABLE DATA; Schema: public; Owner: -
--

COPY public.cmmsmachineparts_maintenanceeventxlshelper (id, query, createdate, updatedate, createuser, updateuser) FROM stdin;
\.


--
-- Data for Name: cmmsmachineparts_operationtool; Type: TABLE DATA; Schema: public; Owner: -
--

COPY public.cmmsmachineparts_operationtool (id, toolcategory, operation_id, tool_id, description, plannedquantity, unit, quantity) FROM stdin;
\.


--
-- Data for Name: cmmsmachineparts_orderstoolrequirement; Type: TABLE DATA; Schema: public; Owner: -
--

COPY public.cmmsmachineparts_orderstoolrequirement (id, number, name, generated, worker, date, filename) FROM stdin;
\.


--
-- Data for Name: cmmsmachineparts_orderstoolrequirementtool; Type: TABLE DATA; Schema: public; Owner: -
--

COPY public.cmmsmachineparts_orderstoolrequirementtool (id, orderstoolrequirement_id, date, order_id, operation_id, technologyoperationtool_id, quantity) FROM stdin;
\.


--
-- Data for Name: cmmsmachineparts_plannedevent; Type: TABLE DATA; Schema: public; Owner: -
--

COPY public.cmmsmachineparts_plannedevent (id, number, type, description, owner_id, ownername, state, factory_id, division_id, productionline_id, workstation_id, subassembly_id, plannedeventcontext_id, createdate, updatedate, createuser, updateuser, plannedseparately, afterreview, requiresshutdown, company_id, basedon, date, counter, countertolerance, duration, effectiveduration, effectivecounter, startdate, finishdate, isdeadline, solutiondescription, entityversion, maintenanceevent_id, sourcecost_id, recurringevent_id) FROM stdin;
\.


--
-- Data for Name: cmmsmachineparts_plannedeventattachment; Type: TABLE DATA; Schema: public; Owner: -
--

COPY public.cmmsmachineparts_plannedeventattachment (id, plannedevent_id, attachment, name, size, ext, entityversion) FROM stdin;
\.


--
-- Data for Name: cmmsmachineparts_plannedeventcontext; Type: TABLE DATA; Schema: public; Owner: -
--

COPY public.cmmsmachineparts_plannedeventcontext (id, factory_id, division_id, generated, confirmed, entityversion, datefrom, dateto) FROM stdin;
\.


--
-- Data for Name: cmmsmachineparts_plannedeventrealization; Type: TABLE DATA; Schema: public; Owner: -
--

COPY public.cmmsmachineparts_plannedeventrealization (id, plannedevent_id, worker_id, action_id, startdate, finishdate, duration, entityversion, confirmed) FROM stdin;
\.


--
-- Data for Name: cmmsmachineparts_plannedeventstatechange; Type: TABLE DATA; Schema: public; Owner: -
--

COPY public.cmmsmachineparts_plannedeventstatechange (id, dateandtime, sourcestate, targetstate, status, phase, worker, plannedevent_id, shift_id, comment, commentrequired) FROM stdin;
\.


--
-- Data for Name: cmmsmachineparts_plannedeventxlshelper; Type: TABLE DATA; Schema: public; Owner: -
--

COPY public.cmmsmachineparts_plannedeventxlshelper (id, query, createdate, updatedate, createuser, updateuser) FROM stdin;
\.


--
-- Data for Name: cmmsmachineparts_sourcecost; Type: TABLE DATA; Schema: public; Owner: -
--

COPY public.cmmsmachineparts_sourcecost (id, number, name, factory_id, defaultcost, active) FROM stdin;
\.


--
-- Data for Name: cmmsmachineparts_sourcecostreportfilter; Type: TABLE DATA; Schema: public; Owner: -
--

COPY public.cmmsmachineparts_sourcecostreportfilter (id, fromdate, todate, sourcecost_id, createdate, updatedate, createuser, updateuser, dontsave) FROM stdin;
\.


--
-- Data for Name: cmmsmachineparts_staffworktime; Type: TABLE DATA; Schema: public; Owner: -
--

COPY public.cmmsmachineparts_staffworktime (id, maintenanceevent_id, worker_id, labortime, effectiveexecutiontimestart, effectiveexecutiontimeend, entityversion) FROM stdin;
\.


--
-- Data for Name: cmmsmachineparts_technologyoperationtool; Type: TABLE DATA; Schema: public; Owner: -
--

COPY public.cmmsmachineparts_technologyoperationtool (id, toolcategory, technologyoperationcomponent_id, tool_id, description, quantity, unit) FROM stdin;
\.


--
-- Data for Name: cmmsmachineparts_timeusagereportfilter; Type: TABLE DATA; Schema: public; Owner: -
--

COPY public.cmmsmachineparts_timeusagereportfilter (id, fromdate, todate, workersselection, createdate, updatedate, createuser, updateuser) FROM stdin;
\.


--
-- Data for Name: cmmsmachineparts_tool; Type: TABLE DATA; Schema: public; Owner: -
--

COPY public.cmmsmachineparts_tool (id, number, name, description, toolcategory, producer, inventorynumber, serialnumber, unit) FROM stdin;
\.


--
-- Data for Name: cmmsmachineparts_toolattachment; Type: TABLE DATA; Schema: public; Owner: -
--

COPY public.cmmsmachineparts_toolattachment (id, tool_id, attachment, name, size, ext) FROM stdin;
\.


--
-- Data for Name: cmmsscheduler_actionforrecurringevent; Type: TABLE DATA; Schema: public; Owner: -
--

COPY public.cmmsscheduler_actionforrecurringevent (id, recurringevent_id, description, action_id) FROM stdin;
\.


--
-- Data for Name: cmmsscheduler_recurringevent; Type: TABLE DATA; Schema: public; Owner: -
--

COPY public.cmmsscheduler_recurringevent (id, number, type, periodicitydate, periodicitystate, generation, description, owner_id, ownername, state, factory_id, division_id, productionline_id, workstation_id, subassembly_id, company_id, sourcecost_id, plannedseparately, requiresshutdown, basedon, date, counter, countertolerance, duration, effectiveduration, effectivecounter, recurringeventcontext_id, active, createdate, updatedate, createuser, updateuser, nextgenerationdate, nextdate, multiplier) FROM stdin;
\.


--
-- Data for Name: cmmsscheduler_recurringeventattachment; Type: TABLE DATA; Schema: public; Owner: -
--

COPY public.cmmsscheduler_recurringeventattachment (id, recurringevent_id, attachment, name, size, ext) FROM stdin;
\.


--
-- Data for Name: cmmsscheduler_recurringeventcontext; Type: TABLE DATA; Schema: public; Owner: -
--

COPY public.cmmsscheduler_recurringeventcontext (id, factory_id, division_id, generated, confirmed, datefrom, dateto) FROM stdin;
\.


--
-- Data for Name: cmmsscheduler_recurringeventstatechange; Type: TABLE DATA; Schema: public; Owner: -
--

COPY public.cmmsscheduler_recurringeventstatechange (id, dateandtime, sourcestate, targetstate, status, phase, worker, recurringevent_id, shift_id) FROM stdin;
\.


--
-- Data for Name: costcalculation_additionaldirectcost; Type: TABLE DATA; Schema: public; Owner: -
--

COPY public.costcalculation_additionaldirectcost (id, number, name, active) FROM stdin;
\.


--
-- Data for Name: costcalculation_additionaldirectcostitem; Type: TABLE DATA; Schema: public; Owner: -
--

COPY public.costcalculation_additionaldirectcostitem (id, additionaldirectcost_id, actualcost, datefrom, dateto) FROM stdin;
\.


--
-- Data for Name: costcalculation_calculationresult; Type: TABLE DATA; Schema: public; Owner: -
--

COPY public.costcalculation_calculationresult (id, costcalculation_id, product_id, technology_id, materialcosts, labourcost, productioncosts, totalcost, registrationprice, technicalproductioncost, sellingprice, nomaterialprice, profitvalue, registrationpriceoverheadvalue, materialcostmarginvalue, labourcostmarginvalue, totalmanufacturingcost, technicalproductioncostoverheadvalue) FROM stdin;
\.


--
-- Data for Name: costcalculation_componentcost; Type: TABLE DATA; Schema: public; Owner: -
--

COPY public.costcalculation_componentcost (id, costcalculation_id, product_id, priceperunit) FROM stdin;
\.


--
-- Data for Name: costcalculation_costcalculation; Type: TABLE DATA; Schema: public; Owner: -
--

COPY public.costcalculation_costcalculation (id, number, quantity, productioncostmargin, materialcostmargin, additionaloverhead, description, includetpz, includeadditionaltime, materialcostsused, date, generated, filename, includecomponents, entityversion, sourceofoperationcosts, registrationpriceoverhead, profit, standardlaborcost_id, averagemachinehourlycost, averagelaborhourlycost, usenominalcostpricenotspecified, pdf, technicalproductioncostoverhead, offer_id) FROM stdin;
\.


--
-- Data for Name: costcalculation_orderadditionaldirectcost; Type: TABLE DATA; Schema: public; Owner: -
--

COPY public.costcalculation_orderadditionaldirectcost (id, additionaldirectcost_id, order_id, actualcost) FROM stdin;
\.


--
-- Data for Name: costcalculation_standardlaborcost; Type: TABLE DATA; Schema: public; Owner: -
--

COPY public.costcalculation_standardlaborcost (id, number, name, laborcost) FROM stdin;
\.


--
-- Data for Name: costnormsformaterials_technologyinstoperproductincomp; Type: TABLE DATA; Schema: public; Owner: -
--

COPY public.costnormsformaterials_technologyinstoperproductincomp (id, order_id, product_id, costfororder, entityversion, averagepricesubcontractor) FROM stdin;
\.


--
-- Data for Name: costnormsforoperation_calculationoperationcomponent; Type: TABLE DATA; Schema: public; Owner: -
--

COPY public.costnormsforoperation_calculationoperationcomponent (id, nodenumber, operation_id, technologyoperationcomponent_id, parent_id, entitytype, priority, tpz, tj, areproductquantitiesdivisible, istjdivisible, machineutilization, laborutilization, productioninonecycle, nextoperationafterproducedtype, nextoperationafterproducedquantity, timenextoperation, operationoffset, effectiveoperationrealizationtime, effectivedatefrom, effectivedateto, duration, machineworktime, laborworktime, operationcost, totalmachineoperationcost, totallaboroperationcost, laborhourlycost, machinehourlycost, costcalculation_id, entityversion) FROM stdin;
\.


--
-- Data for Name: deliveries_columnfordeliveries; Type: TABLE DATA; Schema: public; Owner: -
--

COPY public.deliveries_columnfordeliveries (id, identifier, name, description, columnfiller, alignment, parameter_id, succession, entityversion) FROM stdin;
1	succession	deliveries.columnForDeliveries.name.value.succession	deliveries.columnForDeliveries.description.value.succession	com.qcadoo.mes.deliveries.columnExtension.DeliveriesColumnFiller	01left	1	1	0
2	productNumber	deliveries.columnForDeliveries.name.value.productNumber	deliveries.columnForDeliveries.description.value.productNumber	com.qcadoo.mes.deliveries.columnExtension.DeliveriesColumnFiller	01left	1	2	0
3	productName	deliveries.columnForDeliveries.name.value.productName	deliveries.columnForDeliveries.description.value.productName	com.qcadoo.mes.deliveries.columnExtension.DeliveriesColumnFiller	01left	1	3	0
4	orderedQuantity	deliveries.columnForDeliveries.name.value.orderedQuantity	deliveries.columnForDeliveries.description.value.orderedQuantity	com.qcadoo.mes.deliveries.columnExtension.DeliveriesColumnFiller	02right	1	4	0
5	deliveredQuantity	deliveries.columnForDeliveries.name.value.deliveredQuantity	deliveries.columnForDeliveries.description.value.deliveredQuantity	com.qcadoo.mes.deliveries.columnExtension.DeliveriesColumnFiller	02right	1	5	0
6	damagedQuantity	deliveries.columnForDeliveries.name.value.damagedQuantity	deliveries.columnForDeliveries.description.value.damagedQuantity	com.qcadoo.mes.deliveries.columnExtension.DeliveriesColumnFiller	02right	1	6	0
7	productUnit	deliveries.columnForDeliveries.name.value.productUnit	deliveries.columnForDeliveries.description.value.productUnit	com.qcadoo.mes.deliveries.columnExtension.DeliveriesColumnFiller	01left	1	7	0
8	pricePerUnit	deliveries.columnForDeliveries.name.value.pricePerUnit	deliveries.columnForDeliveries.description.value.pricePerUnit	com.qcadoo.mes.deliveries.columnExtension.DeliveriesColumnFiller	02right	1	8	0
9	totalPrice	deliveries.columnForDeliveries.name.value.totalPrice	deliveries.columnForDeliveries.description.value.totalPrice	com.qcadoo.mes.deliveries.columnExtension.DeliveriesColumnFiller	02right	1	9	0
10	currency	deliveries.columnForDeliveries.name.value.currency	deliveries.columnForDeliveries.description.value.currency	com.qcadoo.mes.deliveries.columnExtension.DeliveriesColumnFiller	01left	1	10	0
11	offerNumber	deliveries.columnForDeliveries.name.value.offerNumber	deliveries.columnForDeliveries.description.value.offerNumber	com.qcadoo.mes.supplyNegotiations.columnExtension.DeliveriesColumnFillerSN	01left	1	11	0
\.


--
-- Data for Name: deliveries_columnfororders; Type: TABLE DATA; Schema: public; Owner: -
--

COPY public.deliveries_columnfororders (id, identifier, name, description, columnfiller, alignment, parameter_id, succession, entityversion) FROM stdin;
1	succession	deliveries.columnForOrders.name.value.succession	deliveries.columnForOrders.description.value.succession	com.qcadoo.mes.deliveries.columnExtension.DeliveriesColumnFiller	01left	1	1	0
2	productNumber	deliveries.columnForOrders.name.value.productNumber	deliveries.columnForOrders.description.value.productNumber	com.qcadoo.mes.deliveries.columnExtension.DeliveriesColumnFiller	01left	1	2	0
3	productName	deliveries.columnForOrders.name.value.productName	deliveries.columnForOrders.description.value.productName	com.qcadoo.mes.deliveries.columnExtension.DeliveriesColumnFiller	01left	1	3	0
4	orderedQuantity	deliveries.columnForOrders.name.value.orderedQuantity	deliveries.columnForOrders.description.value.orderedQuantity	com.qcadoo.mes.deliveries.columnExtension.DeliveriesColumnFiller	02right	1	4	0
5	productUnit	deliveries.columnForOrders.name.value.productUnit	deliveries.columnForOrders.description.value.productUnit	com.qcadoo.mes.deliveries.columnExtension.DeliveriesColumnFiller	01left	1	5	0
6	description	deliveries.columnForOrders.name.value.description	deliveries.columnForOrders.description.value.description	com.qcadoo.mes.deliveries.columnExtension.DeliveriesColumnFiller	01left	1	6	0
7	pricePerUnit	deliveries.columnForOrders.name.value.pricePerUnit	deliveries.columnForOrders.description.value.pricePerUnit	com.qcadoo.mes.deliveries.columnExtension.DeliveriesColumnFiller	02right	1	7	0
8	totalPrice	deliveries.columnForOrders.name.value.totalPrice	deliveries.columnForOrders.description.value.totalPrice	com.qcadoo.mes.deliveries.columnExtension.DeliveriesColumnFiller	02right	1	8	0
9	currency	deliveries.columnForOrders.name.value.currency	deliveries.columnForOrders.description.value.currency	com.qcadoo.mes.deliveries.columnExtension.DeliveriesColumnFiller	01left	1	9	0
10	offerNumber	deliveries.columnForOrders.name.value.offerNumber	deliveries.columnForOrders.description.value.offerNumber	com.qcadoo.mes.supplyNegotiations.columnExtension.DeliveriesColumnFillerSN	01left	1	10	0
\.


--
-- Data for Name: deliveries_companyproduct; Type: TABLE DATA; Schema: public; Owner: -
--

COPY public.deliveries_companyproduct (id, company_id, product_id, isdefault, entityversion, minimumorderquantity, bufferfordeliverytimes) FROM stdin;
\.


--
-- Data for Name: deliveries_deliveredpackage; Type: TABLE DATA; Schema: public; Owner: -
--

COPY public.deliveries_deliveredpackage (id, delivery_id, product_id, deliveredquantity) FROM stdin;
\.


--
-- Data for Name: deliveries_deliveredproduct; Type: TABLE DATA; Schema: public; Owner: -
--

COPY public.deliveries_deliveredproduct (id, delivery_id, product_id, deliveredquantity, damagedquantity, priceperunit, totalprice, succession, operation_id, offer_id, batchnumber, productiondate, expirationdate, entityversion, palletnumber_id, pallettype, storagelocation_id, additionalquantity, conversion, iswaste, additionalunit, damaged, batch_id, orderedproduct_id, qualityrating) FROM stdin;
\.


--
-- Data for Name: deliveries_deliveredproductattributeval; Type: TABLE DATA; Schema: public; Owner: -
--

COPY public.deliveries_deliveredproductattributeval (id, deliveredproduct_id, attribute_id, attributevalue_id, value) FROM stdin;
\.


--
-- Data for Name: deliveries_deliveredproductmulti; Type: TABLE DATA; Schema: public; Owner: -
--

COPY public.deliveries_deliveredproductmulti (id, delivery_id, palletnumber_id, pallettype, storagelocation_id, createdate, updatedate, createuser, updateuser) FROM stdin;
\.


--
-- Data for Name: deliveries_deliveredproductmultiposition; Type: TABLE DATA; Schema: public; Owner: -
--

COPY public.deliveries_deliveredproductmultiposition (id, deliveredproductmulti_id, product_id, quantity, additionalquantity, conversion, iswaste, expirationdate, unit, additionalunit, offer_id, batch_id, priceperunit) FROM stdin;
\.


--
-- Data for Name: deliveries_delivery; Type: TABLE DATA; Schema: public; Owner: -
--

COPY public.deliveries_delivery (id, number, name, description, supplier_id, deliverydate, deliveryaddress, relateddelivery_id, currency_id, externalnumber, externalsynchronized, state, location_id, active, createdate, updatedate, createuser, updateuser, synchronizationstatus, entityversion, paymentform, salesplan_id, wms, stateinwms, datesendtowms, pickingworker, dateconfirmationofcompletion) FROM stdin;
\.


--
-- Data for Name: deliveries_deliveryattachment; Type: TABLE DATA; Schema: public; Owner: -
--

COPY public.deliveries_deliveryattachment (id, delivery_id, attachment, name, size, ext) FROM stdin;
\.


--
-- Data for Name: deliveries_deliverybypallettypereport; Type: TABLE DATA; Schema: public; Owner: -
--

COPY public.deliveries_deliverybypallettypereport (id, fromdate, todate) FROM stdin;
\.


--
-- Data for Name: deliveries_deliverystatechange; Type: TABLE DATA; Schema: public; Owner: -
--

COPY public.deliveries_deliverystatechange (id, dateandtime, sourcestate, targetstate, status, phase, shift_id, worker, delivery_id, entityversion) FROM stdin;
\.


--
-- Data for Name: deliveries_orderedproduct; Type: TABLE DATA; Schema: public; Owner: -
--

COPY public.deliveries_orderedproduct (id, delivery_id, product_id, orderedquantity, priceperunit, totalprice, description, succession, operation_id, offer_id, actualversion, entityversion, additionalquantity, conversion, deliveredquantity, additionaldeliveredquantity, batchnumber, batch_id, qualitycard_id) FROM stdin;
\.


--
-- Data for Name: deliveries_parameterdeliveryordercolumn; Type: TABLE DATA; Schema: public; Owner: -
--

COPY public.deliveries_parameterdeliveryordercolumn (id, parameter_id, columnfororders_id, succession, entityversion) FROM stdin;
1	1	1	1	0
2	1	2	2	0
3	1	3	3	0
4	1	4	4	0
5	1	5	5	0
6	1	6	6	0
7	1	7	7	0
8	1	8	8	0
9	1	9	9	0
10	1	10	10	0
\.


--
-- Data for Name: emailnotifications_staffnotification; Type: TABLE DATA; Schema: public; Owner: -
--

COPY public.emailnotifications_staffnotification (id, email, staff_id, createdate, updatedate, createuser, updateuser, parameter_id, createdeliveryminstate, entityversion, pmmnotification) FROM stdin;
\.


--
-- Data for Name: goodfood_confectionadditionalinputproduct; Type: TABLE DATA; Schema: public; Owner: -
--

COPY public.goodfood_confectionadditionalinputproduct (id, confectionprotocol_id, batch_id, product_id, takenonquantity, takenofquantity, cullquantity, effectivequantity, entityversion) FROM stdin;
\.


--
-- Data for Name: goodfood_confectioncontext; Type: TABLE DATA; Schema: public; Owner: -
--

COPY public.goodfood_confectioncontext (id, day, generated, confirmed, place, productionline_id, shift_id, operator_id, entityversion) FROM stdin;
\.


--
-- Data for Name: goodfood_confectionfilmproduct; Type: TABLE DATA; Schema: public; Owner: -
--

COPY public.goodfood_confectionfilmproduct (id, confectionprotocol_id, filmproduct_id, beyondrecipe) FROM stdin;
\.


--
-- Data for Name: goodfood_confectionfilmproductentry; Type: TABLE DATA; Schema: public; Owner: -
--

COPY public.goodfood_confectionfilmproductentry (id, batch_id, confectionfilmproduct_id, takenonquantity, takenofquantity, cullquantity, effectivequantity) FROM stdin;
\.


--
-- Data for Name: goodfood_confectioninputproduct; Type: TABLE DATA; Schema: public; Owner: -
--

COPY public.goodfood_confectioninputproduct (id, confectionprotocol_id, batch_id, product_id, takenonquantity, takenofquantity, cullquantity, effectivequantity, entityversion) FROM stdin;
\.


--
-- Data for Name: goodfood_confectionprotocol; Type: TABLE DATA; Schema: public; Owner: -
--

COPY public.goodfood_confectionprotocol (id, generationdate, state, laststatechangefails, confectioncontext_id, number, dayofshiftstart, productionline_id, toproduce, startdate, finishdate, order_id, ordernumber, productnameandnumber, qcp5code, filmproduct_id, restoneofcartonsquantity, resttwoofcartonsquantity, allpalletquantity, quantityofallcartonsquantity, wastewafers, effectiveproducedquantity, effectiveexecutiontimestart, effectiveexecutiontimeend, externalnumber, externalsynchronized, active, laststatechangefailcause, showlaststatechangeresult, isdoubled, additionalfilmproduct_id, iscorrected, productiondate, entityversion, comments, sendagaintoblackbox, finalprotocol, plannextorderinfo, plannextorderinfoargs, plannextorderstatechangeinfo) FROM stdin;
\.


--
-- Data for Name: goodfood_confectionprotocolcorrect; Type: TABLE DATA; Schema: public; Owner: -
--

COPY public.goodfood_confectionprotocolcorrect (id, confectionprotocol_id, correctdate, correctreason, createdate, updatedate, createuser, updateuser, isconfirmed, entityversion) FROM stdin;
\.


--
-- Data for Name: goodfood_confectionprotocolstatechange; Type: TABLE DATA; Schema: public; Owner: -
--

COPY public.goodfood_confectionprotocolstatechange (id, dateandtime, sourcestate, targetstate, status, phase, shift_id, worker, confectionprotocol_id, entityversion) FROM stdin;
\.


--
-- Data for Name: goodfood_confectionremainderinputproduct; Type: TABLE DATA; Schema: public; Owner: -
--

COPY public.goodfood_confectionremainderinputproduct (id, confectionprotocol_id, product_id, usedquantity, isdoubled, entityversion, usedbatches, beyondrecipe) FROM stdin;
\.


--
-- Data for Name: goodfood_confectionstaff; Type: TABLE DATA; Schema: public; Owner: -
--

COPY public.goodfood_confectionstaff (id, confectionprotocol_id, worker_id, labortime, effectiveexecutiontimestart, effectiveexecutiontimeend, entityversion) FROM stdin;
\.


--
-- Data for Name: goodfood_eventlog; Type: TABLE DATA; Schema: public; Owner: -
--

COPY public.goodfood_eventlog (id, eventtype, description, user_id, startdate, finishdate, product_id, ssccnumber, quantity, sourcelocation, destinationlocation, createdate, updatedate, createuser, updateuser, entityversion) FROM stdin;
\.


--
-- Data for Name: goodfood_extrusionaddedmixentry; Type: TABLE DATA; Schema: public; Owner: -
--

COPY public.goodfood_extrusionaddedmixentry (id, extrusionprotocol_id, quantity, entityversion, extrusionmix_id) FROM stdin;
\.


--
-- Data for Name: goodfood_extrusionaddedmixingredient; Type: TABLE DATA; Schema: public; Owner: -
--

COPY public.goodfood_extrusionaddedmixingredient (id, extrusionaddedmixentry_id, extrusionmixingredient_id, product_id, batch_id, quantity, beyondrecipe) FROM stdin;
\.


--
-- Data for Name: goodfood_extrusioncontext; Type: TABLE DATA; Schema: public; Owner: -
--

COPY public.goodfood_extrusioncontext (id, day, generated, confirmed, place, productionline_id, shift_id, operator_id, entityversion) FROM stdin;
\.


--
-- Data for Name: goodfood_extrusionmix; Type: TABLE DATA; Schema: public; Owner: -
--

COPY public.goodfood_extrusionmix (id, number, technology_id, product_id, productionline_id, takenoffdate, shift_id, quantity, operator_id, comment, active) FROM stdin;
\.


--
-- Data for Name: goodfood_extrusionmixingredient; Type: TABLE DATA; Schema: public; Owner: -
--

COPY public.goodfood_extrusionmixingredient (id, extrusionmix_id, product_id, batch_id, quantity, beyondrecipe) FROM stdin;
\.


--
-- Data for Name: goodfood_extrusionpouring; Type: TABLE DATA; Schema: public; Owner: -
--

COPY public.goodfood_extrusionpouring (id, extrusionprotocol_id, finaladdedquantity, addedquantity, totalmixquantity, addedquantitymanual, addedquantityrelatesto, mixwaterquantity, priority) FROM stdin;
\.


--
-- Data for Name: goodfood_extrusionpouringingredient; Type: TABLE DATA; Schema: public; Owner: -
--

COPY public.goodfood_extrusionpouringingredient (id, extrusionpouring_id, product_id, batch_id, quantity, ratio, manual, skip, frommix, requiredquantity, quantityinmix, beyondrecipe, addedbyuser, extrusionpouringmix_id) FROM stdin;
\.


--
-- Data for Name: goodfood_extrusionpouringmix; Type: TABLE DATA; Schema: public; Owner: -
--

COPY public.goodfood_extrusionpouringmix (id, extrusionpouring_id, mixid, requiredscalequantity, scalequantity, scalequantitymanual, totalmixquantity, mixwaterquantity) FROM stdin;
\.


--
-- Data for Name: goodfood_extrusionprotocol; Type: TABLE DATA; Schema: public; Owner: -
--

COPY public.goodfood_extrusionprotocol (id, generationdate, state, laststatechangefails, extrusioncontext_id, number, dayofshiftstart, productionline_id, toproduce, changeover, startdate, finishdate, numberofavailableworkstation, order_id, ordernumber, productnameandnumber, mixproduct, operatorworkstartdate, operatorworkfinishdate, externalnumber, externalsynchronized, active, laststatechangefailcause, showlaststatechangeresult, iscorrected, entityversion, comments, sendagaintoblackbox) FROM stdin;
\.


--
-- Data for Name: goodfood_extrusionprotocolcorrect; Type: TABLE DATA; Schema: public; Owner: -
--

COPY public.goodfood_extrusionprotocolcorrect (id, extrusionprotocol_id, correctdate, correctreason, createdate, updatedate, createuser, updateuser, isconfirmed, entityversion) FROM stdin;
\.


--
-- Data for Name: goodfood_extrusionprotocolstatechange; Type: TABLE DATA; Schema: public; Owner: -
--

COPY public.goodfood_extrusionprotocolstatechange (id, dateandtime, sourcestate, targetstate, status, phase, shift_id, worker, extrusionprotocol_id, entityversion) FROM stdin;
\.


--
-- Data for Name: goodfood_extrusionsouse; Type: TABLE DATA; Schema: public; Owner: -
--

COPY public.goodfood_extrusionsouse (id, extrusionprotocol_id, category, datesouse, datedownload, worker_id, wetness, entityversion) FROM stdin;
\.


--
-- Data for Name: goodfood_extrusiontakenoffmixentry; Type: TABLE DATA; Schema: public; Owner: -
--

COPY public.goodfood_extrusiontakenoffmixentry (id, extrusionprotocol_id, quantity, entityversion, extrusionmix_id) FROM stdin;
\.


--
-- Data for Name: goodfood_extrusiontakenoffmixingredient; Type: TABLE DATA; Schema: public; Owner: -
--

COPY public.goodfood_extrusiontakenoffmixingredient (id, extrusiontakenoffmixentry_id, extrusionmixingredient_id, product_id, batch_id, quantity, beyondrecipe) FROM stdin;
\.


--
-- Data for Name: goodfood_goodfoodreport; Type: TABLE DATA; Schema: public; Owner: -
--

COPY public.goodfood_goodfoodreport (id, number, name, datefrom, dateto, filename, generated, createdate, updatedate, createuser, updateuser, entityversion) FROM stdin;
\.


--
-- Data for Name: goodfood_pallet; Type: TABLE DATA; Schema: public; Owner: -
--

COPY public.goodfood_pallet (id, palletcontext_id, palletlabel_id, typeoflogistics, printedcount, ssccnumber, palletnumber, secondpallet_id, state, isstateerror, stateerror, registrationdate, senddate, active, packagescount, laststatechangefails, laststatechangefailcause, externalnumber, externalsynchronized, eurocod, entityversion, sendagaintoblackbox, product_id) FROM stdin;
\.


--
-- Data for Name: goodfood_palletcontext; Type: TABLE DATA; Schema: public; Owner: -
--

COPY public.goodfood_palletcontext (id, confirmed, day, shift_id, createdate, updatedate, createuser, updateuser, operator_id, entityversion) FROM stdin;
\.


--
-- Data for Name: goodfood_palletlabel; Type: TABLE DATA; Schema: public; Owner: -
--

COPY public.goodfood_palletlabel (id, palletcontext_id, printedcount, firstssccnumber, firstpalletnumber, lastssccnumber, lastpalletnumber, masterorder_id, productionline_id, batchnumber, bestbefore, registrationdate, active, batch_id, state, entityversion) FROM stdin;
\.


--
-- Data for Name: goodfood_palletlabelstatechange; Type: TABLE DATA; Schema: public; Owner: -
--

COPY public.goodfood_palletlabelstatechange (id, dateandtime, sourcestate, targetstate, status, phase, shift_id, worker, palletlabel_id, entityversion) FROM stdin;
\.


--
-- Data for Name: goodfood_palletstatechange; Type: TABLE DATA; Schema: public; Owner: -
--

COPY public.goodfood_palletstatechange (id, dateandtime, sourcestate, targetstate, status, phase, shift_id, worker, pallet_id, entityversion) FROM stdin;
\.


--
-- Data for Name: goodfood_palnumber; Type: TABLE DATA; Schema: public; Owner: -
--

COPY public.goodfood_palnumber (id, number, masterorder_id, ssccnumber) FROM stdin;
\.


--
-- Data for Name: goodfood_printedlabel; Type: TABLE DATA; Schema: public; Owner: -
--

COPY public.goodfood_printedlabel (id, cartonlabel, masterorder_id, ssccnumber, palletcontext_id, productionline_id, createdate, updatedate, createuser, updateuser, active) FROM stdin;
\.


--
-- Data for Name: goodfood_ssccnumber; Type: TABLE DATA; Schema: public; Owner: -
--

COPY public.goodfood_ssccnumber (id, prefix, number, suffix, entityversion) FROM stdin;
\.


--
-- Data for Name: integrationbartender_printer; Type: TABLE DATA; Schema: public; Owner: -
--

COPY public.integrationbartender_printer (id, name, description, printertype, createdate, updatedate, createuser, updateuser, active) FROM stdin;
\.


--
-- Data for Name: integrationbartender_printlabelshelper; Type: TABLE DATA; Schema: public; Owner: -
--

COPY public.integrationbartender_printlabelshelper (id, createdate, updatedate, createuser, updateuser, quantity, masterorder_id, printer_id, path, ssccnumbers, order_id, barcodeismasterorderid) FROM stdin;
\.


--
-- Data for Name: integrationbartender_sendtoprint; Type: TABLE DATA; Schema: public; Owner: -
--

COPY public.integrationbartender_sendtoprint (id, printlabelshelper_id, createdate, updatedate, createuser, updateuser) FROM stdin;
\.


--
-- Data for Name: integrationbaselinker_baselinkerparameters; Type: TABLE DATA; Schema: public; Owner: -
--

COPY public.integrationbaselinker_baselinkerparameters (id, documenttype, locationfrom_id, locationto_id, createmasterorders, createdocuments) FROM stdin;
\.


--
-- Data for Name: integrationbaselinker_statusesfordocument; Type: TABLE DATA; Schema: public; Owner: -
--

COPY public.integrationbaselinker_statusesfordocument (id, baselinkerparameters_id, statustaken, statusawarded) FROM stdin;
\.


--
-- Data for Name: integrationbaselinker_statusesformasterorder; Type: TABLE DATA; Schema: public; Owner: -
--

COPY public.integrationbaselinker_statusesformasterorder (id, baselinkerparameters_id, statustaken, statusawarded) FROM stdin;
\.


--
-- Data for Name: integrationscales_productionlineforscale; Type: TABLE DATA; Schema: public; Owner: -
--

COPY public.integrationscales_productionlineforscale (id, productionline_id, master, scale_id) FROM stdin;
\.


--
-- Data for Name: integrationscales_scale; Type: TABLE DATA; Schema: public; Owner: -
--

COPY public.integrationscales_scale (id, name, comment, port, ip, type) FROM stdin;
\.


--
-- Data for Name: jointable_action_subassembly; Type: TABLE DATA; Schema: public; Owner: -
--

COPY public.jointable_action_subassembly (action_id, subassembly_id) FROM stdin;
\.


--
-- Data for Name: jointable_action_workstation; Type: TABLE DATA; Schema: public; Owner: -
--

COPY public.jointable_action_workstation (action_id, workstation_id) FROM stdin;
\.


--
-- Data for Name: jointable_action_workstationtype; Type: TABLE DATA; Schema: public; Owner: -
--

COPY public.jointable_action_workstationtype (action_id, workstationtype_id) FROM stdin;
\.


--
-- Data for Name: jointable_additionaldirectcost_technology; Type: TABLE DATA; Schema: public; Owner: -
--

COPY public.jointable_additionaldirectcost_technology (additionaldirectcost_id, technology_id) FROM stdin;
\.


--
-- Data for Name: jointable_anomaly_anomalyreason; Type: TABLE DATA; Schema: public; Owner: -
--

COPY public.jointable_anomaly_anomalyreason (anomalyreason_id, anomaly_id) FROM stdin;
\.


--
-- Data for Name: jointable_batch_productioncountingquantity; Type: TABLE DATA; Schema: public; Owner: -
--

COPY public.jointable_batch_productioncountingquantity (productioncountingquantity_id, batch_id) FROM stdin;
\.


--
-- Data for Name: jointable_company_negotiation; Type: TABLE DATA; Schema: public; Owner: -
--

COPY public.jointable_company_negotiation (negotiation_id, company_id) FROM stdin;
\.


--
-- Data for Name: jointable_company_subassembly; Type: TABLE DATA; Schema: public; Owner: -
--

COPY public.jointable_company_subassembly (company_id, subassembly_id) FROM stdin;
\.


--
-- Data for Name: jointable_company_workstation; Type: TABLE DATA; Schema: public; Owner: -
--

COPY public.jointable_company_workstation (company_id, workstation_id) FROM stdin;
\.


--
-- Data for Name: jointable_costcalculation_technology; Type: TABLE DATA; Schema: public; Owner: -
--

COPY public.jointable_costcalculation_technology (costcalculation_id, technology_id) FROM stdin;
\.


--
-- Data for Name: jointable_division_productionline; Type: TABLE DATA; Schema: public; Owner: -
--

COPY public.jointable_division_productionline (productionline_id, division_id) FROM stdin;
\.


--
-- Data for Name: jointable_faulttype_subassembly; Type: TABLE DATA; Schema: public; Owner: -
--

COPY public.jointable_faulttype_subassembly (faulttype_id, subassembly_id) FROM stdin;
\.


--
-- Data for Name: jointable_faulttype_workstation; Type: TABLE DATA; Schema: public; Owner: -
--

COPY public.jointable_faulttype_workstation (workstation_id, faulttype_id) FROM stdin;
\.


--
-- Data for Name: jointable_faulttype_workstationtype; Type: TABLE DATA; Schema: public; Owner: -
--

COPY public.jointable_faulttype_workstationtype (workstationtype_id, faulttype_id) FROM stdin;
\.


--
-- Data for Name: jointable_group_role; Type: TABLE DATA; Schema: public; Owner: -
--

COPY public.jointable_group_role (group_id, role_id) FROM stdin;
1	2
5	9
6	1
4	1
4	2
4	4
4	5
4	6
4	7
4	8
4	9
4	10
4	11
4	12
4	13
4	14
4	15
4	16
4	17
4	18
4	19
4	20
4	21
4	22
4	23
4	24
4	25
4	26
4	27
4	28
4	29
4	30
4	31
4	32
4	33
4	34
4	35
4	36
4	37
4	38
4	39
4	40
4	41
4	42
4	43
4	44
4	45
4	46
4	47
4	48
4	49
4	50
4	51
4	52
4	53
4	54
4	55
4	56
4	57
4	58
4	59
4	60
4	61
4	62
4	63
4	64
4	65
4	66
4	67
4	68
4	69
4	70
4	71
4	72
4	73
4	74
4	75
4	76
4	77
4	78
4	79
4	80
4	81
4	82
4	83
4	84
4	85
4	87
4	88
4	89
4	90
4	91
4	92
4	93
4	94
4	95
4	96
4	97
4	98
4	99
4	100
4	101
4	102
4	103
4	104
4	105
4	107
4	108
4	109
4	110
4	111
4	112
4	113
4	114
4	115
4	116
4	117
4	118
4	119
4	120
2	1
2	2
2	3
2	4
2	5
2	6
2	7
2	8
2	9
2	10
2	11
2	12
2	13
2	14
2	15
2	16
2	17
2	18
2	19
2	20
2	21
2	22
2	23
2	24
2	25
2	26
2	27
2	28
2	29
2	30
2	31
2	32
2	33
2	34
2	35
2	36
2	37
2	38
2	39
2	40
2	41
2	42
2	43
2	44
2	45
2	46
2	47
2	48
2	49
2	50
2	51
2	52
2	53
2	54
2	55
2	56
2	57
2	58
2	59
2	60
2	61
2	62
2	63
2	64
2	65
2	66
2	67
2	68
2	69
2	70
2	71
2	72
2	73
2	74
2	75
2	76
2	77
2	78
2	79
2	80
2	81
2	82
2	83
2	84
2	85
2	87
2	88
2	89
2	90
2	91
2	92
2	93
2	94
2	95
2	96
2	97
2	98
2	99
2	100
2	101
2	102
2	103
2	104
2	105
2	107
2	108
2	109
2	110
2	111
2	112
2	113
2	114
2	115
2	116
2	117
2	118
2	119
2	120
3	1
3	2
3	5
3	7
3	9
3	10
3	11
3	12
3	13
3	14
3	15
3	16
3	17
3	18
3	19
3	20
3	21
3	22
3	23
3	24
3	25
3	26
3	27
3	28
3	29
3	30
3	31
3	32
3	33
3	34
3	35
3	36
3	37
3	38
3	39
3	40
3	41
3	42
3	43
3	44
3	45
3	46
3	47
3	48
3	49
3	50
3	51
3	52
3	53
3	54
3	55
3	56
3	57
3	58
3	59
3	60
3	61
3	62
3	63
3	64
3	65
3	66
3	67
3	68
3	69
3	70
3	71
3	72
3	73
3	74
3	75
3	76
3	77
3	78
3	79
3	80
3	81
3	82
3	83
3	84
3	85
3	88
3	89
3	90
3	91
3	92
3	93
3	94
3	95
3	96
3	97
3	98
3	99
3	100
3	101
3	102
3	103
3	104
3	105
3	107
3	108
3	109
3	110
3	111
3	112
3	113
3	114
3	115
3	116
3	117
3	119
2	121
4	121
2	122
4	122
2	124
4	124
3	124
2	126
4	126
2	128
4	129
2	129
3	129
2	130
4	130
2	131
4	131
2	132
2	133
2	134
3	134
4	134
2	135
2	137
3	137
4	137
2	138
3	138
4	138
2	139
3	139
4	139
2	140
3	140
4	140
2	142
3	142
4	142
2	143
3	143
4	143
2	144
3	144
4	144
2	145
3	145
4	145
4	146
2	146
3	146
4	148
2	148
2	149
3	149
4	149
2	123
2	125
2	127
2	136
2	147
4	125
4	127
4	128
4	132
4	135
4	136
4	147
3	87
3	121
3	126
3	127
3	128
3	130
3	131
3	135
3	147
3	148
7	1
7	78
7	19
8	73
8	65
8	1
8	78
8	19
8	5
9	1
9	78
9	127
10	1
10	78
10	127
10	73
10	65
10	5
11	1
11	78
11	127
11	19
12	1
12	78
12	127
12	19
12	73
12	65
12	5
13	1
13	78
13	127
13	19
13	129
13	82
13	5
14	1
14	78
14	19
14	129
14	82
14	5
15	1
15	78
15	19
15	129
15	82
15	5
15	73
15	65
16	1
16	78
16	127
16	19
16	129
16	82
16	5
16	73
16	65
17	1
17	78
17	127
17	19
17	129
17	82
17	126
17	134
17	5
18	1
18	78
18	19
18	129
18	82
18	126
18	134
18	5
19	1
19	78
19	19
19	129
19	82
19	126
19	134
19	5
19	73
19	65
20	1
20	78
20	127
20	19
20	129
20	82
20	126
20	134
20	5
20	73
20	65
21	1
21	78
21	127
21	19
21	129
21	142
21	5
22	1
22	78
22	19
22	129
22	142
22	5
23	1
23	78
23	19
23	129
23	142
23	5
23	73
23	65
24	1
24	78
24	127
24	19
24	129
24	142
24	5
24	73
24	65
25	1
25	78
25	127
25	19
25	129
25	142
25	126
25	134
25	5
26	1
26	78
26	19
26	129
26	142
26	126
26	134
26	5
27	1
27	78
27	19
27	129
27	142
27	126
27	134
27	5
27	73
27	65
28	1
28	78
28	127
28	19
28	129
28	142
28	126
28	134
28	5
28	73
28	65
29	97
29	144
29	26
29	25
29	24
29	35
29	17
29	1
29	101
29	99
29	93
29	100
29	137
29	5
29	34
30	144
30	26
30	25
30	24
30	35
30	17
30	1
30	101
30	99
30	93
30	100
30	137
30	5
30	34
30	108
31	1
31	135
31	78
31	19
31	116
31	119
31	100
31	137
31	5
31	145
32	20
32	4
32	33
32	94
32	29
32	31
32	97
32	96
32	95
32	88
32	37
32	26
32	25
32	24
32	6
32	35
32	17
32	73
32	66
32	65
32	64
32	63
32	68
32	72
32	58
32	57
32	55
32	67
32	69
32	59
32	71
32	70
32	60
32	62
32	61
32	56
32	36
32	1
32	89
32	91
32	101
32	118
32	117
32	87
32	53
32	51
32	52
32	50
32	48
32	41
32	39
32	49
32	47
32	46
32	40
32	45
32	43
32	44
32	42
32	83
32	103
32	129
32	81
32	82
32	102
32	98
32	99
32	28
32	93
32	38
32	115
32	32
32	92
32	7
32	5
32	34
33	20
33	4
33	33
33	94
33	29
33	31
33	97
33	96
33	95
33	88
33	37
33	26
33	25
33	24
33	6
33	35
33	17
33	73
33	66
33	65
33	64
33	63
33	68
33	72
33	58
33	57
33	55
33	54
33	67
33	69
33	59
33	71
33	70
33	60
33	62
33	61
33	56
33	36
33	1
33	89
33	91
33	101
33	118
33	117
33	87
33	53
33	51
33	52
33	50
33	48
33	41
33	39
33	49
33	47
33	46
33	40
33	45
33	43
33	44
33	42
33	83
33	103
33	129
33	81
33	82
33	102
33	98
33	99
33	28
33	93
33	38
33	115
33	32
33	92
33	7
33	5
33	34
34	20
34	33
34	29
34	31
34	96
34	95
34	88
34	37
34	25
34	35
34	17
34	73
34	66
34	65
34	64
34	63
34	68
34	58
34	57
34	55
34	67
34	69
34	59
34	71
34	70
34	60
34	62
34	61
34	56
34	36
34	1
34	89
34	91
34	101
34	53
34	51
34	50
34	48
34	41
34	39
34	49
34	47
34	46
34	40
34	45
34	43
34	44
34	42
34	82
34	28
34	93
34	32
34	5
34	34
35	20
35	33
35	29
35	31
35	96
35	95
35	88
35	37
35	25
35	35
35	17
35	73
35	66
35	65
35	64
35	63
35	68
35	58
35	57
35	55
35	54
35	67
35	69
35	59
35	71
35	70
35	60
35	62
35	61
35	56
35	36
35	1
35	89
35	91
35	101
35	53
35	51
35	50
35	48
35	41
35	39
35	49
35	47
35	46
35	40
35	45
35	43
35	44
35	42
35	82
35	28
35	93
35	32
35	5
35	34
36	30
36	31
36	96
36	35
36	73
36	65
36	64
36	63
36	68
36	58
36	57
36	55
36	71
36	70
36	60
36	61
36	56
36	1
36	91
36	51
36	50
36	41
36	49
36	45
36	42
36	93
36	5
36	34
37	30
37	31
37	96
37	35
37	73
37	65
37	64
37	63
37	68
37	58
37	57
37	55
37	54
37	71
37	70
37	60
37	61
37	56
37	1
37	91
37	51
37	50
37	41
37	49
37	45
37	42
37	93
37	5
37	34
38	27
38	97
38	88
38	1
38	142
38	83
38	103
38	129
38	82
38	102
38	98
38	99
38	5
38	34
39	27
39	97
39	96
39	95
39	1
39	98
39	99
39	138
39	119
39	115
39	124
39	85
39	84
39	7
39	5
39	34
40	105
40	27
40	35
40	1
40	101
40	120
40	80
40	100
40	5
40	34
41	105
41	27
41	35
41	1
41	120
41	142
41	129
41	82
41	80
41	119
41	5
41	34
42	97
42	88
42	144
42	26
42	25
42	24
42	35
42	1
42	142
42	129
42	82
42	98
42	99
42	93
42	5
42	34
2	150
2	151
32	147
33	147
38	147
2	152
3	152
4	152
4	150
3	150
32	150
33	150
38	150
4	151
3	151
32	151
33	151
38	151
2	153
4	155
2	155
3	155
32	155
33	155
38	155
3	153
4	153
29	153
30	153
42	153
4	156
2	156
3	156
29	156
30	156
32	156
33	156
34	156
35	156
36	156
37	156
42	156
4	157
2	157
3	157
29	157
30	157
32	157
33	157
34	157
35	157
36	157
37	157
42	157
4	158
2	158
3	158
29	158
30	158
32	158
33	158
34	158
35	158
36	158
37	158
42	158
4	159
2	159
3	159
29	159
30	159
32	159
33	159
38	159
39	159
42	159
13	150
14	150
15	150
16	150
17	150
18	150
19	150
20	150
34	150
35	150
41	150
42	150
4	160
2	160
3	160
32	160
33	160
38	160
2	161
4	162
2	162
3	162
32	162
33	162
38	162
4	163
2	163
3	163
32	163
33	163
4	164
2	164
3	164
32	164
33	164
4	165
2	165
3	165
32	165
33	165
4	166
2	166
32	166
33	166
4	167
2	167
3	167
4	168
2	168
3	168
32	168
33	168
38	168
4	169
2	169
3	169
32	169
33	169
38	169
4	170
2	170
3	170
32	170
33	170
4	171
2	171
3	171
32	171
33	171
\.


--
-- Data for Name: jointable_issue_productstoissuehelper; Type: TABLE DATA; Schema: public; Owner: -
--

COPY public.jointable_issue_productstoissuehelper (productstoissuehelper_id, issue_id) FROM stdin;
\.


--
-- Data for Name: jointable_masterorder_masterordersmaterialrequirement; Type: TABLE DATA; Schema: public; Owner: -
--

COPY public.jointable_masterorder_masterordersmaterialrequirement (masterorder_id, masterordersmaterialrequirement_id) FROM stdin;
\.


--
-- Data for Name: jointable_materialrequirement_order; Type: TABLE DATA; Schema: public; Owner: -
--

COPY public.jointable_materialrequirement_order (materialrequirement_id, order_id) FROM stdin;
\.


--
-- Data for Name: jointable_materialrequirementcoverage_order; Type: TABLE DATA; Schema: public; Owner: -
--

COPY public.jointable_materialrequirementcoverage_order (materialrequirementcoverage_id, order_id) FROM stdin;
\.


--
-- Data for Name: jointable_multiassignmenttoshift_staff; Type: TABLE DATA; Schema: public; Owner: -
--

COPY public.jointable_multiassignmenttoshift_staff (multiassignmenttoshift_id, staff_id) FROM stdin;
\.


--
-- Data for Name: jointable_oee_productionline; Type: TABLE DATA; Schema: public; Owner: -
--

COPY public.jointable_oee_productionline (oee_id, productionline_id) FROM stdin;
\.


--
-- Data for Name: jointable_oee_workstation; Type: TABLE DATA; Schema: public; Owner: -
--

COPY public.jointable_oee_workstation (oee_id, workstation_id) FROM stdin;
\.


--
-- Data for Name: jointable_operation_workstation; Type: TABLE DATA; Schema: public; Owner: -
--

COPY public.jointable_operation_workstation (workstation_id, operation_id) FROM stdin;
\.


--
-- Data for Name: jointable_operationaltask_staff; Type: TABLE DATA; Schema: public; Owner: -
--

COPY public.jointable_operationaltask_staff (staff_id, operationaltask_id) FROM stdin;
\.


--
-- Data for Name: jointable_order_orderstoolrequirement; Type: TABLE DATA; Schema: public; Owner: -
--

COPY public.jointable_order_orderstoolrequirement (order_id, orderstoolrequirement_id) FROM stdin;
\.


--
-- Data for Name: jointable_order_printlabelshelper; Type: TABLE DATA; Schema: public; Owner: -
--

COPY public.jointable_order_printlabelshelper (printlabelshelper_id, order_id) FROM stdin;
\.


--
-- Data for Name: jointable_order_productionbalance; Type: TABLE DATA; Schema: public; Owner: -
--

COPY public.jointable_order_productionbalance (productionbalance_id, order_id) FROM stdin;
\.


--
-- Data for Name: jointable_order_productionlineschedule; Type: TABLE DATA; Schema: public; Owner: -
--

COPY public.jointable_order_productionlineschedule (order_id, productionlineschedule_id) FROM stdin;
\.


--
-- Data for Name: jointable_order_schedule; Type: TABLE DATA; Schema: public; Owner: -
--

COPY public.jointable_order_schedule (order_id, schedule_id) FROM stdin;
\.


--
-- Data for Name: jointable_order_staff; Type: TABLE DATA; Schema: public; Owner: -
--

COPY public.jointable_order_staff (order_id, staff_id) FROM stdin;
\.


--
-- Data for Name: jointable_order_workplan; Type: TABLE DATA; Schema: public; Owner: -
--

COPY public.jointable_order_workplan (workplan_id, order_id) FROM stdin;
\.


--
-- Data for Name: jointable_palletlabel_printlabelshelper; Type: TABLE DATA; Schema: public; Owner: -
--

COPY public.jointable_palletlabel_printlabelshelper (printlabelshelper_id, palletlabel_id) FROM stdin;
\.


--
-- Data for Name: jointable_palletnumber_palletnumberhelper; Type: TABLE DATA; Schema: public; Owner: -
--

COPY public.jointable_palletnumber_palletnumberhelper (palletnumberhelper_id, palletnumber_id) FROM stdin;
\.


--
-- Data for Name: jointable_parameter_productionline; Type: TABLE DATA; Schema: public; Owner: -
--

COPY public.jointable_parameter_productionline (parameter_id, productionline_id) FROM stdin;
\.


--
-- Data for Name: jointable_plannedevent_plannedevent; Type: TABLE DATA; Schema: public; Owner: -
--

COPY public.jointable_plannedevent_plannedevent (plannedevent_id, relatedevent_id) FROM stdin;
\.


--
-- Data for Name: jointable_plannedevent_staff; Type: TABLE DATA; Schema: public; Owner: -
--

COPY public.jointable_plannedevent_staff (plannedevent_id, staff_id) FROM stdin;
\.


--
-- Data for Name: jointable_printlabelshelper_printedlabel; Type: TABLE DATA; Schema: public; Owner: -
--

COPY public.jointable_printlabelshelper_printedlabel (printedlabel_id, printlabelshelper_id) FROM stdin;
\.


--
-- Data for Name: jointable_product_qualitycard; Type: TABLE DATA; Schema: public; Owner: -
--

COPY public.jointable_product_qualitycard (product_id, qualitycard_id) FROM stdin;
\.


--
-- Data for Name: jointable_product_salesvolumemulti; Type: TABLE DATA; Schema: public; Owner: -
--

COPY public.jointable_product_salesvolumemulti (product_id, salesvolumemulti_id) FROM stdin;
\.


--
-- Data for Name: jointable_product_scale; Type: TABLE DATA; Schema: public; Owner: -
--

COPY public.jointable_product_scale (product_id, scale_id) FROM stdin;
\.


--
-- Data for Name: jointable_product_storagelocation; Type: TABLE DATA; Schema: public; Owner: -
--

COPY public.jointable_product_storagelocation (product_id, storagelocation_id) FROM stdin;
\.


--
-- Data for Name: jointable_product_warehouseminimumstatemulti; Type: TABLE DATA; Schema: public; Owner: -
--

COPY public.jointable_product_warehouseminimumstatemulti (product_id, warehouseminimumstatemulti_id) FROM stdin;
\.


--
-- Data for Name: jointable_productionline_scale; Type: TABLE DATA; Schema: public; Owner: -
--

COPY public.jointable_productionline_scale (productionline_id, scale_id) FROM stdin;
\.


--
-- Data for Name: jointable_productionline_shift; Type: TABLE DATA; Schema: public; Owner: -
--

COPY public.jointable_productionline_shift (productionline_id, shift_id) FROM stdin;
\.


--
-- Data for Name: jointable_productionline_shifttimetableexception; Type: TABLE DATA; Schema: public; Owner: -
--

COPY public.jointable_productionline_shifttimetableexception (productionline_id, shifttimetableexception_id) FROM stdin;
\.


--
-- Data for Name: jointable_productionline_technology; Type: TABLE DATA; Schema: public; Owner: -
--

COPY public.jointable_productionline_technology (technology_id, productionline_id) FROM stdin;
\.


--
-- Data for Name: jointable_productionline_technologygroup; Type: TABLE DATA; Schema: public; Owner: -
--

COPY public.jointable_productionline_technologygroup (technologygroup_id, productionline_id) FROM stdin;
\.


--
-- Data for Name: jointable_shift_shifttimetableexception; Type: TABLE DATA; Schema: public; Owner: -
--

COPY public.jointable_shift_shifttimetableexception (shift_id, shifttimetableexception_id) FROM stdin;
\.


--
-- Data for Name: jointable_size_sizegroup; Type: TABLE DATA; Schema: public; Owner: -
--

COPY public.jointable_size_sizegroup (size_id, sizegroup_id) FROM stdin;
\.


--
-- Data for Name: jointable_staff_timeusagereportfilter; Type: TABLE DATA; Schema: public; Owner: -
--

COPY public.jointable_staff_timeusagereportfilter (staff_id, timeusagereportfilter_id) FROM stdin;
\.


--
-- Data for Name: jointable_stocktaking_storagelocation; Type: TABLE DATA; Schema: public; Owner: -
--

COPY public.jointable_stocktaking_storagelocation (stocktaking_id, storagelocation_id) FROM stdin;
\.


--
-- Data for Name: jointable_storagelocation_storagelocationnumberhelper; Type: TABLE DATA; Schema: public; Owner: -
--

COPY public.jointable_storagelocation_storagelocationnumberhelper (storagelocation_id, storagelocationnumberhelper_id) FROM stdin;
\.


--
-- Data for Name: jointable_storagelocation_warehousestockreport; Type: TABLE DATA; Schema: public; Owner: -
--

COPY public.jointable_storagelocation_warehousestockreport (storagelocation_id, warehousestockreport_id) FROM stdin;
\.


--
-- Data for Name: jointable_technologyoperationcomponent_workstation; Type: TABLE DATA; Schema: public; Owner: -
--

COPY public.jointable_technologyoperationcomponent_workstation (technologyoperationcomponent_id, workstation_id) FROM stdin;
\.


--
-- Data for Name: linechangeovernorms_linechangeovernorms; Type: TABLE DATA; Schema: public; Owner: -
--

COPY public.linechangeovernorms_linechangeovernorms (id, number, changeovertype, fromtechnology_id, totechnology_id, fromtechnologygroup_id, totechnologygroup_id, productionline_id, duration, name, entityversion) FROM stdin;
\.


--
-- Data for Name: masterorders_generatingordershelper; Type: TABLE DATA; Schema: public; Owner: -
--

COPY public.masterorders_generatingordershelper (id, selectedentities, startdate, finishdate) FROM stdin;
\.


--
-- Data for Name: masterorders_masterorder; Type: TABLE DATA; Schema: public; Owner: -
--

COPY public.masterorders_masterorder (id, number, name, description, externalnumber, deadline, addmasterprefixtonumber, masterorderstate, company_id, externalsynchronized, generationdateoneec, cancelsynchronizationreason, active, pw2prod, batch_id, masterorderdefinition_id, startdate, finishdate, entityversion, sendagaintoblackbox, dateofreceipt, address_id, externalproductionorderid, ponumber, direction, createdate, updatedate, createuser, updateuser, deliverynotenumber, cancelsynchronizationtype, companypayer_id, productioncode, commissionnumber, machinetype, pipedriveupdate, state, asanataskid, asanatasknameupdated, asanataskcommentadded, sendagaintoasana, sendagaintoasanatries, asanastatecompleteddate, colourral, salesplan_id, materialsissued, warehouseorder, synchronize, synchronizationdate) FROM stdin;
\.


--
-- Data for Name: masterorders_masterorderdefinition; Type: TABLE DATA; Schema: public; Owner: -
--

COPY public.masterorders_masterorderdefinition (id, number, name, parameter_id, active, entityversion) FROM stdin;
\.


--
-- Data for Name: masterorders_masterorderproduct; Type: TABLE DATA; Schema: public; Owner: -
--

COPY public.masterorders_masterorderproduct (id, product_id, technology_id, masterorder_id, masterorderquantity, cumulatedorderquantity, producedorderquantity, entityversion, lefttorelease, comments, masterorderpositionstatus, quantitytakenfromwarehouse, quantityremainingtoorder, deliverydate, line, vendorinfo, vendorso, price, priceslistprice) FROM stdin;
\.


--
-- Data for Name: masterorders_masterorderproductattrvalue; Type: TABLE DATA; Schema: public; Owner: -
--

COPY public.masterorders_masterorderproductattrvalue (id, masterorderproduct_id, attribute_id, attributevalue_id, value, succession) FROM stdin;
\.


--
-- Data for Name: masterorders_masterordersmaterialrequirement; Type: TABLE DATA; Schema: public; Owner: -
--

COPY public.masterorders_masterordersmaterialrequirement (id, number, name, generated, worker, date, includecomponents) FROM stdin;
\.


--
-- Data for Name: masterorders_masterordersmaterialrequirementproduct; Type: TABLE DATA; Schema: public; Owner: -
--

COPY public.masterorders_masterordersmaterialrequirementproduct (id, masterordersmaterialrequirement_id, product_id, technologyinputproducttype_id, quantity, currentstock, neededquantity, supplier_id) FROM stdin;
\.


--
-- Data for Name: masterorders_orderedproductconfigurator; Type: TABLE DATA; Schema: public; Owner: -
--

COPY public.masterorders_orderedproductconfigurator (id, number, name) FROM stdin;
\.


--
-- Data for Name: masterorders_orderedproductconfiguratorattribute; Type: TABLE DATA; Schema: public; Owner: -
--

COPY public.masterorders_orderedproductconfiguratorattribute (id, orderedproductconfigurator_id, attribute_id, succession) FROM stdin;
\.


--
-- Data for Name: masterorders_ordersgenerationhelper; Type: TABLE DATA; Schema: public; Owner: -
--

COPY public.masterorders_ordersgenerationhelper (id, plannedquantity, datefrom, dateto) FROM stdin;
\.


--
-- Data for Name: masterorders_outsourceprocessingcomponenthelper; Type: TABLE DATA; Schema: public; Owner: -
--

COPY public.masterorders_outsourceprocessingcomponenthelper (id, quantity, datefrom, dateto) FROM stdin;
\.


--
-- Data for Name: masterorders_position_deliveryproductquantityhelper; Type: TABLE DATA; Schema: public; Owner: -
--

COPY public.masterorders_position_deliveryproductquantityhelper (id, product_id, quantity) FROM stdin;
\.


--
-- Data for Name: masterorders_position_warehousestatehelper; Type: TABLE DATA; Schema: public; Owner: -
--

COPY public.masterorders_position_warehousestatehelper (id, product_id, location_id, quantity) FROM stdin;
\.


--
-- Data for Name: masterorders_priceslist; Type: TABLE DATA; Schema: public; Owner: -
--

COPY public.masterorders_priceslist (id, product_id, productcategory, attribute1value_id, value1, attribute2value_id, value2, price, datefrom, dateto) FROM stdin;
\.


--
-- Data for Name: masterorders_productsbyattributeentryhelper; Type: TABLE DATA; Schema: public; Owner: -
--

COPY public.masterorders_productsbyattributeentryhelper (id, productsbyattributehelper_id, product_id, attribute_id, attributevalue_id, value) FROM stdin;
\.


--
-- Data for Name: masterorders_productsbyattributehelper; Type: TABLE DATA; Schema: public; Owner: -
--

COPY public.masterorders_productsbyattributehelper (id, masterorder_id, product_id, orderedquantity, comments) FROM stdin;
\.


--
-- Data for Name: masterorders_productsbysizeentryhelper; Type: TABLE DATA; Schema: public; Owner: -
--

COPY public.masterorders_productsbysizeentryhelper (id, size_id, productsbysizehelper_id, quantity, product_id) FROM stdin;
\.


--
-- Data for Name: masterorders_productsbysizehelper; Type: TABLE DATA; Schema: public; Owner: -
--

COPY public.masterorders_productsbysizehelper (id, product_id, totalquantity, masterorder_id, salesplan_id, ordersgroup_id) FROM stdin;
\.


--
-- Data for Name: masterorders_salesplan; Type: TABLE DATA; Schema: public; Owner: -
--

COPY public.masterorders_salesplan (id, number, name, description, state, datefrom, dateto) FROM stdin;
\.


--
-- Data for Name: masterorders_salesplanmaterialrequirement; Type: TABLE DATA; Schema: public; Owner: -
--

COPY public.masterorders_salesplanmaterialrequirement (id, number, salesplan_id, generated, worker, date, includecomponents) FROM stdin;
\.


--
-- Data for Name: masterorders_salesplanmaterialrequirementproduct; Type: TABLE DATA; Schema: public; Owner: -
--

COPY public.masterorders_salesplanmaterialrequirementproduct (id, salesplanmaterialrequirement_id, product_id, quantity, sizegroup_id, sumforsizes, currentstock, neededquantity, supplier_id, minimumorderquantity, isdeliverycreated) FROM stdin;
\.


--
-- Data for Name: masterorders_salesplanordersgroupentryhelper; Type: TABLE DATA; Schema: public; Owner: -
--

COPY public.masterorders_salesplanordersgroupentryhelper (id, salesplanordersgrouphelper_id, productfamily_id, product_id, plannedquantity, orderedquantity, orderquantity, technology_id) FROM stdin;
\.


--
-- Data for Name: masterorders_salesplanordersgrouphelper; Type: TABLE DATA; Schema: public; Owner: -
--

COPY public.masterorders_salesplanordersgrouphelper (id, salesplan_id) FROM stdin;
\.


--
-- Data for Name: masterorders_salesplanproduct; Type: TABLE DATA; Schema: public; Owner: -
--

COPY public.masterorders_salesplanproduct (id, salesplan_id, product_id, technology_id, plannedquantity, orderedquantity, surplusfromplan, orderedtowarehouse) FROM stdin;
\.


--
-- Data for Name: masterorders_salesplanstatechange; Type: TABLE DATA; Schema: public; Owner: -
--

COPY public.masterorders_salesplanstatechange (id, dateandtime, salesplan_id, shift_id, sourcestate, targetstate, status, phase, worker) FROM stdin;
\.


--
-- Data for Name: masterorders_salesvolume; Type: TABLE DATA; Schema: public; Owner: -
--

COPY public.masterorders_salesvolume (id, product_id, dailysalesvolume, optimalstock, currentstock, stockfordays) FROM stdin;
\.


--
-- Data for Name: masterorders_salesvolumemulti; Type: TABLE DATA; Schema: public; Owner: -
--

COPY public.masterorders_salesvolumemulti (id, dailysalesvolume, optimalstock, createdate, updatedate, createuser, updateuser) FROM stdin;
\.


--
-- Data for Name: materialflow_location; Type: TABLE DATA; Schema: public; Owner: -
--

COPY public.materialflow_location (id, number, name, externalnumber, algorithm, requireprice, requirebatch, requireproductiondate, requireexpirationdate, entityversion, warehousenumberinoptima, draftmakesreservation, realizationlocation_id, active) FROM stdin;
\.


--
-- Data for Name: materialflow_userlocation; Type: TABLE DATA; Schema: public; Owner: -
--

COPY public.materialflow_userlocation (id, location_id, user_id) FROM stdin;
\.


--
-- Data for Name: materialflowresources_costnormsgenerator; Type: TABLE DATA; Schema: public; Owner: -
--

COPY public.materialflowresources_costnormsgenerator (id, costssource, productstoupdate, entityversion) FROM stdin;
\.


--
-- Data for Name: materialflowresources_costnormslocation; Type: TABLE DATA; Schema: public; Owner: -
--

COPY public.materialflowresources_costnormslocation (id, costnormsgenerator_id, location_id, entityversion, parameter_id) FROM stdin;
\.


--
-- Data for Name: materialflowresources_document; Type: TABLE DATA; Schema: public; Owner: -
--

COPY public.materialflowresources_document (id, number, type, "time", state, locationfrom_id, locationto_id, user_id, delivery_id, active, createdate, updatedate, createuser, updateuser, order_id, description, suborder_id, company_id, maintenanceevent_id, entityversion, plannedevent_id, name, createlinkeddocument, linkeddocumentlocation_id, address_id, generationdate, filename, acceptationinprogress, externalnumber, issend, wms, datesendtowms, stateinwms, pickingworker, dateconfirmationofcompletion, editinwms, staff_id, ordersgroup_id, invoicenumber) FROM stdin;
\.


--
-- Data for Name: materialflowresources_documentpositionparameters; Type: TABLE DATA; Schema: public; Owner: -
--

COPY public.materialflowresources_documentpositionparameters (id, suggestresource, acceptanceofdocumentbeforeprinting, notshowprices, presenttotalamountandrest, pallettoshift, palletwithfreeplace, fillresourceirrespectiveofconversion, numberofmonthsforpositionsdata, colorresourcesafterdeadline, shortexpirydate, transferpallettoreceivingwarehouse, runningoutofstockdays) FROM stdin;
1	f	t	f	f	\N	\N	f	1	f	14	f	0
\.


--
-- Data for Name: materialflowresources_documentpositionparametersitem; Type: TABLE DATA; Schema: public; Owner: -
--

COPY public.materialflowresources_documentpositionparametersitem (id, checked, editable, parameters_id, name, ordering, forattribute, attribute_id) FROM stdin;
1	t	f	1	act	1	f	\N
2	t	f	1	number	2	f	\N
3	t	f	1	product	3	f	\N
4	t	t	1	productName	4	f	\N
6	t	f	1	quantity	6	f	\N
7	t	f	1	unit	7	f	\N
8	t	f	1	givenquantity	8	f	\N
9	t	f	1	givenunit	9	f	\N
10	t	f	1	conversion	10	f	\N
11	t	t	1	resource	11	f	\N
12	t	t	1	price	12	f	\N
13	t	t	1	batch	13	f	\N
14	t	t	1	productionDate	14	f	\N
15	t	t	1	expirationDate	15	f	\N
16	t	t	1	storageLocation	16	f	\N
17	t	t	1	palletNumber	17	f	\N
18	t	t	1	typeOfPallet	18	f	\N
21	t	t	1	resourceNumber	21	f	\N
22	f	t	1	sellingPrice	22	f	\N
19	f	t	1	waste	19	f	\N
23	f	t	1	pickingDate	23	f	\N
24	f	t	1	pickingWorker	24	f	\N
20	f	t	1	lastResource	22	f	\N
\.


--
-- Data for Name: materialflowresources_documentstatechange; Type: TABLE DATA; Schema: public; Owner: -
--

COPY public.materialflowresources_documentstatechange (id, dateandtime, document_id, sourcestate, targetstate, status, worker) FROM stdin;
\.


--
-- Data for Name: materialflowresources_importstoragelocation; Type: TABLE DATA; Schema: public; Owner: -
--

COPY public.materialflowresources_importstoragelocation (id, location_id, positionsfile) FROM stdin;
\.


--
-- Data for Name: materialflowresources_palletbalance; Type: TABLE DATA; Schema: public; Owner: -
--

COPY public.materialflowresources_palletbalance (id, number, name, datefrom, dateto, includeweekends, createdate, updatedate, createuser, updateuser, generated, filename, generateddate, generatedby) FROM stdin;
\.


--
-- Data for Name: materialflowresources_palletmovehelper; Type: TABLE DATA; Schema: public; Owner: -
--

COPY public.materialflowresources_palletmovehelper (id) FROM stdin;
\.


--
-- Data for Name: materialflowresources_position; Type: TABLE DATA; Schema: public; Owner: -
--

COPY public.materialflowresources_position (id, document_id, product_id, quantity, price, productiondate, expirationdate, number, resource_id, givenunit, givenquantity, entityversion, storagelocation_id, conversion, palletnumber_id, typeofpallet, waste, resourcereceiptdocument, lastresource, resourcenumber, externaldocumentnumber, orderid, sellingprice, batch_id, qualityrating, pickingdate, pickingworker_id, documentpart_id) FROM stdin;
\.


--
-- Data for Name: materialflowresources_positionaddmultihelper; Type: TABLE DATA; Schema: public; Owner: -
--

COPY public.materialflowresources_positionaddmultihelper (id) FROM stdin;
\.


--
-- Data for Name: materialflowresources_positionattributevalue; Type: TABLE DATA; Schema: public; Owner: -
--

COPY public.materialflowresources_positionattributevalue (id, position_id, attribute_id, attributevalue_id, value) FROM stdin;
\.


--
-- Data for Name: materialflowresources_reservation; Type: TABLE DATA; Schema: public; Owner: -
--

COPY public.materialflowresources_reservation (id, location_id, product_id, quantity, position_id, productstoissue_id, resource_id, order_id, orderproductresourcereservation_id, date) FROM stdin;
\.


--
-- Data for Name: materialflowresources_resource; Type: TABLE DATA; Schema: public; Owner: -
--

COPY public.materialflowresources_resource (id, location_id, product_id, quantity, price, _batch, "time", productiondate, expirationdate, iscorrected, entityversion, storagelocation_id, number, quantityinadditionalunit, conversion, palletnumber_id, typeofpallet, givenunit, username, waste, availablequantity, reservedquantity, deliverynumber, documentnumber, batch_id, blockedforqualitycontrol, qualityrating) FROM stdin;
\.


--
-- Data for Name: materialflowresources_resourceattributevalue; Type: TABLE DATA; Schema: public; Owner: -
--

COPY public.materialflowresources_resourceattributevalue (id, resource_id, attribute_id, attributevalue_id, value, fromdefinition) FROM stdin;
\.


--
-- Data for Name: materialflowresources_resourceattributevalueaftercorrection; Type: TABLE DATA; Schema: public; Owner: -
--

COPY public.materialflowresources_resourceattributevalueaftercorrection (id, resourcecorrection_id, attribute_id, value) FROM stdin;
\.


--
-- Data for Name: materialflowresources_resourceattributevaluebeforecorrection; Type: TABLE DATA; Schema: public; Owner: -
--

COPY public.materialflowresources_resourceattributevaluebeforecorrection (id, resourcecorrection_id, attribute_id, value) FROM stdin;
\.


--
-- Data for Name: materialflowresources_resourcecorrection; Type: TABLE DATA; Schema: public; Owner: -
--

COPY public.materialflowresources_resourcecorrection (id, number, product_id, newquantity, oldquantity, location_id, "time", createdate, updatedate, createuser, updateuser, _oldbatch, resource_id, entityversion, oldstoragelocation_id, newstoragelocation_id, oldprice, newprice, _newbatch, oldpalletnumber_id, newpalletnumber_id, oldtypeofpallet, newtypeofpallet, oldexpirationdate, newexpirationdate, productiondate, oldconversion, newconversion, resourcenumber, deliverynumber, oldbatch_id, newbatch_id, oldqualityrating, newqualityrating) FROM stdin;
\.


--
-- Data for Name: materialflowresources_resourcestock; Type: TABLE DATA; Schema: public; Owner: -
--

COPY public.materialflowresources_resourcestock (id, location_id, product_id) FROM stdin;
\.


--
-- Data for Name: materialflowresources_stocktaking; Type: TABLE DATA; Schema: public; Owner: -
--

COPY public.materialflowresources_stocktaking (id, number, stocktakingdate, generationdate, category, wastemode, storagelocationmode, location_id, generated, filename, active) FROM stdin;
\.


--
-- Data for Name: materialflowresources_storagelocation; Type: TABLE DATA; Schema: public; Owner: -
--

COPY public.materialflowresources_storagelocation (id, number, state, location_id, placestoragelocation, maximumnumberofpallets, createdate, updatedate, createuser, updateuser, active, highstoragelocation) FROM stdin;
\.


--
-- Data for Name: materialflowresources_storagelocationhelper; Type: TABLE DATA; Schema: public; Owner: -
--

COPY public.materialflowresources_storagelocationhelper (id, prefix, number, location_id, placestoragelocation, numberofstoragelocations, maximumnumberofpallets, highstoragelocation) FROM stdin;
\.


--
-- Data for Name: materialflowresources_storagelocationnumberhelper; Type: TABLE DATA; Schema: public; Owner: -
--

COPY public.materialflowresources_storagelocationnumberhelper (id) FROM stdin;
\.


--
-- Data for Name: materialflowresources_warehousestockreport; Type: TABLE DATA; Schema: public; Owner: -
--

COPY public.materialflowresources_warehousestockreport (id, warehousestockdate, generationdate, category, wastemode, storagelocationmode, location_id, generated, filename, active) FROM stdin;
\.


--
-- Data for Name: materialrequirementcoveragefororder_columnforcoveragesfororder; Type: TABLE DATA; Schema: public; Owner: -
--

COPY public.materialrequirementcoveragefororder_columnforcoveragesfororder (id, identifier, name, description, columnfiller, alignment, succession, entityversion) FROM stdin;
\.


--
-- Data for Name: materialrequirementcoveragefororder_coveragefororder; Type: TABLE DATA; Schema: public; Owner: -
--

COPY public.materialrequirementcoveragefororder_coveragefororder (id, number, coveragetodate, actualdate, generateddate, generatedby, generated, saved, filename, coveragetype, includedraftdeliveries, order_id, createdate, updatedate, createuser, updateuser, generatedorders, entityversion) FROM stdin;
\.


--
-- Data for Name: materialrequirementcoveragefororder_coveragelocation; Type: TABLE DATA; Schema: public; Owner: -
--

COPY public.materialrequirementcoveragefororder_coveragelocation (id, coveragefororder_id, location_id, parameter_id, entityversion) FROM stdin;
\.


--
-- Data for Name: materialrequirementcoveragefororder_coverageproduct; Type: TABLE DATA; Schema: public; Owner: -
--

COPY public.materialrequirementcoveragefororder_coverageproduct (id, coveragefororder_id, product_id, lackfromdate, demandquantity, coveredquantity, reservemissingquantity, deliveredquantity, locationsquantity, state, ispurchased, issubcontracted, producttype, order_id, planedquantity, entityversion) FROM stdin;
\.


--
-- Data for Name: materialrequirementcoveragefororder_coverageproductlogging; Type: TABLE DATA; Schema: public; Owner: -
--

COPY public.materialrequirementcoveragefororder_coverageproductlogging (id, coverageproduct_id, date, delivery_id, order_id, operation_id, reservemissingquantity, changes, eventtype, state, subcontractedoperation_id, entityversion) FROM stdin;
\.


--
-- Data for Name: materialrequirements_materialrequirement; Type: TABLE DATA; Schema: public; Owner: -
--

COPY public.materialrequirements_materialrequirement (id, name, number, date, worker, mrpalgorithm, generated, filename, active, entityversion, includewarehouse, showcurrentstocklevel, includestartdateorder, location_id) FROM stdin;
\.


--
-- Data for Name: materialrequirements_materialrequirementproduct; Type: TABLE DATA; Schema: public; Owner: -
--

COPY public.materialrequirements_materialrequirementproduct (id, materialrequirement_id, product_id, location_id, quantity, currentstock, orderstartdate, batch_id, batchstock) FROM stdin;
\.


--
-- Data for Name: mobilewms_wmsdocumentpart; Type: TABLE DATA; Schema: public; Owner: -
--

COPY public.mobilewms_wmsdocumentpart (id, number, part, company, stateinwms, pickingworker, document_id, parts, type, documentdate) FROM stdin;
\.


--
-- Data for Name: nutritionfacts_nutrientcalculation; Type: TABLE DATA; Schema: public; Owner: -
--

COPY public.nutritionfacts_nutrientcalculation (id, product_id, productportion, formatue, formatusa, generated, entityversion) FROM stdin;
\.


--
-- Data for Name: nutritionfacts_nutrition; Type: TABLE DATA; Schema: public; Owner: -
--

COPY public.nutritionfacts_nutrition (id, name, nameen, unit, nutritiongroup_id, priority, rwsvalue, reportue, dvvalue, entityversion) FROM stdin;
\.


--
-- Data for Name: nutritionfacts_nutritionelement; Type: TABLE DATA; Schema: public; Owner: -
--

COPY public.nutritionfacts_nutritionelement (id, nutrition_id, quantity, product_id, prototypeproduct_id, entityversion) FROM stdin;
\.


--
-- Data for Name: nutritionfacts_nutritiongroup; Type: TABLE DATA; Schema: public; Owner: -
--

COPY public.nutritionfacts_nutritiongroup (id, name, priority, rws, entityversion) FROM stdin;
\.


--
-- Data for Name: nutritionfacts_prototypeproduct; Type: TABLE DATA; Schema: public; Owner: -
--

COPY public.nutritionfacts_prototypeproduct (id, name, number, status, createdate, updatedate, createuser, updateuser, generated, productportion, entityversion) FROM stdin;
\.


--
-- Data for Name: nutritionfacts_prototypeproductcomponent; Type: TABLE DATA; Schema: public; Owner: -
--

COPY public.nutritionfacts_prototypeproductcomponent (id, prototypeproduct_id, quantity, product_id, entityversion) FROM stdin;
\.


--
-- Data for Name: oee_oee; Type: TABLE DATA; Schema: public; Owner: -
--

COPY public.oee_oee (id, datefrom, dateto, oeefor, oeepercent, generated, date, worker, active, createdate, updatedate, createuser, updateuser) FROM stdin;
\.


--
-- Data for Name: oee_oeevalue; Type: TABLE DATA; Schema: public; Owner: -
--

COPY public.oee_oeevalue (id, oee_id, productionline_id, workstation_id, totalavailabletime, effectivetime, oeepercent) FROM stdin;
\.


--
-- Data for Name: orders_changedateshelper; Type: TABLE DATA; Schema: public; Owner: -
--

COPY public.orders_changedateshelper (id, datefrom, dateto, commentreasontypecorrectiondatefrom, commentreasontypecorrectiondateto, ids, orderids) FROM stdin;
\.


--
-- Data for Name: orders_dimensioncontrolattribute; Type: TABLE DATA; Schema: public; Owner: -
--

COPY public.orders_dimensioncontrolattribute (id, parameter_id, attribute_id) FROM stdin;
\.


--
-- Data for Name: orders_operationaltask; Type: TABLE DATA; Schema: public; Owner: -
--

COPY public.orders_operationaltask (id, number, name, description, type, startdate, finishdate, order_id, entityversion, staff_id, workstation_id, state, technologyoperationcomponent_id, product_id, scheduleposition_id, division_id, actualstaff, suborder_id) FROM stdin;
\.


--
-- Data for Name: orders_operationaltaskstatechange; Type: TABLE DATA; Schema: public; Owner: -
--

COPY public.orders_operationaltaskstatechange (id, dateandtime, sourcestate, targetstate, status, phase, worker, operationaltask_id, shift_id) FROM stdin;
\.


--
-- Data for Name: orders_order; Type: TABLE DATA; Schema: public; Owner: -
--

COPY public.orders_order (id, number, name, description, commentreasontypecorrectiondatefrom, commentreasontypecorrectiondateto, commentreasondeviationeffectivestart, commentreasondeviationeffectiveend, externalnumber, commentreasontypedeviationsquantity, datefrom, dateto, effectivedatefrom, effectivedateto, deadline, correcteddatefrom, correcteddateto, startdate, finishdate, state, company_id, product_id, technology_id, productionline_id, plannedquantity, donequantity, externalsynchronized, commissionedplannedquantity, commissionedcorrectedquantity, amountofproductproduced, remainingamountofproducttoproduce, ownlinechangeoverduration, registerproductiontime, registerquantityinproduct, laborworktime, includetpz, inputproductsrequiredfortype, generatedenddate, machineworktime, ownlinechangeover, registerquantityoutproduct, operationdurationquantityunit, realizationtime, calculate, includeadditionaltime, typeofproductionrecording, masterorder_id, active, productpriceperunit, failuresyncmessage, targetstate, ignorerequiredcomponents, automaticallymoveoverusage, updatecomponentsavailability, technologyprototype_id, level, parent_id, ignoremissingcomponents, masterorderproduct_id, dateschanged, sourcecorrecteddatefrom, sourcecorrecteddateto, sourcestartdate, sourcefinishdate, batchnumber, root_id, includeordersforcomponent, plannedfinishallorders, plannedstartallorders, calculatedfinishallorders, registerfilled, workplandelivered, calculatedstartallorders, scadacreatedorupdatestate, entityversion, workertochange, masterorderproductcomponent_id, wastesquantity, existsrepairorders, ordercategory, address_id, finalproductiontracking, updatefinishdate, ordersgroup_id, plannedquantityforadditionalunit, division_id, salesplan_id, reportedproductionquantity, expirationdate, additionalfinalproducts, optimizecuttingsolution, vendorinfo, priority) FROM stdin;
\.


--
-- Data for Name: orders_orderattachment; Type: TABLE DATA; Schema: public; Owner: -
--

COPY public.orders_orderattachment (id, order_id, attachment, name, size, ext) FROM stdin;
\.


--
-- Data for Name: orders_ordercategorycolor; Type: TABLE DATA; Schema: public; Owner: -
--

COPY public.orders_ordercategorycolor (id, parameter_id, ordercategory, color) FROM stdin;
\.


--
-- Data for Name: orders_orderpack; Type: TABLE DATA; Schema: public; Owner: -
--

COPY public.orders_orderpack (id, number, order_id, quantity, state) FROM stdin;
\.


--
-- Data for Name: orders_orderpackstatechange; Type: TABLE DATA; Schema: public; Owner: -
--

COPY public.orders_orderpackstatechange (id, dateandtime, sourcestate, targetstate, status, phase, worker, orderpack_id, shift_id) FROM stdin;
\.


--
-- Data for Name: orders_orderstatechange; Type: TABLE DATA; Schema: public; Owner: -
--

COPY public.orders_orderstatechange (id, comment, reasonrequired, dateandtime, sourcestate, targetstate, status, phase, worker, order_id, shift_id, additionalinformation, sourcecorrecteddatefrom, sourcecorrecteddateto, sourcestartdate, sourcefinishdate, targetcorrecteddatefrom, targetcorrecteddateto, targetstartdate, targetfinishdate, dateschanged, entityversion) FROM stdin;
\.


--
-- Data for Name: orders_ordertechnologicalprocess; Type: TABLE DATA; Schema: public; Owner: -
--

COPY public.orders_ordertechnologicalprocess (id, number, orderpack_id, order_id, product_id, operation_id, technologicalprocess_id, quantity, worker_id, date, wastesquantity, technologyoperationcomponent_id, createdate) FROM stdin;
\.


--
-- Data for Name: orders_ordertechnologicalprocesspart; Type: TABLE DATA; Schema: public; Owner: -
--

COPY public.orders_ordertechnologicalprocesspart (id, number, quantity, ordertechnologicalprocess_id) FROM stdin;
\.


--
-- Data for Name: orders_ordertechnologicalprocesswaste; Type: TABLE DATA; Schema: public; Owner: -
--

COPY public.orders_ordertechnologicalprocesswaste (id, number, ordertechnologicalprocess_id, orderpack_id, order_id, product_id, technologicalprocess_id, wastequantity, causeofwaste, worker_id, date, description) FROM stdin;
\.


--
-- Data for Name: orders_productionlineschedule; Type: TABLE DATA; Schema: public; Owner: -
--

COPY public.orders_productionlineschedule (id, number, name, starttime, state, durationofordercalculatedonbasis, sortorder, productionlineassigncriterion, approvetime, allowproductionlinechange) FROM stdin;
\.


--
-- Data for Name: orders_productionlinescheduleposition; Type: TABLE DATA; Schema: public; Owner: -
--

COPY public.orders_productionlinescheduleposition (id, productionlineschedule_id, order_id, productionline_id, linechangeovernorm_id, starttime, endtime, additionaltime) FROM stdin;
\.


--
-- Data for Name: orders_productionlineschedulestatechange; Type: TABLE DATA; Schema: public; Owner: -
--

COPY public.orders_productionlineschedulestatechange (id, dateandtime, sourcestate, targetstate, status, phase, worker, productionlineschedule_id, shift_id) FROM stdin;
\.


--
-- Data for Name: orders_reasontypecorrectiondatefrom; Type: TABLE DATA; Schema: public; Owner: -
--

COPY public.orders_reasontypecorrectiondatefrom (id, order_id, reasontypeofchangingorderstate, date, entityversion, changedateshelper_id) FROM stdin;
\.


--
-- Data for Name: orders_reasontypecorrectiondateto; Type: TABLE DATA; Schema: public; Owner: -
--

COPY public.orders_reasontypecorrectiondateto (id, order_id, reasontypeofchangingorderstate, date, entityversion, changedateshelper_id) FROM stdin;
\.


--
-- Data for Name: orders_reasontypedeviationeffectiveend; Type: TABLE DATA; Schema: public; Owner: -
--

COPY public.orders_reasontypedeviationeffectiveend (id, order_id, reasontypeofchangingorderstate, date, entityversion) FROM stdin;
\.


--
-- Data for Name: orders_reasontypedeviationeffectivestart; Type: TABLE DATA; Schema: public; Owner: -
--

COPY public.orders_reasontypedeviationeffectivestart (id, order_id, reasontypeofchangingorderstate, date, entityversion) FROM stdin;
\.


--
-- Data for Name: orders_reasontypeofchangingorderstate; Type: TABLE DATA; Schema: public; Owner: -
--

COPY public.orders_reasontypeofchangingorderstate (id, orderstatechange_id, reasontypeofchangingorderstate, entityversion) FROM stdin;
\.


--
-- Data for Name: orders_schedule; Type: TABLE DATA; Schema: public; Owner: -
--

COPY public.orders_schedule (id, number, name, starttime, state, sortorder, workstationassigncriterion, workerassigncriterion, approvetime, additionaltimeextendsoperation, includetpz, onlyworkstationsoflinefromorder, token, plannerworkstationassigncriterion, deadlinesort, operationlevelsort, orderprioritysort, abcanalysissort, includetpzchanged) FROM stdin;
\.


--
-- Data for Name: orders_scheduleposition; Type: TABLE DATA; Schema: public; Owner: -
--

COPY public.orders_scheduleposition (id, schedule_id, technologyoperationcomponent_id, additionaltime, machineworktime, laborworktime, order_id, product_id, workstation_id, quantity, starttime, endtime, staff_id, operationruns, partialoperationruns) FROM stdin;
\.


--
-- Data for Name: orders_schedulestatechange; Type: TABLE DATA; Schema: public; Owner: -
--

COPY public.orders_schedulestatechange (id, dateandtime, sourcestate, targetstate, status, phase, worker, schedule_id, shift_id) FROM stdin;
\.


--
-- Data for Name: orders_setcategory; Type: TABLE DATA; Schema: public; Owner: -
--

COPY public.orders_setcategory (id, ordercategory) FROM stdin;
\.


--
-- Data for Name: orders_splitorderchild; Type: TABLE DATA; Schema: public; Owner: -
--

COPY public.orders_splitorderchild (id, splitorderparent_id, number, name, datefrom, dateto, plannedquantity, unit) FROM stdin;
\.


--
-- Data for Name: orders_splitorderhelper; Type: TABLE DATA; Schema: public; Owner: -
--

COPY public.orders_splitorderhelper (id, datefrom, dateto, parts) FROM stdin;
\.


--
-- Data for Name: orders_splitorderparent; Type: TABLE DATA; Schema: public; Owner: -
--

COPY public.orders_splitorderparent (id, splitorderhelper_id, order_id, number, name, datefrom, dateto, plannedquantity, unit) FROM stdin;
\.


--
-- Data for Name: orders_typeofcorrectioncauses; Type: TABLE DATA; Schema: public; Owner: -
--

COPY public.orders_typeofcorrectioncauses (id, order_id, reasontype, date, entityversion) FROM stdin;
\.


--
-- Data for Name: orders_workstationchangeoverforoperationaltask; Type: TABLE DATA; Schema: public; Owner: -
--

COPY public.orders_workstationchangeoverforoperationaltask (id, number, name, description, workstation_id, currentoperationaltask_id, previousoperationaltask_id, changeovertype, workstationchangeovernorm_id, attribute_id, fromattributevalue_id, toattributevalue_id, startdate, finishdate, duration, isparallel) FROM stdin;
\.


--
-- Data for Name: orders_workstationchangeoverforscheduleposition; Type: TABLE DATA; Schema: public; Owner: -
--

COPY public.orders_workstationchangeoverforscheduleposition (id, currentscheduleposition_id, previousscheduleposition_id, previousoperationaltask_id, workstationchangeovernorm_id, startdate, finishdate) FROM stdin;
\.


--
-- Data for Name: ordersforsubproductsgeneration_suborders; Type: TABLE DATA; Schema: public; Owner: -
--

COPY public.ordersforsubproductsgeneration_suborders (id, order_id, ordersgroup_id, createdate, updatedate, createuser, updateuser, ordersgroupsgenerated, generatedorders, ordergenerationinprogress) FROM stdin;
\.


--
-- Data for Name: ordersgantt_ordersganttparameters; Type: TABLE DATA; Schema: public; Owner: -
--

COPY public.ordersgantt_ordersganttparameters (id, datasource, manualwritingplan, calculateorderstime, detectcollisions, donotletcollisions, changeovernormsfrom, typeofsave) FROM stdin;
1	01orders	t	t	f	f	01lack	01saveOnly
\.


--
-- Data for Name: ordersgroups_ordersgroup; Type: TABLE DATA; Schema: public; Owner: -
--

COPY public.ordersgroups_ordersgroup (id, number, assortment_id, productionline_id, startdate, finishdate, deadline, quantity, producedquantity, remainingquantity, state, active, masterorder_id, parent_id, remainingquantityinorders, description, salesplan_id) FROM stdin;
\.


--
-- Data for Name: ordersgroups_ordersgroupissuedmaterial; Type: TABLE DATA; Schema: public; Owner: -
--

COPY public.ordersgroups_ordersgroupissuedmaterial (id, ordersgroup_id, product_id, quantity, value, averageprice) FROM stdin;
\.


--
-- Data for Name: ordersgroups_ordersgroupissuedmaterialposition; Type: TABLE DATA; Schema: public; Owner: -
--

COPY public.ordersgroups_ordersgroupissuedmaterialposition (id, ordersgroupissuedmaterial_id, documentnumber, quantity, price, value, externaldocumentid) FROM stdin;
\.


--
-- Data for Name: ordersgroups_ordersgroupmaterialrequirement; Type: TABLE DATA; Schema: public; Owner: -
--

COPY public.ordersgroups_ordersgroupmaterialrequirement (id, number, ordersgroup_id, generated, worker, date, filename) FROM stdin;
\.


--
-- Data for Name: ordersgroups_ordersgroupmaterialrequirementproduct; Type: TABLE DATA; Schema: public; Owner: -
--

COPY public.ordersgroups_ordersgroupmaterialrequirementproduct (id, ordersgroupmaterialrequirement_id, product_id, quantity, currentstock, technologyinputproducttype_id, orderstartdate, division_id, location_id, issuedquantity, supplier_id) FROM stdin;
\.


--
-- Data for Name: ordersgroups_ordersgroupproducedproduct; Type: TABLE DATA; Schema: public; Owner: -
--

COPY public.ordersgroups_ordersgroupproducedproduct (id, ordersgroup_id, product_id, location_id, document_id, quantity, accepted, externaldocumentnumber, batch_id, storagelocation_id, palletnumber_id, typeofpallet) FROM stdin;
\.


--
-- Data for Name: ordersgroups_ordersgroupproductstoissueentryhelper; Type: TABLE DATA; Schema: public; Owner: -
--

COPY public.ordersgroups_ordersgroupproductstoissueentryhelper (id, ordersgroupmaterialrequirementproduct_id, ordersgroupproductstoissuehelper_id, quantity) FROM stdin;
\.


--
-- Data for Name: ordersgroups_ordersgroupproductstoissuehelper; Type: TABLE DATA; Schema: public; Owner: -
--

COPY public.ordersgroups_ordersgroupproductstoissuehelper (id, ordersgroupmaterialrequirement_id) FROM stdin;
\.


--
-- Data for Name: ordersgroups_productionbalance; Type: TABLE DATA; Schema: public; Owner: -
--

COPY public.ordersgroups_productionbalance (id, number, name, generated, worker, date, filename, ordersgroup_id, plannedmaterialcost, usenominalcostpricenotspecified, realmaterialcost, orderedquantity, producedquantity, quantitydeviation, plannedcost, realcost, costdeviation, active) FROM stdin;
\.


--
-- Data for Name: ordersgroups_sizegroupcolor; Type: TABLE DATA; Schema: public; Owner: -
--

COPY public.ordersgroups_sizegroupcolor (id, parameter_id, sizegroup_id, color, succession) FROM stdin;
\.


--
-- Data for Name: ordersupplies_columnforcoverages; Type: TABLE DATA; Schema: public; Owner: -
--

COPY public.ordersupplies_columnforcoverages (id, identifier, name, description, columnfiller, alignment, succession, entityversion) FROM stdin;
\.


--
-- Data for Name: ordersupplies_coverageanalysisfororder; Type: TABLE DATA; Schema: public; Owner: -
--

COPY public.ordersupplies_coverageanalysisfororder (id, order_id, orderedproduct_id, plannedquantity, coveragedegree, coveredfromtheday, deliverytime, componentsproductiondate, materialrequirementcoverage_id) FROM stdin;
\.


--
-- Data for Name: ordersupplies_coveragelocation; Type: TABLE DATA; Schema: public; Owner: -
--

COPY public.ordersupplies_coveragelocation (id, materialrequirementcoverage_id, location_id, parameter_id, entityversion) FROM stdin;
\.


--
-- Data for Name: ordersupplies_coverageorderstate; Type: TABLE DATA; Schema: public; Owner: -
--

COPY public.ordersupplies_coverageorderstate (id, materialrequirementcoverage_id, parameter_id, state) FROM stdin;
\.


--
-- Data for Name: ordersupplies_coverageproduct; Type: TABLE DATA; Schema: public; Owner: -
--

COPY public.ordersupplies_coverageproduct (id, materialrequirementcoverage_id, product_id, lackfromdate, demandquantity, coveredquantity, reservemissingquantity, deliveredquantity, locationsquantity, state, issubcontracted, ispurchased, productnumber, productname, productunit, producttype, planedquantity, producequantity, fromselectedorder, entityversion, company_id, price) FROM stdin;
\.


--
-- Data for Name: ordersupplies_coverageproductgenerated; Type: TABLE DATA; Schema: public; Owner: -
--

COPY public.ordersupplies_coverageproductgenerated (id, productid, entityversion) FROM stdin;
\.


--
-- Data for Name: ordersupplies_coverageproductlogging; Type: TABLE DATA; Schema: public; Owner: -
--

COPY public.ordersupplies_coverageproductlogging (id, coverageproduct_id, date, delivery_id, order_id, operation_id, reservemissingquantity, changes, eventtype, state, subcontractedoperation_id, deliverynumberexternal, warehousenumber, entityversion) FROM stdin;
\.


--
-- Data for Name: ordersupplies_coverageproductselected; Type: TABLE DATA; Schema: public; Owner: -
--

COPY public.ordersupplies_coverageproductselected (id, coverageproduct_id, entityversion) FROM stdin;
\.


--
-- Data for Name: ordersupplies_materialrequirementcoverage; Type: TABLE DATA; Schema: public; Owner: -
--

COPY public.ordersupplies_materialrequirementcoverage (id, number, coveragetodate, actualdate, generateddate, generatedby, generated, saved, coveragetype, includedraftdeliveries, createdate, updatedate, createuser, updateuser, filename, automaticsavecoverage, order_id, entityversion, ordergenerationinprogress, forordersgroup_id, ordersgroupsgenerated, includeincalculationdeliveries) FROM stdin;
\.


--
-- Data for Name: productcatalognumbers_productcatalognumbers; Type: TABLE DATA; Schema: public; Owner: -
--

COPY public.productcatalognumbers_productcatalognumbers (id, catalognumber, product_id, company_id, entityversion) FROM stdin;
\.


--
-- Data for Name: productflowthrudivision_issue; Type: TABLE DATA; Schema: public; Owner: -
--

COPY public.productflowthrudivision_issue (id, warehouseissue_id, product_id, productincomponent_id, demandquantity, locationsquantity, issuequantity, location_id, entityversion, locationtoquantity, quantityperunit, issued, additionaldemandquantity, conversion, dateofissued, document_id) FROM stdin;
\.


--
-- Data for Name: productflowthrudivision_materialavailability; Type: TABLE DATA; Schema: public; Owner: -
--

COPY public.productflowthrudivision_materialavailability (id, order_id, product_id, availablequantity, requiredquantity, unit, entityversion, location_id, availability, replacement, batchesid, batches, batchesquantity) FROM stdin;
\.


--
-- Data for Name: productflowthrudivision_modelcard; Type: TABLE DATA; Schema: public; Owner: -
--

COPY public.productflowthrudivision_modelcard (id, number, name, generated, filename, date, worker, materialcostsused, usenominalcostpricenotspecified) FROM stdin;
\.


--
-- Data for Name: productflowthrudivision_modelcardproduct; Type: TABLE DATA; Schema: public; Owner: -
--

COPY public.productflowthrudivision_modelcardproduct (id, modelcard_id, product_id, technology_id, quantity, succession) FROM stdin;
\.


--
-- Data for Name: productflowthrudivision_opertaskmaterialavailability; Type: TABLE DATA; Schema: public; Owner: -
--

COPY public.productflowthrudivision_opertaskmaterialavailability (id, operationaltask_id, product_id, location_id, availablequantity, requiredquantity, unit, availability, replacement, batchesid, batches, batchesquantity, typeofmaterial, produced) FROM stdin;
\.


--
-- Data for Name: productflowthrudivision_orderproductresourcereservation; Type: TABLE DATA; Schema: public; Owner: -
--

COPY public.productflowthrudivision_orderproductresourcereservation (id, resource_id, resourcenumber, planedquantity, usedquantity, productioncountingquantity_id, priority, resourceunit, creationdate) FROM stdin;
\.


--
-- Data for Name: productflowthrudivision_productandquantityhelper; Type: TABLE DATA; Schema: public; Owner: -
--

COPY public.productflowthrudivision_productandquantityhelper (id, product_id, location_id, locationsquantity) FROM stdin;
\.


--
-- Data for Name: productflowthrudivision_productstoissue; Type: TABLE DATA; Schema: public; Owner: -
--

COPY public.productflowthrudivision_productstoissue (id, warehouseissue_id, product_id, productincomponent_id, demandquantity, locationsquantity, placeofissuequantity, issuequantity, location_id, entityversion, issued, additionaldemandquantity, conversion, correction) FROM stdin;
\.


--
-- Data for Name: productflowthrudivision_productstoissuehelper; Type: TABLE DATA; Schema: public; Owner: -
--

COPY public.productflowthrudivision_productstoissuehelper (id, locationfrom_id, productstoissueids, generated, additionalinfo) FROM stdin;
\.


--
-- Data for Name: productflowthrudivision_producttoissuecorrection; Type: TABLE DATA; Schema: public; Owner: -
--

COPY public.productflowthrudivision_producttoissuecorrection (id, producttoissuecorrectionhelper_id, warehouseissue_id, product_id, correctionquantity, correctionquantityinadditionalunit, quantitytoissue, demandquantity, conversion, location_id, description, createdate, updatedate, createuser, updateuser, productstoissue_id) FROM stdin;
\.


--
-- Data for Name: productflowthrudivision_producttoissuecorrectionhelper; Type: TABLE DATA; Schema: public; Owner: -
--

COPY public.productflowthrudivision_producttoissuecorrectionhelper (id, locationfrom_id, locationto_id, productstoissueids) FROM stdin;
\.


--
-- Data for Name: productflowthrudivision_trackingproductresourcereservation; Type: TABLE DATA; Schema: public; Owner: -
--

COPY public.productflowthrudivision_trackingproductresourcereservation (id, priority, orderproductresourcereservation_id, trackingoperationproductincomponent_id, usedquantity) FROM stdin;
\.


--
-- Data for Name: productflowthrudivision_warehouseissue; Type: TABLE DATA; Schema: public; Owner: -
--

COPY public.productflowthrudivision_warehouseissue (id, number, description, order_id, placeofissue_id, division_id, workerwhoissued_id, workerwhocollected_id, dateofissued, dateofcreation, technologyoperationcomponent_id, collectionproducts, state, createdate, updatedate, createuser, updateuser, entityversion, productstoissuemode) FROM stdin;
\.


--
-- Data for Name: productflowthrudivision_warehouseissuestatechange; Type: TABLE DATA; Schema: public; Owner: -
--

COPY public.productflowthrudivision_warehouseissuestatechange (id, dateandtime, sourcestate, targetstate, status, phase, worker, warehouseissue_id, shift_id, additionalinformation, entityversion) FROM stdin;
\.


--
-- Data for Name: productioncounting_anomaly; Type: TABLE DATA; Schema: public; Owner: -
--

COPY public.productioncounting_anomaly (id, number, productiontracking_id, masterproduct_id, product_id, usedquantity, state, issued, createdate, updatedate, createuser, updateuser, location_id) FROM stdin;
\.


--
-- Data for Name: productioncounting_anomalyexplanation; Type: TABLE DATA; Schema: public; Owner: -
--

COPY public.productioncounting_anomalyexplanation (id, anomaly_id, product_id, location_id, usedquantity, givenquantity, givenunit, usewaste, description, createdate, updatedate, createuser, updateuser) FROM stdin;
\.


--
-- Data for Name: productioncounting_anomalyproductiontrackingentryhelper; Type: TABLE DATA; Schema: public; Owner: -
--

COPY public.productioncounting_anomalyproductiontrackingentryhelper (id, anomalyproductiontracking_id, trackingoperationproductincomponent_id, createdate, updatedate, createuser, updateuser) FROM stdin;
\.


--
-- Data for Name: productioncounting_anomalyproductiontrackinghelper; Type: TABLE DATA; Schema: public; Owner: -
--

COPY public.productioncounting_anomalyproductiontrackinghelper (id, createdate, updatedate, createuser, updateuser) FROM stdin;
\.


--
-- Data for Name: productioncounting_anomalyreason; Type: TABLE DATA; Schema: public; Owner: -
--

COPY public.productioncounting_anomalyreason (id, name, defaultreason) FROM stdin;
\.


--
-- Data for Name: productioncounting_anomalyreasoncontainer; Type: TABLE DATA; Schema: public; Owner: -
--

COPY public.productioncounting_anomalyreasoncontainer (id, anomalyproductiontrackingentryhelper_id, anomalyreason_id) FROM stdin;
\.


--
-- Data for Name: productioncounting_lack; Type: TABLE DATA; Schema: public; Owner: -
--

COPY public.productioncounting_lack (id, trackingoperationproductoutcomponent_id, lackquantity, createdate, updatedate, createuser, updateuser) FROM stdin;
\.


--
-- Data for Name: productioncounting_lackreason; Type: TABLE DATA; Schema: public; Owner: -
--

COPY public.productioncounting_lackreason (id, lack_id, causeofwastes, description, createdate, updatedate, createuser, updateuser) FROM stdin;
\.


--
-- Data for Name: productioncounting_orderbalance; Type: TABLE DATA; Schema: public; Owner: -
--

COPY public.productioncounting_orderbalance (id, productionbalance_id, ordernumber, productnumber, productname, plannedquantity, producedquantity, deviation, productunit, plannedmaterialcosts, materialcosts, materialcostsdeviation, plannedproductioncosts, productioncosts, productioncostsdeviation, technicalproductioncosts, materialcostmargin, materialcostmarginvalue, productioncostmargin, productioncostmarginvalue, additionaloverhead, directadditionalcost, totalcosts, registrationprice, registrationpriceoverhead, registrationpriceoverheadvalue, realproductioncosts, technicalproductioncostoverhead, technicalproductioncostoverheadvalue, totalmanufacturingcost, profit, profitvalue, sellprice, externalservicescost) FROM stdin;
\.


--
-- Data for Name: productioncounting_prodoutresourceattrval; Type: TABLE DATA; Schema: public; Owner: -
--

COPY public.productioncounting_prodoutresourceattrval (id, trackingoperationproductoutcomponent_id, attribute_id, attributevalue_id, value) FROM stdin;
\.


--
-- Data for Name: productioncounting_productionbalance; Type: TABLE DATA; Schema: public; Owner: -
--

COPY public.productioncounting_productionbalance (id, generated, name, date, worker, description, filename, includetpz, includeadditionaltime, materialcostmargin, materialcostsused, productioncostmargin, active, entityversion, sourceofoperationcosts, registrationpriceoverhead, profit, number, additionaloverhead, includewagegroups, technicalproductioncostoverhead) FROM stdin;
\.


--
-- Data for Name: productioncounting_productiontracking; Type: TABLE DATA; Schema: public; Owner: -
--

COPY public.productioncounting_productiontracking (id, number, order_id, technologyinstanceoperationcomponent_id, shift_id, state, lasttracking, machinetime, labortime, staff_id, workstationtype_id, division_id, active, createdate, updatedate, createuser, updateuser, laststatechangefails, laststatechangefailcause, isexternalsynchronized, timerangefrom, timerangeto, shiftstartday, changeovertime, subcontractor_id, technologyoperationcomponent_id, entityversion, repairorder_id, correction_id, iscorrection, planforordercompleted, workstation_id, batch_id, expirationdate, qualityrating, iscorrected, comments) FROM stdin;
\.


--
-- Data for Name: productioncounting_productiontrackingattachment; Type: TABLE DATA; Schema: public; Owner: -
--

COPY public.productioncounting_productiontrackingattachment (id, productiontracking_id, attachment, name, size, ext) FROM stdin;
\.


--
-- Data for Name: productioncounting_productiontrackingstatechange; Type: TABLE DATA; Schema: public; Owner: -
--

COPY public.productioncounting_productiontrackingstatechange (id, dateandtime, sourcestate, targetstate, status, phase, worker, productiontracking_id, shift_id, entityversion) FROM stdin;
\.


--
-- Data for Name: productioncounting_staffworktime; Type: TABLE DATA; Schema: public; Owner: -
--

COPY public.productioncounting_staffworktime (id, productionrecord_id, worker_id, labortime, effectiveexecutiontimestart, effectiveexecutiontimeend, entityversion) FROM stdin;
\.


--
-- Data for Name: productioncounting_trackinginproductreplacementhelper; Type: TABLE DATA; Schema: public; Owner: -
--

COPY public.productioncounting_trackinginproductreplacementhelper (id, productiontracking_id, product_id, quantity, basicproduct_id) FROM stdin;
\.


--
-- Data for Name: productioncounting_trackingoperationproductincomponent; Type: TABLE DATA; Schema: public; Owner: -
--

COPY public.productioncounting_trackingoperationproductincomponent (id, productiontracking_id, product_id, usedquantity, balance, obtainedquantity, remainedquantity, effectiveusedquantity, givenunit, givenquantity, entityversion, typeofmaterial, wasteused, wasteusedonly, wasteusedquantity, wasteunit, additionalinformation, replacementto_id) FROM stdin;
\.


--
-- Data for Name: productioncounting_trackingoperationproductoutcomponent; Type: TABLE DATA; Schema: public; Owner: -
--

COPY public.productioncounting_trackingoperationproductoutcomponent (id, productiontracking_id, product_id, usedquantity, balance, batch_id, wastedquantity, givenunit, givenquantity, entityversion, wastesquantity, typeofmaterial, storagelocation_id, causeofwastes, palletnumber_id, manyreasonsforlacks, typeofpallet) FROM stdin;
\.


--
-- Data for Name: productioncounting_usedbatch; Type: TABLE DATA; Schema: public; Owner: -
--

COPY public.productioncounting_usedbatch (id, trackingoperationproductincomponent_id, batch_id, quantity) FROM stdin;
\.


--
-- Data for Name: productionlines_factorystructureelement; Type: TABLE DATA; Schema: public; Owner: -
--

COPY public.productionlines_factorystructureelement (id, number, name, parent_id, priority, nodenumber, entitytype, current, subassembly_id, workstation_id, entityid, maintenanceevent_id, entityversion, productionline_id) FROM stdin;
\.


--
-- Data for Name: productionlines_productionline; Type: TABLE DATA; Schema: public; Owner: -
--

COPY public.productionlines_productionline (id, number, name, division_id, place, description, supportsalltechnologies, documentation, supportsothertechnologiesworkstationtypes, quantityforotherworkstationtypes, active, eurocodsymbol, availabilityindicator, production, entityversion, placeinscada, printer_id, printedlabelstype, printedlabelstime, isblocked) FROM stdin;
1	Line	Main line	\N	\N	\N	t	\N	t	1	t	\N	\N	t	0	\N	\N	\N	\N	f
\.


--
-- Data for Name: productionlines_workstationtypecomponent; Type: TABLE DATA; Schema: public; Owner: -
--

COPY public.productionlines_workstationtypecomponent (id, productionline_id, workstationtype_id, quantity, entityversion, datefrom, dateto) FROM stdin;
\.


--
-- Data for Name: productionpershift_balance; Type: TABLE DATA; Schema: public; Owner: -
--

COPY public.productionpershift_balance (id, context_id, day, shiftname, ordernumber, productnumber, productunit, registeredquantity, plannedquantity, difference, percentagedeviation, entityversion) FROM stdin;
\.


--
-- Data for Name: productionpershift_balancecontext; Type: TABLE DATA; Schema: public; Owner: -
--

COPY public.productionpershift_balancecontext (id, fromdate, todate, viewisinitialized, plannedquantityrequired, deviationrequired, deviationthreshold, entityversion) FROM stdin;
\.


--
-- Data for Name: productionpershift_dailyprogress; Type: TABLE DATA; Schema: public; Owner: -
--

COPY public.productionpershift_dailyprogress (id, progressforday_id, shift_id, quantity, locked, entityversion, efficiencytime) FROM stdin;
\.


--
-- Data for Name: productionpershift_plandailyprogress; Type: TABLE DATA; Schema: public; Owner: -
--

COPY public.productionpershift_plandailyprogress (id, progressforday_id, shift_id, quantity, efficiencytime) FROM stdin;
\.


--
-- Data for Name: productionpershift_planproductionpershift; Type: TABLE DATA; Schema: public; Owner: -
--

COPY public.productionpershift_planproductionpershift (id, order_id, productionlineschedule_id, productionline_id) FROM stdin;
\.


--
-- Data for Name: productionpershift_planprogressforday; Type: TABLE DATA; Schema: public; Owner: -
--

COPY public.productionpershift_planprogressforday (id, day, dateofday, actualdateofday, productionpershift_id) FROM stdin;
\.


--
-- Data for Name: productionpershift_ppsreport; Type: TABLE DATA; Schema: public; Owner: -
--

COPY public.productionpershift_ppsreport (id, number, name, datefrom, dateto, filename, generated, createdate, updatedate, createuser, updateuser) FROM stdin;
\.


--
-- Data for Name: productionpershift_productionpershift; Type: TABLE DATA; Schema: public; Owner: -
--

COPY public.productionpershift_productionpershift (id, order_id, plannedprogresscorrectioncomment, orderfinishdate, entityversion) FROM stdin;
\.


--
-- Data for Name: productionpershift_progressforday; Type: TABLE DATA; Schema: public; Owner: -
--

COPY public.productionpershift_progressforday (id, day, corrected, dateofday, actualdateofday, entityversion, productionpershift_id) FROM stdin;
\.


--
-- Data for Name: productionpershift_reasontypeofcorrectionplan; Type: TABLE DATA; Schema: public; Owner: -
--

COPY public.productionpershift_reasontypeofcorrectionplan (id, productionpershift_id, reasontype, date, entityversion) FROM stdin;
\.


--
-- Data for Name: productionplans_dimensioncontrolattribute; Type: TABLE DATA; Schema: public; Owner: -
--

COPY public.productionplans_dimensioncontrolattribute (id, parameter_id, attribute_id) FROM stdin;
\.


--
-- Data for Name: productionscheduling_opercomptimecalculation; Type: TABLE DATA; Schema: public; Owner: -
--

COPY public.productionscheduling_opercomptimecalculation (id, ordertimecalculation_id, technologyoperationcomponent_id, operationoffset, effectiveoperationrealizationtime, effectivedatefrom, effectivedateto, duration, machineworktime, laborworktime) FROM stdin;
\.


--
-- Data for Name: productionscheduling_ordertimecalculation; Type: TABLE DATA; Schema: public; Owner: -
--

COPY public.productionscheduling_ordertimecalculation (id, order_id, effectivedatefrom, effectivedateto) FROM stdin;
\.


--
-- Data for Name: productionscheduling_planopercomptimecalculation; Type: TABLE DATA; Schema: public; Owner: -
--

COPY public.productionscheduling_planopercomptimecalculation (id, ordertimecalculation_id, technologyoperationcomponent_id, operationoffset, effectiveoperationrealizationtime, effectivedatefrom, effectivedateto) FROM stdin;
\.


--
-- Data for Name: productionscheduling_planordertimecalculation; Type: TABLE DATA; Schema: public; Owner: -
--

COPY public.productionscheduling_planordertimecalculation (id, order_id, productionlineschedule_id, productionline_id, effectivedatefrom, effectivedateto) FROM stdin;
\.


--
-- Data for Name: qcadoocustomtranslation_customtranslation; Type: TABLE DATA; Schema: public; Owner: -
--

COPY public.qcadoocustomtranslation_customtranslation (id, pluginidentifier, key, propertiestranslation, customtranslation, active, locale, entityversion) FROM stdin;
\.


--
-- Data for Name: qcadoomodel_dictionary; Type: TABLE DATA; Schema: public; Owner: -
--

COPY public.qcadoomodel_dictionary (id, name, pluginidentifier, active, entityversion) FROM stdin;
1	units	qcadooModel	t	0
2	color	basic	t	0
3	descriptionTypes	basic	t	0
4	addressType	basic	t	0
5	typeOfPallet	basic	t	0
6	typeOfSubassembly	basic	t	0
7	reasonTypeOfChangingOrderState	basic	t	0
9	categories	basic	t	0
10	productionLinePlaces	productionLines	t	0
11	superiorWageGroups	wageGroups	t	0
12	orderCategory	orders	t	0
13	paymentForm	deliveries	t	0
15	masterOrderPositionStatus	masterOrders	t	0
16	masterOrderState	masterOrders	t	0
17	occupationType	assignmentToShift	t	0
18	productionLinePlacesForSCADA	productionLines	t	0
21	causesOfWastes	productionCounting	t	0
22	typeOfProducts	basic	t	0
23	contractorCategory	basic	t	0
25	toolCategory	cmmsMachineParts	t	0
20	qualityRating	qualityControl	f	0
24	sampling	basic	t	0
\.


--
-- Data for Name: qcadoomodel_dictionaryitem; Type: TABLE DATA; Schema: public; Owner: -
--

COPY public.qcadoomodel_dictionaryitem (id, name, externalnumber, description, technicalcode, dictionary_id, active, entityversion, isinteger, priority) FROM stdin;
1	EPAL	\N	\N	01epal	5	t	0	f	2
3	main	\N	\N	01main	4	t	0	f	1
4	white	\N	#ffffff	01white	2	t	0	f	6
5	grey	\N	#bfbfbf	02grey	2	t	0	f	3
6	yellow	\N	#ffff99	03yellow	2	t	0	f	7
7	orange	\N	#ff944d	04orange	2	t	0	f	4
8	red	\N	#ff6666	05red	2	t	0	f	5
9	green	\N	#85e085	06green	2	t	0	f	2
10	blue	\N	#66a3ff	07blue	2	t	0	f	1
11	Work on line	\N	\N	01workOnLine	17	t	0	f	3
12	Sick leave	\N	\N	\N	17	t	0	f	2
13	Other tasks	\N	\N	02otherCase	17	t	0	f	1
14	mm	\N	Millimeter	\N	1	t	0	f	12
15	cm	\N	Centimeter	\N	1	t	0	f	1
16	dm	\N	Decimeter	\N	1	t	0	f	4
17	m	\N	Meter	\N	1	t	0	f	9
18	cm2	\N	Cubic centimeter	\N	1	t	0	f	2
19	m2	\N	Square meter	\N	1	t	0	f	10
20	dam	\N	Cubic decimeter	\N	1	t	0	f	3
21	m3	\N	Cubic meter	\N	1	t	0	f	11
22	g	\N	Gram	\N	1	t	0	f	5
23	kg	\N	Kilogram	\N	1	t	0	f	7
24	l	\N	Liter	\N	1	t	0	f	8
25	hl	\N	Hectoliter	\N	1	t	0	f	6
26	pc	\N	Piece	\N	1	t	0	f	14
27	pair	\N	Pair	\N	1	t	0	f	13
28	set	\N	Set	\N	1	t	0	f	15
29	Employee absence	\N	\N	\N	7	t	0	f	2
30	Delays in materials delivery	\N	\N	\N	7	t	0	f	1
31	Faulty materials	\N	\N	\N	7	t	0	f	3
32	Production resources overload	\N	\N	\N	7	t	0	f	6
33	Machine malfunction	\N	\N	\N	7	t	0	f	4
34	Other	\N	\N	\N	7	t	0	f	5
35	universal printer	\N	\N	01universalPrinter	\N	t	0	f	5
36	printer for everything	\N	\N	02allPrinter	\N	t	0	f	3
37	carton label printer	\N	\N	03cartonLabelsPrinter	\N	t	0	f	1
38	pallet label printer	\N	\N	04palletLabelsPrinter	\N	t	0	f	2
39	sticker printer	\N	\N	05stickerPrinter	\N	t	0	f	4
40	new	\N	\N	01new	15	t	0	f	1
41	ordered	\N	\N	02ordered	15	t	0	f	2
2	CHEP EUR	\N	\N	02chepEur	5	t	0	f	1
\.


--
-- Data for Name: qcadoomodel_globalunitconversionsaggregate; Type: TABLE DATA; Schema: public; Owner: -
--

COPY public.qcadoomodel_globalunitconversionsaggregate (id, entityversion) FROM stdin;
1	0
\.


--
-- Data for Name: qcadoomodel_unitconversionitem; Type: TABLE DATA; Schema: public; Owner: -
--

COPY public.qcadoomodel_unitconversionitem (id, quantityfrom, quantityto, unitfrom, unitto, globalunitconversionsaggregate_id, product_id, entityversion) FROM stdin;
1	1.00000	100.00000	m	cm	1	\N	0
2	1.00000	10.00000	dm	cm	1	\N	0
3	1.00000	10.00000	cm	mm	1	\N	0
4	1.00000	10000.00000	m2	cm2	1	\N	0
5	1.00000	1000.00000	m3	dam	1	\N	0
6	1.00000	1000.00000	kg	g	1	\N	0
7	1.00000	1.00000	l	dam	1	\N	0
8	1.00000	100.00000	hl	l	1	\N	0
9	1.00000	2.00000	pair	pc	1	\N	0
\.


--
-- Data for Name: qcadooplugin_plugin; Type: TABLE DATA; Schema: public; Owner: -
--

COPY public.qcadooplugin_plugin (id, identifier, version, state, issystem, entityversion, groupname, license) FROM stdin;
2	ercWarehouse	1.5.0	DISABLED	f	0	supplies	Commercial
3	urcMasterOrders	1.5.0	DISABLED	f	0	\N	Commercial
8	urcDeliveriesToWarehouse	1.5.0	DISABLED	f	0	supplies	Commercial
12	srcWarehouse	1.5.0	DISABLED	f	0	supplies	Commercial
14	integration	1.5.0	DISABLED	f	0	other	Commercial
20	urcTechnologies	1.5.0	DISABLED	f	0	technologies	Commercial
78	nutritionFacts	1.5.0	DISABLED	f	0	framework	Commercial
22	qcadooModel	1.5.0	ENABLED	t	0	framework	AGPL
23	qcadooSecurity	1.5.0	ENABLED	t	0	framework	AGPL
24	qcadooView	1.5.0	ENABLED	t	0	framework	AGPL
25	qcadooReport	1.5.0	ENABLED	t	0	framework	AGPL
26	columnExtension	1.5.0	ENABLED	f	0	supplies	AGPL
27	qcadooCustomTranslation	1.5.0	ENABLED	f	0	framework	AGPL
28	qcadooPlugins	1.5.0	ENABLED	f	0	framework	AGPL
29	qcadooMenu	1.5.0	ENABLED	f	0	framework	AGPL
30	qcadooUsers	1.5.0	ENABLED	f	0	framework	AGPL
31	qcadooExport	1.5.0	ENABLED	f	0	framework	AGPL
32	qcadooUnitConversions	1.5.0	ENABLED	f	0	framework	AGPL
33	basic	1.5.0	ENABLED	f	0	basic	AGPL
34	states	1.5.0	ENABLED	f	0	other	AGPL
36	productionLines	1.5.0	ENABLED	f	0	basic	AGPL
40	costNormsForOperation	1.5.0	ENABLED	f	0	technologies	AGPL
42	orders	1.5.0	ENABLED	f	0	planning	AGPL
45	costNormsForOperationInOrder	1.5.0	ENABLED	f	0	planning	AGPL
47	deliveries	1.5.0	ENABLED	f	0	supplies	AGPL
48	stoppage	1.5.0	ENABLED	f	0	other	AGPL
50	materialFlowResources	1.5.0	ENABLED	f	0	flow	AGPL
51	masterOrders	1.5.0	ENABLED	f	0	planning	AGPL
52	basicProductionCounting	1.5.0	ENABLED	f	0	tracking	AGPL
54	cmmsMachineParts	1.5.0	ENABLED	f	0	other	AGPL
60	assignmentToShift	1.5.0	ENABLED	f	0	planning	AGPL
61	productionCounting	1.5.0	ENABLED	f	0	tracking	AGPL
65	productionPerShift	1.5.0	ENABLED	f	0	planning	AGPL
83	urcCostNormsForProduct	1.5.0	DISABLED	f	0	basic	Commercial
86	urcAdvGenealogyForOrders	1.5.0	DISABLED	f	0	genealogy	Commercial
88	urcCostNormsForMaterials	1.5.0	DISABLED	f	0	planning	Commercial
94	urcMaterialFlowResources	1.5.0	DISABLED	f	0	supplies	Commercial
97	cfcSimple	1.5.0	DISABLED	f	0	other	Commercial
98	urcMaterialAvailability	1.5.0	DISABLED	f	0	planning	Commercial
100	srcAdvGenealogyForOrders	1.5.0	DISABLED	f	0	genealogy	Commercial
103	ziepiwowarski	1.5.0	DISABLED	f	0	other	Commercial
104	cdnrcAneks	1.5.0	DISABLED	f	0	other	Commercial
105	qcadooPlugin	1.5.0	ENABLED	t	0	framework	AGPL
21	qcadooLocalization	1.5.0	ENABLED	t	0	framework	AGPL
107	qcadooCustomTranslations	1.5.0	ENABLED	f	0	framework	AGPL
108	qcadooDictionaries	1.5.0	ENABLED	f	0	framework	AGPL
109	costNormsForProduct	1.5.0	ENABLED	f	0	basic	AGPL
111	wageGroups	1.5.0	ENABLED	f	0	basic	AGPL
112	technologies	1.5.0	ENABLED	f	0	technologies	AGPL
113	timeNormsForOperations	1.5.0	ENABLED	f	0	technologies	AGPL
114	materialFlow	1.5.0	ENABLED	f	0	flow	AGPL
118	operationTimeCalculations	1.5.0	ENABLED	f	0	calculations	AGPL
44	lineChangeoverNorms	1.5.0	ENABLED	f	0	technologies	AGPL
120	operationCostCalculations	1.5.0	ENABLED	f	0	calculations	AGPL
122	costNormsForMaterials	1.5.0	ENABLED	f	0	basic	AGPL
125	costCalculation	1.5.0	ENABLED	f	0	calculations	AGPL
126	lineChangeoverNormsForOrders	1.5.0	ENABLED	f	0	planning	AGPL
127	productionScheduling	1.5.0	ENABLED	f	0	planning	AGPL
69	urcBasicProductionCounting	1.5.0	DISABLED	f	0	tracking	Commercial
135	urcMaterialRequirements	1.5.0	DISABLED	f	0	planning	Commercial
55	urcOrders	1.5.0	DISABLED	f	0	planning	Commercial
37	urcBasic	1.5.0	DISABLED	f	0	basic	Commercial
106	urcCore	1.5.0	DISABLED	f	0	other	Commercial
35	ganttForShifts	1.5.0	DISABLED	f	0	basic	AGPL
146	ordersGroups	1.5.0	DISABLED	f	0	other	Commercial
130	catNumbersInDeliveries	1.5.0	DISABLED	f	0	supplies	AGPL
39	productCatalogNumbers	1.5.0	DISABLED	f	0	basic	AGPL
73	subcontractorPortal	1.5.0	DISABLED	f	0	other	Commercial
132	techSubcontrForOperTasks	1.5.0	DISABLED	f	0	planning	AGPL
57	techSubcontracting	1.5.0	DISABLED	f	0	technologies	AGPL
58	deliveriesToMaterialFlow	1.5.0	DISABLED	f	0	supplies	AGPL
62	workPlans	1.5.0	DISABLED	f	0	planning	AGPL
63	avgLaborCostCalcForOrder	1.5.0	DISABLED	f	0	planning	AGPL
116	materialRequirements	1.5.0	DISABLED	f	0	calculations	AGPL
133	ganttForOperations	1.5.0	DISABLED	f	0	planning	AGPL
136	techSubcontrForProductionCounting	1.5.0	DISABLED	f	0	tracking	AGPL
138	cmmsScheduler	1.5.0	DISABLED	f	0	other	Commercial
139	deviationCausesReporting	1.5.0	DISABLED	f	0	planning	AGPL
143	repairs	1.5.0	DISABLED	f	0	other	Commercial
145	ordersGantt	1.5.0	ENABLED	f	0	other	Commercial
49	supplyNegotiations	1.5.0	ENABLED	f	0	supplies	AGPL
121	advancedGenealogy	1.5.0	ENABLED	f	0	genealogy	AGPL
149	integrationBaseLinker	1.5.0	DISABLED	f	0	other	Commercial
152	integrationPipedrive	1.5.0	DISABLED	f	0	\N	\N
153	arch	1.5.0	DISABLED	f	0	\N	Commercial
53	warehouseMinimalState	1.5.0	ENABLED	f	0	other	AGPL
150	integrationAsana	1.5.0	DISABLED	f	0	\N	Commercial
157	luxon	1.5.0	DISABLED	f	0	\N	\N
154	scheduleGantt	1.5.0	ENABLED	f	0	\N	Commercial
159	mobileWMS	1.5.0	DISABLED	f	0	\N	\N
161	optimizeCutting	1.5.0	DISABLED	f	0	\N	\N
162	moldrew	1.5.0	DISABLED	f	0	\N	\N
76	urcProductionCounting	1.5.0	DISABLED	f	0	tracking	Commercial
131	deliveriesMinState	1.5.0	DISABLED	f	0	deliveries	AGPL
38	emailNotifications	1.5.0	DISABLED	f	0	basic	AGPL
71	techSubcontrForOrderSupplies	1.5.0	DISABLED	f	0	supplies	AGPL
72	ordersForSubproductsGeneration	1.5.0	DISABLED	f	0	other	AGPL
142	materialRequirementCoverageForOrder	1.5.0	DISABLED	f	0	other	AGPL
66	orderSupplies	1.5.0	DISABLED	f	0	supplies	AGPL
67	catNumbersInNegot	1.5.0	DISABLED	f	0	supplies	AGPL
41	technologiesGenerator	1.5.0	DISABLED	f	0	other	AGPL
56	timeGapsPreview	1.5.0	DISABLED	f	0	other	AGPL
134	techSubcontrForNegot	1.5.0	DISABLED	f	0	supplies	AGPL
59	techSubcontrForDeliveries	1.5.0	DISABLED	f	0	supplies	AGPL
68	advancedGenealogyForOrders	1.5.0	DISABLED	f	0	genealogy	Commercial
158	configurator	1.5.0	DISABLED	f	0	other	Commercial
141	productFlowThruDivision	1.5.0	DISABLED	f	0	other	AGPL
155	qualityControl	1.5.0	DISABLED	f	0	other	Commercial
156	oee	1.5.0	DISABLED	f	0	other	Commercial
163	productionPlans	1.5.0	ENABLED	f	0	other	Commercial
\.


--
-- Data for Name: qcadoosecurity_group; Type: TABLE DATA; Schema: public; Owner: -
--

COPY public.qcadoosecurity_group (id, name, description, identifier, entityversion, permissiontype) FROM stdin;
3	User	\N	USER	0	02officeLicense
4	Admin	\N	ADMIN	0	02officeLicense
1	API	\N	API	0	01superAdmin
2	Super admin	\N	SUPER_ADMIN	0	01superAdmin
32	DUR admin	\N	DUR_ADMIN	0	02officeLicense
29	Obsługa magazynu (produkty, firmy, magazyn, zaopatrzenie)	\N	WAREHOUSE	0	02officeLicense
30	Obsługa magazynu (produkty, firmy, magazyn, zaopatrzenie) + dźwięki	\N	WAREHOUSE_NOTIFICATION	0	02officeLicense
31	Kontrola jakości	\N	QUALITY_CONTROL	0	02officeLicense
33	DUR admin + dźwięki	\N	DUR_ADMIN_NOTIFICATION	0	02officeLicense
34	DUR planista	\N	DUR_PLANNER	0	02officeLicense
35	DUR planista + dźwięki	\N	DUR_PLANNER_NOTIFICATION	0	02officeLicense
36	DUR pracownik	\N	DUR_WORKER	0	02officeLicense
37	DUR pracownik + dźwięki	\N	DUR_WORKER_NOTIFICATION	0	02officeLicense
38	Sprzedaż	\N	SALES	0	02officeLicense
39	Technolog	\N	TECHNOLOGIST	0	02officeLicense
40	Księgowa	\N	ACCOUNTANT	0	02officeLicense
41	Analizy (zarząd)	\N	ANALYSIS	0	02officeLicense
42	Zakup	\N	PURCHASE	0	02officeLicense
5	Podwykonawca	\N	SUBCONTRACTOR	0	02officeLicense
7	Terminal rejestracji produkcji	\N	PRODUCTION_TERMINAL	0	02officeLicense
8	Terminal rejestracji produkcji + awarie	\N	PRODUCTION_TERMINAL_EVENTS	0	02officeLicense
9	Terminal potwierdzania procesów	\N	PROCESS_TERMINAL	0	02officeLicense
10	Terminal potwierdzania procesów + awarie	\N	PROCESS_TERMINAL_EVENTS	0	02officeLicense
11	Terminale	\N	TERMINALS	0	02officeLicense
12	Terminale + awarie	\N	TERMINALS_EVENTS	0	02officeLicense
14	Podgląd Gantt zleceń + terminal rejestracji produkcji	\N	ORDERS_GANTT_PRODUCTION_TERMINAL	0	02officeLicense
15	Podgląd Gantt zleceń + terminal rejestracji produkcji + awarie	\N	ORDERS_GANTT_PRODUCTION_TERMINAL_EVENTS	0	02officeLicense
18	Podgląd Gantt zleceń + terminal rejestracji produkcji + Dashboard	\N	ORDERS_GANTT_PRODUCTION_TERMINAL_DASHBOARD	0	02officeLicense
19	Podgląd Gantt zleceń + terminal rejestracji produkcji + Dashboard + awarie	\N	ORDERS_GANTT_PRODUCTION_TERMINAL_DASHBOARD_EVENTS	0	02officeLicense
13	Podgląd Gantt zleceń + terminale	\N	ORDERS_GANTT_TERMINALS	0	02officeLicense
16	Podgląd Gantt zleceń + terminale + awarie	\N	ORDERS_GANTT_TERMINALS_EVENTS	0	02officeLicense
17	Podgląd Gantt zleceń + terminale + Dashboard	\N	ORDERS_GANTT_TERMINALS_DASHBOARD	0	02officeLicense
20	Podgląd Gantt zleceń + terminale + Dashboard + awarie	\N	ORDERS_GANTT_TERMINALS_DASHBOARD_EVENTS	0	02officeLicense
22	Podgląd Gantt zadań + terminal rejestracji produkcji	\N	TASKS_GANTT_PRODUCTION_TERMINAL	0	02officeLicense
23	Podgląd Gantt zadań + terminal rejestracji produkcji + awarie	\N	TASKS_GANTT_PRODUCTION_TERMINAL_EVENTS	0	02officeLicense
26	Podgląd Gantt zadań + terminal rejestracji produkcji + Dashboard	\N	TASKS_GANTT_PRODUCTION_TERMINAL_DASHBOARD	0	02officeLicense
27	Podgląd Gantt zadań + terminal rejestracji produkcji + Dashboard + awarie	\N	TASKS_GANTT_PRODUCTION_TERMINAL_DASHBOARD_EVENTS	0	02officeLicense
21	Podgląd Gantt zadań + terminale	\N	TASKS_GANTT_TERMINALS	0	02officeLicense
24	Podgląd Gantt zadań + terminale + awarie	\N	TASKS_GANTT_TERMINALS_EVENTS	0	02officeLicense
25	Podgląd Gantt zadań + terminale + Dashboard	\N	TASKS_GANTT_TERMINALS_DASHBOARD	0	02officeLicense
28	Podgląd Gantt zadań + terminale + Dashboard + awarie	\N	TASKS_GANTT_TERMINALS_DASHBOARD_EVENTS	0	02officeLicense
6	Brak dostępu	\N	DELETED	0	06lackOfAccess
\.


--
-- Data for Name: qcadoosecurity_passwordresettoken; Type: TABLE DATA; Schema: public; Owner: -
--

COPY public.qcadoosecurity_passwordresettoken (id, user_id, token, active, expirationtime) FROM stdin;
\.


--
-- Data for Name: qcadoosecurity_persistenttoken; Type: TABLE DATA; Schema: public; Owner: -
--

COPY public.qcadoosecurity_persistenttoken (id, username, series, token, lastused, entityversion) FROM stdin;
\.


--
-- Data for Name: qcadoosecurity_role; Type: TABLE DATA; Schema: public; Owner: -
--

COPY public.qcadoosecurity_role (id, identifier, description, entityversion) FROM stdin;
2	ROLE_API	\N	0
3	ROLE_SUPERADMIN	\N	0
4	ROLE_ADMIN	\N	0
5	ROLE_USER	\N	0
6	ROLE_DICTIONARY_VIEW	\N	0
7	ROLE_UNIT_CONVERSIONS	\N	0
8	ROLE_LOGS	\N	0
9	ROLE_SUBCONTRACTOR	\N	0
10	ROLE_TERMINAL_CONFECTION_PRINT_MULTIPLE	\N	0
11	ROLE_TERMINAL_PALLET_PRINT_MULTIPLE	\N	0
12	ROLE_PALLET_LIST	\N	0
13	ROLE_TERMINAL_PALLET_USER	\N	0
14	ROLE_TERMINAL_EXTRUSION_USER	\N	0
15	ROLE_TERMINAL_CONFECTION_USER	\N	0
16	ROLE_TERMINAL_USER	\N	0
17	ROLE_DOCUMENTS_CORRECTIONS_MIN_STATES	\N	0
18	ROLE_REPAIR_ORDERS	\N	0
19	ROLE_PRODUCTION_REGISTRATION_TERMINAL	\N	0
20	ROLE_ACTIONS	\N	0
21	ROLE_PRODUCTION_PER_SHIFT	\N	0
22	ROLE_LINE_CHANGEOVER_NORMS_IN_ORDERS	\N	0
23	ROLE_TIME_GAPS	\N	0
24	ROLE_DELIVERIES_STATES_OTHER	\N	0
25	ROLE_DELIVERIES_STATES_DECLINE	\N	0
26	ROLE_DELIVERIES_EDIT	\N	0
27	ROLE_CALCULATIONS	\N	0
28	ROLE_RECURRING_EVENTS	\N	0
29	ROLE_CMMS_SCHEDULER_FULL_EDIT	\N	0
30	ROLE_CMMS_SCHEDULER_PART_EDIT	\N	0
31	ROLE_CMMS_SCHEDULER_PREVIEW	\N	0
32	ROLE_SOURCE_COST	\N	0
33	ROLE_ASSIGNMENT_TO_SHIFT	\N	0
34	ROLE_WAREHOUSE_STATES	\N	0
35	ROLE_DOCUMENT_POSITIONS	\N	0
36	ROLE_FAULT_TYPES	\N	0
37	ROLE_CREW	\N	0
38	ROLE_SHIFTS	\N	0
39	ROLE_PLANNED_EVENTS_ATTACHMENTS_REMOVE	\N	0
40	ROLE_PLANNED_EVENTS_EDIT_RELATED	\N	0
41	ROLE_PLANNED_EVENTS_ATTACHMENTS	\N	0
42	ROLE_PLANNED_EVENTS_STATES_START_STOP	\N	0
43	ROLE_PLANNED_EVENTS_STATES_ACCEPT	\N	0
44	ROLE_PLANNED_EVENTS_STATES_OTHER	\N	0
45	ROLE_PLANNED_EVENTS_HISTORY	\N	0
46	ROLE_PLANNED_EVENTS_DOCUMENTS	\N	0
47	ROLE_PLANNED_EVENTS_DATES_EDIT	\N	0
48	ROLE_PLANNED_EVENTS_ADVANCED_EDIT	\N	0
49	ROLE_PLANNED_EVENTS_BASIC_EDIT	\N	0
50	ROLE_PLANNED_EVENTS_ACTIONS_VIEW	\N	0
51	ROLE_PLANNED_EVENTS_ACTIONS_EDIT	\N	0
52	ROLE_PLANNED_EVENTS_ACTIONS_REMOVE	\N	0
53	ROLE_PLANNED_EVENTS_ACTIONS_ADD	\N	0
54	ROLE_EVENTS_NOTIFICATION	\N	0
55	ROLE_EVENTS_LIST_EXPORT	\N	0
56	ROLE_EVENTS_VIEW_PARTS_TIME_DESCRIPTION	\N	0
57	ROLE_EVENTS_EDIT_AFTER_SAVE	\N	0
58	ROLE_EVENTS_DELETE_ATTACHMENT	\N	0
59	ROLE_EVENTS_SOURCE_COST_CHANGE	\N	0
60	ROLE_EVENTS_TAB_ATTACHMENTS	\N	0
61	ROLE_EVENTS_TAB_HISTORY	\N	0
62	ROLE_EVENTS_TAB_DOCUMENTS	\N	0
63	ROLE_EVENTS_ADD_PROPOSAL	\N	0
64	ROLE_EVENTS_ADD_ISSUE	\N	0
65	ROLE_EVENTS_ADD_FAILURE	\N	0
66	ROLE_EVENTS_ACCEPT	\N	0
67	ROLE_EVENTS_PLAN	\N	0
68	ROLE_EVENTS_CLOSE	\N	0
69	ROLE_EVENTS_REVOKE	\N	0
70	ROLE_EVENTS_STOP	\N	0
71	ROLE_EVENTS_START	\N	0
72	ROLE_EVENTS_DELETE	\N	0
73	ROLE_EVENTS	\N	0
74	ROLE_PALLET_NUMBERS	\N	0
75	ROLE_BATCHES	\N	0
76	ROLE_ADVANCED_GENEALOGY	\N	0
77	ROLE_GENEALOGY	\N	0
78	ROLE_ORDERS_TRACKING	\N	0
79	ROLE_PRODUCTION_TRACKING	\N	0
80	ROLE_PRODUCTION_COUNTING	\N	0
81	ROLE_PLANNING_ON_LINE_ACTIONS	\N	0
82	ROLE_PLANNING_ON_LINE_VIEW	\N	0
83	ROLE_PLANNING	\N	0
84	ROLE_TECHNOLOGIES_ADVANCED	\N	0
85	ROLE_TECHNOLOGIES	\N	0
87	ROLE_PARAMETERS	\N	0
88	ROLE_COUNTRIES	\N	0
89	ROLE_MACHINE_PARTS	\N	0
90	ROLE_MAINTENANCE_MENU	\N	0
91	ROLE_MAINTENANCE	\N	0
92	ROLE_STAFF_WAGES	\N	0
93	ROLE_REQUIREMENTS	\N	0
94	ROLE_BASE_FUNCTIONALITY	\N	0
95	ROLE_COMPANY_STRUCTURE_EDIT	\N	0
96	ROLE_COMPANY_STRUCTURE	\N	0
97	ROLE_COMPANY	\N	0
98	ROLE_PRODUCT_FAMILIES	\N	0
99	ROLE_PRODUCTS	\N	0
100	ROLE_RESOURCE_PRICE	\N	0
101	ROLE_MATERIAL_FLOW	\N	0
102	ROLE_PLANNING_ORDERS	\N	0
103	ROLE_PLANNING_MASTER_ORDERS	\N	0
104	ROLE_TERMINAL_CARTON_LABELS	\N	0
105	ROLE_ANALYSIS_VIEWER	\N	0
107	ROLE_PRODUCTION_COUNTING_FROM_PRODUCTION_TRACKING	\N	0
108	ROLE_DOCUMENTS_NOTIFICATION	\N	0
109	ROLE_PALLET_LIST_EDIT	\N	0
110	ROLE_EXTRUSION_PROTOCOLS_LIST	\N	0
111	ROLE_PALLET_DETAILS_FIX_STATE	\N	0
112	ROLE_TERMINAL_EXTRUSION_PRINT	\N	0
113	ROLE_PRINTED_LABEL_DETAILS_REPRINT	\N	0
114	ROLE_PRINTERS	\N	0
115	ROLE_SKILLS	\N	0
116	ROLE_PRODUCTION_TRACKING_REGISTRATION	\N	0
117	ROLE_ORDER_MATERIAL_AVAILABILITY	\N	0
118	ROLE_NUMBER_PATTERN	\N	0
119	ROLE_QUALITY_CONTROL	\N	0
120	ROLE_OEE	\N	0
121	ROLE_STOPPAGES	\N	0
122	ROLE_STOPPAGE_REASONS	\N	0
123	ROLE_WMS	\N	0
1	ROLE_HOME_PROFILE	\N	0
124	ROLE_TECHNOLOGICAL_PROCESSES	\N	0
125	ROLE_CLEAN_EXTERNAL_NUMBER	\N	0
126	ROLE_DASHBOARD_KANBAN	\N	0
127	ROLE_PROCESS_CONFIRMATION_TERMINAL	\N	0
128	ROLE_PRINTED_PALLET_LABELS	\N	0
129	ROLE_PLANNING_MENU	\N	0
130	ROLE_DASHBOARD_KANBAN_CREATE_ORDERS	\N	0
131	ROLE_DASHBOARD_KANBAN_GOTO_ORDER_EDIT	\N	0
132	ROLE_GROUPS_VIEW	\N	0
133	ROLE_GROUPS_EDIT	\N	0
134	ROLE_DASHBOARD_KANBAN_PRINT_LABEL	\N	0
135	ROLE_ORDER_MATERIAL_AVAILABILITY_SHOW_RESOURCES	\N	0
136	ROLE_MASTER_ORDER_WITH_EXTERNAL_NUMBER_DELETE	\N	0
137	ROLE_RESOURCES	\N	0
138	ROLE_PRODUCTS_ADDITIONAL	\N	0
139	ROLE_ATTACHMENTS	\N	0
140	ROLE_FORMS	\N	0
142	ROLE_OPERATIONAL_TASKS_GANTT_VIEW	\N	0
143	ROLE_OPERATIONAL_TASKS_GANTT_EDIT	\N	0
144	ROLE_DELIVERIES	\N	0
145	ROLE_ATTRIBUTES	\N	0
146	ROLE_ORDERS_VIEW	\N	0
147	ROLE_PRODUCTION_LINE_SCHEDULES	\N	0
148	ROLE_USERS_EDIT	\N	0
149	ROLE_ANOMALIES	\N	0
150	ROLE_ORDERS_GANTT_VIEW	\N	0
151	ROLE_ORDERS_GANTT_EDIT	\N	0
152	ROLE_TOOLS	\N	0
153	ROLE_DELIVERIES_PRICE	\N	0
154	ROLE_ARCHIVING	\N	0
155	ROLE_ORDER_TECHNOLOGICAL_PROCESSES	\N	0
156	ROLE_REQUEST_FOR_QUOTATIONS	\N	0
157	ROLE_OFFERS	\N	0
158	ROLE_NEGOTIATIONS	\N	0
159	ROLE_PRODUCT_COSTS	\N	0
160	ROLE_OPTIMIZE_CUTTING	\N	0
161	ROLE_MENU_VIEW	\N	0
162	ROLE_SALE	\N	0
163	ROLE_PARAMETERS_MENU	\N	0
164	ROLE_PLANNING_PARAMETERS	\N	0
165	ROLE_PLANNER_PARAMETERS	\N	0
166	ROLE_SCHEDULES	\N	0
167	ROLE_ORDER_DETAILS_VIEW	\N	0
168	ROLE_WORKSTATION_CHANGEOVERS	\N	0
169	ROLE_OPERATIONAL_TASKS	\N	0
170	ROLE_DASHBOARD_PARAMETERS	\N	0
171	ROLE_PRODUCTION_COUNTING_QUANTITY	\N	0
\.


--
-- Data for Name: qcadoosecurity_user; Type: TABLE DATA; Schema: public; Owner: -
--

COPY public.qcadoosecurity_user (id, username, email, firstname, lastname, enabled, description, password, lastactivity, staff_id, group_id, entityversion, factory_id, ipaddress, showonlymyregistrationrecords, productionline_id, groupchangedate, pswdlastchanged, afterfirstpswdchange, isblocked, showonlymyoperationaltasksandorders) FROM stdin;
3	qcadoo_bot	\N	qcadoo_bot	qcadoo_bot	t	\N	\N	\N	\N	1	0	\N	\N	f	\N	2022-05-26 00:00:00	\N	f	f	f
2	admin	admin@qcadoo.com	generated admin	generated admin	t	\N	$2a$11$fK09LNi7Y4ZHKWAg0PCLxeOP/oTENa6AKO4CcuxYRbtrOeStRZYVm	\N	\N	4	0	\N	\N	f	\N	2022-05-26 00:00:00	\N	t	f	f
1	superadmin	superadmin@qcadoo.com	generated superadmin	generated superadmin	t	\N	$2a$11$tzoAWwNksWYQPgkvvczy6eQaJHMAFBlUlq5OzAz.GeNNMqTEt1FE2	\N	\N	2	0	\N	\N	f	\N	2022-05-26 00:00:00	\N	t	f	f
\.


--
-- Data for Name: qcadooview_alert; Type: TABLE DATA; Schema: public; Owner: -
--

COPY public.qcadooview_alert (id, message, type, expirationdate, sound) FROM stdin;
\.


--
-- Data for Name: qcadooview_category; Type: TABLE DATA; Schema: public; Owner: -
--

COPY public.qcadooview_category (id, pluginidentifier, name, succession, authrole, entityversion) FROM stdin;
2	qcadooView	home	2	\N	0
3	basic	companyStructure	3	ROLE_COMPANY_STRUCTURE	0
1	qcadooView	administration	1	ROLE_HOME_PROFILE	0
17	basic	calendars	4	ROLE_SHIFTS	0
18	basic	staff	5	\N	0
4	basic	basic	6	\N	0
19	basic	products	7	\N	0
5	technologies	technology	8	ROLE_TECHNOLOGIES	0
6	materialFlow	materialFlow	9	\N	0
9	materialRequirements	requirements	10	\N	0
7	orders	orders	11	ROLE_PLANNING_MENU	0
8	orders	ordersTracking	12	ROLE_ORDERS_TRACKING	0
10	lineChangeoverNorms	calculations	13	\N	0
11	advancedGenealogy	advancedGenealogy	14	ROLE_GENEALOGY	0
23	masterOrders	sales	11	ROLE_SALE	0
13	cmmsMachineParts	maintenance	15	\N	0
15	productionCounting	analysis	16	ROLE_ANALYSIS_VIEWER	0
16	arch	archives	17	\N	0
21	basic	parameters	18	ROLE_PARAMETERS_MENU	0
\.


--
-- Data for Name: qcadooview_item; Type: TABLE DATA; Schema: public; Owner: -
--

COPY public.qcadooview_item (id, pluginidentifier, name, active, category_id, view_id, succession, authrole, entityversion) FROM stdin;
1	qcadooView	systemInfo	t	1	1	1	\N	0
2	qcadooPlugins	plugins	t	1	2	2	ROLE_SUPERADMIN	0
4	qcadooCustomTranslations	customTranslations	t	1	4	4	\N	0
5	qcadooUsers	groups	t	1	5	5	\N	0
6	qcadooUsers	roles	t	1	6	6	\N	0
7	qcadooUsers	users	t	1	7	7	\N	0
9	qcadooDictionaries	dictionaries	t	1	9	9	\N	0
10	qcadooUnitConversions	unitConversions	t	1	10	10	ROLE_UNIT_CONVERSIONS	0
11	basic	logsList	t	1	11	11	ROLE_LOGS	0
215	orders	workstationChangeoverForOperationalTasksList	t	7	214	18	ROLE_WORKSTATION_CHANGEOVERS	0
26	basic	countries	t	1	26	12	ROLE_COUNTRIES	0
27	basic	companies	t	4	27	10	ROLE_COMPANY	0
28	basic	conversion	t	4	28	11	ROLE_BASE_FUNCTIONALITY	0
30	basic	dictionariesInBasic	t	4	30	12	ROLE_DICTIONARY_VIEW	0
31	basic	home	t	2	31	1	\N	0
92	productionCounting	productionTrackingForProductGrouped	t	8	92	6	ROLE_PRODUCTION_TRACKING	0
38	technologies	operations	t	5	38	3	ROLE_TECHNOLOGIES	0
39	technologies	technologies	t	5	39	4	ROLE_TECHNOLOGIES	0
93	productionCounting	productionTrackingForProduct	t	8	93	5	ROLE_PRODUCTION_TRACKING	0
13	basic	divisions	t	3	13	2	ROLE_COMPANY_STRUCTURE	0
32	productionLines	productionLines	t	3	32	3	ROLE_COMPANY_STRUCTURE	0
15	basic	workstationTypes	t	3	15	4	ROLE_COMPANY_STRUCTURE	0
14	basic	workstations	t	3	14	5	ROLE_COMPANY_STRUCTURE	0
139	productionCounting	productionTrackingsDraftList	f	8	138	9	ROLE_PRODUCTION_TRACKING	0
147	integrationBarTender	printedCartonLabelsList	f	8	146	12	ROLE_TERMINAL_CARTON_LABELS	0
79	productionScheduling	orderTimePrediction	t	10	79	2	ROLE_CALCULATIONS	0
117	integrationBartender	cartonLabels	t	\N	116	\N	ROLE_TERMINAL_CARTON_LABELS	0
123	deliveries	deliveryByPalletTypeReport	t	\N	122	1	ROLE_REQUIREMENTS	0
135	goodFood	extrusionMixesList	t	\N	134	1	ROLE_TERMINAL_EXTRUSION_USER	0
138	arch	archOrdersGroups	t	16	137	3	ROLE_PLANNING	0
140	arch	archMasterOrderPositionsList	t	16	139	2	ROLE_PLANNING	0
141	arch	archMasterOrdersList	t	16	140	1	ROLE_PLANNING	0
143	arch	archProductionTrackingsList	t	16	142	5	ROLE_PRODUCTION_TRACKING	0
144	arch	archDocumentPositionsList	t	16	143	7	ROLE_DOCUMENTS_CORRECTIONS_MIN_STATES	0
145	arch	archDocumentsList	t	16	144	6	ROLE_DOCUMENTS_CORRECTIONS_MIN_STATES	0
146	integrationBarTender	printersList	t	1	145	15	ROLE_PRINTERS	0
156	basic	numberPatternsList	t	1	155	16	ROLE_NUMBER_PATTERN	0
23	basic	shifts	t	17	23	7	ROLE_SHIFTS	0
132	basic	exceptionsForLineList	t	17	131	20	ROLE_SHIFTS	0
22	basic	products	t	19	22	3	ROLE_PRODUCTS	0
151	basic	productsAttributes	t	19	150	4	ROLE_PRODUCTS	0
21	basic	productsFamilies	t	19	21	5	ROLE_PRODUCT_FAMILIES	0
186	technologies	technologyInputProductTypesList	t	5	185	9	ROLE_TECHNOLOGIES	0
96	productionCounting	productionTracking	t	8	96	1	ROLE_PRODUCTION_TRACKING_REGISTRATION	0
25	basic	staff	t	18	25	9	ROLE_STAFF_WAGES	0
8	qcadooUsers	profile	t	1	8	8	ROLE_HOME_PROFILE	0
165	basic	generalParameters	t	21	164	1	ROLE_PARAMETERS	0
167	technologies	technologiesParameters	t	21	166	3	ROLE_PARAMETERS	0
170	productionCounting	productionCountingParameters	t	21	169	6	ROLE_PARAMETERS	0
173	productionCounting	productionAnalysisParameters	t	21	172	7	ROLE_PARAMETERS	0
12	basic	factories	t	3	12	1	ROLE_COMPANY_STRUCTURE	0
154	scheduleGantt	operationalTasksGantt	t	7	153	8	ROLE_OPERATIONAL_TASKS_GANTT_VIEW	0
95	productionCounting	productionBalance	t	15	95	1	ROLE_PRODUCTION_COUNTING	0
176	basic	sizesList	t	19	175	6	ROLE_PRODUCTS_ADDITIONAL	0
177	basic	sizeGroupsList	t	19	176	7	ROLE_PRODUCTS_ADDITIONAL	0
207	technologies	technologyConfigurator	t	5	206	11	ROLE_TECHNOLOGIES	0
20	basic	assortments	t	19	20	1	ROLE_PRODUCTS_ADDITIONAL	0
213	technologies	workstationChangeoverNormsList	t	5	212	12	ROLE_TECHNOLOGIES	0
180	basic	modelsList	t	19	179	2	ROLE_PRODUCTS_ADDITIONAL	0
134	basic	attachmentsList	t	4	133	21	ROLE_ATTACHMENTS	0
201	basic	licenses	t	1	200	17	ROLE_ADMIN	0
150	basic	attributesList	t	4	149	24	ROLE_ATTRIBUTES	0
142	arch	archOrdersList	t	16	141	4	ROLE_ORDERS_VIEW	0
48	orders	productionOrders	t	7	48	5	ROLE_ORDERS_VIEW	0
47	orders	productionOrdersPlanning	t	7	47	4	ROLE_ORDERS_VIEW	0
204	arch	archivingList	t	16	203	8	ROLE_ARCHIVING	0
3	qcadooMenu	menu	t	1	3	3	ROLE_MENU_VIEW	0
161	basic	formsList	f	4	160	27	ROLE_FORMS	0
222	masterOrders	pricesListsList	f	23	221	4	ROLE_SALE	0
46	orders	operationalTasks	t	7	46	6	ROLE_OPERATIONAL_TASKS	0
52	advancedGenealogy	tree	f	11	52	2	ROLE_ADVANCED_GENEALOGY	0
166	orders	planningParameters	t	21	165	2	ROLE_PLANNING_PARAMETERS	0
17	basic	faultTypes	f	4	17	1	ROLE_FAULT_TYPES	0
18	basic	palletNumberHelpers	f	4	18	2	ROLE_PALLET_NUMBERS	0
19	basic	palletNumbers	f	4	19	3	ROLE_PALLET_NUMBERS	0
36	technologies	technologyGroups	f	5	36	1	ROLE_TECHNOLOGIES	0
37	technologies	operationGroups	f	5	37	2	ROLE_TECHNOLOGIES	0
16	basic	subassemblies	f	3	16	6	ROLE_COMPANY_STRUCTURE	0
45	materialFlow	locations	f	6	45	1	ROLE_MATERIAL_FLOW	0
70	materialFlowResources	storageLocations	f	6	70	2	ROLE_MATERIAL_FLOW	0
71	materialFlowResources	documentPositions	f	6	71	4	ROLE_DOCUMENT_POSITIONS	0
72	materialFlowResources	warehouseStock	f	6	72	6	ROLE_WAREHOUSE_STATES	0
68	materialFlowResources	storageLocationsState	f	6	68	7	ROLE_MATERIAL_FLOW	0
74	materialFlowResources	resourceCorrections	f	6	74	11	ROLE_DOCUMENTS_CORRECTIONS_MIN_STATES	0
69	materialFlowResources	reservations	f	6	69	12	ROLE_MATERIAL_FLOW	0
78	warehouseMinimalState	warehouseMinimumStateList	f	6	78	13	ROLE_DOCUMENTS_CORRECTIONS_MIN_STATES	0
60	costCalculation	costCalculation	f	10	60	1	ROLE_CALCULATIONS	0
50	lineChangeoverNorms	matchingChangeoverNorms	f	10	50	4	ROLE_CALCULATIONS	0
55	advancedGenealogy	batches	f	11	55	1	ROLE_BATCHES	0
82	cmmsMachineParts	actions	f	4	82	16	ROLE_ACTIONS	0
84	cmmsMachineParts	machineParts	f	4	84	17	ROLE_MACHINE_PARTS	0
133	qcadooView	attachmentViewer	f	1	132	14	\N	0
136	integrationScales	scales	f	4	135	22	ROLE_COMPANY_STRUCTURE	0
122	materialFlowResources	palletStorageState	f	6	121	8	ROLE_MATERIAL_FLOW	0
125	materialFlowResources	palletBalances	f	6	124	14	ROLE_MATERIAL_FLOW	0
130	materialFlowResources	stocktaking	f	6	129	15	ROLE_MATERIAL_FLOW	0
131	materialFlowResources	warehouseStockReports	f	6	130	16	ROLE_MATERIAL_FLOW	0
85	cmmsMachineParts	events	f	13	85	1	ROLE_EVENTS	0
83	cmmsMachineParts	plannedEvents	f	13	83	2	ROLE_PLANNED_EVENTS_ACTIONS_VIEW	0
121	productionCounting	productionAnalysis	f	15	120	2	ROLE_ANALYSIS_VIEWER	0
119	productionCounting	finalProductAnalysis	f	15	118	5	ROLE_ANALYSIS_VIEWER	0
24	basic	crews	f	18	24	8	ROLE_CREW	0
148	basic	skillsList	f	18	147	23	ROLE_SKILLS	0
34	wageGroups	wageGroups	f	18	34	14	ROLE_STAFF_WAGES	0
33	wageGroups	wages	f	18	33	13	ROLE_STAFF_WAGES	0
157	stoppage	stoppageReasonsList	f	4	156	26	ROLE_STOPPAGE_REASONS	0
168	deliveries	supplyParameters	f	21	167	4	ROLE_PARAMETERS	0
169	materialFlowResources	materialFlowResourcesParameters	f	21	168	5	ROLE_PARAMETERS	0
182	basic	technologicalProcessRateList	f	18	181	24	ROLE_TECHNOLOGICAL_PROCESSES	0
73	materialFlowResources	documents	f	6	73	3	ROLE_DOCUMENTS_CORRECTIONS_MIN_STATES	0
53	advancedGenealogy	genealogyTables	f	11	53	3	ROLE_ADVANCED_GENEALOGY	0
127	productionCounting	trackingOperationProductInComponentAdditionalInformationReport	f	8	126	7	ROLE_PRODUCTION_TRACKING	0
128	productionCounting	anomalyList	f	8	127	8	ROLE_ANOMALIES	0
137	goodFood	printedLabelsList	f	8	136	10	ROLE_TERMINAL_PALLET_USER	0
54	advancedGenealogy	trackingRecordsSimple	f	11	54	4	ROLE_ADVANCED_GENEALOGY	0
149	orders	schedulesList	t	7	148	7	ROLE_SCHEDULES	0
51	lineChangeoverNorms	lineChangeoverNorms	f	5	51	5	\N	0
155	technologies	productsToProductGroupTechnology	f	5	154	6	ROLE_TECHNOLOGIES	0
183	technologies	technologicalProcessesList	f	5	182	7	ROLE_TECHNOLOGICAL_PROCESSES	0
184	technologies	technologicalProcessListsList	f	5	183	8	ROLE_TECHNOLOGICAL_PROCESSES	0
90	assignmentToShift	assignmentToShiftReportList	f	7	90	12	ROLE_ASSIGNMENT_TO_SHIFT	0
91	assignmentToShift	assignmentToShift	f	7	91	11	ROLE_ASSIGNMENT_TO_SHIFT	0
98	productionPerShift	ppsReports	f	7	98	13	ROLE_PLANNING	0
80	cmmsMachineParts	sourceCostReports	f	13	80	4	ROLE_MAINTENANCE	0
81	cmmsMachineParts	timeUsageReport	f	13	81	5	ROLE_MAINTENANCE	0
86	cmmsMachineParts	sourceCostList	f	13	86	3	ROLE_SOURCE_COST	0
153	materialFlowResources	documentPositionsAttributes	f	6	152	5	ROLE_DOCUMENT_POSITIONS	0
185	costCalculation	standardLaborCostsList	f	10	184	3	ROLE_CALCULATIONS	0
164	productionCounting	employeeWorkingTimeSettlement	f	15	163	3	ROLE_ANALYSIS_VIEWER	0
120	productionCounting	beforeAdditionalActionsAnalysis	f	15	119	6	ROLE_ANALYSIS_VIEWER	0
75	materialFlowResources	resources	f	6	75	9	ROLE_RESOURCES	0
152	materialFlowResources	resourcesAttributes	f	6	151	10	ROLE_RESOURCES	0
179	basic	labelsList	f	4	178	28	ROLE_PRODUCTS_ADDITIONAL	0
126	productionCounting	anomalyReasonList	f	4	125	19	ROLE_ANOMALIES	0
203	cmmsMachineParts	toolsList	f	13	202	1	ROLE_TOOLS	0
212	costCalculation	additionalDirectCostsList	f	10	211	5	ROLE_CALCULATIONS	0
214	basic	pieceRateList	f	18	213	25	ROLE_BASE_FUNCTIONALITY	0
218	scheduleGantt	workstationsWorkChart	f	3	217	7	ROLE_COMPANY_STRUCTURE	0
77	masterOrders	masterOrders	f	23	77	2	ROLE_SALE	0
76	masterOrders	masterOrderPositions	f	23	76	3	ROLE_SALE	0
181	masterOrders	salesPlansList	f	23	180	1	ROLE_SALE	0
208	masterOrders	salesVolumesList	f	6	207	17	ROLE_REQUIREMENTS	0
63	stoppage	stoppages	f	8	63	2	ROLE_STOPPAGES	0
191	orders	orderTechnologicalProcessesList	f	8	190	3	ROLE_ORDER_TECHNOLOGICAL_PROCESSES	0
107	productionPerShift	balancePerShift	f	15	106	7	\N	0
219	subcontractorPortal	subOrderIssuedProductsReportsList	f	15	218	14	ROLE_ANALYSIS_VIEWER	0
192	orders	orderTechnologicalProcessWastesList	f	8	191	4	ROLE_ORDER_TECHNOLOGICAL_PROCESSES	0
195	integrationBarTender	printedPalletLabelsList	f	8	194	11	ROLE_PRINTED_PALLET_LABELS	0
116	ordersGantt	ordersGantt	f	7	115	9	ROLE_PLANNING_ON_LINE_VIEW	0
187	orders	orderPacksList	f	7	186	10	ROLE_PLANNING	0
194	orders	orderTechnologicalProcessesAnalysis	f	15	193	8	ROLE_ANALYSIS_VIEWER	0
199	masterOrders	masterOrdersMaterialRequirementsList	f	9	198	12	ROLE_REQUIREMENTS	0
209	masterOrders	orderedProductConfiguratorsList	f	19	208	8	ROLE_PLANNING	0
206	cmmsMachineParts	ordersToolRequirementsList	f	13	205	6	ROLE_TOOLS	0
198	productionCounting	operationDurationAnalysis	f	15	197	9	ROLE_ANALYSIS_VIEWER	0
205	productionCounting	productionBalanceAnalysis	f	15	204	10	ROLE_ANALYSIS_VIEWER	0
211	productionCounting	linesProducedQuantitiesChart	f	15	210	11	ROLE_ANALYSIS_VIEWER	0
200	orders	productionLineSchedulesList	f	7	199	15	ROLE_PRODUCTION_LINE_SCHEDULES	0
61	deliveries	supplyItems	f	9	61	5	ROLE_DELIVERIES	0
62	deliveries	deliveries	f	9	62	4	ROLE_DELIVERIES	0
64	supplyNegotiations	negotiation	f	9	64	9	ROLE_NEGOTIATIONS	0
65	supplyNegotiations	offersItems	f	9	65	7	ROLE_OFFERS	0
66	supplyNegotiations	offer	f	9	66	6	ROLE_OFFERS	0
67	supplyNegotiations	requestsForQuotation	f	9	67	8	ROLE_REQUEST_FOR_QUOTATIONS	0
202	scheduleGantt	sgOrdersGantt	f	7	201	16	ROLE_ORDERS_GANTT_VIEW	0
210	lineChangeoverNormsForOrders	lineChangeoverNormsForOrdersList	f	7	209	17	ROLE_LINE_CHANGEOVER_NORMS_IN_ORDERS	0
216	productionCounting	performanceAnalysisMv	f	15	215	12	ROLE_ANALYSIS_VIEWER	0
196	technologies	productionLineTechnologyGroupList	f	5	195	10	ROLE_TECHNOLOGIES	0
220	technologies	productData	f	5	219	13	ROLE_TECHNOLOGIES	0
217	productionCounting	employeePieceworkSettlement	f	15	216	13	ROLE_ANALYSIS_VIEWER	0
188	masterOrders	salesPlanMaterialRequirementsList	f	9	187	1	ROLE_REQUIREMENTS	0
189	ordersGroups	ordersGroupMaterialRequirementsList	f	9	188	2	ROLE_REQUIREMENTS	0
221	masterOrders	salesParameters	f	21	220	8	ROLE_PARAMETERS	0
171	basicProductionCounting	productionCountingQuantityList	f	9	170	3	ROLE_PRODUCTION_COUNTING_QUANTITY	0
\.


--
-- Data for Name: qcadooview_systeminfo; Type: TABLE DATA; Schema: public; Owner: -
--

COPY public.qcadooview_systeminfo (id, nextupdatetime) FROM stdin;
\.


--
-- Data for Name: qcadooview_view; Type: TABLE DATA; Schema: public; Owner: -
--

COPY public.qcadooview_view (id, pluginidentifier, name, view, url, entityversion) FROM stdin;
1	qcadooView	systemInfo	\N	/systemInfo.html	0
2	qcadooPlugins	pluginsList	pluginsList	\N	0
3	qcadooMenu	menuCategoriesList	menuCategoriesList	\N	0
4	qcadooCustomTranslations	customTranslationsList	customTranslationsList	\N	0
5	qcadooUsers	groupsList	groupsList	\N	0
6	qcadooUsers	rolesList	rolesList	\N	0
7	qcadooUsers	usersList	usersList	\N	0
8	qcadooUsers	profile	\N	/userProfile.html	0
9	qcadooDictionaries	dictionariesList	dictionariesList	\N	0
10	qcadooUnitConversions	unitConversions	\N	/unitConversions.html	0
11	basic	logsList	logsList	\N	0
12	basic	factoriesList	factoriesList	\N	0
13	basic	divisionsList	divisionsList	\N	0
14	basic	workstationsList	workstationsList	\N	0
15	basic	workstationTypesList	workstationTypesList	\N	0
16	basic	subassembliesList	subassembliesList	\N	0
17	basic	faultTypesList	faultTypesList	\N	0
18	basic	palletNumberHelpersList	palletNumberHelpersList	\N	0
19	basic	palletNumbersList	palletNumbersList	\N	0
20	basic	assortmentsList	assortmentsList	\N	0
21	basic	productsFamilies	productsFamilies	\N	0
22	basic	productsList	productsList	\N	0
23	basic	shiftsList	shiftsList	\N	0
24	basic	crewsList	crewsList	\N	0
25	basic	staffsList	staffsList	\N	0
26	basic	countriesList	countriesList	\N	0
27	basic	companiesList	companiesList	\N	0
28	basic	conversion	\N	/unitConversions.html	0
30	basic	dictionariesInBasic	\N	/page/qcadooDictionaries/dictionariesList.html	0
31	basic	home	\N	/dashboard.html	0
32	productionLines	productionLinesList	productionLinesList	\N	0
33	wageGroups	wagesList	wagesList	\N	0
34	wageGroups	wageGroupsList	wageGroupsList	\N	0
36	technologies	technologyGroupsList	technologyGroupsList	\N	0
37	technologies	operationGroupsList	operationGroupsList	\N	0
38	technologies	operationsList	operationsList	\N	0
39	technologies	technologiesList	technologiesList	\N	0
45	materialFlow	locationsList	locationsList	\N	0
47	orders	ordersPlanningList	ordersPlanningList	\N	0
48	orders	ordersList	ordersList	\N	0
50	lineChangeoverNorms	matchingChangeoverNormsDetails	matchingChangeoverNormsDetails	\N	0
51	lineChangeoverNorms	lineChangeoverNormsList	lineChangeoverNormsList	\N	0
52	advancedGenealogy	genealogyTree	genealogyTree	\N	0
53	advancedGenealogy	genealogyTablesList	genealogyTablesList	\N	0
54	advancedGenealogy	trackingRecordsSimpleList	trackingRecordsSimpleList	\N	0
55	advancedGenealogy	batchesList	batchesList	\N	0
60	costCalculation	costCalculationList	costCalculationList	\N	0
61	deliveries	supplyItems	supplyItems	\N	0
62	deliveries	deliveriesList	deliveriesList	\N	0
63	stoppage	allStoppages	allStoppages	\N	0
64	supplyNegotiations	negotiationsList	negotiationsList	\N	0
65	supplyNegotiations	offersItems	offersItems	\N	0
66	supplyNegotiations	offersList	offersList	\N	0
67	supplyNegotiations	requestForQuotationsList	requestForQuotationsList	\N	0
68	materialFlowResources	storageLocationsStateList	storageLocationsStateList	\N	0
69	materialFlowResources	reservationsList	reservationsList	\N	0
70	materialFlowResources	storageLocationList	storageLocationList	\N	0
71	materialFlowResources	documentPositionsList	documentPositionsList	\N	0
72	materialFlowResources	warehouseStocksList	warehouseStocksList	\N	0
73	materialFlowResources	documentsList	documentsList	\N	0
74	materialFlowResources	resourceCorrectionsList	resourceCorrectionsList	\N	0
75	materialFlowResources	resourcesList	resourcesList	\N	0
76	masterOrders	masterOrderPositionsList	masterOrderPositionsList	\N	0
77	masterOrders	masterOrdersList	masterOrdersList	\N	0
78	warehouseMinimalState	warehouseMinimumStateList	warehouseMinimumStateList	\N	0
79	productionScheduling	orderTimePrediction	orderTimePrediction	\N	0
80	cmmsMachineParts	sourceCostReports	sourceCostReports	\N	0
81	cmmsMachineParts	timeUsageReport	timeUsageReport	\N	0
82	cmmsMachineParts	actionsList	actionsList	\N	0
83	cmmsMachineParts	plannedEventsList	plannedEventsList	\N	0
84	cmmsMachineParts	machinePartsList	machinePartsList	\N	0
85	cmmsMachineParts	eventsList	eventsList	\N	0
86	cmmsMachineParts	sourceCostList	sourceCostList	\N	0
90	assignmentToShift	assignmentToShiftReportList	assignmentToShiftReportList	\N	0
91	assignmentToShift	assignmentToShiftList	assignmentToShiftList	\N	0
98	productionPerShift	ppsReportsList	ppsReportsList	\N	0
92	productionCounting	productionTrackingsForProductGroupedList	productionTrackingsForProductGroupedList	\N	0
93	productionCounting	productionTrackingsForProductList	productionTrackingsForProductList	\N	0
95	productionCounting	productionBalancesList	productionBalancesList	\N	0
96	productionCounting	productionTrackingsList	productionTrackingsList	\N	0
115	ordersGantt	ordersGantt	\N	/ordersGantt.html	0
116	integrationBartender	cartonLabels	cartonLabelsDetails	\N	0
118	productionCounting	finalProductAnalysisGenerator	finalProductAnalysisGenerator	\N	0
119	productionCounting	beforeAdditionalActionsAnalysisGenerator	beforeAdditionalActionsAnalysisGenerator	\N	0
120	productionCounting	productionAnalysisList	productionAnalysisList	\N	0
121	materialFlowResources	palletStorageStateList	palletStorageStateList	\N	0
122	deliveries	deliveryByPalletTypeReportDetails	deliveryByPalletTypeReportDetails	\N	0
124	materialFlowResources	palletBalancesList	palletBalancesList	\N	0
125	productionCounting	anomalyReasonList	anomalyReasonList	\N	0
126	productionCounting	trackingOperationProductInComponentAdditionalInformationReport	trackingOperationProductInComponentAdditionalInformationReport	\N	0
127	productionCounting	anomalyList	anomalyList	\N	0
129	materialFlowResources	stocktakingsList	stocktakingsList	\N	0
130	materialFlowResources	warehouseStockReportsList	warehouseStockReportsList	\N	0
131	basic	exceptionsForLineList	exceptionsForLineList	\N	0
132	qcadooView	attachmentViewer	\N	/attachmentViewer.html	0
133	basic	attachmentsList	attachmentsList	\N	0
134	goodFood	extrusionMixesList	extrusionMixesList	\N	0
135	integrationScales	scalesList	scalesList	\N	0
136	goodFood	printedLabelsList	printedLabelsList	\N	0
137	arch	archOrdersGroups	archOrdersGroupsList	\N	0
138	productionCounting	productionTrackingsDraftList	productionTrackingsDraftList	\N	0
139	arch	archMasterOrderPositionsList	archMasterOrderPositionsList	\N	0
140	arch	archMasterOrdersList	archMasterOrdersList	\N	0
141	arch	archOrdersList	archOrdersList	\N	0
142	arch	archProductionTrackingsList	archProductionTrackingsList	\N	0
143	arch	archDocumentPositionsList	archDocumentPositionsList	\N	0
144	arch	archDocumentsList	archDocumentsList	\N	0
145	integrationBarTender	printersList	printersList	\N	0
146	integrationBarTender	printedCartonLabelsList	printedCartonLabelsList	\N	0
147	basic	skillsList	skillsList	\N	0
148	orders	schedulesList	schedulesList	\N	0
46	orders	operationalTasksList	operationalTasksList	\N	0
149	basic	attributesList	attributesList	\N	0
150	basic	productsAttributes	\N	/productsAttributes.html	0
151	materialFlowResources	resourcesAttributes	\N	/resourcesAttributes.html	0
152	materialFlowResources	documentPositionsAttributes	\N	/documentPositionsAttributes.html	0
153	scheduleGantt	operationalTasksGantt	\N	/operationalTasksGantt.html	0
154	technologies	productsToProductGroupTechnologyList	productsToProductGroupTechnologyList	\N	0
155	basic	numberPatternsList	numberPatternsList	\N	0
156	stoppage	stoppageReasonsList	stoppageReasonsList	\N	0
106	productionPerShift	generateBalance	generateBalance	\N	0
160	basic	formsList	formsList	\N	0
163	productionCounting	employeeWorkingTimeSettlement	\N	/employeeWorkingTimeSettlement.html	0
164	basic	generalParameters	\N	/generalParameters.html	0
165	orders	planningParameters	\N	/planningParameters.html	0
166	technologies	technologiesParameters	\N	/technologiesParameters.html	0
167	deliveries	supplyParameters	\N	/supplyParameters.html	0
168	materialFlowResources	materialFlowResourcesParameters	\N	/materialFlowResourcesParameters.html	0
169	productionCounting	productionCountingParameters	\N	/productionCountingParameters.html	0
170	basicProductionCounting	productionCountingQuantityList	productionCountingQuantityList	\N	0
172	productionCounting	productionAnalysisParameters	\N	/productionAnalysisParameters.html	0
175	basic	sizesList	sizesList	\N	0
176	basic	sizeGroupsList	sizeGroupsList	\N	0
178	basic	labelsList	labelsList	\N	0
179	basic	modelsList	modelsList	\N	0
180	masterOrders	salesPlansList	salesPlansList	\N	0
181	basic	technologicalProcessRateList	technologicalProcessRateList	\N	0
182	technologies	technologicalProcessesList	technologicalProcessesList	\N	0
183	technologies	technologicalProcessListsList	technologicalProcessListsList	\N	0
184	costCalculation	standardLaborCostsList	standardLaborCostsList	\N	0
185	technologies	technologyInputProductTypesList	technologyInputProductTypesList	\N	0
186	orders	orderPacksList	orderPacksList	\N	0
187	masterOrders	salesPlanMaterialRequirementsList	salesPlanMaterialRequirementsList	\N	0
188	ordersGroups	ordersGroupMaterialRequirementsList	ordersGroupMaterialRequirementsList	\N	0
190	orders	orderTechnologicalProcessesList	orderTechnologicalProcessesList	\N	0
191	orders	orderTechnologicalProcessWastesList	orderTechnologicalProcessWastesList	\N	0
193	orders	orderTechnologicalProcessesAnalysis	\N	/orderTechnologicalProcessesAnalysis.html	0
194	integrationBarTender	printedPalletLabelsList	printedPalletLabelsList	\N	0
195	technologies	productionLineTechnologyGroupList	productionLineTechnologyGroupList	\N	0
197	productionCounting	operationDurationAnalysis	\N	/operationDurationAnalysis.html	0
198	masterOrders	masterOrdersMaterialRequirementsList	masterOrdersMaterialRequirementsList	\N	0
199	orders	productionLineSchedulesList	productionLineSchedulesList	\N	0
200	basic	licenses	\N	/licenses.html	0
201	scheduleGantt	sgOrdersGantt	\N	/sgOrdersGantt.html	0
202	cmmsMachineParts	toolsList	toolsList	\N	0
203	arch	archivingList	archivingList	\N	0
204	productionCounting	productionBalanceAnalysis	\N	/productionBalanceAnalysis.html	0
205	cmmsMachineParts	ordersToolRequirementsList	ordersToolRequirementsList	\N	0
206	technologies	technologyConfigurator	\N	/technologyConfigurator.html	0
207	masterOrders	salesVolumesList	salesVolumesList	\N	0
208	masterOrders	orderedProductConfiguratorsList	orderedProductConfiguratorsList	\N	0
209	lineChangeoverNormsForOrders	lineChangeoverNormsForOrdersList	lineChangeoverNormsForOrdersList	\N	0
210	productionCounting	linesProducedQuantitiesChart	\N	/linesProducedQuantitiesChart.html	0
211	costCalculation	additionalDirectCostsList	additionalDirectCostsList	\N	0
212	technologies	workstationChangeoverNormsList	workstationChangeoverNormsList	\N	0
213	basic	pieceRateList	pieceRateList	\N	0
214	orders	workstationChangeoverForOperationalTasksList	workstationChangeoverForOperationalTasksList	\N	0
215	productionCounting	performanceAnalysisMvList	performanceAnalysisMvList	\N	0
217	scheduleGantt	workstationsWorkChart		/workstationsWorkChart.html	0
216	productionCounting	employeePieceworkSettlement		/employeePieceworkSettlement.html	0
218	subcontractorPortal	subOrderIssuedProductsReportsList	subOrderIssuedProductsReportsList	\N	0
219	technologies	productDatasList	productDatasList	\N	0
220	masterOrders	salesParameters	\N	/salesParameters.html	0
221	masterOrders	pricesListsList	pricesListsList	\N	0
\.


--
-- Data for Name: qcadooview_viewedalert; Type: TABLE DATA; Schema: public; Owner: -
--

COPY public.qcadooview_viewedalert (id, user_id, alert_id) FROM stdin;
\.


--
-- Data for Name: qualitycontrol_changequalitycards; Type: TABLE DATA; Schema: public; Owner: -
--

COPY public.qualitycontrol_changequalitycards (id, cleanqualitycard, qualitycard_id, createdate, updatedate, createuser, updateuser) FROM stdin;
\.


--
-- Data for Name: qualitycontrol_deliveryqualitycontrol; Type: TABLE DATA; Schema: public; Owner: -
--

COPY public.qualitycontrol_deliveryqualitycontrol (id, createdate, updatedate, createuser, updateuser, delivery_id) FROM stdin;
\.


--
-- Data for Name: qualitycontrol_qualitycardattachment; Type: TABLE DATA; Schema: public; Owner: -
--

COPY public.qualitycontrol_qualitycardattachment (id, qualitycard_id, attachment, name, size, ext) FROM stdin;
\.


--
-- Data for Name: qualitycontrol_qualitycontrol; Type: TABLE DATA; Schema: public; Owner: -
--

COPY public.qualitycontrol_qualitycontrol (id, number, product_id, qualitycard_id, controltype, batch_id, date, staff_id, order_id, qualityrating, state, delivery_id, description) FROM stdin;
\.


--
-- Data for Name: qualitycontrol_qualitycontrolattachment; Type: TABLE DATA; Schema: public; Owner: -
--

COPY public.qualitycontrol_qualitycontrolattachment (id, qualitycontrol_id, attachment, name, size, ext) FROM stdin;
\.


--
-- Data for Name: qualitycontrol_qualitycontrolattribute; Type: TABLE DATA; Schema: public; Owner: -
--

COPY public.qualitycontrol_qualitycontrolattribute (id, qualitycard_id, attribute_id, priority, attributenumber) FROM stdin;
\.


--
-- Data for Name: qualitycontrol_qualitycontrolattributedeliveredprod; Type: TABLE DATA; Schema: public; Owner: -
--

COPY public.qualitycontrol_qualitycontrolattributedeliveredprod (id, qualitydeliveredproduct_id, attribute_id, attributevalue_id, value) FROM stdin;
\.


--
-- Data for Name: qualitycontrol_qualitycontrolattributeprodtracking; Type: TABLE DATA; Schema: public; Owner: -
--

COPY public.qualitycontrol_qualitycontrolattributeprodtracking (id, productiontracking_id, attribute_id, attributevalue_id, value, fromtechnology, moment, adddate) FROM stdin;
\.


--
-- Data for Name: qualitycontrol_qualitycontrolattributetoc; Type: TABLE DATA; Schema: public; Owner: -
--

COPY public.qualitycontrol_qualitycontrolattributetoc (id, qualitycontrolattribute_id, technologyoperationcomponent_id, moment) FROM stdin;
\.


--
-- Data for Name: qualitycontrol_qualitycontrolattributevalue; Type: TABLE DATA; Schema: public; Owner: -
--

COPY public.qualitycontrol_qualitycontrolattributevalue (id, qualitycontrol_id, attribute_id, attributevalue_id, value, productiontracking_id, fromqualitycard, priority) FROM stdin;
\.


--
-- Data for Name: qualitycontrol_qualitycontrolresource; Type: TABLE DATA; Schema: public; Owner: -
--

COPY public.qualitycontrol_qualitycontrolresource (id, resourcenumber, qualitycontrol_id, resource_id) FROM stdin;
\.


--
-- Data for Name: qualitycontrol_qualitycontrolstatechange; Type: TABLE DATA; Schema: public; Owner: -
--

COPY public.qualitycontrol_qualitycontrolstatechange (id, dateandtime, sourcestate, targetstate, status, phase, worker, qualitycontrol_id, shift_id) FROM stdin;
\.


--
-- Data for Name: qualitycontrol_qualitydeliveredproduct; Type: TABLE DATA; Schema: public; Owner: -
--

COPY public.qualitycontrol_qualitydeliveredproduct (id, deliveryqualitycontrol_id, qualitycard_id, qualityrating, product_id, batch_id, batchnumber, deliveredquantity, priceperunit, storagelocation_id, orderedproduct_id, productiondate, expirationdate) FROM stdin;
\.


--
-- Data for Name: repairs_repairorder; Type: TABLE DATA; Schema: public; Owner: -
--

COPY public.repairs_repairorder (id, number, state, order_id, division_id, createdate, shift_id, startdate, enddate, staff_id, product_id, faulttype_id, description, quantitytorepair, quantityrepaired, lack, active, orderdto_id, entityversion, productiontracking_id, labortime, machinetime, repairorderproduct_id) FROM stdin;
\.


--
-- Data for Name: repairs_repairorderproduct; Type: TABLE DATA; Schema: public; Owner: -
--

COPY public.repairs_repairorderproduct (id, trackingoperationproductincomponent_id, division_id, location_id, product_id, faulttype_id, description, givenquantity, givenunit, entityversion) FROM stdin;
\.


--
-- Data for Name: repairs_repairorderstatechange; Type: TABLE DATA; Schema: public; Owner: -
--

COPY public.repairs_repairorderstatechange (id, dateandtime, sourcestate, targetstate, phase, worker, repairorder_id, shift_id, status) FROM stdin;
\.


--
-- Data for Name: repairs_repairorderworktime; Type: TABLE DATA; Schema: public; Owner: -
--

COPY public.repairs_repairorderworktime (id, repairorder_id, staff_id, labortime, effectiveexecutiontimestart, effectiveexecutiontimeend) FROM stdin;
\.


--
-- Data for Name: states_message; Type: TABLE DATA; Schema: public; Owner: -
--

COPY public.states_message (id, type, translationkey, translationargs, correspondfieldname, autoclose, productiontrackingstatechange_id, deliverystatechange_id, assignmenttoshiftstatechange_id, technologystatechange_id, orderstatechange_id, extrusionprotocolstatechange_id, confectionprotocolstatechange_id, palletstatechange_id, batchstatechange_id, trackingrecordstatechange_id, requestforquotationstatechange_id, offerstatechange_id, negotiationstatechange_id, warehouseissuestatechange_id, palletlabelstatechange_id, maintenanceeventstatechange_id, entityversion, plannedeventstatechange_id, recurringeventstatechange_id) FROM stdin;
\.


--
-- Data for Name: stoppage_stoppage; Type: TABLE DATA; Schema: public; Owner: -
--

COPY public.stoppage_stoppage (id, order_id, duration, entityversion, productiontracking_id, reason_id, description, datefrom, dateto) FROM stdin;
\.


--
-- Data for Name: stoppage_stoppagereason; Type: TABLE DATA; Schema: public; Owner: -
--

COPY public.stoppage_stoppagereason (id, name, description, type) FROM stdin;
1	Other	\N	02other
\.


--
-- Data for Name: subcontractorportal_operation; Type: TABLE DATA; Schema: public; Owner: -
--

COPY public.subcontractorportal_operation (id, orderid, operationid, cost, number, operation, ordernumber, ordername, datefrom, dateto, status, company_id, operationcomponent_id, active, entityversion) FROM stdin;
\.


--
-- Data for Name: subcontractorportal_suborder; Type: TABLE DATA; Schema: public; Owner: -
--

COPY public.subcontractorportal_suborder (id, number, ordernumber, description, datefrom, dateto, state, company_id, active, changedby_id, hasoperations, entityversion) FROM stdin;
\.


--
-- Data for Name: subcontractorportal_suborderattachment; Type: TABLE DATA; Schema: public; Owner: -
--

COPY public.subcontractorportal_suborderattachment (id, attachment, name, ext, size, suborder_id, active, entityversion) FROM stdin;
\.


--
-- Data for Name: subcontractorportal_subordercost; Type: TABLE DATA; Schema: public; Owner: -
--

COPY public.subcontractorportal_subordercost (id, deliveredquantity, unitprice, totalprice, suborder_id, product_id, active, entityversion, operationaltask_id, order_id) FROM stdin;
\.


--
-- Data for Name: subcontractorportal_suborderevent; Type: TABLE DATA; Schema: public; Owner: -
--

COPY public.subcontractorportal_suborderevent (id, date, prevvalue, currvalue, type, action, staff_id, suborder_id, active, entityversion) FROM stdin;
\.


--
-- Data for Name: subcontractorportal_suborderinput; Type: TABLE DATA; Schema: public; Owner: -
--

COPY public.subcontractorportal_suborderinput (id, unit, plannedquantity, deliveredquantity, remainingquantity, product_id, location_id, suborder_id, active, operations, entityversion) FROM stdin;
\.


--
-- Data for Name: subcontractorportal_suborderissuedproductsreport; Type: TABLE DATA; Schema: public; Owner: -
--

COPY public.subcontractorportal_suborderissuedproductsreport (id, number, name, datefrom, dateto, company_id, withoutfinishedsuborders, withoutfullyreceivedsuborders, generated, worker, date, filename) FROM stdin;
\.


--
-- Data for Name: subcontractorportal_subordermessage; Type: TABLE DATA; Schema: public; Owner: -
--

COPY public.subcontractorportal_subordermessage (id, date, createdat, description, staff_id, company_id, suborder_id, active, entityversion) FROM stdin;
\.


--
-- Data for Name: subcontractorportal_suborderoperation; Type: TABLE DATA; Schema: public; Owner: -
--

COPY public.subcontractorportal_suborderoperation (id, orderid, operationid, cost, number, operation, ordernumber, ordername, datefrom, dateto, status, company_id, suborder_id, operationcomponent_id, active, entityversion) FROM stdin;
\.


--
-- Data for Name: subcontractorportal_suborderoutput; Type: TABLE DATA; Schema: public; Owner: -
--

COPY public.subcontractorportal_suborderoutput (id, unit, plannedquantity, deliveredquantity, producedquantity, remainingquantity, unitprice, createdmanually, product_id, location_id, suborder_id, active, operations, entityversion) FROM stdin;
\.


--
-- Data for Name: subcontractorportal_suborderrealisation; Type: TABLE DATA; Schema: public; Owner: -
--

COPY public.subcontractorportal_suborderrealisation (id, date, producedquantity, remainingquantity, product_id, suborder_id, active, entityversion) FROM stdin;
\.


--
-- Data for Name: subcontractorportal_suborderstatechange; Type: TABLE DATA; Schema: public; Owner: -
--

COPY public.subcontractorportal_suborderstatechange (id, dateandtime, sourcestate, targetstate, status, phase, worker, suborder_id, shift_id) FROM stdin;
\.


--
-- Data for Name: subcontractorportal_subordertmp; Type: TABLE DATA; Schema: public; Owner: -
--

COPY public.subcontractorportal_subordertmp (id, number, ordernumber, datefrom, dateto, planneddatefrom, planneddateto, status, company_id, active, entityversion) FROM stdin;
\.


--
-- Data for Name: supplynegotiations_columnforoffers; Type: TABLE DATA; Schema: public; Owner: -
--

COPY public.supplynegotiations_columnforoffers (id, identifier, name, description, columnfiller, alignment, parameter_id, succession, entityversion) FROM stdin;
1	succession	supplyNegotiations.columnForOffers.name.value.succession	supplyNegotiations.columnForOffers.description.value.succession	com.qcadoo.mes.supplyNegotiations.columnExtension.SupplyNegotiationsColumnFiller	01left	1	1	0
2	productNumber	supplyNegotiations.columnForOffers.name.value.productNumber	supplyNegotiations.columnForOffers.description.value.productNumber	com.qcadoo.mes.supplyNegotiations.columnExtension.SupplyNegotiationsColumnFiller	01left	1	2	0
3	productName	supplyNegotiations.columnForOffers.name.value.productName	supplyNegotiations.columnForOffers.description.value.productName	com.qcadoo.mes.supplyNegotiations.columnExtension.SupplyNegotiationsColumnFiller	01left	1	3	0
4	quantity	supplyNegotiations.columnForOffers.name.value.quantity	supplyNegotiations.columnForOffers.description.value.quantity	com.qcadoo.mes.supplyNegotiations.columnExtension.SupplyNegotiationsColumnFiller	02right	1	4	0
5	productUnit	supplyNegotiations.columnForOffers.name.value.productUnit	supplyNegotiations.columnForOffers.description.value.productUnit	com.qcadoo.mes.supplyNegotiations.columnExtension.SupplyNegotiationsColumnFiller	01left	1	5	0
6	pricePerUnit	supplyNegotiations.columnForOffers.name.value.pricePerUnit	supplyNegotiations.columnForOffers.description.value.pricePerUnit	com.qcadoo.mes.supplyNegotiations.columnExtension.SupplyNegotiationsColumnFiller	02right	1	6	0
7	totalPrice	supplyNegotiations.columnForOffers.name.value.totalPrice	supplyNegotiations.columnForOffers.description.value.totalPrice	com.qcadoo.mes.supplyNegotiations.columnExtension.SupplyNegotiationsColumnFiller	02right	1	7	0
8	currency	supplyNegotiations.columnForOffers.name.value.currency	supplyNegotiations.columnForOffers.description.value.currency	com.qcadoo.mes.supplyNegotiations.columnExtension.SupplyNegotiationsColumnFiller	01left	1	8	0
\.


--
-- Data for Name: supplynegotiations_columnforrequests; Type: TABLE DATA; Schema: public; Owner: -
--

COPY public.supplynegotiations_columnforrequests (id, identifier, name, description, columnfiller, alignment, parameter_id, succession, entityversion) FROM stdin;
1	succession	supplyNegotiations.columnForRequests.name.value.succession	supplyNegotiations.columnForRequests.description.value.succession	com.qcadoo.mes.supplyNegotiations.columnExtension.SupplyNegotiationsColumnFiller	01left	1	1	0
2	productNumber	supplyNegotiations.columnForRequests.name.value.productNumber	supplyNegotiations.columnForRequests.description.value.productNumber	com.qcadoo.mes.supplyNegotiations.columnExtension.SupplyNegotiationsColumnFiller	01left	1	2	0
3	productName	supplyNegotiations.columnForRequests.name.value.productName	supplyNegotiations.columnForRequests.description.value.productName	com.qcadoo.mes.supplyNegotiations.columnExtension.SupplyNegotiationsColumnFiller	01left	1	3	0
4	orderedQuantity	supplyNegotiations.columnForRequests.name.value.orderedQuantity	supplyNegotiations.columnForRequests.description.value.orderedQuantity	com.qcadoo.mes.supplyNegotiations.columnExtension.SupplyNegotiationsColumnFiller	02right	1	4	0
5	productUnit	supplyNegotiations.columnForRequests.name.value.productUnit	supplyNegotiations.columnForRequests.description.value.productUnit	com.qcadoo.mes.supplyNegotiations.columnExtension.SupplyNegotiationsColumnFiller	01left	1	5	0
6	annualVolume	supplyNegotiations.columnForRequests.name.value.annualVolume	supplyNegotiations.columnForRequests.description.value.annualVolume	com.qcadoo.mes.supplyNegotiations.columnExtension.SupplyNegotiationsColumnFiller	02right	1	6	0
\.


--
-- Data for Name: supplynegotiations_negotiation; Type: TABLE DATA; Schema: public; Owner: -
--

COPY public.supplynegotiations_negotiation (id, number, name, state, generatedate, active, createdate, updatedate, createuser, updateuser, entityversion) FROM stdin;
\.


--
-- Data for Name: supplynegotiations_negotiationproduct; Type: TABLE DATA; Schema: public; Owner: -
--

COPY public.supplynegotiations_negotiationproduct (id, negotiation_id, product_id, neededquantity, approveddeliveredquantity, draftdeliveredquantity, leftquantity, duedate, operation_id, requestforquotationsnumber, entityversion) FROM stdin;
\.


--
-- Data for Name: supplynegotiations_negotiationstatechange; Type: TABLE DATA; Schema: public; Owner: -
--

COPY public.supplynegotiations_negotiationstatechange (id, dateandtime, sourcestate, targetstate, status, phase, worker, negotiation_id, shift_id, entityversion) FROM stdin;
\.


--
-- Data for Name: supplynegotiations_offer; Type: TABLE DATA; Schema: public; Owner: -
--

COPY public.supplynegotiations_offer (id, number, name, description, supplier_id, requestforquotation_id, offereddate, attachment, transportcost, state, active, createdate, updatedate, createuser, updateuser, workingdaysafterorder, negotiation_id, entityversion, offerdate, currency_id) FROM stdin;
\.


--
-- Data for Name: supplynegotiations_offerproduct; Type: TABLE DATA; Schema: public; Owner: -
--

COPY public.supplynegotiations_offerproduct (id, offer_id, product_id, quantity, priceperunit, totalprice, operation_id, succession, actualversion, entityversion) FROM stdin;
\.


--
-- Data for Name: supplynegotiations_offerstatechange; Type: TABLE DATA; Schema: public; Owner: -
--

COPY public.supplynegotiations_offerstatechange (id, dateandtime, sourcestate, targetstate, status, phase, worker, offer_id, shift_id, entityversion) FROM stdin;
\.


--
-- Data for Name: supplynegotiations_parametercolumnforoffers; Type: TABLE DATA; Schema: public; Owner: -
--

COPY public.supplynegotiations_parametercolumnforoffers (id, parameter_id, columnforoffers_id, succession, entityversion) FROM stdin;
1	1	1	1	0
2	1	2	2	0
3	1	3	3	0
4	1	4	4	0
5	1	5	5	0
6	1	6	6	0
7	1	7	7	0
8	1	8	8	0
\.


--
-- Data for Name: supplynegotiations_parametercolumnforrequests; Type: TABLE DATA; Schema: public; Owner: -
--

COPY public.supplynegotiations_parametercolumnforrequests (id, parameter_id, columnforrequests_id, succession, entityversion) FROM stdin;
1	1	1	1	0
2	1	2	2	0
3	1	3	3	0
4	1	4	4	0
5	1	5	5	0
6	1	6	6	0
\.


--
-- Data for Name: supplynegotiations_requestforquotation; Type: TABLE DATA; Schema: public; Owner: -
--

COPY public.supplynegotiations_requestforquotation (id, number, name, description, supplier_id, desireddate, active, createdate, updatedate, createuser, updateuser, state, workingdaysafterorder, negotiation_id, entityversion) FROM stdin;
\.


--
-- Data for Name: supplynegotiations_requestforquotationproduct; Type: TABLE DATA; Schema: public; Owner: -
--

COPY public.supplynegotiations_requestforquotationproduct (id, requestforquotation_id, product_id, orderedquantity, annualvolume, operation_id, succession, entityversion) FROM stdin;
\.


--
-- Data for Name: supplynegotiations_requestforquotationstatechange; Type: TABLE DATA; Schema: public; Owner: -
--

COPY public.supplynegotiations_requestforquotationstatechange (id, dateandtime, sourcestate, targetstate, status, phase, worker, requestforquotation_id, shift_id, entityversion) FROM stdin;
\.


--
-- Data for Name: technologies_barcodeoperationcomponent; Type: TABLE DATA; Schema: public; Owner: -
--

COPY public.technologies_barcodeoperationcomponent (id, operationcomponent_id, code, active, entityversion, order_id) FROM stdin;
\.


--
-- Data for Name: technologies_changetechnologyparameters; Type: TABLE DATA; Schema: public; Owner: -
--

COPY public.technologies_changetechnologyparameters (id, changeperformancenorm, standardperformance, changegroup, technologygroup_id, createdate, updatedate, createuser, updateuser, updateoperationtimenorms, updateoperationworkstations, updateoperationcostnorms) FROM stdin;
\.


--
-- Data for Name: technologies_dimensioncontrolattribute; Type: TABLE DATA; Schema: public; Owner: -
--

COPY public.technologies_dimensioncontrolattribute (id, parameter_id, attribute_id) FROM stdin;
\.


--
-- Data for Name: technologies_modifytechnologyaddproducthelper; Type: TABLE DATA; Schema: public; Owner: -
--

COPY public.technologies_modifytechnologyaddproducthelper (id, modifytechnologyhelper_id, product_id, quantity) FROM stdin;
\.


--
-- Data for Name: technologies_modifytechnologyhelper; Type: TABLE DATA; Schema: public; Owner: -
--

COPY public.technologies_modifytechnologyhelper (id, remove, addnew, replace, selectedentities, product_id, replaceproduct_id, replaceproductquantity, createdate, updatedate, createuser, updateuser, sizeproduct) FROM stdin;
\.


--
-- Data for Name: technologies_operation; Type: TABLE DATA; Schema: public; Owner: -
--

COPY public.technologies_operation (id, number, name, comment, workstationtype_id, attachment, areproductquantitiesdivisible, istjdivisible, operationgroup_id, imageurlinworkplan, productioninonecycle, laborhourlycost, laborutilization, nextoperationafterproducedtype, nextoperationafterproducedquantityunit, machinehourlycost, tj, nextoperationafterproducedquantity, machineutilization, timenextoperation, tpz, productioninonecycleunit, active, issubcontracting, assignedtooperation, quantityofworkstations, division_id, showinproductdata, productdatanumber, entityversion, product_id, createoperationoutput, tjdecreasesforenlargedstaff, minstaff, optimalstaff, pieceworkproduction, piecerate_id, unitcost, reservationrawmaterialresourcerequired, optimizecutting) FROM stdin;
\.


--
-- Data for Name: technologies_operationgroup; Type: TABLE DATA; Schema: public; Owner: -
--

COPY public.technologies_operationgroup (id, number, name, active, entityversion) FROM stdin;
\.


--
-- Data for Name: technologies_operationproductincomponent; Type: TABLE DATA; Schema: public; Owner: -
--

COPY public.technologies_operationproductincomponent (id, operationcomponent_id, product_id, quantity, itemnumberintheexplodedview, componentslocation_id, componentsoutputlocation_id, priority, showinproductdata, productdatanumber, productsflowlocation_id, productionflow, givenquantity, givenunit, entityversion, showmaterialcomponent, quantityformula, technologyinputproducttype_id, differentproductsindifferentsizes, description, variousquantitiesinproductsbysize, attribute_id) FROM stdin;
\.


--
-- Data for Name: technologies_operationproductoutcomponent; Type: TABLE DATA; Schema: public; Owner: -
--

COPY public.technologies_operationproductoutcomponent (id, operationcomponent_id, product_id, quantity, productsinputlocation_id, productsflowlocation_id, productionflow, automaticmove, entityversion, waste, wastereceptionwarehouse_id) FROM stdin;
\.


--
-- Data for Name: technologies_operationskill; Type: TABLE DATA; Schema: public; Owner: -
--

COPY public.technologies_operationskill (id, operation_id, skill_id, requiredlevel, active) FROM stdin;
\.


--
-- Data for Name: technologies_productbysizegroup; Type: TABLE DATA; Schema: public; Owner: -
--

COPY public.technologies_productbysizegroup (id, operationproductincomponent_id, sizegroup_id, product_id, quantity, givenquantity, givenunit) FROM stdin;
\.


--
-- Data for Name: technologies_productcomponent; Type: TABLE DATA; Schema: public; Owner: -
--

COPY public.technologies_productcomponent (id, product_id, operationin_id, operationout_id, active, entityversion) FROM stdin;
\.


--
-- Data for Name: technologies_productdata; Type: TABLE DATA; Schema: public; Owner: -
--

COPY public.technologies_productdata (id, number, filename, generated, loaded, saved, dategenerated, staff_id, product_id, technology_id, active, description, entityversion) FROM stdin;
\.


--
-- Data for Name: technologies_productdataattachment; Type: TABLE DATA; Schema: public; Owner: -
--

COPY public.technologies_productdataattachment (id, attachment, name, ext, size, productdata_id, active, entityversion) FROM stdin;
\.


--
-- Data for Name: technologies_productdatainput; Type: TABLE DATA; Schema: public; Owner: -
--

COPY public.technologies_productdatainput (id, name, number, productdata_id, succession, active, quantity, entityversion, unit, operationproductincomponent_id) FROM stdin;
\.


--
-- Data for Name: technologies_productdataoperation; Type: TABLE DATA; Schema: public; Owner: -
--

COPY public.technologies_productdataoperation (id, number, name, description, productdata_id, technologyoperationcomponent_id, succession, active, entityversion) FROM stdin;
\.


--
-- Data for Name: technologies_productionlinetechnologygroup; Type: TABLE DATA; Schema: public; Owner: -
--

COPY public.technologies_productionlinetechnologygroup (id, technologygroup_id, productionline_id) FROM stdin;
\.


--
-- Data for Name: technologies_productstructuretreenode; Type: TABLE DATA; Schema: public; Owner: -
--

COPY public.technologies_productstructuretreenode (id, priority, technology_id, parent_id, nodenumber, number, product_id, createdate, updatedate, createuser, updateuser, entityversion, standardperformance, technologygroup_id, maintechnology_id, operation_id, quantity, division_id, entitytype, unit, technologyinputproducttype_id, differentproductsindifferentsizes, sizegroup_id, variousquantitiesinproductsbysize) FROM stdin;
\.


--
-- Data for Name: technologies_producttoproductgrouptechnology; Type: TABLE DATA; Schema: public; Owner: -
--

COPY public.technologies_producttoproductgrouptechnology (id, finalproduct_id, productfamily_id, orderproduct_id) FROM stdin;
\.


--
-- Data for Name: technologies_section; Type: TABLE DATA; Schema: public; Owner: -
--

COPY public.technologies_section (id, operationproductincomponent_id, length, quantity, unit) FROM stdin;
\.


--
-- Data for Name: technologies_technologicalprocess; Type: TABLE DATA; Schema: public; Owner: -
--

COPY public.technologies_technologicalprocess (id, name, workstationtype_id, workstation_id, tj, extendedtimeforsizegroup, increasepercent, sizegroup_id, technologicalprocessrate_id, tpz, additionaltime) FROM stdin;
\.


--
-- Data for Name: technologies_technologicalprocesscomponent; Type: TABLE DATA; Schema: public; Owner: -
--

COPY public.technologies_technologicalprocesscomponent (id, tj, extendedtimeforsizegroup, increasepercent, sizegroup_id, succession, technologicalprocesslist_id, technologicalprocess_id, tpz, additionaltime, remarks) FROM stdin;
\.


--
-- Data for Name: technologies_technologicalprocesslist; Type: TABLE DATA; Schema: public; Owner: -
--

COPY public.technologies_technologicalprocesslist (id, number, name, operation_id) FROM stdin;
\.


--
-- Data for Name: technologies_technology; Type: TABLE DATA; Schema: public; Owner: -
--

COPY public.technologies_technology (id, number, name, product_id, technologygroup_id, externalsynchronized, master, description, state, recipeimportstatus, recipeimportmsg, formula, minimalquantity, active, isstandardgoodfoodtechnology, range, division_id, componentslocation_id, componentsoutputlocation_id, productsinputlocation_id, technologytype, technologyprototype_id, productionflow, productsflowlocation_id, typeofproductionrecording, registerquantityoutproduct, registerquantityinproduct, registerproductiontime, entityversion, template, additionalactions, generatorcontext_id, qualitycard_id, istemplateaccepted, wastereceptionwarehouse_id, pieceworkproduction, piecerate_id) FROM stdin;
\.


--
-- Data for Name: technologies_technologyattachment; Type: TABLE DATA; Schema: public; Owner: -
--

COPY public.technologies_technologyattachment (id, technology_id, attachment, name, size, ext, entityversion) FROM stdin;
\.


--
-- Data for Name: technologies_technologygroup; Type: TABLE DATA; Schema: public; Owner: -
--

COPY public.technologies_technologygroup (id, number, name, active, entityversion) FROM stdin;
\.


--
-- Data for Name: technologies_technologyinputproducttype; Type: TABLE DATA; Schema: public; Owner: -
--

COPY public.technologies_technologyinputproducttype (id, name, averageprice, createdate, updatedate, createuser, updateuser, active) FROM stdin;
\.


--
-- Data for Name: technologies_technologyoperationcomponent; Type: TABLE DATA; Schema: public; Owner: -
--

COPY public.technologies_technologyoperationcomponent (id, technology_id, operation_id, parent_id, entitytype, priority, nodenumber, comment, attachment, areproductquantitiesdivisible, istjdivisible, tpz, laborworktime, productioninonecycleunit, nextoperationafterproducedquantityunit, nextoperationafterproducedquantity, nextoperationafterproducedtype, machineutilization, timenextoperation, machineworktime, productioninonecycle, laborutilization, duration, tj, machinehourlycost, laborhourlycost, issubcontracting, assignedtooperation, workstationtype_id, quantityofworkstations, createdate, updatedate, createuser, updateuser, techopercomptimecalculation_id, hascorrections, division_id, showinproductdata, productdatanumber, entityversion, technologicalprocesslist_id, technologicalprocesslistassignmentdate, tjdecreasesforenlargedstaff, minstaff, optimalstaff, pieceworkproduction, piecerate_id, unitcost) FROM stdin;
\.


--
-- Data for Name: technologies_technologyproductionline; Type: TABLE DATA; Schema: public; Owner: -
--

COPY public.technologies_technologyproductionline (id, productionline_id, technology_id, master, standardperformance, plannedstaff) FROM stdin;
\.


--
-- Data for Name: technologies_technologystatechange; Type: TABLE DATA; Schema: public; Owner: -
--

COPY public.technologies_technologystatechange (id, dateandtime, sourcestate, targetstate, status, phase, worker, technology_id, shift_id, entityversion) FROM stdin;
\.


--
-- Data for Name: technologies_technologytocreationhelper; Type: TABLE DATA; Schema: public; Owner: -
--

COPY public.technologies_technologytocreationhelper (id, number, reprocessed, active) FROM stdin;
\.


--
-- Data for Name: technologies_workstationchangeovernorm; Type: TABLE DATA; Schema: public; Owner: -
--

COPY public.technologies_workstationchangeovernorm (id, name, description, workstationtype_id, workstation_id, attribute_id, changeovertype, fromattributevalue_id, toattributevalue_id, duration, isparallel, active) FROM stdin;
\.


--
-- Data for Name: technologies_workstationstatechange; Type: TABLE DATA; Schema: public; Owner: -
--

COPY public.technologies_workstationstatechange (id, dateandtime, sourcestate, targetstate, status, phase, worker, workstation_id, shift_id) FROM stdin;
\.


--
-- Data for Name: technologiesgenerator_generatorcontext; Type: TABLE DATA; Schema: public; Owner: -
--

COPY public.technologiesgenerator_generatorcontext (id, technology_id, product_id, fetchtechnologiesforcomponents, createandswapproducts, createdate, updatedate, createuser, updateuser, generated, entityversion, saved, generationinprogress, number) FROM stdin;
\.


--
-- Data for Name: technologiesgenerator_generatortechnologiesforproduct; Type: TABLE DATA; Schema: public; Owner: -
--

COPY public.technologiesgenerator_generatortechnologiesforproduct (id, technology_id, product_id, generatorcontext_id, createdate, updatedate, createuser, updateuser) FROM stdin;
\.


--
-- Data for Name: technologiesgenerator_generatortreenode; Type: TABLE DATA; Schema: public; Owner: -
--

COPY public.technologiesgenerator_generatortreenode (id, parent_id, generatorcontext_id, entitytype, priority, nodenumber, quantity, product_id, operation_id, producttechnology_id, originaltechnology_id, division_id, entityversion, standardperformance, technologygroup_id, unit, technologyinputproducttype_id, differentproductsindifferentsizes, sizegroup_id, variousquantitiesinproductsbysize) FROM stdin;
\.


--
-- Data for Name: techsubcontracting_companyoperation; Type: TABLE DATA; Schema: public; Owner: -
--

COPY public.techsubcontracting_companyoperation (id, company_id, operation_id, isdefault) FROM stdin;
\.


--
-- Data for Name: techsubcontracting_companyoperationgroup; Type: TABLE DATA; Schema: public; Owner: -
--

COPY public.techsubcontracting_companyoperationgroup (id, company_id, operationgroup_id, isdefault) FROM stdin;
\.


--
-- Data for Name: techsubcontracting_orderexternalservicecost; Type: TABLE DATA; Schema: public; Owner: -
--

COPY public.techsubcontracting_orderexternalservicecost (id, order_id, technologyoperationcomponent_id, product_id, quantity, unitcost, totalcost, isaddedmanually) FROM stdin;
\.


--
-- Data for Name: timegapspreview_timegap; Type: TABLE DATA; Schema: public; Owner: -
--

COPY public.timegapspreview_timegap (id, productionline_id, fromdate, todate, duration, context_id, entityversion) FROM stdin;
\.


--
-- Data for Name: timegapspreview_timegapscontext; Type: TABLE DATA; Schema: public; Owner: -
--

COPY public.timegapspreview_timegapscontext (id, fromdate, todate, supportedtechnology_id, supportedtechnologygroup_id, totalduration, longestduration, longestdurationline_id, viewisinitialized, durationfilter, entityversion) FROM stdin;
\.


--
-- Data for Name: timenormsforoperations_operationworkstationtime; Type: TABLE DATA; Schema: public; Owner: -
--

COPY public.timenormsforoperations_operationworkstationtime (id, operation_id, workstation_id, tj, tpz, timenextoperation) FROM stdin;
\.


--
-- Data for Name: timenormsforoperations_techopercomptimecalculation; Type: TABLE DATA; Schema: public; Owner: -
--

COPY public.timenormsforoperations_techopercomptimecalculation (id, operationoffset, effectiveoperationrealizationtime, effectivedatefrom, effectivedateto, duration, machineworktime, laborworktime, entityversion) FROM stdin;
\.


--
-- Data for Name: timenormsforoperations_techopercompworkstationtime; Type: TABLE DATA; Schema: public; Owner: -
--

COPY public.timenormsforoperations_techopercompworkstationtime (id, technologyoperationcomponent_id, workstation_id, tj, tpz, timenextoperation) FROM stdin;
\.


--
-- Data for Name: urccore_lastsynchronizationdate; Type: TABLE DATA; Schema: public; Owner: -
--

COPY public.urccore_lastsynchronizationdate (id, lastsynchronizationdate, entityversion) FROM stdin;
\.


--
-- Data for Name: urccore_synchronizationstatus; Type: TABLE DATA; Schema: public; Owner: -
--

COPY public.urccore_synchronizationstatus (id, syncphase, syncfinishedat, successful, entityversion) FROM stdin;
\.


--
-- Data for Name: urcmaterialavailability_requiredcomponent; Type: TABLE DATA; Schema: public; Owner: -
--

COPY public.urcmaterialavailability_requiredcomponent (id, order_id, technology_id, product_id, availablequantity, reservedquantity, requiredquantity, unit, availability, createdate, updatedate, createuser, updateuser, entityversion) FROM stdin;
\.


--
-- Data for Name: urcproductioncounting_requestrepair; Type: TABLE DATA; Schema: public; Owner: -
--

COPY public.urcproductioncounting_requestrepair (id, division_id, quantitytorepair, faulttype_id, description, location_id) FROM stdin;
\.


--
-- Data for Name: wagegroups_wagegroup; Type: TABLE DATA; Schema: public; Owner: -
--

COPY public.wagegroups_wagegroup (id, number, name, superiorwagegroup, laborhourlycost, laborhourlycostcurrency, laborhourlycostfromwagegroup, determinedindividually, individuallaborhourlycost, entityversion) FROM stdin;
\.


--
-- Data for Name: walusiak_exportdocumenthistory; Type: TABLE DATA; Schema: public; Owner: -
--

COPY public.walusiak_exportdocumenthistory (id, dateexported, datefrom, dateto, entityversion) FROM stdin;
\.


--
-- Data for Name: warehouseminimalstate_warehouseminimumstate; Type: TABLE DATA; Schema: public; Owner: -
--

COPY public.warehouseminimalstate_warehouseminimumstate (id, product_id, location_id, minimumstate, optimalorderquantity, createdate, updatedate, createuser, updateuser, entityversion) FROM stdin;
\.


--
-- Data for Name: warehouseminimalstate_warehouseminimumstatemulti; Type: TABLE DATA; Schema: public; Owner: -
--

COPY public.warehouseminimalstate_warehouseminimumstatemulti (id, location_id, minimumstate, optimalorderquantity, createdate, updatedate, createuser, updateuser, entityversion) FROM stdin;
\.


--
-- Data for Name: workplans_columnforinputproducts; Type: TABLE DATA; Schema: public; Owner: -
--

COPY public.workplans_columnforinputproducts (id, identifier, name, description, columnfiller, alignment, entityversion) FROM stdin;
\.


--
-- Data for Name: workplans_columnfororders; Type: TABLE DATA; Schema: public; Owner: -
--

COPY public.workplans_columnfororders (id, identifier, name, description, columnfiller, alignment, entityversion) FROM stdin;
\.


--
-- Data for Name: workplans_columnforoutputproducts; Type: TABLE DATA; Schema: public; Owner: -
--

COPY public.workplans_columnforoutputproducts (id, identifier, name, description, columnfiller, alignment, entityversion) FROM stdin;
\.


--
-- Data for Name: workplans_parameterinputcolumn; Type: TABLE DATA; Schema: public; Owner: -
--

COPY public.workplans_parameterinputcolumn (id, parameter_id, columnforinputproducts_id, succession, entityversion) FROM stdin;
\.


--
-- Data for Name: workplans_parameterordercolumn; Type: TABLE DATA; Schema: public; Owner: -
--

COPY public.workplans_parameterordercolumn (id, parameter_id, columnfororders_id, succession, entityversion) FROM stdin;
\.


--
-- Data for Name: workplans_parameteroutputcolumn; Type: TABLE DATA; Schema: public; Owner: -
--

COPY public.workplans_parameteroutputcolumn (id, parameter_id, columnforoutputproducts_id, succession, entityversion) FROM stdin;
\.


--
-- Data for Name: workplans_workplan; Type: TABLE DATA; Schema: public; Owner: -
--

COPY public.workplans_workplan (id, name, date, worker, generated, filename, type, dontprintordersinworkplans, active, ordersorting, inputproductcolumntosortby_id, entityversion) FROM stdin;
\.


--
-- Data for Name: workplans_workplanordercolumn; Type: TABLE DATA; Schema: public; Owner: -
--

COPY public.workplans_workplanordercolumn (id, workplan_id, columnfororders_id, succession, entityversion) FROM stdin;
\.


--
-- Name: advancedgenealogy_batch_id_seq; Type: SEQUENCE SET; Schema: public; Owner: -
--

SELECT pg_catalog.setval('public.advancedgenealogy_batch_id_seq', 1, false);


--
-- Name: advancedgenealogy_batchattachment_id_seq; Type: SEQUENCE SET; Schema: public; Owner: -
--

SELECT pg_catalog.setval('public.advancedgenealogy_batchattachment_id_seq', 1, false);


--
-- Name: advancedgenealogy_batchdto_id_seq; Type: SEQUENCE SET; Schema: public; Owner: -
--

SELECT pg_catalog.setval('public.advancedgenealogy_batchdto_id_seq', 1, false);


--
-- Name: advancedgenealogy_batchstatechange_id_seq; Type: SEQUENCE SET; Schema: public; Owner: -
--

SELECT pg_catalog.setval('public.advancedgenealogy_batchstatechange_id_seq', 1, false);


--
-- Name: advancedgenealogy_genealogyreport_id_seq; Type: SEQUENCE SET; Schema: public; Owner: -
--

SELECT pg_catalog.setval('public.advancedgenealogy_genealogyreport_id_seq', 1, false);


--
-- Name: advancedgenealogy_trackingrecord_id_seq; Type: SEQUENCE SET; Schema: public; Owner: -
--

SELECT pg_catalog.setval('public.advancedgenealogy_trackingrecord_id_seq', 1, false);


--
-- Name: advancedgenealogy_trackingrecordstatechange_id_seq; Type: SEQUENCE SET; Schema: public; Owner: -
--

SELECT pg_catalog.setval('public.advancedgenealogy_trackingrecordstatechange_id_seq', 1, false);


--
-- Name: advancedgenealogy_usedbatchsimple_id_seq; Type: SEQUENCE SET; Schema: public; Owner: -
--

SELECT pg_catalog.setval('public.advancedgenealogy_usedbatchsimple_id_seq', 1, false);


--
-- Name: advancedgenealogyfororders_genealogyproductinbatch_id_seq; Type: SEQUENCE SET; Schema: public; Owner: -
--

SELECT pg_catalog.setval('public.advancedgenealogyfororders_genealogyproductinbatch_id_seq', 1, false);


--
-- Name: advancedgenealogyfororders_genealogyproductincomponent_id_seq; Type: SEQUENCE SET; Schema: public; Owner: -
--

SELECT pg_catalog.setval('public.advancedgenealogyfororders_genealogyproductincomponent_id_seq', 1, false);


--
-- Name: arch_advancedgenealogy_trackingrecord_id_seq; Type: SEQUENCE SET; Schema: public; Owner: -
--

SELECT pg_catalog.setval('public.arch_advancedgenealogy_trackingrecord_id_seq', 1, false);


--
-- Name: arch_advancedgenealogy_trackingrecordstatechange_id_seq; Type: SEQUENCE SET; Schema: public; Owner: -
--

SELECT pg_catalog.setval('public.arch_advancedgenealogy_trackingrecordstatechange_id_seq', 1, false);


--
-- Name: arch_advancedgenealogy_usedbatchsimple_id_seq; Type: SEQUENCE SET; Schema: public; Owner: -
--

SELECT pg_catalog.setval('public.arch_advancedgenealogy_usedbatchsimple_id_seq', 1, false);


--
-- Name: arch_advancedgenealogyfororders_genealogyproductinbatch_id_seq; Type: SEQUENCE SET; Schema: public; Owner: -
--

SELECT pg_catalog.setval('public.arch_advancedgenealogyfororders_genealogyproductinbatch_id_seq', 1, false);


--
-- Name: arch_advancedgenealogyfororders_genealogyproductincomponent_id_; Type: SEQUENCE SET; Schema: public; Owner: -
--

SELECT pg_catalog.setval('public.arch_advancedgenealogyfororders_genealogyproductincomponent_id_', 1, false);


--
-- Name: arch_archiving_id_seq; Type: SEQUENCE SET; Schema: public; Owner: -
--

SELECT pg_catalog.setval('public.arch_archiving_id_seq', 1, false);


--
-- Name: arch_assignmenttoshift_multiassignmenttoshift_id_seq; Type: SEQUENCE SET; Schema: public; Owner: -
--

SELECT pg_catalog.setval('public.arch_assignmenttoshift_multiassignmenttoshift_id_seq', 1, false);


--
-- Name: arch_assignmenttoshift_staffassignmenttoshift_id_seq; Type: SEQUENCE SET; Schema: public; Owner: -
--

SELECT pg_catalog.setval('public.arch_assignmenttoshift_staffassignmenttoshift_id_seq', 1, false);


--
-- Name: arch_avglaborcostcalcfororder_assignmentworkertoshift_id_seq; Type: SEQUENCE SET; Schema: public; Owner: -
--

SELECT pg_catalog.setval('public.arch_avglaborcostcalcfororder_assignmentworkertoshift_id_seq', 1, false);


--
-- Name: arch_avglaborcostcalcfororder_avglaborcostcalcfororder_id_seq; Type: SEQUENCE SET; Schema: public; Owner: -
--

SELECT pg_catalog.setval('public.arch_avglaborcostcalcfororder_avglaborcostcalcfororder_id_seq', 1, false);


--
-- Name: arch_basicproductioncounting_basicproductioncounting_id_seq; Type: SEQUENCE SET; Schema: public; Owner: -
--

SELECT pg_catalog.setval('public.arch_basicproductioncounting_basicproductioncounting_id_seq', 1, false);


--
-- Name: arch_basicproductioncounting_productioncountingattributevalue_i; Type: SEQUENCE SET; Schema: public; Owner: -
--

SELECT pg_catalog.setval('public.arch_basicproductioncounting_productioncountingattributevalue_i', 1, false);


--
-- Name: arch_basicproductioncounting_productioncountingoperationrun_id_; Type: SEQUENCE SET; Schema: public; Owner: -
--

SELECT pg_catalog.setval('public.arch_basicproductioncounting_productioncountingoperationrun_id_', 1, false);


--
-- Name: arch_basicproductioncounting_productioncountingquantity_id_seq; Type: SEQUENCE SET; Schema: public; Owner: -
--

SELECT pg_catalog.setval('public.arch_basicproductioncounting_productioncountingquantity_id_seq', 1, false);


--
-- Name: arch_cdnrcgoodfood_cancelprotocol_id_seq; Type: SEQUENCE SET; Schema: public; Owner: -
--

SELECT pg_catalog.setval('public.arch_cdnrcgoodfood_cancelprotocol_id_seq', 1, false);


--
-- Name: arch_costnormsformaterials_technologyinstoperproductincomp_id_s; Type: SEQUENCE SET; Schema: public; Owner: -
--

SELECT pg_catalog.setval('public.arch_costnormsformaterials_technologyinstoperproductincomp_id_s', 1, false);


--
-- Name: arch_goodfood_confectionadditionalinputproduct_id_seq; Type: SEQUENCE SET; Schema: public; Owner: -
--

SELECT pg_catalog.setval('public.arch_goodfood_confectionadditionalinputproduct_id_seq', 1, false);


--
-- Name: arch_goodfood_confectionfilmproduct_id_seq; Type: SEQUENCE SET; Schema: public; Owner: -
--

SELECT pg_catalog.setval('public.arch_goodfood_confectionfilmproduct_id_seq', 1, false);


--
-- Name: arch_goodfood_confectionfilmproductentry_id_seq; Type: SEQUENCE SET; Schema: public; Owner: -
--

SELECT pg_catalog.setval('public.arch_goodfood_confectionfilmproductentry_id_seq', 1, false);


--
-- Name: arch_goodfood_confectioninputproduct_id_seq; Type: SEQUENCE SET; Schema: public; Owner: -
--

SELECT pg_catalog.setval('public.arch_goodfood_confectioninputproduct_id_seq', 1, false);


--
-- Name: arch_goodfood_confectionprotocol_id_seq; Type: SEQUENCE SET; Schema: public; Owner: -
--

SELECT pg_catalog.setval('public.arch_goodfood_confectionprotocol_id_seq', 1, false);


--
-- Name: arch_goodfood_confectionprotocolcorrect_id_seq; Type: SEQUENCE SET; Schema: public; Owner: -
--

SELECT pg_catalog.setval('public.arch_goodfood_confectionprotocolcorrect_id_seq', 1, false);


--
-- Name: arch_goodfood_confectionprotocolstatechange_id_seq; Type: SEQUENCE SET; Schema: public; Owner: -
--

SELECT pg_catalog.setval('public.arch_goodfood_confectionprotocolstatechange_id_seq', 1, false);


--
-- Name: arch_goodfood_confectionremainderinputproduct_id_seq; Type: SEQUENCE SET; Schema: public; Owner: -
--

SELECT pg_catalog.setval('public.arch_goodfood_confectionremainderinputproduct_id_seq', 1, false);


--
-- Name: arch_goodfood_confectionstaff_id_seq; Type: SEQUENCE SET; Schema: public; Owner: -
--

SELECT pg_catalog.setval('public.arch_goodfood_confectionstaff_id_seq', 1, false);


--
-- Name: arch_goodfood_extrusionaddedmixentry_id_seq; Type: SEQUENCE SET; Schema: public; Owner: -
--

SELECT pg_catalog.setval('public.arch_goodfood_extrusionaddedmixentry_id_seq', 1, false);


--
-- Name: arch_goodfood_extrusionaddedmixingredient_id_seq; Type: SEQUENCE SET; Schema: public; Owner: -
--

SELECT pg_catalog.setval('public.arch_goodfood_extrusionaddedmixingredient_id_seq', 1, false);


--
-- Name: arch_goodfood_extrusionpouring_id_seq; Type: SEQUENCE SET; Schema: public; Owner: -
--

SELECT pg_catalog.setval('public.arch_goodfood_extrusionpouring_id_seq', 1, false);


--
-- Name: arch_goodfood_extrusionpouringingredient_id_seq; Type: SEQUENCE SET; Schema: public; Owner: -
--

SELECT pg_catalog.setval('public.arch_goodfood_extrusionpouringingredient_id_seq', 1, false);


--
-- Name: arch_goodfood_extrusionpouringmix_id_seq; Type: SEQUENCE SET; Schema: public; Owner: -
--

SELECT pg_catalog.setval('public.arch_goodfood_extrusionpouringmix_id_seq', 1, false);


--
-- Name: arch_goodfood_extrusionprotocol_id_seq; Type: SEQUENCE SET; Schema: public; Owner: -
--

SELECT pg_catalog.setval('public.arch_goodfood_extrusionprotocol_id_seq', 1, false);


--
-- Name: arch_goodfood_extrusionprotocolcorrect_id_seq; Type: SEQUENCE SET; Schema: public; Owner: -
--

SELECT pg_catalog.setval('public.arch_goodfood_extrusionprotocolcorrect_id_seq', 1, false);


--
-- Name: arch_goodfood_extrusionprotocolstatechange_id_seq; Type: SEQUENCE SET; Schema: public; Owner: -
--

SELECT pg_catalog.setval('public.arch_goodfood_extrusionprotocolstatechange_id_seq', 1, false);


--
-- Name: arch_goodfood_extrusionsouse_id_seq; Type: SEQUENCE SET; Schema: public; Owner: -
--

SELECT pg_catalog.setval('public.arch_goodfood_extrusionsouse_id_seq', 1, false);


--
-- Name: arch_goodfood_extrusiontakenoffmixentry_id_seq; Type: SEQUENCE SET; Schema: public; Owner: -
--

SELECT pg_catalog.setval('public.arch_goodfood_extrusiontakenoffmixentry_id_seq', 1, false);


--
-- Name: arch_goodfood_extrusiontakenoffmixingredient_id_seq; Type: SEQUENCE SET; Schema: public; Owner: -
--

SELECT pg_catalog.setval('public.arch_goodfood_extrusiontakenoffmixingredient_id_seq', 1, false);


--
-- Name: arch_goodfood_pallet_id_seq; Type: SEQUENCE SET; Schema: public; Owner: -
--

SELECT pg_catalog.setval('public.arch_goodfood_pallet_id_seq', 1, false);


--
-- Name: arch_goodfood_palletlabel_id_seq; Type: SEQUENCE SET; Schema: public; Owner: -
--

SELECT pg_catalog.setval('public.arch_goodfood_palletlabel_id_seq', 1, false);


--
-- Name: arch_goodfood_palletlabelstatechange_id_seq; Type: SEQUENCE SET; Schema: public; Owner: -
--

SELECT pg_catalog.setval('public.arch_goodfood_palletlabelstatechange_id_seq', 1, false);


--
-- Name: arch_goodfood_palletstatechange_id_seq; Type: SEQUENCE SET; Schema: public; Owner: -
--

SELECT pg_catalog.setval('public.arch_goodfood_palletstatechange_id_seq', 1, false);


--
-- Name: arch_goodfood_printedlabel_id_seq; Type: SEQUENCE SET; Schema: public; Owner: -
--

SELECT pg_catalog.setval('public.arch_goodfood_printedlabel_id_seq', 1, false);


--
-- Name: arch_integrationbartender_printlabelshelper_id_seq; Type: SEQUENCE SET; Schema: public; Owner: -
--

SELECT pg_catalog.setval('public.arch_integrationbartender_printlabelshelper_id_seq', 1, false);


--
-- Name: arch_integrationbartender_sendtoprint_id_seq; Type: SEQUENCE SET; Schema: public; Owner: -
--

SELECT pg_catalog.setval('public.arch_integrationbartender_sendtoprint_id_seq', 1, false);


--
-- Name: arch_masterorders_masterorder_id_seq; Type: SEQUENCE SET; Schema: public; Owner: -
--

SELECT pg_catalog.setval('public.arch_masterorders_masterorder_id_seq', 1, false);


--
-- Name: arch_masterorders_masterorderdto_id_seq; Type: SEQUENCE SET; Schema: public; Owner: -
--

SELECT pg_catalog.setval('public.arch_masterorders_masterorderdto_id_seq', 1, false);


--
-- Name: arch_masterorders_masterorderposition_manyproducts_id_seq; Type: SEQUENCE SET; Schema: public; Owner: -
--

SELECT pg_catalog.setval('public.arch_masterorders_masterorderposition_manyproducts_id_seq', 1, false);


--
-- Name: arch_masterorders_masterorderpositiondto_id_seq; Type: SEQUENCE SET; Schema: public; Owner: -
--

SELECT pg_catalog.setval('public.arch_masterorders_masterorderpositiondto_id_seq', 1, false);


--
-- Name: arch_masterorders_masterorderproduct_id_seq; Type: SEQUENCE SET; Schema: public; Owner: -
--

SELECT pg_catalog.setval('public.arch_masterorders_masterorderproduct_id_seq', 1, false);


--
-- Name: arch_masterorders_masterorderproductattrvalue_id_seq; Type: SEQUENCE SET; Schema: public; Owner: -
--

SELECT pg_catalog.setval('public.arch_masterorders_masterorderproductattrvalue_id_seq', 1, false);


--
-- Name: arch_masterorders_productsbysizeentryhelper_id_seq; Type: SEQUENCE SET; Schema: public; Owner: -
--

SELECT pg_catalog.setval('public.arch_masterorders_productsbysizeentryhelper_id_seq', 1, false);


--
-- Name: arch_masterorders_productsbysizehelper_id_seq; Type: SEQUENCE SET; Schema: public; Owner: -
--

SELECT pg_catalog.setval('public.arch_masterorders_productsbysizehelper_id_seq', 1, false);


--
-- Name: arch_materialflowresources_document_id_seq; Type: SEQUENCE SET; Schema: public; Owner: -
--

SELECT pg_catalog.setval('public.arch_materialflowresources_document_id_seq', 1, false);


--
-- Name: arch_materialflowresources_documentdto_id_seq; Type: SEQUENCE SET; Schema: public; Owner: -
--

SELECT pg_catalog.setval('public.arch_materialflowresources_documentdto_id_seq', 1, false);


--
-- Name: arch_materialflowresources_documentstatechange_id_seq; Type: SEQUENCE SET; Schema: public; Owner: -
--

SELECT pg_catalog.setval('public.arch_materialflowresources_documentstatechange_id_seq', 1, false);


--
-- Name: arch_materialflowresources_position_id_seq; Type: SEQUENCE SET; Schema: public; Owner: -
--

SELECT pg_catalog.setval('public.arch_materialflowresources_position_id_seq', 1, false);


--
-- Name: arch_materialflowresources_positionattributevalue_id_seq; Type: SEQUENCE SET; Schema: public; Owner: -
--

SELECT pg_catalog.setval('public.arch_materialflowresources_positionattributevalue_id_seq', 1, false);


--
-- Name: arch_materialflowresources_positiondto_id_seq; Type: SEQUENCE SET; Schema: public; Owner: -
--

SELECT pg_catalog.setval('public.arch_materialflowresources_positiondto_id_seq', 1, false);


--
-- Name: arch_materialflowresources_reservation_id_seq; Type: SEQUENCE SET; Schema: public; Owner: -
--

SELECT pg_catalog.setval('public.arch_materialflowresources_reservation_id_seq', 1, false);


--
-- Name: arch_materialrequirementcoveragefororder_coveragefororder_id_se; Type: SEQUENCE SET; Schema: public; Owner: -
--

SELECT pg_catalog.setval('public.arch_materialrequirementcoveragefororder_coveragefororder_id_se', 1, false);


--
-- Name: arch_materialrequirementcoveragefororder_coveragelocation_id_se; Type: SEQUENCE SET; Schema: public; Owner: -
--

SELECT pg_catalog.setval('public.arch_materialrequirementcoveragefororder_coveragelocation_id_se', 1, false);


--
-- Name: arch_materialrequirementcoveragefororder_coverageproduct_id_seq; Type: SEQUENCE SET; Schema: public; Owner: -
--

SELECT pg_catalog.setval('public.arch_materialrequirementcoveragefororder_coverageproduct_id_seq', 1, false);


--
-- Name: arch_orders_operationaltask_id_seq; Type: SEQUENCE SET; Schema: public; Owner: -
--

SELECT pg_catalog.setval('public.arch_orders_operationaltask_id_seq', 1, false);


--
-- Name: arch_orders_operationaltaskstatechange_id_seq; Type: SEQUENCE SET; Schema: public; Owner: -
--

SELECT pg_catalog.setval('public.arch_orders_operationaltaskstatechange_id_seq', 1, false);


--
-- Name: arch_orders_order_id_seq; Type: SEQUENCE SET; Schema: public; Owner: -
--

SELECT pg_catalog.setval('public.arch_orders_order_id_seq', 1, false);


--
-- Name: arch_orders_orderlistdto_id_seq; Type: SEQUENCE SET; Schema: public; Owner: -
--

SELECT pg_catalog.setval('public.arch_orders_orderlistdto_id_seq', 1, false);


--
-- Name: arch_orders_orderpack_id_seq; Type: SEQUENCE SET; Schema: public; Owner: -
--

SELECT pg_catalog.setval('public.arch_orders_orderpack_id_seq', 1, false);


--
-- Name: arch_orders_orderpackstatechange_id_seq; Type: SEQUENCE SET; Schema: public; Owner: -
--

SELECT pg_catalog.setval('public.arch_orders_orderpackstatechange_id_seq', 1, false);


--
-- Name: arch_orders_orderstatechange_id_seq; Type: SEQUENCE SET; Schema: public; Owner: -
--

SELECT pg_catalog.setval('public.arch_orders_orderstatechange_id_seq', 1, false);


--
-- Name: arch_orders_ordertechnologicalprocess_id_seq; Type: SEQUENCE SET; Schema: public; Owner: -
--

SELECT pg_catalog.setval('public.arch_orders_ordertechnologicalprocess_id_seq', 1, false);


--
-- Name: arch_orders_ordertechnologicalprocesspart_id_seq; Type: SEQUENCE SET; Schema: public; Owner: -
--

SELECT pg_catalog.setval('public.arch_orders_ordertechnologicalprocesspart_id_seq', 1, false);


--
-- Name: arch_orders_ordertechnologicalprocesswaste_id_seq; Type: SEQUENCE SET; Schema: public; Owner: -
--

SELECT pg_catalog.setval('public.arch_orders_ordertechnologicalprocesswaste_id_seq', 1, false);


--
-- Name: arch_orders_productionlinescheduleposition_id_seq; Type: SEQUENCE SET; Schema: public; Owner: -
--

SELECT pg_catalog.setval('public.arch_orders_productionlinescheduleposition_id_seq', 1, false);


--
-- Name: arch_orders_reasontypecorrectiondatefrom_id_seq; Type: SEQUENCE SET; Schema: public; Owner: -
--

SELECT pg_catalog.setval('public.arch_orders_reasontypecorrectiondatefrom_id_seq', 1, false);


--
-- Name: arch_orders_reasontypecorrectiondateto_id_seq; Type: SEQUENCE SET; Schema: public; Owner: -
--

SELECT pg_catalog.setval('public.arch_orders_reasontypecorrectiondateto_id_seq', 1, false);


--
-- Name: arch_orders_reasontypedeviationeffectiveend_id_seq; Type: SEQUENCE SET; Schema: public; Owner: -
--

SELECT pg_catalog.setval('public.arch_orders_reasontypedeviationeffectiveend_id_seq', 1, false);


--
-- Name: arch_orders_reasontypedeviationeffectivestart_id_seq; Type: SEQUENCE SET; Schema: public; Owner: -
--

SELECT pg_catalog.setval('public.arch_orders_reasontypedeviationeffectivestart_id_seq', 1, false);


--
-- Name: arch_orders_reasontypeofchangingorderstate_id_seq; Type: SEQUENCE SET; Schema: public; Owner: -
--

SELECT pg_catalog.setval('public.arch_orders_reasontypeofchangingorderstate_id_seq', 1, false);


--
-- Name: arch_orders_scheduleposition_id_seq; Type: SEQUENCE SET; Schema: public; Owner: -
--

SELECT pg_catalog.setval('public.arch_orders_scheduleposition_id_seq', 1, false);


--
-- Name: arch_orders_typeofcorrectioncauses_id_seq; Type: SEQUENCE SET; Schema: public; Owner: -
--

SELECT pg_catalog.setval('public.arch_orders_typeofcorrectioncauses_id_seq', 1, false);


--
-- Name: arch_ordersforsubproductsgeneration_suborders_id_seq; Type: SEQUENCE SET; Schema: public; Owner: -
--

SELECT pg_catalog.setval('public.arch_ordersforsubproductsgeneration_suborders_id_seq', 1, false);


--
-- Name: arch_ordersgroups_drafrptquantitydto_id_seq; Type: SEQUENCE SET; Schema: public; Owner: -
--

SELECT pg_catalog.setval('public.arch_ordersgroups_drafrptquantitydto_id_seq', 1, false);


--
-- Name: arch_ordersgroups_ordersgroup_id_seq; Type: SEQUENCE SET; Schema: public; Owner: -
--

SELECT pg_catalog.setval('public.arch_ordersgroups_ordersgroup_id_seq', 1, false);


--
-- Name: arch_ordersgroups_ordersgroupdto_id_seq; Type: SEQUENCE SET; Schema: public; Owner: -
--

SELECT pg_catalog.setval('public.arch_ordersgroups_ordersgroupdto_id_seq', 1, false);


--
-- Name: arch_ordersgroups_ordersgroupissuedmaterial_id_seq; Type: SEQUENCE SET; Schema: public; Owner: -
--

SELECT pg_catalog.setval('public.arch_ordersgroups_ordersgroupissuedmaterial_id_seq', 1, false);


--
-- Name: arch_ordersgroups_ordersgroupissuedmaterialposition_id_seq; Type: SEQUENCE SET; Schema: public; Owner: -
--

SELECT pg_catalog.setval('public.arch_ordersgroups_ordersgroupissuedmaterialposition_id_seq', 1, false);


--
-- Name: arch_ordersgroups_ordersgroupmaterialrequirement_id_seq; Type: SEQUENCE SET; Schema: public; Owner: -
--

SELECT pg_catalog.setval('public.arch_ordersgroups_ordersgroupmaterialrequirement_id_seq', 1, false);


--
-- Name: arch_ordersgroups_ordersgroupmaterialrequirementproduct_id_seq; Type: SEQUENCE SET; Schema: public; Owner: -
--

SELECT pg_catalog.setval('public.arch_ordersgroups_ordersgroupmaterialrequirementproduct_id_seq', 1, false);


--
-- Name: arch_ordersgroups_ordersgroupproducedproduct_id_seq; Type: SEQUENCE SET; Schema: public; Owner: -
--

SELECT pg_catalog.setval('public.arch_ordersgroups_ordersgroupproducedproduct_id_seq', 1, false);


--
-- Name: arch_ordersgroups_ordersgroupproductstoissueentryhelper_id_seq; Type: SEQUENCE SET; Schema: public; Owner: -
--

SELECT pg_catalog.setval('public.arch_ordersgroups_ordersgroupproductstoissueentryhelper_id_seq', 1, false);


--
-- Name: arch_ordersgroups_ordersgroupproductstoissuehelper_id_seq; Type: SEQUENCE SET; Schema: public; Owner: -
--

SELECT pg_catalog.setval('public.arch_ordersgroups_ordersgroupproductstoissuehelper_id_seq', 1, false);


--
-- Name: arch_ordersgroups_productionbalance_id_seq; Type: SEQUENCE SET; Schema: public; Owner: -
--

SELECT pg_catalog.setval('public.arch_ordersgroups_productionbalance_id_seq', 1, false);


--
-- Name: arch_ordersupplies_coverageanalysisfororder_id_seq; Type: SEQUENCE SET; Schema: public; Owner: -
--

SELECT pg_catalog.setval('public.arch_ordersupplies_coverageanalysisfororder_id_seq', 1, false);


--
-- Name: arch_ordersupplies_coveragelocation_id_seq; Type: SEQUENCE SET; Schema: public; Owner: -
--

SELECT pg_catalog.setval('public.arch_ordersupplies_coveragelocation_id_seq', 1, false);


--
-- Name: arch_ordersupplies_coverageorderstate_id_seq; Type: SEQUENCE SET; Schema: public; Owner: -
--

SELECT pg_catalog.setval('public.arch_ordersupplies_coverageorderstate_id_seq', 1, false);


--
-- Name: arch_ordersupplies_coverageproduct_id_seq; Type: SEQUENCE SET; Schema: public; Owner: -
--

SELECT pg_catalog.setval('public.arch_ordersupplies_coverageproduct_id_seq', 1, false);


--
-- Name: arch_ordersupplies_coverageproductlogging_id_seq; Type: SEQUENCE SET; Schema: public; Owner: -
--

SELECT pg_catalog.setval('public.arch_ordersupplies_coverageproductlogging_id_seq', 1, false);


--
-- Name: arch_ordersupplies_coverageproductselected_id_seq; Type: SEQUENCE SET; Schema: public; Owner: -
--

SELECT pg_catalog.setval('public.arch_ordersupplies_coverageproductselected_id_seq', 1, false);


--
-- Name: arch_ordersupplies_materialrequirementcoverage_id_seq; Type: SEQUENCE SET; Schema: public; Owner: -
--

SELECT pg_catalog.setval('public.arch_ordersupplies_materialrequirementcoverage_id_seq', 1, false);


--
-- Name: arch_productflowthrudivision_issue_id_seq; Type: SEQUENCE SET; Schema: public; Owner: -
--

SELECT pg_catalog.setval('public.arch_productflowthrudivision_issue_id_seq', 1, false);


--
-- Name: arch_productflowthrudivision_materialavailability_id_seq; Type: SEQUENCE SET; Schema: public; Owner: -
--

SELECT pg_catalog.setval('public.arch_productflowthrudivision_materialavailability_id_seq', 1, false);


--
-- Name: arch_productflowthrudivision_productstoissue_id_seq; Type: SEQUENCE SET; Schema: public; Owner: -
--

SELECT pg_catalog.setval('public.arch_productflowthrudivision_productstoissue_id_seq', 1, false);


--
-- Name: arch_productflowthrudivision_producttoissuecorrection_id_seq; Type: SEQUENCE SET; Schema: public; Owner: -
--

SELECT pg_catalog.setval('public.arch_productflowthrudivision_producttoissuecorrection_id_seq', 1, false);


--
-- Name: arch_productflowthrudivision_warehouseissue_id_seq; Type: SEQUENCE SET; Schema: public; Owner: -
--

SELECT pg_catalog.setval('public.arch_productflowthrudivision_warehouseissue_id_seq', 1, false);


--
-- Name: arch_productflowthrudivision_warehouseissuestatechange_id_seq; Type: SEQUENCE SET; Schema: public; Owner: -
--

SELECT pg_catalog.setval('public.arch_productflowthrudivision_warehouseissuestatechange_id_seq', 1, false);


--
-- Name: arch_productioncounting_anomaly_id_seq; Type: SEQUENCE SET; Schema: public; Owner: -
--

SELECT pg_catalog.setval('public.arch_productioncounting_anomaly_id_seq', 1, false);


--
-- Name: arch_productioncounting_anomalyexplanation_id_seq; Type: SEQUENCE SET; Schema: public; Owner: -
--

SELECT pg_catalog.setval('public.arch_productioncounting_anomalyexplanation_id_seq', 1, false);


--
-- Name: arch_productioncounting_anomalyproductiontrackingentryhelper_id; Type: SEQUENCE SET; Schema: public; Owner: -
--

SELECT pg_catalog.setval('public.arch_productioncounting_anomalyproductiontrackingentryhelper_id', 1, false);


--
-- Name: arch_productioncounting_anomalyreasoncontainer_id_seq; Type: SEQUENCE SET; Schema: public; Owner: -
--

SELECT pg_catalog.setval('public.arch_productioncounting_anomalyreasoncontainer_id_seq', 1, false);


--
-- Name: arch_productioncounting_lack_id_seq; Type: SEQUENCE SET; Schema: public; Owner: -
--

SELECT pg_catalog.setval('public.arch_productioncounting_lack_id_seq', 1, false);


--
-- Name: arch_productioncounting_prodoutresourceattrval_id_seq; Type: SEQUENCE SET; Schema: public; Owner: -
--

SELECT pg_catalog.setval('public.arch_productioncounting_prodoutresourceattrval_id_seq', 1, false);


--
-- Name: arch_productioncounting_productiontracking_id_seq; Type: SEQUENCE SET; Schema: public; Owner: -
--

SELECT pg_catalog.setval('public.arch_productioncounting_productiontracking_id_seq', 1, false);


--
-- Name: arch_productioncounting_productiontrackingattachment_id_seq; Type: SEQUENCE SET; Schema: public; Owner: -
--

SELECT pg_catalog.setval('public.arch_productioncounting_productiontrackingattachment_id_seq', 1, false);


--
-- Name: arch_productioncounting_productiontrackingdto_id_seq; Type: SEQUENCE SET; Schema: public; Owner: -
--

SELECT pg_catalog.setval('public.arch_productioncounting_productiontrackingdto_id_seq', 1, false);


--
-- Name: arch_productioncounting_productiontrackingstatechange_id_seq; Type: SEQUENCE SET; Schema: public; Owner: -
--

SELECT pg_catalog.setval('public.arch_productioncounting_productiontrackingstatechange_id_seq', 1, false);


--
-- Name: arch_productioncounting_staffworktime_id_seq; Type: SEQUENCE SET; Schema: public; Owner: -
--

SELECT pg_catalog.setval('public.arch_productioncounting_staffworktime_id_seq', 1, false);


--
-- Name: arch_productioncounting_trackinginproductreplacementhelper_id_s; Type: SEQUENCE SET; Schema: public; Owner: -
--

SELECT pg_catalog.setval('public.arch_productioncounting_trackinginproductreplacementhelper_id_s', 1, false);


--
-- Name: arch_productioncounting_trackingoperationproductincomponent_id_; Type: SEQUENCE SET; Schema: public; Owner: -
--

SELECT pg_catalog.setval('public.arch_productioncounting_trackingoperationproductincomponent_id_', 1, false);


--
-- Name: arch_productioncounting_trackingoperationproductoutcomponent_id; Type: SEQUENCE SET; Schema: public; Owner: -
--

SELECT pg_catalog.setval('public.arch_productioncounting_trackingoperationproductoutcomponent_id', 1, false);


--
-- Name: arch_productioncounting_usedbatch_id_seq; Type: SEQUENCE SET; Schema: public; Owner: -
--

SELECT pg_catalog.setval('public.arch_productioncounting_usedbatch_id_seq', 1, false);


--
-- Name: arch_productionpershift_dailyprogress_id_seq; Type: SEQUENCE SET; Schema: public; Owner: -
--

SELECT pg_catalog.setval('public.arch_productionpershift_dailyprogress_id_seq', 1, false);


--
-- Name: arch_productionpershift_productionpershift_id_seq; Type: SEQUENCE SET; Schema: public; Owner: -
--

SELECT pg_catalog.setval('public.arch_productionpershift_productionpershift_id_seq', 1, false);


--
-- Name: arch_productionpershift_progressforday_id_seq; Type: SEQUENCE SET; Schema: public; Owner: -
--

SELECT pg_catalog.setval('public.arch_productionpershift_progressforday_id_seq', 1, false);


--
-- Name: arch_productionpershift_reasontypeofcorrectionplan_id_seq; Type: SEQUENCE SET; Schema: public; Owner: -
--

SELECT pg_catalog.setval('public.arch_productionpershift_reasontypeofcorrectionplan_id_seq', 1, false);


--
-- Name: arch_productionscheduling_opercomptimecalculation_id_seq; Type: SEQUENCE SET; Schema: public; Owner: -
--

SELECT pg_catalog.setval('public.arch_productionscheduling_opercomptimecalculation_id_seq', 1, false);


--
-- Name: arch_productionscheduling_ordertimecalculation_id_seq; Type: SEQUENCE SET; Schema: public; Owner: -
--

SELECT pg_catalog.setval('public.arch_productionscheduling_ordertimecalculation_id_seq', 1, false);


--
-- Name: arch_qualitycontrol_qualitycontrol_id_seq; Type: SEQUENCE SET; Schema: public; Owner: -
--

SELECT pg_catalog.setval('public.arch_qualitycontrol_qualitycontrol_id_seq', 1, false);


--
-- Name: arch_qualitycontrol_qualitycontrolattachment_id_seq; Type: SEQUENCE SET; Schema: public; Owner: -
--

SELECT pg_catalog.setval('public.arch_qualitycontrol_qualitycontrolattachment_id_seq', 1, false);


--
-- Name: arch_qualitycontrol_qualitycontrolattributeprodtracking_id_seq; Type: SEQUENCE SET; Schema: public; Owner: -
--

SELECT pg_catalog.setval('public.arch_qualitycontrol_qualitycontrolattributeprodtracking_id_seq', 1, false);


--
-- Name: arch_qualitycontrol_qualitycontrolattributevalue_id_seq; Type: SEQUENCE SET; Schema: public; Owner: -
--

SELECT pg_catalog.setval('public.arch_qualitycontrol_qualitycontrolattributevalue_id_seq', 1, false);


--
-- Name: arch_qualitycontrol_qualitycontrolresource_id_seq; Type: SEQUENCE SET; Schema: public; Owner: -
--

SELECT pg_catalog.setval('public.arch_qualitycontrol_qualitycontrolresource_id_seq', 1, false);


--
-- Name: arch_qualitycontrol_qualitycontrolstatechange_id_seq; Type: SEQUENCE SET; Schema: public; Owner: -
--

SELECT pg_catalog.setval('public.arch_qualitycontrol_qualitycontrolstatechange_id_seq', 1, false);


--
-- Name: arch_repairs_repairorder_id_seq; Type: SEQUENCE SET; Schema: public; Owner: -
--

SELECT pg_catalog.setval('public.arch_repairs_repairorder_id_seq', 1, false);


--
-- Name: arch_repairs_repairorderproduct_id_seq; Type: SEQUENCE SET; Schema: public; Owner: -
--

SELECT pg_catalog.setval('public.arch_repairs_repairorderproduct_id_seq', 1, false);


--
-- Name: arch_repairs_repairorderstatechange_id_seq; Type: SEQUENCE SET; Schema: public; Owner: -
--

SELECT pg_catalog.setval('public.arch_repairs_repairorderstatechange_id_seq', 1, false);


--
-- Name: arch_repairs_repairorderworktime_id_seq; Type: SEQUENCE SET; Schema: public; Owner: -
--

SELECT pg_catalog.setval('public.arch_repairs_repairorderworktime_id_seq', 1, false);


--
-- Name: arch_states_message_id_seq; Type: SEQUENCE SET; Schema: public; Owner: -
--

SELECT pg_catalog.setval('public.arch_states_message_id_seq', 1, false);


--
-- Name: arch_stoppage_stoppage_id_seq; Type: SEQUENCE SET; Schema: public; Owner: -
--

SELECT pg_catalog.setval('public.arch_stoppage_stoppage_id_seq', 1, false);


--
-- Name: arch_technologies_barcodeoperationcomponent_id_seq; Type: SEQUENCE SET; Schema: public; Owner: -
--

SELECT pg_catalog.setval('public.arch_technologies_barcodeoperationcomponent_id_seq', 1, false);


--
-- Name: arch_urcmaterialavailability_requiredcomponent_id_seq; Type: SEQUENCE SET; Schema: public; Owner: -
--

SELECT pg_catalog.setval('public.arch_urcmaterialavailability_requiredcomponent_id_seq', 1, false);


--
-- Name: assignmenttoshift_assignmenttoshift_externalnumber_seq; Type: SEQUENCE SET; Schema: public; Owner: -
--

SELECT pg_catalog.setval('public.assignmenttoshift_assignmenttoshift_externalnumber_seq', 1, false);


--
-- Name: assignmenttoshift_assignmenttoshift_id_seq; Type: SEQUENCE SET; Schema: public; Owner: -
--

SELECT pg_catalog.setval('public.assignmenttoshift_assignmenttoshift_id_seq', 1, false);


--
-- Name: assignmenttoshift_assignmenttoshiftreport_id_seq; Type: SEQUENCE SET; Schema: public; Owner: -
--

SELECT pg_catalog.setval('public.assignmenttoshift_assignmenttoshiftreport_id_seq', 1, false);


--
-- Name: assignmenttoshift_assignmenttoshiftstatechange_id_seq; Type: SEQUENCE SET; Schema: public; Owner: -
--

SELECT pg_catalog.setval('public.assignmenttoshift_assignmenttoshiftstatechange_id_seq', 1, false);


--
-- Name: assignmenttoshift_multiassignmenttoshift_id_seq; Type: SEQUENCE SET; Schema: public; Owner: -
--

SELECT pg_catalog.setval('public.assignmenttoshift_multiassignmenttoshift_id_seq', 1, false);


--
-- Name: assignmenttoshift_staffassignmenttoshift_id_seq; Type: SEQUENCE SET; Schema: public; Owner: -
--

SELECT pg_catalog.setval('public.assignmenttoshift_staffassignmenttoshift_id_seq', 1, false);


--
-- Name: avglaborcostcalcfororder_assignmentworkertoshift_id_seq; Type: SEQUENCE SET; Schema: public; Owner: -
--

SELECT pg_catalog.setval('public.avglaborcostcalcfororder_assignmentworkertoshift_id_seq', 1, false);


--
-- Name: avglaborcostcalcfororder_avglaborcostcalcfororder_id_seq; Type: SEQUENCE SET; Schema: public; Owner: -
--

SELECT pg_catalog.setval('public.avglaborcostcalcfororder_avglaborcostcalcfororder_id_seq', 1, false);


--
-- Name: basic_address_id_seq; Type: SEQUENCE SET; Schema: public; Owner: -
--

SELECT pg_catalog.setval('public.basic_address_id_seq', 2, false);


--
-- Name: basic_assortment_id_seq; Type: SEQUENCE SET; Schema: public; Owner: -
--

SELECT pg_catalog.setval('public.basic_assortment_id_seq', 1, false);


--
-- Name: basic_assortmentelement_id_seq; Type: SEQUENCE SET; Schema: public; Owner: -
--

SELECT pg_catalog.setval('public.basic_assortmentelement_id_seq', 1, false);


--
-- Name: basic_attachmentdto_id_seq; Type: SEQUENCE SET; Schema: public; Owner: -
--

SELECT pg_catalog.setval('public.basic_attachmentdto_id_seq', 1, false);


--
-- Name: basic_attribute_id_seq; Type: SEQUENCE SET; Schema: public; Owner: -
--

SELECT pg_catalog.setval('public.basic_attribute_id_seq', 1, false);


--
-- Name: basic_attributevalue_id_seq; Type: SEQUENCE SET; Schema: public; Owner: -
--

SELECT pg_catalog.setval('public.basic_attributevalue_id_seq', 1, false);


--
-- Name: basic_company_id_seq; Type: SEQUENCE SET; Schema: public; Owner: -
--

SELECT pg_catalog.setval('public.basic_company_id_seq', 2, false);


--
-- Name: basic_country_id_seq; Type: SEQUENCE SET; Schema: public; Owner: -
--

SELECT pg_catalog.setval('public.basic_country_id_seq', 250, false);


--
-- Name: basic_crew_id_seq; Type: SEQUENCE SET; Schema: public; Owner: -
--

SELECT pg_catalog.setval('public.basic_crew_id_seq', 1, false);


--
-- Name: basic_currency_id_seq; Type: SEQUENCE SET; Schema: public; Owner: -
--

SELECT pg_catalog.setval('public.basic_currency_id_seq', 183, false);


--
-- Name: basic_dashboardbutton_id_seq; Type: SEQUENCE SET; Schema: public; Owner: -
--

SELECT pg_catalog.setval('public.basic_dashboardbutton_id_seq', 18, true);


--
-- Name: basic_division_id_seq; Type: SEQUENCE SET; Schema: public; Owner: -
--

SELECT pg_catalog.setval('public.basic_division_id_seq', 1, false);


--
-- Name: basic_factory_id_seq; Type: SEQUENCE SET; Schema: public; Owner: -
--

SELECT pg_catalog.setval('public.basic_factory_id_seq', 1, false);


--
-- Name: basic_faulttype_id_seq; Type: SEQUENCE SET; Schema: public; Owner: -
--

SELECT pg_catalog.setval('public.basic_faulttype_id_seq', 2, false);


--
-- Name: basic_forms_id_seq; Type: SEQUENCE SET; Schema: public; Owner: -
--

SELECT pg_catalog.setval('public.basic_forms_id_seq', 1, false);


--
-- Name: basic_label_id_seq; Type: SEQUENCE SET; Schema: public; Owner: -
--

SELECT pg_catalog.setval('public.basic_label_id_seq', 1, false);


--
-- Name: basic_licenseusage_id_seq; Type: SEQUENCE SET; Schema: public; Owner: -
--

SELECT pg_catalog.setval('public.basic_licenseusage_id_seq', 1, false);


--
-- Name: basic_log_id_seq; Type: SEQUENCE SET; Schema: public; Owner: -
--

SELECT pg_catalog.setval('public.basic_log_id_seq', 1, false);


--
-- Name: basic_machineworkingperiod_id_seq; Type: SEQUENCE SET; Schema: public; Owner: -
--

SELECT pg_catalog.setval('public.basic_machineworkingperiod_id_seq', 1, false);


--
-- Name: basic_model_id_seq; Type: SEQUENCE SET; Schema: public; Owner: -
--

SELECT pg_catalog.setval('public.basic_model_id_seq', 1, false);


--
-- Name: basic_numberpattern_id_seq; Type: SEQUENCE SET; Schema: public; Owner: -
--

SELECT pg_catalog.setval('public.basic_numberpattern_id_seq', 1, false);


--
-- Name: basic_numberpatternelement_id_seq; Type: SEQUENCE SET; Schema: public; Owner: -
--

SELECT pg_catalog.setval('public.basic_numberpatternelement_id_seq', 1, false);


--
-- Name: basic_palletnumber_id_seq; Type: SEQUENCE SET; Schema: public; Owner: -
--

SELECT pg_catalog.setval('public.basic_palletnumber_id_seq', 1, false);


--
-- Name: basic_palletnumberhelper_id_seq; Type: SEQUENCE SET; Schema: public; Owner: -
--

SELECT pg_catalog.setval('public.basic_palletnumberhelper_id_seq', 1, false);


--
-- Name: basic_parameter_id_seq; Type: SEQUENCE SET; Schema: public; Owner: -
--

SELECT pg_catalog.setval('public.basic_parameter_id_seq', 2, false);


--
-- Name: basic_piece_rate_number_seq; Type: SEQUENCE SET; Schema: public; Owner: -
--

SELECT pg_catalog.setval('public.basic_piece_rate_number_seq', 1, false);


--
-- Name: basic_piecerate_id_seq; Type: SEQUENCE SET; Schema: public; Owner: -
--

SELECT pg_catalog.setval('public.basic_piecerate_id_seq', 1, false);


--
-- Name: basic_piecerateitem_id_seq; Type: SEQUENCE SET; Schema: public; Owner: -
--

SELECT pg_catalog.setval('public.basic_piecerateitem_id_seq', 1, false);


--
-- Name: basic_product_id_seq; Type: SEQUENCE SET; Schema: public; Owner: -
--

SELECT pg_catalog.setval('public.basic_product_id_seq', 1, false);


--
-- Name: basic_productattachment_id_seq; Type: SEQUENCE SET; Schema: public; Owner: -
--

SELECT pg_catalog.setval('public.basic_productattachment_id_seq', 1, false);


--
-- Name: basic_productattributevalue_id_seq; Type: SEQUENCE SET; Schema: public; Owner: -
--

SELECT pg_catalog.setval('public.basic_productattributevalue_id_seq', 1, false);


--
-- Name: basic_productdto_id_seq; Type: SEQUENCE SET; Schema: public; Owner: -
--

SELECT pg_catalog.setval('public.basic_productdto_id_seq', 1, false);


--
-- Name: basic_qualitycard_id_seq; Type: SEQUENCE SET; Schema: public; Owner: -
--

SELECT pg_catalog.setval('public.basic_qualitycard_id_seq', 1, false);


--
-- Name: basic_qualitycardstatechange_id_seq; Type: SEQUENCE SET; Schema: public; Owner: -
--

SELECT pg_catalog.setval('public.basic_qualitycardstatechange_id_seq', 1, false);


--
-- Name: basic_reportcolumnwidth_id_seq; Type: SEQUENCE SET; Schema: public; Owner: -
--

SELECT pg_catalog.setval('public.basic_reportcolumnwidth_id_seq', 9, false);


--
-- Name: basic_shift_id_seq; Type: SEQUENCE SET; Schema: public; Owner: -
--

SELECT pg_catalog.setval('public.basic_shift_id_seq', 2, false);


--
-- Name: basic_shifttimetableexception_id_seq; Type: SEQUENCE SET; Schema: public; Owner: -
--

SELECT pg_catalog.setval('public.basic_shifttimetableexception_id_seq', 1, false);


--
-- Name: basic_size_id_seq; Type: SEQUENCE SET; Schema: public; Owner: -
--

SELECT pg_catalog.setval('public.basic_size_id_seq', 1, false);


--
-- Name: basic_sizegroup_id_seq; Type: SEQUENCE SET; Schema: public; Owner: -
--

SELECT pg_catalog.setval('public.basic_sizegroup_id_seq', 1, false);


--
-- Name: basic_skill_id_seq; Type: SEQUENCE SET; Schema: public; Owner: -
--

SELECT pg_catalog.setval('public.basic_skill_id_seq', 1, false);


--
-- Name: basic_staff_id_seq; Type: SEQUENCE SET; Schema: public; Owner: -
--

SELECT pg_catalog.setval('public.basic_staff_id_seq', 1, false);


--
-- Name: basic_staffdto_id_seq; Type: SEQUENCE SET; Schema: public; Owner: -
--

SELECT pg_catalog.setval('public.basic_staffdto_id_seq', 1, false);


--
-- Name: basic_staffskill_id_seq; Type: SEQUENCE SET; Schema: public; Owner: -
--

SELECT pg_catalog.setval('public.basic_staffskill_id_seq', 1, false);


--
-- Name: basic_subassembly_id_seq; Type: SEQUENCE SET; Schema: public; Owner: -
--

SELECT pg_catalog.setval('public.basic_subassembly_id_seq', 1, false);


--
-- Name: basic_subassemblyattachment_id_seq; Type: SEQUENCE SET; Schema: public; Owner: -
--

SELECT pg_catalog.setval('public.basic_subassemblyattachment_id_seq', 1, false);


--
-- Name: basic_subassemblylistdto_id_seq; Type: SEQUENCE SET; Schema: public; Owner: -
--

SELECT pg_catalog.setval('public.basic_subassemblylistdto_id_seq', 1, false);


--
-- Name: basic_subassemblytoworkstationhelper_id_seq; Type: SEQUENCE SET; Schema: public; Owner: -
--

SELECT pg_catalog.setval('public.basic_subassemblytoworkstationhelper_id_seq', 1, false);


--
-- Name: basic_substitutecomponent_id_seq; Type: SEQUENCE SET; Schema: public; Owner: -
--

SELECT pg_catalog.setval('public.basic_substitutecomponent_id_seq', 1, false);


--
-- Name: basic_technological_process_rate_number_seq; Type: SEQUENCE SET; Schema: public; Owner: -
--

SELECT pg_catalog.setval('public.basic_technological_process_rate_number_seq', 1, false);


--
-- Name: basic_technologicalprocessrate_id_seq; Type: SEQUENCE SET; Schema: public; Owner: -
--

SELECT pg_catalog.setval('public.basic_technologicalprocessrate_id_seq', 1, false);


--
-- Name: basic_technologicalprocessrateitem_id_seq; Type: SEQUENCE SET; Schema: public; Owner: -
--

SELECT pg_catalog.setval('public.basic_technologicalprocessrateitem_id_seq', 1, false);


--
-- Name: basic_timetableexceptiondto_id_seq; Type: SEQUENCE SET; Schema: public; Owner: -
--

SELECT pg_catalog.setval('public.basic_timetableexceptiondto_id_seq', 1, false);


--
-- Name: basic_timetableexceptionpershiftdto_id_seq; Type: SEQUENCE SET; Schema: public; Owner: -
--

SELECT pg_catalog.setval('public.basic_timetableexceptionpershiftdto_id_seq', 1, false);


--
-- Name: basic_viewedactivity_id_seq; Type: SEQUENCE SET; Schema: public; Owner: -
--

SELECT pg_catalog.setval('public.basic_viewedactivity_id_seq', 1, false);


--
-- Name: basic_workstation_id_seq; Type: SEQUENCE SET; Schema: public; Owner: -
--

SELECT pg_catalog.setval('public.basic_workstation_id_seq', 1, false);


--
-- Name: basic_workstationattachment_id_seq; Type: SEQUENCE SET; Schema: public; Owner: -
--

SELECT pg_catalog.setval('public.basic_workstationattachment_id_seq', 1, false);


--
-- Name: basic_workstationdto_id_seq; Type: SEQUENCE SET; Schema: public; Owner: -
--

SELECT pg_catalog.setval('public.basic_workstationdto_id_seq', 1, false);


--
-- Name: basic_workstationtype_id_seq; Type: SEQUENCE SET; Schema: public; Owner: -
--

SELECT pg_catalog.setval('public.basic_workstationtype_id_seq', 1, false);


--
-- Name: basicproductioncounting_basicproductioncounting_id_seq; Type: SEQUENCE SET; Schema: public; Owner: -
--

SELECT pg_catalog.setval('public.basicproductioncounting_basicproductioncounting_id_seq', 1, false);


--
-- Name: basicproductioncounting_basicproductioncountingdto_id_seq; Type: SEQUENCE SET; Schema: public; Owner: -
--

SELECT pg_catalog.setval('public.basicproductioncounting_basicproductioncountingdto_id_seq', 1, false);


--
-- Name: basicproductioncounting_productioncountingattributevalue_id_seq; Type: SEQUENCE SET; Schema: public; Owner: -
--

SELECT pg_catalog.setval('public.basicproductioncounting_productioncountingattributevalue_id_seq', 1, false);


--
-- Name: basicproductioncounting_productioncountingoperationrun_id_seq; Type: SEQUENCE SET; Schema: public; Owner: -
--

SELECT pg_catalog.setval('public.basicproductioncounting_productioncountingoperationrun_id_seq', 1, false);


--
-- Name: basicproductioncounting_productioncountingquantity_id_seq; Type: SEQUENCE SET; Schema: public; Owner: -
--

SELECT pg_catalog.setval('public.basicproductioncounting_productioncountingquantity_id_seq', 1, false);


--
-- Name: basicproductioncounting_productioncountingquantitychange_id_seq; Type: SEQUENCE SET; Schema: public; Owner: -
--

SELECT pg_catalog.setval('public.basicproductioncounting_productioncountingquantitychange_id_seq', 1, false);


--
-- Name: basicproductioncounting_productioncountingquantitydto_id_seq; Type: SEQUENCE SET; Schema: public; Owner: -
--

SELECT pg_catalog.setval('public.basicproductioncounting_productioncountingquantitydto_id_seq', 1, false);


--
-- Name: basicproductioncounting_productioncountingquantitylistdto_id_se; Type: SEQUENCE SET; Schema: public; Owner: -
--

SELECT pg_catalog.setval('public.basicproductioncounting_productioncountingquantitylistdto_id_se', 1, false);


--
-- Name: basicproductioncounting_productioncountingreplacementhelper_id_; Type: SEQUENCE SET; Schema: public; Owner: -
--

SELECT pg_catalog.setval('public.basicproductioncounting_productioncountingreplacementhelper_id_', 1, false);


--
-- Name: basicproductioncounting_section_id_seq; Type: SEQUENCE SET; Schema: public; Owner: -
--

SELECT pg_catalog.setval('public.basicproductioncounting_section_id_seq', 1, false);


--
-- Name: cdnrcgoodfood_cancelprotocol_id_seq; Type: SEQUENCE SET; Schema: public; Owner: -
--

SELECT pg_catalog.setval('public.cdnrcgoodfood_cancelprotocol_id_seq', 1, false);


--
-- Name: cdnrcgoodfood_highestmasterordernum_id_seq; Type: SEQUENCE SET; Schema: public; Owner: -
--

SELECT pg_catalog.setval('public.cdnrcgoodfood_highestmasterordernum_id_seq', 1, false);


--
-- Name: cmmsmachineparts_action_id_seq; Type: SEQUENCE SET; Schema: public; Owner: -
--

SELECT pg_catalog.setval('public.cmmsmachineparts_action_id_seq', 2, false);


--
-- Name: cmmsmachineparts_actionforplannedevent_id_seq; Type: SEQUENCE SET; Schema: public; Owner: -
--

SELECT pg_catalog.setval('public.cmmsmachineparts_actionforplannedevent_id_seq', 1, false);


--
-- Name: cmmsmachineparts_eventattachment_id_seq; Type: SEQUENCE SET; Schema: public; Owner: -
--

SELECT pg_catalog.setval('public.cmmsmachineparts_eventattachment_id_seq', 1, false);


--
-- Name: cmmsmachineparts_machinepartattachment_id_seq; Type: SEQUENCE SET; Schema: public; Owner: -
--

SELECT pg_catalog.setval('public.cmmsmachineparts_machinepartattachment_id_seq', 1, false);


--
-- Name: cmmsmachineparts_machinepartforevent_id_seq; Type: SEQUENCE SET; Schema: public; Owner: -
--

SELECT pg_catalog.setval('public.cmmsmachineparts_machinepartforevent_id_seq', 1, false);


--
-- Name: cmmsmachineparts_maintenanceevent_id_seq; Type: SEQUENCE SET; Schema: public; Owner: -
--

SELECT pg_catalog.setval('public.cmmsmachineparts_maintenanceevent_id_seq', 1, false);


--
-- Name: cmmsmachineparts_maintenanceevent_number_seq; Type: SEQUENCE SET; Schema: public; Owner: -
--

SELECT pg_catalog.setval('public.cmmsmachineparts_maintenanceevent_number_seq', 1, false);


--
-- Name: cmmsmachineparts_maintenanceeventcontext_id_seq; Type: SEQUENCE SET; Schema: public; Owner: -
--

SELECT pg_catalog.setval('public.cmmsmachineparts_maintenanceeventcontext_id_seq', 1, false);


--
-- Name: cmmsmachineparts_maintenanceeventlistdto_id_seq; Type: SEQUENCE SET; Schema: public; Owner: -
--

SELECT pg_catalog.setval('public.cmmsmachineparts_maintenanceeventlistdto_id_seq', 1, false);


--
-- Name: cmmsmachineparts_maintenanceeventstatechange_id_seq; Type: SEQUENCE SET; Schema: public; Owner: -
--

SELECT pg_catalog.setval('public.cmmsmachineparts_maintenanceeventstatechange_id_seq', 1, false);


--
-- Name: cmmsmachineparts_maintenanceeventxlshelper_id_seq; Type: SEQUENCE SET; Schema: public; Owner: -
--

SELECT pg_catalog.setval('public.cmmsmachineparts_maintenanceeventxlshelper_id_seq', 1, false);


--
-- Name: cmmsmachineparts_operationtool_id_seq; Type: SEQUENCE SET; Schema: public; Owner: -
--

SELECT pg_catalog.setval('public.cmmsmachineparts_operationtool_id_seq', 1, false);


--
-- Name: cmmsmachineparts_orderstoolrequirement_id_seq; Type: SEQUENCE SET; Schema: public; Owner: -
--

SELECT pg_catalog.setval('public.cmmsmachineparts_orderstoolrequirement_id_seq', 1, false);


--
-- Name: cmmsmachineparts_orderstoolrequirement_number_seq; Type: SEQUENCE SET; Schema: public; Owner: -
--

SELECT pg_catalog.setval('public.cmmsmachineparts_orderstoolrequirement_number_seq', 1, false);


--
-- Name: cmmsmachineparts_orderstoolrequirementtool_id_seq; Type: SEQUENCE SET; Schema: public; Owner: -
--

SELECT pg_catalog.setval('public.cmmsmachineparts_orderstoolrequirementtool_id_seq', 1, false);


--
-- Name: cmmsmachineparts_plannedevent_id_seq; Type: SEQUENCE SET; Schema: public; Owner: -
--

SELECT pg_catalog.setval('public.cmmsmachineparts_plannedevent_id_seq', 1, false);


--
-- Name: cmmsmachineparts_plannedeventattachment_id_seq; Type: SEQUENCE SET; Schema: public; Owner: -
--

SELECT pg_catalog.setval('public.cmmsmachineparts_plannedeventattachment_id_seq', 1, false);


--
-- Name: cmmsmachineparts_plannedeventcontext_id_seq; Type: SEQUENCE SET; Schema: public; Owner: -
--

SELECT pg_catalog.setval('public.cmmsmachineparts_plannedeventcontext_id_seq', 1, false);


--
-- Name: cmmsmachineparts_plannedeventlistdto_id_seq; Type: SEQUENCE SET; Schema: public; Owner: -
--

SELECT pg_catalog.setval('public.cmmsmachineparts_plannedeventlistdto_id_seq', 1, false);


--
-- Name: cmmsmachineparts_plannedeventrealization_id_seq; Type: SEQUENCE SET; Schema: public; Owner: -
--

SELECT pg_catalog.setval('public.cmmsmachineparts_plannedeventrealization_id_seq', 1, false);


--
-- Name: cmmsmachineparts_plannedeventstatechange_id_seq; Type: SEQUENCE SET; Schema: public; Owner: -
--

SELECT pg_catalog.setval('public.cmmsmachineparts_plannedeventstatechange_id_seq', 1, false);


--
-- Name: cmmsmachineparts_plannedeventxlshelper_id_seq; Type: SEQUENCE SET; Schema: public; Owner: -
--

SELECT pg_catalog.setval('public.cmmsmachineparts_plannedeventxlshelper_id_seq', 1, false);


--
-- Name: cmmsmachineparts_sourcecost_id_seq; Type: SEQUENCE SET; Schema: public; Owner: -
--

SELECT pg_catalog.setval('public.cmmsmachineparts_sourcecost_id_seq', 1, false);


--
-- Name: cmmsmachineparts_sourcecostreportfilter_id_seq; Type: SEQUENCE SET; Schema: public; Owner: -
--

SELECT pg_catalog.setval('public.cmmsmachineparts_sourcecostreportfilter_id_seq', 1, false);


--
-- Name: cmmsmachineparts_staffworktime_id_seq; Type: SEQUENCE SET; Schema: public; Owner: -
--

SELECT pg_catalog.setval('public.cmmsmachineparts_staffworktime_id_seq', 1, false);


--
-- Name: cmmsmachineparts_technologyoperationtool_id_seq; Type: SEQUENCE SET; Schema: public; Owner: -
--

SELECT pg_catalog.setval('public.cmmsmachineparts_technologyoperationtool_id_seq', 1, false);


--
-- Name: cmmsmachineparts_timeusagereportfilter_id_seq; Type: SEQUENCE SET; Schema: public; Owner: -
--

SELECT pg_catalog.setval('public.cmmsmachineparts_timeusagereportfilter_id_seq', 1, false);


--
-- Name: cmmsmachineparts_tool_id_seq; Type: SEQUENCE SET; Schema: public; Owner: -
--

SELECT pg_catalog.setval('public.cmmsmachineparts_tool_id_seq', 1, false);


--
-- Name: cmmsmachineparts_toolattachment_id_seq; Type: SEQUENCE SET; Schema: public; Owner: -
--

SELECT pg_catalog.setval('public.cmmsmachineparts_toolattachment_id_seq', 1, false);


--
-- Name: cmmsmachineparts_worktimeforuserdto_id_seq; Type: SEQUENCE SET; Schema: public; Owner: -
--

SELECT pg_catalog.setval('public.cmmsmachineparts_worktimeforuserdto_id_seq', 1, false);


--
-- Name: cmmsscheduler_actionforrecurringevent_id_seq; Type: SEQUENCE SET; Schema: public; Owner: -
--

SELECT pg_catalog.setval('public.cmmsscheduler_actionforrecurringevent_id_seq', 1, false);


--
-- Name: cmmsscheduler_recurringevent_id_seq; Type: SEQUENCE SET; Schema: public; Owner: -
--

SELECT pg_catalog.setval('public.cmmsscheduler_recurringevent_id_seq', 1, false);


--
-- Name: cmmsscheduler_recurringeventattachment_id_seq; Type: SEQUENCE SET; Schema: public; Owner: -
--

SELECT pg_catalog.setval('public.cmmsscheduler_recurringeventattachment_id_seq', 1, false);


--
-- Name: cmmsscheduler_recurringeventcontext_id_seq; Type: SEQUENCE SET; Schema: public; Owner: -
--

SELECT pg_catalog.setval('public.cmmsscheduler_recurringeventcontext_id_seq', 1, false);


--
-- Name: cmmsscheduler_recurringeventstatechange_id_seq; Type: SEQUENCE SET; Schema: public; Owner: -
--

SELECT pg_catalog.setval('public.cmmsscheduler_recurringeventstatechange_id_seq', 1, false);


--
-- Name: costcalculation_additionaldirectcost_id_seq; Type: SEQUENCE SET; Schema: public; Owner: -
--

SELECT pg_catalog.setval('public.costcalculation_additionaldirectcost_id_seq', 1, false);


--
-- Name: costcalculation_additionaldirectcostitem_id_seq; Type: SEQUENCE SET; Schema: public; Owner: -
--

SELECT pg_catalog.setval('public.costcalculation_additionaldirectcostitem_id_seq', 1, false);


--
-- Name: costcalculation_calculationresult_id_seq; Type: SEQUENCE SET; Schema: public; Owner: -
--

SELECT pg_catalog.setval('public.costcalculation_calculationresult_id_seq', 1, false);


--
-- Name: costcalculation_componentcost_id_seq; Type: SEQUENCE SET; Schema: public; Owner: -
--

SELECT pg_catalog.setval('public.costcalculation_componentcost_id_seq', 1, false);


--
-- Name: costcalculation_costcalculation_id_seq; Type: SEQUENCE SET; Schema: public; Owner: -
--

SELECT pg_catalog.setval('public.costcalculation_costcalculation_id_seq', 1, false);


--
-- Name: costcalculation_orderadditionaldirectcost_id_seq; Type: SEQUENCE SET; Schema: public; Owner: -
--

SELECT pg_catalog.setval('public.costcalculation_orderadditionaldirectcost_id_seq', 1, false);


--
-- Name: costcalculation_standard_labor_cost_number_seq; Type: SEQUENCE SET; Schema: public; Owner: -
--

SELECT pg_catalog.setval('public.costcalculation_standard_labor_cost_number_seq', 1, false);


--
-- Name: costcalculation_standardlaborcost_id_seq; Type: SEQUENCE SET; Schema: public; Owner: -
--

SELECT pg_catalog.setval('public.costcalculation_standardlaborcost_id_seq', 1, false);


--
-- Name: costnormsformaterials_technologyinstoperproductincomp_id_seq; Type: SEQUENCE SET; Schema: public; Owner: -
--

SELECT pg_catalog.setval('public.costnormsformaterials_technologyinstoperproductincomp_id_seq', 1, false);


--
-- Name: costnormsformaterials_technologyinstoperproductincompdto_id_seq; Type: SEQUENCE SET; Schema: public; Owner: -
--

SELECT pg_catalog.setval('public.costnormsformaterials_technologyinstoperproductincompdto_id_seq', 1, false);


--
-- Name: costnormsforoperation_calculationoperationcomponent_id_seq; Type: SEQUENCE SET; Schema: public; Owner: -
--

SELECT pg_catalog.setval('public.costnormsforoperation_calculationoperationcomponent_id_seq', 1, false);


--
-- Name: deliveries_columnfordeliveries_id_seq; Type: SEQUENCE SET; Schema: public; Owner: -
--

SELECT pg_catalog.setval('public.deliveries_columnfordeliveries_id_seq', 14, false);


--
-- Name: deliveries_columnfororders_id_seq; Type: SEQUENCE SET; Schema: public; Owner: -
--

SELECT pg_catalog.setval('public.deliveries_columnfororders_id_seq', 13, false);


--
-- Name: deliveries_companyproduct_id_seq; Type: SEQUENCE SET; Schema: public; Owner: -
--

SELECT pg_catalog.setval('public.deliveries_companyproduct_id_seq', 1, false);


--
-- Name: deliveries_deliveredpackage_id_seq; Type: SEQUENCE SET; Schema: public; Owner: -
--

SELECT pg_catalog.setval('public.deliveries_deliveredpackage_id_seq', 1, false);


--
-- Name: deliveries_deliveredproduct_id_seq; Type: SEQUENCE SET; Schema: public; Owner: -
--

SELECT pg_catalog.setval('public.deliveries_deliveredproduct_id_seq', 1, false);


--
-- Name: deliveries_deliveredproductattributeval_id_seq; Type: SEQUENCE SET; Schema: public; Owner: -
--

SELECT pg_catalog.setval('public.deliveries_deliveredproductattributeval_id_seq', 1, false);


--
-- Name: deliveries_deliveredproductdto_id_seq; Type: SEQUENCE SET; Schema: public; Owner: -
--

SELECT pg_catalog.setval('public.deliveries_deliveredproductdto_id_seq', 1, false);


--
-- Name: deliveries_deliveredproductmulti_id_seq; Type: SEQUENCE SET; Schema: public; Owner: -
--

SELECT pg_catalog.setval('public.deliveries_deliveredproductmulti_id_seq', 1, false);


--
-- Name: deliveries_deliveredproductmultiposition_id_seq; Type: SEQUENCE SET; Schema: public; Owner: -
--

SELECT pg_catalog.setval('public.deliveries_deliveredproductmultiposition_id_seq', 1, false);


--
-- Name: deliveries_delivery_id_seq; Type: SEQUENCE SET; Schema: public; Owner: -
--

SELECT pg_catalog.setval('public.deliveries_delivery_id_seq', 1, false);


--
-- Name: deliveries_deliveryattachment_id_seq; Type: SEQUENCE SET; Schema: public; Owner: -
--

SELECT pg_catalog.setval('public.deliveries_deliveryattachment_id_seq', 1, false);


--
-- Name: deliveries_deliverybypallettypereport_id_seq; Type: SEQUENCE SET; Schema: public; Owner: -
--

SELECT pg_catalog.setval('public.deliveries_deliverybypallettypereport_id_seq', 1, false);


--
-- Name: deliveries_deliverystatechange_id_seq; Type: SEQUENCE SET; Schema: public; Owner: -
--

SELECT pg_catalog.setval('public.deliveries_deliverystatechange_id_seq', 1, false);


--
-- Name: deliveries_orderedproduct_id_seq; Type: SEQUENCE SET; Schema: public; Owner: -
--

SELECT pg_catalog.setval('public.deliveries_orderedproduct_id_seq', 1, false);


--
-- Name: deliveries_orderedproductdto_id_seq; Type: SEQUENCE SET; Schema: public; Owner: -
--

SELECT pg_catalog.setval('public.deliveries_orderedproductdto_id_seq', 1, false);


--
-- Name: deliveries_orderedproductlistdto_id_seq; Type: SEQUENCE SET; Schema: public; Owner: -
--

SELECT pg_catalog.setval('public.deliveries_orderedproductlistdto_id_seq', 1, false);


--
-- Name: deliveries_parameterdeliveryordercolumn_id_seq; Type: SEQUENCE SET; Schema: public; Owner: -
--

SELECT pg_catalog.setval('public.deliveries_parameterdeliveryordercolumn_id_seq', 13, false);


--
-- Name: emailnotifications_staffnotification_id_seq; Type: SEQUENCE SET; Schema: public; Owner: -
--

SELECT pg_catalog.setval('public.emailnotifications_staffnotification_id_seq', 1, false);


--
-- Name: goodfood_confectionadditionalinputproduct_id_seq; Type: SEQUENCE SET; Schema: public; Owner: -
--

SELECT pg_catalog.setval('public.goodfood_confectionadditionalinputproduct_id_seq', 1, false);


--
-- Name: goodfood_confectioncontext_id_seq; Type: SEQUENCE SET; Schema: public; Owner: -
--

SELECT pg_catalog.setval('public.goodfood_confectioncontext_id_seq', 1, false);


--
-- Name: goodfood_confectionfilm_id_seq; Type: SEQUENCE SET; Schema: public; Owner: -
--

SELECT pg_catalog.setval('public.goodfood_confectionfilm_id_seq', 1, false);


--
-- Name: goodfood_confectionfilmproduct_id_seq; Type: SEQUENCE SET; Schema: public; Owner: -
--

SELECT pg_catalog.setval('public.goodfood_confectionfilmproduct_id_seq', 1, false);


--
-- Name: goodfood_confectionfilmproductentry_id_seq; Type: SEQUENCE SET; Schema: public; Owner: -
--

SELECT pg_catalog.setval('public.goodfood_confectionfilmproductentry_id_seq', 1, false);


--
-- Name: goodfood_confectioninputproduct_id_seq; Type: SEQUENCE SET; Schema: public; Owner: -
--

SELECT pg_catalog.setval('public.goodfood_confectioninputproduct_id_seq', 1, false);


--
-- Name: goodfood_confectionprotocol_externalnumber_seq; Type: SEQUENCE SET; Schema: public; Owner: -
--

SELECT pg_catalog.setval('public.goodfood_confectionprotocol_externalnumber_seq', 1, false);


--
-- Name: goodfood_confectionprotocol_id_seq; Type: SEQUENCE SET; Schema: public; Owner: -
--

SELECT pg_catalog.setval('public.goodfood_confectionprotocol_id_seq', 1, false);


--
-- Name: goodfood_confectionprotocolcorrect_id_seq; Type: SEQUENCE SET; Schema: public; Owner: -
--

SELECT pg_catalog.setval('public.goodfood_confectionprotocolcorrect_id_seq', 1, false);


--
-- Name: goodfood_confectionprotocoldto_id_seq; Type: SEQUENCE SET; Schema: public; Owner: -
--

SELECT pg_catalog.setval('public.goodfood_confectionprotocoldto_id_seq', 1, false);


--
-- Name: goodfood_confectionprotocolstatechange_id_seq; Type: SEQUENCE SET; Schema: public; Owner: -
--

SELECT pg_catalog.setval('public.goodfood_confectionprotocolstatechange_id_seq', 1, false);


--
-- Name: goodfood_confectionremainderinputproduct_id_seq; Type: SEQUENCE SET; Schema: public; Owner: -
--

SELECT pg_catalog.setval('public.goodfood_confectionremainderinputproduct_id_seq', 1, false);


--
-- Name: goodfood_confectionstaff_id_seq; Type: SEQUENCE SET; Schema: public; Owner: -
--

SELECT pg_catalog.setval('public.goodfood_confectionstaff_id_seq', 1, false);


--
-- Name: goodfood_eventlog_id_seq; Type: SEQUENCE SET; Schema: public; Owner: -
--

SELECT pg_catalog.setval('public.goodfood_eventlog_id_seq', 1, false);


--
-- Name: goodfood_extrusionaddedmixentry_id_seq; Type: SEQUENCE SET; Schema: public; Owner: -
--

SELECT pg_catalog.setval('public.goodfood_extrusionaddedmixentry_id_seq', 1, false);


--
-- Name: goodfood_extrusionaddedmixingredient_id_seq; Type: SEQUENCE SET; Schema: public; Owner: -
--

SELECT pg_catalog.setval('public.goodfood_extrusionaddedmixingredient_id_seq', 1, false);


--
-- Name: goodfood_extrusionbatchingredientdto_id_seq; Type: SEQUENCE SET; Schema: public; Owner: -
--

SELECT pg_catalog.setval('public.goodfood_extrusionbatchingredientdto_id_seq', 1, false);


--
-- Name: goodfood_extrusioncontext_id_seq; Type: SEQUENCE SET; Schema: public; Owner: -
--

SELECT pg_catalog.setval('public.goodfood_extrusioncontext_id_seq', 1, false);


--
-- Name: goodfood_extrusionmix_id_seq; Type: SEQUENCE SET; Schema: public; Owner: -
--

SELECT pg_catalog.setval('public.goodfood_extrusionmix_id_seq', 1, false);


--
-- Name: goodfood_extrusionmix_number_seq; Type: SEQUENCE SET; Schema: public; Owner: -
--

SELECT pg_catalog.setval('public.goodfood_extrusionmix_number_seq', 1, false);


--
-- Name: goodfood_extrusionmixingredient_id_seq; Type: SEQUENCE SET; Schema: public; Owner: -
--

SELECT pg_catalog.setval('public.goodfood_extrusionmixingredient_id_seq', 1, false);


--
-- Name: goodfood_extrusionpouring_id_seq; Type: SEQUENCE SET; Schema: public; Owner: -
--

SELECT pg_catalog.setval('public.goodfood_extrusionpouring_id_seq', 1, false);


--
-- Name: goodfood_extrusionpouringdto_id_seq; Type: SEQUENCE SET; Schema: public; Owner: -
--

SELECT pg_catalog.setval('public.goodfood_extrusionpouringdto_id_seq', 1, false);


--
-- Name: goodfood_extrusionpouringingredient_id_seq; Type: SEQUENCE SET; Schema: public; Owner: -
--

SELECT pg_catalog.setval('public.goodfood_extrusionpouringingredient_id_seq', 1, false);


--
-- Name: goodfood_extrusionpouringmix_id_seq; Type: SEQUENCE SET; Schema: public; Owner: -
--

SELECT pg_catalog.setval('public.goodfood_extrusionpouringmix_id_seq', 1, false);


--
-- Name: goodfood_extrusionprotocol_externalnumber_seq; Type: SEQUENCE SET; Schema: public; Owner: -
--

SELECT pg_catalog.setval('public.goodfood_extrusionprotocol_externalnumber_seq', 1, false);


--
-- Name: goodfood_extrusionprotocol_id_seq; Type: SEQUENCE SET; Schema: public; Owner: -
--

SELECT pg_catalog.setval('public.goodfood_extrusionprotocol_id_seq', 1, false);


--
-- Name: goodfood_extrusionprotocolcorrect_id_seq; Type: SEQUENCE SET; Schema: public; Owner: -
--

SELECT pg_catalog.setval('public.goodfood_extrusionprotocolcorrect_id_seq', 1, false);


--
-- Name: goodfood_extrusionprotocoldto_id_seq; Type: SEQUENCE SET; Schema: public; Owner: -
--

SELECT pg_catalog.setval('public.goodfood_extrusionprotocoldto_id_seq', 1, false);


--
-- Name: goodfood_extrusionprotocolstatechange_id_seq; Type: SEQUENCE SET; Schema: public; Owner: -
--

SELECT pg_catalog.setval('public.goodfood_extrusionprotocolstatechange_id_seq', 1, false);


--
-- Name: goodfood_extrusionsouse_id_seq; Type: SEQUENCE SET; Schema: public; Owner: -
--

SELECT pg_catalog.setval('public.goodfood_extrusionsouse_id_seq', 1, false);


--
-- Name: goodfood_extrusiontakenoffmixentry_id_seq; Type: SEQUENCE SET; Schema: public; Owner: -
--

SELECT pg_catalog.setval('public.goodfood_extrusiontakenoffmixentry_id_seq', 1, false);


--
-- Name: goodfood_extrusiontakenoffmixingredient_id_seq; Type: SEQUENCE SET; Schema: public; Owner: -
--

SELECT pg_catalog.setval('public.goodfood_extrusiontakenoffmixingredient_id_seq', 1, false);


--
-- Name: goodfood_extrusionusedbatchingredientdto_id_seq; Type: SEQUENCE SET; Schema: public; Owner: -
--

SELECT pg_catalog.setval('public.goodfood_extrusionusedbatchingredientdto_id_seq', 1, false);


--
-- Name: goodfood_goodfoodreport_id_seq; Type: SEQUENCE SET; Schema: public; Owner: -
--

SELECT pg_catalog.setval('public.goodfood_goodfoodreport_id_seq', 1, false);


--
-- Name: goodfood_labeldto_id_seq; Type: SEQUENCE SET; Schema: public; Owner: -
--

SELECT pg_catalog.setval('public.goodfood_labeldto_id_seq', 1, false);


--
-- Name: goodfood_pallet_externalnumber_seq; Type: SEQUENCE SET; Schema: public; Owner: -
--

SELECT pg_catalog.setval('public.goodfood_pallet_externalnumber_seq', 1, false);


--
-- Name: goodfood_pallet_id_seq; Type: SEQUENCE SET; Schema: public; Owner: -
--

SELECT pg_catalog.setval('public.goodfood_pallet_id_seq', 1, false);


--
-- Name: goodfood_palletactivedto_id_seq; Type: SEQUENCE SET; Schema: public; Owner: -
--

SELECT pg_catalog.setval('public.goodfood_palletactivedto_id_seq', 1, false);


--
-- Name: goodfood_palletcontext_id_seq; Type: SEQUENCE SET; Schema: public; Owner: -
--

SELECT pg_catalog.setval('public.goodfood_palletcontext_id_seq', 1, false);


--
-- Name: goodfood_palletdto_id_seq; Type: SEQUENCE SET; Schema: public; Owner: -
--

SELECT pg_catalog.setval('public.goodfood_palletdto_id_seq', 1, false);


--
-- Name: goodfood_palletlabel_id_seq; Type: SEQUENCE SET; Schema: public; Owner: -
--

SELECT pg_catalog.setval('public.goodfood_palletlabel_id_seq', 1, false);


--
-- Name: goodfood_palletlabelactivedto_id_seq; Type: SEQUENCE SET; Schema: public; Owner: -
--

SELECT pg_catalog.setval('public.goodfood_palletlabelactivedto_id_seq', 1, false);


--
-- Name: goodfood_palletlabeldto_id_seq; Type: SEQUENCE SET; Schema: public; Owner: -
--

SELECT pg_catalog.setval('public.goodfood_palletlabeldto_id_seq', 1, false);


--
-- Name: goodfood_palletlabelstatechange_id_seq; Type: SEQUENCE SET; Schema: public; Owner: -
--

SELECT pg_catalog.setval('public.goodfood_palletlabelstatechange_id_seq', 1, false);


--
-- Name: goodfood_palletstatechange_id_seq; Type: SEQUENCE SET; Schema: public; Owner: -
--

SELECT pg_catalog.setval('public.goodfood_palletstatechange_id_seq', 1, false);


--
-- Name: goodfood_palnumber_id_seq; Type: SEQUENCE SET; Schema: public; Owner: -
--

SELECT pg_catalog.setval('public.goodfood_palnumber_id_seq', 1, false);


--
-- Name: goodfood_printedlabel_id_seq; Type: SEQUENCE SET; Schema: public; Owner: -
--

SELECT pg_catalog.setval('public.goodfood_printedlabel_id_seq', 1, false);


--
-- Name: goodfood_printedlabeldto_id_seq; Type: SEQUENCE SET; Schema: public; Owner: -
--

SELECT pg_catalog.setval('public.goodfood_printedlabeldto_id_seq', 1, false);


--
-- Name: goodfood_ssccnumber_id_seq; Type: SEQUENCE SET; Schema: public; Owner: -
--

SELECT pg_catalog.setval('public.goodfood_ssccnumber_id_seq', 1, false);


--
-- Name: hibernate_sequence; Type: SEQUENCE SET; Schema: public; Owner: -
--

SELECT pg_catalog.setval('public.hibernate_sequence', 1, false);


--
-- Name: integrationbartender_printedcartonlabeldto_id_seq; Type: SEQUENCE SET; Schema: public; Owner: -
--

SELECT pg_catalog.setval('public.integrationbartender_printedcartonlabeldto_id_seq', 1, false);


--
-- Name: integrationbartender_printedpalletlabeldto_id_seq; Type: SEQUENCE SET; Schema: public; Owner: -
--

SELECT pg_catalog.setval('public.integrationbartender_printedpalletlabeldto_id_seq', 1, false);


--
-- Name: integrationbartender_printer_id_seq; Type: SEQUENCE SET; Schema: public; Owner: -
--

SELECT pg_catalog.setval('public.integrationbartender_printer_id_seq', 1, false);


--
-- Name: integrationbartender_printlabelshelper_id_seq; Type: SEQUENCE SET; Schema: public; Owner: -
--

SELECT pg_catalog.setval('public.integrationbartender_printlabelshelper_id_seq', 1, false);


--
-- Name: integrationbartender_sendtoprint_id_seq; Type: SEQUENCE SET; Schema: public; Owner: -
--

SELECT pg_catalog.setval('public.integrationbartender_sendtoprint_id_seq', 1, false);


--
-- Name: integrationbaselinker_baselinkerparameters_id_seq; Type: SEQUENCE SET; Schema: public; Owner: -
--

SELECT pg_catalog.setval('public.integrationbaselinker_baselinkerparameters_id_seq', 1, false);


--
-- Name: integrationbaselinker_statusesfordocument_id_seq; Type: SEQUENCE SET; Schema: public; Owner: -
--

SELECT pg_catalog.setval('public.integrationbaselinker_statusesfordocument_id_seq', 1, false);


--
-- Name: integrationbaselinker_statusesformasterorder_id_seq; Type: SEQUENCE SET; Schema: public; Owner: -
--

SELECT pg_catalog.setval('public.integrationbaselinker_statusesformasterorder_id_seq', 1, false);


--
-- Name: integrationscales_productionlineforscale_id_seq; Type: SEQUENCE SET; Schema: public; Owner: -
--

SELECT pg_catalog.setval('public.integrationscales_productionlineforscale_id_seq', 1, false);


--
-- Name: integrationscales_scale_id_seq; Type: SEQUENCE SET; Schema: public; Owner: -
--

SELECT pg_catalog.setval('public.integrationscales_scale_id_seq', 1, false);


--
-- Name: integrationscales_scaledto_id_seq; Type: SEQUENCE SET; Schema: public; Owner: -
--

SELECT pg_catalog.setval('public.integrationscales_scaledto_id_seq', 1, false);


--
-- Name: linechangeovernorms_groupsview_id_seq; Type: SEQUENCE SET; Schema: public; Owner: -
--

SELECT pg_catalog.setval('public.linechangeovernorms_groupsview_id_seq', 1, false);


--
-- Name: linechangeovernorms_linechangeovernorms_id_seq; Type: SEQUENCE SET; Schema: public; Owner: -
--

SELECT pg_catalog.setval('public.linechangeovernorms_linechangeovernorms_id_seq', 1, false);


--
-- Name: linechangeovernorms_normflatview_id_seq; Type: SEQUENCE SET; Schema: public; Owner: -
--

SELECT pg_catalog.setval('public.linechangeovernorms_normflatview_id_seq', 1, false);


--
-- Name: linechangeovernorms_ordersnormview_id_seq; Type: SEQUENCE SET; Schema: public; Owner: -
--

SELECT pg_catalog.setval('public.linechangeovernorms_ordersnormview_id_seq', 1, false);


--
-- Name: linechangeovernormsfororders_linechangeoverfororderdto_id_seq; Type: SEQUENCE SET; Schema: public; Owner: -
--

SELECT pg_catalog.setval('public.linechangeovernormsfororders_linechangeoverfororderdto_id_seq', 1, false);


--
-- Name: linechangeovernormsfororders_linechangeoverfororderdtohelper_id; Type: SEQUENCE SET; Schema: public; Owner: -
--

SELECT pg_catalog.setval('public.linechangeovernormsfororders_linechangeoverfororderdtohelper_id', 1, false);


--
-- Name: masterorders_generatingordershelper_id_seq; Type: SEQUENCE SET; Schema: public; Owner: -
--

SELECT pg_catalog.setval('public.masterorders_generatingordershelper_id_seq', 1, false);


--
-- Name: masterorders_masterorder_id_seq; Type: SEQUENCE SET; Schema: public; Owner: -
--

SELECT pg_catalog.setval('public.masterorders_masterorder_id_seq', 1, false);


--
-- Name: masterorders_masterorderdefinition_id_seq; Type: SEQUENCE SET; Schema: public; Owner: -
--

SELECT pg_catalog.setval('public.masterorders_masterorderdefinition_id_seq', 1, false);


--
-- Name: masterorders_masterorderdto_id_seq; Type: SEQUENCE SET; Schema: public; Owner: -
--

SELECT pg_catalog.setval('public.masterorders_masterorderdto_id_seq', 1, false);


--
-- Name: masterorders_masterorderposition_manyproducts_id_seq; Type: SEQUENCE SET; Schema: public; Owner: -
--

SELECT pg_catalog.setval('public.masterorders_masterorderposition_manyproducts_id_seq', 1, false);


--
-- Name: masterorders_masterorderposition_oneproduct_id_seq; Type: SEQUENCE SET; Schema: public; Owner: -
--

SELECT pg_catalog.setval('public.masterorders_masterorderposition_oneproduct_id_seq', 1, false);


--
-- Name: masterorders_masterorderpositiondto_id_seq; Type: SEQUENCE SET; Schema: public; Owner: -
--

SELECT pg_catalog.setval('public.masterorders_masterorderpositiondto_id_seq', 1, false);


--
-- Name: masterorders_masterorderproduct_id_seq; Type: SEQUENCE SET; Schema: public; Owner: -
--

SELECT pg_catalog.setval('public.masterorders_masterorderproduct_id_seq', 1, false);


--
-- Name: masterorders_masterorderproductattrvalue_id_seq; Type: SEQUENCE SET; Schema: public; Owner: -
--

SELECT pg_catalog.setval('public.masterorders_masterorderproductattrvalue_id_seq', 1, false);


--
-- Name: masterorders_masterordersmaterialrequirement_id_seq; Type: SEQUENCE SET; Schema: public; Owner: -
--

SELECT pg_catalog.setval('public.masterorders_masterordersmaterialrequirement_id_seq', 1, false);


--
-- Name: masterorders_masterordersmaterialrequirement_number_seq; Type: SEQUENCE SET; Schema: public; Owner: -
--

SELECT pg_catalog.setval('public.masterorders_masterordersmaterialrequirement_number_seq', 1, false);


--
-- Name: masterorders_masterordersmaterialrequirementproduct_id_seq; Type: SEQUENCE SET; Schema: public; Owner: -
--

SELECT pg_catalog.setval('public.masterorders_masterordersmaterialrequirementproduct_id_seq', 1, false);


--
-- Name: masterorders_orderedproductconfigurator_id_seq; Type: SEQUENCE SET; Schema: public; Owner: -
--

SELECT pg_catalog.setval('public.masterorders_orderedproductconfigurator_id_seq', 1, false);


--
-- Name: masterorders_orderedproductconfiguratorattribute_id_seq; Type: SEQUENCE SET; Schema: public; Owner: -
--

SELECT pg_catalog.setval('public.masterorders_orderedproductconfiguratorattribute_id_seq', 1, false);


--
-- Name: masterorders_ordersgenerationhelper_id_seq; Type: SEQUENCE SET; Schema: public; Owner: -
--

SELECT pg_catalog.setval('public.masterorders_ordersgenerationhelper_id_seq', 1, false);


--
-- Name: masterorders_outsourceprocessingcomponenthelper_id_seq; Type: SEQUENCE SET; Schema: public; Owner: -
--

SELECT pg_catalog.setval('public.masterorders_outsourceprocessingcomponenthelper_id_seq', 1, false);


--
-- Name: masterorders_position_deliveryproductquantityhelper_id_seq; Type: SEQUENCE SET; Schema: public; Owner: -
--

SELECT pg_catalog.setval('public.masterorders_position_deliveryproductquantityhelper_id_seq', 1, false);


--
-- Name: masterorders_position_warehousestatehelper_id_seq; Type: SEQUENCE SET; Schema: public; Owner: -
--

SELECT pg_catalog.setval('public.masterorders_position_warehousestatehelper_id_seq', 1, false);


--
-- Name: masterorders_priceslist_id_seq; Type: SEQUENCE SET; Schema: public; Owner: -
--

SELECT pg_catalog.setval('public.masterorders_priceslist_id_seq', 1, false);


--
-- Name: masterorders_productsbyattributeentryhelper_id_seq; Type: SEQUENCE SET; Schema: public; Owner: -
--

SELECT pg_catalog.setval('public.masterorders_productsbyattributeentryhelper_id_seq', 1, false);


--
-- Name: masterorders_productsbyattributehelper_id_seq; Type: SEQUENCE SET; Schema: public; Owner: -
--

SELECT pg_catalog.setval('public.masterorders_productsbyattributehelper_id_seq', 1, false);


--
-- Name: masterorders_productsbysizeentryhelper_id_seq; Type: SEQUENCE SET; Schema: public; Owner: -
--

SELECT pg_catalog.setval('public.masterorders_productsbysizeentryhelper_id_seq', 1, false);


--
-- Name: masterorders_productsbysizehelper_id_seq; Type: SEQUENCE SET; Schema: public; Owner: -
--

SELECT pg_catalog.setval('public.masterorders_productsbysizehelper_id_seq', 1, false);


--
-- Name: masterorders_sales_plan_number_seq; Type: SEQUENCE SET; Schema: public; Owner: -
--

SELECT pg_catalog.setval('public.masterorders_sales_plan_number_seq', 1, false);


--
-- Name: masterorders_salesplan_id_seq; Type: SEQUENCE SET; Schema: public; Owner: -
--

SELECT pg_catalog.setval('public.masterorders_salesplan_id_seq', 1, false);


--
-- Name: masterorders_salesplanmaterialrequirement_id_seq; Type: SEQUENCE SET; Schema: public; Owner: -
--

SELECT pg_catalog.setval('public.masterorders_salesplanmaterialrequirement_id_seq', 1, false);


--
-- Name: masterorders_salesplanmaterialrequirement_number_seq; Type: SEQUENCE SET; Schema: public; Owner: -
--

SELECT pg_catalog.setval('public.masterorders_salesplanmaterialrequirement_number_seq', 1, false);


--
-- Name: masterorders_salesplanmaterialrequirementproduct_id_seq; Type: SEQUENCE SET; Schema: public; Owner: -
--

SELECT pg_catalog.setval('public.masterorders_salesplanmaterialrequirementproduct_id_seq', 1, false);


--
-- Name: masterorders_salesplanordersgroupentryhelper_id_seq; Type: SEQUENCE SET; Schema: public; Owner: -
--

SELECT pg_catalog.setval('public.masterorders_salesplanordersgroupentryhelper_id_seq', 1, false);


--
-- Name: masterorders_salesplanordersgrouphelper_id_seq; Type: SEQUENCE SET; Schema: public; Owner: -
--

SELECT pg_catalog.setval('public.masterorders_salesplanordersgrouphelper_id_seq', 1, false);


--
-- Name: masterorders_salesplanproduct_id_seq; Type: SEQUENCE SET; Schema: public; Owner: -
--

SELECT pg_catalog.setval('public.masterorders_salesplanproduct_id_seq', 1, false);


--
-- Name: masterorders_salesplanproductdto_id_seq; Type: SEQUENCE SET; Schema: public; Owner: -
--

SELECT pg_catalog.setval('public.masterorders_salesplanproductdto_id_seq', 1, false);


--
-- Name: masterorders_salesplanstatechange_id_seq; Type: SEQUENCE SET; Schema: public; Owner: -
--

SELECT pg_catalog.setval('public.masterorders_salesplanstatechange_id_seq', 1, false);


--
-- Name: masterorders_salesvolume_id_seq; Type: SEQUENCE SET; Schema: public; Owner: -
--

SELECT pg_catalog.setval('public.masterorders_salesvolume_id_seq', 1, false);


--
-- Name: masterorders_salesvolumemulti_id_seq; Type: SEQUENCE SET; Schema: public; Owner: -
--

SELECT pg_catalog.setval('public.masterorders_salesvolumemulti_id_seq', 1, false);


--
-- Name: materialflow_location_id_seq; Type: SEQUENCE SET; Schema: public; Owner: -
--

SELECT pg_catalog.setval('public.materialflow_location_id_seq', 1, false);


--
-- Name: materialflow_userlocation_id_seq; Type: SEQUENCE SET; Schema: public; Owner: -
--

SELECT pg_catalog.setval('public.materialflow_userlocation_id_seq', 1, false);


--
-- Name: materialflowresources_costnormsgenerator_id_seq; Type: SEQUENCE SET; Schema: public; Owner: -
--

SELECT pg_catalog.setval('public.materialflowresources_costnormsgenerator_id_seq', 1, false);


--
-- Name: materialflowresources_costnormslocation_id_seq; Type: SEQUENCE SET; Schema: public; Owner: -
--

SELECT pg_catalog.setval('public.materialflowresources_costnormslocation_id_seq', 1, false);


--
-- Name: materialflowresources_defaultstoragelocationdto_id_seq; Type: SEQUENCE SET; Schema: public; Owner: -
--

SELECT pg_catalog.setval('public.materialflowresources_defaultstoragelocationdto_id_seq', 1, false);


--
-- Name: materialflowresources_document_id_seq; Type: SEQUENCE SET; Schema: public; Owner: -
--

SELECT pg_catalog.setval('public.materialflowresources_document_id_seq', 1, false);


--
-- Name: materialflowresources_document_number_mm; Type: SEQUENCE SET; Schema: public; Owner: -
--

SELECT pg_catalog.setval('public.materialflowresources_document_number_mm', 1, false);


--
-- Name: materialflowresources_document_number_pw; Type: SEQUENCE SET; Schema: public; Owner: -
--

SELECT pg_catalog.setval('public.materialflowresources_document_number_pw', 1, false);


--
-- Name: materialflowresources_document_number_pz; Type: SEQUENCE SET; Schema: public; Owner: -
--

SELECT pg_catalog.setval('public.materialflowresources_document_number_pz', 1, false);


--
-- Name: materialflowresources_document_number_rw; Type: SEQUENCE SET; Schema: public; Owner: -
--

SELECT pg_catalog.setval('public.materialflowresources_document_number_rw', 1, false);


--
-- Name: materialflowresources_document_number_wz; Type: SEQUENCE SET; Schema: public; Owner: -
--

SELECT pg_catalog.setval('public.materialflowresources_document_number_wz', 1, false);


--
-- Name: materialflowresources_documentdto_id_seq; Type: SEQUENCE SET; Schema: public; Owner: -
--

SELECT pg_catalog.setval('public.materialflowresources_documentdto_id_seq', 1, false);


--
-- Name: materialflowresources_documentpositionparameters_id_seq; Type: SEQUENCE SET; Schema: public; Owner: -
--

SELECT pg_catalog.setval('public.materialflowresources_documentpositionparameters_id_seq', 2, false);


--
-- Name: materialflowresources_documentpositionparametersitem_id_seq; Type: SEQUENCE SET; Schema: public; Owner: -
--

SELECT pg_catalog.setval('public.materialflowresources_documentpositionparametersitem_id_seq', 26, true);


--
-- Name: materialflowresources_documentstatechange_id_seq; Type: SEQUENCE SET; Schema: public; Owner: -
--

SELECT pg_catalog.setval('public.materialflowresources_documentstatechange_id_seq', 1, false);


--
-- Name: materialflowresources_importstoragelocation_id_seq; Type: SEQUENCE SET; Schema: public; Owner: -
--

SELECT pg_catalog.setval('public.materialflowresources_importstoragelocation_id_seq', 1, false);


--
-- Name: materialflowresources_palletbalance_id_seq; Type: SEQUENCE SET; Schema: public; Owner: -
--

SELECT pg_catalog.setval('public.materialflowresources_palletbalance_id_seq', 1, false);


--
-- Name: materialflowresources_palletmovehelper_id_seq; Type: SEQUENCE SET; Schema: public; Owner: -
--

SELECT pg_catalog.setval('public.materialflowresources_palletmovehelper_id_seq', 1, false);


--
-- Name: materialflowresources_palletstoragestatedetailsdto_id_seq; Type: SEQUENCE SET; Schema: public; Owner: -
--

SELECT pg_catalog.setval('public.materialflowresources_palletstoragestatedetailsdto_id_seq', 1, false);


--
-- Name: materialflowresources_palletstoragestatedto_id_seq; Type: SEQUENCE SET; Schema: public; Owner: -
--

SELECT pg_catalog.setval('public.materialflowresources_palletstoragestatedto_id_seq', 1, false);


--
-- Name: materialflowresources_position_id_seq; Type: SEQUENCE SET; Schema: public; Owner: -
--

SELECT pg_catalog.setval('public.materialflowresources_position_id_seq', 1, false);


--
-- Name: materialflowresources_positionaddmultihelper_id_seq; Type: SEQUENCE SET; Schema: public; Owner: -
--

SELECT pg_catalog.setval('public.materialflowresources_positionaddmultihelper_id_seq', 1, false);


--
-- Name: materialflowresources_positionattributevalue_id_seq; Type: SEQUENCE SET; Schema: public; Owner: -
--

SELECT pg_catalog.setval('public.materialflowresources_positionattributevalue_id_seq', 1, false);


--
-- Name: materialflowresources_positiondto_id_seq; Type: SEQUENCE SET; Schema: public; Owner: -
--

SELECT pg_catalog.setval('public.materialflowresources_positiondto_id_seq', 1, false);


--
-- Name: materialflowresources_reservation_id_seq; Type: SEQUENCE SET; Schema: public; Owner: -
--

SELECT pg_catalog.setval('public.materialflowresources_reservation_id_seq', 1, false);


--
-- Name: materialflowresources_resource_id_seq; Type: SEQUENCE SET; Schema: public; Owner: -
--

SELECT pg_catalog.setval('public.materialflowresources_resource_id_seq', 1, false);


--
-- Name: materialflowresources_resource_number_2014; Type: SEQUENCE SET; Schema: public; Owner: -
--

SELECT pg_catalog.setval('public.materialflowresources_resource_number_2014', 1, false);


--
-- Name: materialflowresources_resource_number_2015; Type: SEQUENCE SET; Schema: public; Owner: -
--

SELECT pg_catalog.setval('public.materialflowresources_resource_number_2015', 1, false);


--
-- Name: materialflowresources_resource_number_2016; Type: SEQUENCE SET; Schema: public; Owner: -
--

SELECT pg_catalog.setval('public.materialflowresources_resource_number_2016', 1, false);


--
-- Name: materialflowresources_resource_number_2017; Type: SEQUENCE SET; Schema: public; Owner: -
--

SELECT pg_catalog.setval('public.materialflowresources_resource_number_2017', 1, false);


--
-- Name: materialflowresources_resourceattributevalue_id_seq; Type: SEQUENCE SET; Schema: public; Owner: -
--

SELECT pg_catalog.setval('public.materialflowresources_resourceattributevalue_id_seq', 1, false);


--
-- Name: materialflowresources_resourceattributevalueaftercorrection_id_; Type: SEQUENCE SET; Schema: public; Owner: -
--

SELECT pg_catalog.setval('public.materialflowresources_resourceattributevalueaftercorrection_id_', 1, false);


--
-- Name: materialflowresources_resourceattributevaluebeforecorrection_id; Type: SEQUENCE SET; Schema: public; Owner: -
--

SELECT pg_catalog.setval('public.materialflowresources_resourceattributevaluebeforecorrection_id', 1, false);


--
-- Name: materialflowresources_resourcecorrection_id_seq; Type: SEQUENCE SET; Schema: public; Owner: -
--

SELECT pg_catalog.setval('public.materialflowresources_resourcecorrection_id_seq', 1, false);


--
-- Name: materialflowresources_resourcecorrectiondto_id_seq; Type: SEQUENCE SET; Schema: public; Owner: -
--

SELECT pg_catalog.setval('public.materialflowresources_resourcecorrectiondto_id_seq', 1, false);


--
-- Name: materialflowresources_resourcedto_id_seq; Type: SEQUENCE SET; Schema: public; Owner: -
--

SELECT pg_catalog.setval('public.materialflowresources_resourcedto_id_seq', 1, false);


--
-- Name: materialflowresources_resourcestock_id_seq; Type: SEQUENCE SET; Schema: public; Owner: -
--

SELECT pg_catalog.setval('public.materialflowresources_resourcestock_id_seq', 1, false);


--
-- Name: materialflowresources_resourcestockdto_id_seq; Type: SEQUENCE SET; Schema: public; Owner: -
--

SELECT pg_catalog.setval('public.materialflowresources_resourcestockdto_id_seq', 1, false);


--
-- Name: materialflowresources_resourcestockdto_internal_id_seq; Type: SEQUENCE SET; Schema: public; Owner: -
--

SELECT pg_catalog.setval('public.materialflowresources_resourcestockdto_internal_id_seq', 1, false);


--
-- Name: materialflowresources_stocktaking_id_seq; Type: SEQUENCE SET; Schema: public; Owner: -
--

SELECT pg_catalog.setval('public.materialflowresources_stocktaking_id_seq', 1, false);


--
-- Name: materialflowresources_storagelocation_id_seq; Type: SEQUENCE SET; Schema: public; Owner: -
--

SELECT pg_catalog.setval('public.materialflowresources_storagelocation_id_seq', 1, false);


--
-- Name: materialflowresources_storagelocationdto_id_seq; Type: SEQUENCE SET; Schema: public; Owner: -
--

SELECT pg_catalog.setval('public.materialflowresources_storagelocationdto_id_seq', 1, false);


--
-- Name: materialflowresources_storagelocationhelper_id_seq; Type: SEQUENCE SET; Schema: public; Owner: -
--

SELECT pg_catalog.setval('public.materialflowresources_storagelocationhelper_id_seq', 1, false);


--
-- Name: materialflowresources_storagelocationnumberhelper_id_seq; Type: SEQUENCE SET; Schema: public; Owner: -
--

SELECT pg_catalog.setval('public.materialflowresources_storagelocationnumberhelper_id_seq', 1, false);


--
-- Name: materialflowresources_warehousestock_id_seq; Type: SEQUENCE SET; Schema: public; Owner: -
--

SELECT pg_catalog.setval('public.materialflowresources_warehousestock_id_seq', 1, false);


--
-- Name: materialflowresources_warehousestocklistdto_id_seq; Type: SEQUENCE SET; Schema: public; Owner: -
--

SELECT pg_catalog.setval('public.materialflowresources_warehousestocklistdto_id_seq', 1, false);


--
-- Name: materialflowresources_warehousestocklistdto_internal_id_seq; Type: SEQUENCE SET; Schema: public; Owner: -
--

SELECT pg_catalog.setval('public.materialflowresources_warehousestocklistdto_internal_id_seq', 1, false);


--
-- Name: materialflowresources_warehousestockreport_id_seq; Type: SEQUENCE SET; Schema: public; Owner: -
--

SELECT pg_catalog.setval('public.materialflowresources_warehousestockreport_id_seq', 1, false);


--
-- Name: materialrequirementcoveragefororder_columnforcoveragesfororder_; Type: SEQUENCE SET; Schema: public; Owner: -
--

SELECT pg_catalog.setval('public.materialrequirementcoveragefororder_columnforcoveragesfororder_', 10, true);


--
-- Name: materialrequirementcoveragefororder_coveragefororder_id_seq; Type: SEQUENCE SET; Schema: public; Owner: -
--

SELECT pg_catalog.setval('public.materialrequirementcoveragefororder_coveragefororder_id_seq', 1, false);


--
-- Name: materialrequirementcoveragefororder_coveragelocation_id_seq; Type: SEQUENCE SET; Schema: public; Owner: -
--

SELECT pg_catalog.setval('public.materialrequirementcoveragefororder_coveragelocation_id_seq', 1, false);


--
-- Name: materialrequirementcoveragefororder_coverageproduct_id_seq; Type: SEQUENCE SET; Schema: public; Owner: -
--

SELECT pg_catalog.setval('public.materialrequirementcoveragefororder_coverageproduct_id_seq', 1, false);


--
-- Name: materialrequirementcoveragefororder_coverageproductlogging_id_s; Type: SEQUENCE SET; Schema: public; Owner: -
--

SELECT pg_catalog.setval('public.materialrequirementcoveragefororder_coverageproductlogging_id_s', 1, false);


--
-- Name: materialrequirements_materialrequirement_id_seq; Type: SEQUENCE SET; Schema: public; Owner: -
--

SELECT pg_catalog.setval('public.materialrequirements_materialrequirement_id_seq', 1, false);


--
-- Name: materialrequirements_materialrequirementproduct_id_seq; Type: SEQUENCE SET; Schema: public; Owner: -
--

SELECT pg_catalog.setval('public.materialrequirements_materialrequirementproduct_id_seq', 1, false);


--
-- Name: mobilewms_wmsdocumentpart_id_seq; Type: SEQUENCE SET; Schema: public; Owner: -
--

SELECT pg_catalog.setval('public.mobilewms_wmsdocumentpart_id_seq', 1, false);


--
-- Name: model_card_number_seq; Type: SEQUENCE SET; Schema: public; Owner: -
--

SELECT pg_catalog.setval('public.model_card_number_seq', 1, false);


--
-- Name: number_pattern_number_seq; Type: SEQUENCE SET; Schema: public; Owner: -
--

SELECT pg_catalog.setval('public.number_pattern_number_seq', 1, false);


--
-- Name: nutritionfacts_nutrientcalculation_id_seq; Type: SEQUENCE SET; Schema: public; Owner: -
--

SELECT pg_catalog.setval('public.nutritionfacts_nutrientcalculation_id_seq', 1, false);


--
-- Name: nutritionfacts_nutrition_id_seq; Type: SEQUENCE SET; Schema: public; Owner: -
--

SELECT pg_catalog.setval('public.nutritionfacts_nutrition_id_seq', 1, false);


--
-- Name: nutritionfacts_nutritionelement_id_seq; Type: SEQUENCE SET; Schema: public; Owner: -
--

SELECT pg_catalog.setval('public.nutritionfacts_nutritionelement_id_seq', 1, false);


--
-- Name: nutritionfacts_nutritiongroup_id_seq; Type: SEQUENCE SET; Schema: public; Owner: -
--

SELECT pg_catalog.setval('public.nutritionfacts_nutritiongroup_id_seq', 1, false);


--
-- Name: nutritionfacts_prototypeproduct_id_seq; Type: SEQUENCE SET; Schema: public; Owner: -
--

SELECT pg_catalog.setval('public.nutritionfacts_prototypeproduct_id_seq', 1, false);


--
-- Name: nutritionfacts_prototypeproductcomponent_id_seq; Type: SEQUENCE SET; Schema: public; Owner: -
--

SELECT pg_catalog.setval('public.nutritionfacts_prototypeproductcomponent_id_seq', 1, false);


--
-- Name: oee_oee_id_seq; Type: SEQUENCE SET; Schema: public; Owner: -
--

SELECT pg_catalog.setval('public.oee_oee_id_seq', 1, false);


--
-- Name: oee_oeevalue_id_seq; Type: SEQUENCE SET; Schema: public; Owner: -
--

SELECT pg_catalog.setval('public.oee_oeevalue_id_seq', 1, false);


--
-- Name: oee_productionlinedto_id_seq; Type: SEQUENCE SET; Schema: public; Owner: -
--

SELECT pg_catalog.setval('public.oee_productionlinedto_id_seq', 1, false);


--
-- Name: oee_workstationdto_id_seq; Type: SEQUENCE SET; Schema: public; Owner: -
--

SELECT pg_catalog.setval('public.oee_workstationdto_id_seq', 1, false);


--
-- Name: orders_changedateshelper_id_seq; Type: SEQUENCE SET; Schema: public; Owner: -
--

SELECT pg_catalog.setval('public.orders_changedateshelper_id_seq', 1, false);


--
-- Name: orders_dimensioncontrolattribute_id_seq; Type: SEQUENCE SET; Schema: public; Owner: -
--

SELECT pg_catalog.setval('public.orders_dimensioncontrolattribute_id_seq', 1, false);


--
-- Name: orders_group_material_requirement_number_seq; Type: SEQUENCE SET; Schema: public; Owner: -
--

SELECT pg_catalog.setval('public.orders_group_material_requirement_number_seq', 1, false);


--
-- Name: orders_group_production_balance_number_seq; Type: SEQUENCE SET; Schema: public; Owner: -
--

SELECT pg_catalog.setval('public.orders_group_production_balance_number_seq', 1, false);


--
-- Name: orders_operational_task_number_seq; Type: SEQUENCE SET; Schema: public; Owner: -
--

SELECT pg_catalog.setval('public.orders_operational_task_number_seq', 1, false);


--
-- Name: orders_operationaltask_id_seq; Type: SEQUENCE SET; Schema: public; Owner: -
--

SELECT pg_catalog.setval('public.orders_operationaltask_id_seq', 1, false);


--
-- Name: orders_operationaltaskdto_id_seq; Type: SEQUENCE SET; Schema: public; Owner: -
--

SELECT pg_catalog.setval('public.orders_operationaltaskdto_id_seq', 1, false);


--
-- Name: orders_operationaltaskstatechange_id_seq; Type: SEQUENCE SET; Schema: public; Owner: -
--

SELECT pg_catalog.setval('public.orders_operationaltaskstatechange_id_seq', 1, false);


--
-- Name: orders_operationaltaskwithcolordto_id_seq; Type: SEQUENCE SET; Schema: public; Owner: -
--

SELECT pg_catalog.setval('public.orders_operationaltaskwithcolordto_id_seq', 1, false);


--
-- Name: orders_order_id_seq; Type: SEQUENCE SET; Schema: public; Owner: -
--

SELECT pg_catalog.setval('public.orders_order_id_seq', 1, false);


--
-- Name: orders_order_pack_number_seq; Type: SEQUENCE SET; Schema: public; Owner: -
--

SELECT pg_catalog.setval('public.orders_order_pack_number_seq', 1, false);


--
-- Name: orders_orderattachment_id_seq; Type: SEQUENCE SET; Schema: public; Owner: -
--

SELECT pg_catalog.setval('public.orders_orderattachment_id_seq', 1, false);


--
-- Name: orders_ordercategorycolor_id_seq; Type: SEQUENCE SET; Schema: public; Owner: -
--

SELECT pg_catalog.setval('public.orders_ordercategorycolor_id_seq', 1, false);


--
-- Name: orders_orderdto_id_seq; Type: SEQUENCE SET; Schema: public; Owner: -
--

SELECT pg_catalog.setval('public.orders_orderdto_id_seq', 1, false);


--
-- Name: orders_orderlistdto_id_seq; Type: SEQUENCE SET; Schema: public; Owner: -
--

SELECT pg_catalog.setval('public.orders_orderlistdto_id_seq', 1, false);


--
-- Name: orders_orderpack_id_seq; Type: SEQUENCE SET; Schema: public; Owner: -
--

SELECT pg_catalog.setval('public.orders_orderpack_id_seq', 1, false);


--
-- Name: orders_orderpackdto_id_seq; Type: SEQUENCE SET; Schema: public; Owner: -
--

SELECT pg_catalog.setval('public.orders_orderpackdto_id_seq', 1, false);


--
-- Name: orders_orderpackstatechange_id_seq; Type: SEQUENCE SET; Schema: public; Owner: -
--

SELECT pg_catalog.setval('public.orders_orderpackstatechange_id_seq', 1, false);


--
-- Name: orders_orderplanninglistdto_id_seq; Type: SEQUENCE SET; Schema: public; Owner: -
--

SELECT pg_catalog.setval('public.orders_orderplanninglistdto_id_seq', 1, false);


--
-- Name: orders_orderstatechange_id_seq; Type: SEQUENCE SET; Schema: public; Owner: -
--

SELECT pg_catalog.setval('public.orders_orderstatechange_id_seq', 1, false);


--
-- Name: orders_ordertechnologicalprocess_id_seq; Type: SEQUENCE SET; Schema: public; Owner: -
--

SELECT pg_catalog.setval('public.orders_ordertechnologicalprocess_id_seq', 1, false);


--
-- Name: orders_ordertechnologicalprocess_number_seq; Type: SEQUENCE SET; Schema: public; Owner: -
--

SELECT pg_catalog.setval('public.orders_ordertechnologicalprocess_number_seq', 1, false);


--
-- Name: orders_ordertechnologicalprocessdto_id_seq; Type: SEQUENCE SET; Schema: public; Owner: -
--

SELECT pg_catalog.setval('public.orders_ordertechnologicalprocessdto_id_seq', 1, false);


--
-- Name: orders_ordertechnologicalprocesspart_id_seq; Type: SEQUENCE SET; Schema: public; Owner: -
--

SELECT pg_catalog.setval('public.orders_ordertechnologicalprocesspart_id_seq', 1, false);


--
-- Name: orders_ordertechnologicalprocesswaste_id_seq; Type: SEQUENCE SET; Schema: public; Owner: -
--

SELECT pg_catalog.setval('public.orders_ordertechnologicalprocesswaste_id_seq', 1, false);


--
-- Name: orders_ordertechnologicalprocesswaste_number_seq; Type: SEQUENCE SET; Schema: public; Owner: -
--

SELECT pg_catalog.setval('public.orders_ordertechnologicalprocesswaste_number_seq', 1, false);


--
-- Name: orders_ordertechnologicalprocesswastedto_id_seq; Type: SEQUENCE SET; Schema: public; Owner: -
--

SELECT pg_catalog.setval('public.orders_ordertechnologicalprocesswastedto_id_seq', 1, false);


--
-- Name: orders_prod_line_schedule_number_seq; Type: SEQUENCE SET; Schema: public; Owner: -
--

SELECT pg_catalog.setval('public.orders_prod_line_schedule_number_seq', 1, false);


--
-- Name: orders_productionlineschedule_id_seq; Type: SEQUENCE SET; Schema: public; Owner: -
--

SELECT pg_catalog.setval('public.orders_productionlineschedule_id_seq', 1, false);


--
-- Name: orders_productionlinescheduleposition_id_seq; Type: SEQUENCE SET; Schema: public; Owner: -
--

SELECT pg_catalog.setval('public.orders_productionlinescheduleposition_id_seq', 1, false);


--
-- Name: orders_productionlineschedulestatechange_id_seq; Type: SEQUENCE SET; Schema: public; Owner: -
--

SELECT pg_catalog.setval('public.orders_productionlineschedulestatechange_id_seq', 1, false);


--
-- Name: orders_reasontypecorrectiondatefrom_id_seq; Type: SEQUENCE SET; Schema: public; Owner: -
--

SELECT pg_catalog.setval('public.orders_reasontypecorrectiondatefrom_id_seq', 1, false);


--
-- Name: orders_reasontypecorrectiondateto_id_seq; Type: SEQUENCE SET; Schema: public; Owner: -
--

SELECT pg_catalog.setval('public.orders_reasontypecorrectiondateto_id_seq', 1, false);


--
-- Name: orders_reasontypedeviationeffectiveend_id_seq; Type: SEQUENCE SET; Schema: public; Owner: -
--

SELECT pg_catalog.setval('public.orders_reasontypedeviationeffectiveend_id_seq', 1, false);


--
-- Name: orders_reasontypedeviationeffectivestart_id_seq; Type: SEQUENCE SET; Schema: public; Owner: -
--

SELECT pg_catalog.setval('public.orders_reasontypedeviationeffectivestart_id_seq', 1, false);


--
-- Name: orders_reasontypeofchangingorderstate_id_seq; Type: SEQUENCE SET; Schema: public; Owner: -
--

SELECT pg_catalog.setval('public.orders_reasontypeofchangingorderstate_id_seq', 1, false);


--
-- Name: orders_schedule_id_seq; Type: SEQUENCE SET; Schema: public; Owner: -
--

SELECT pg_catalog.setval('public.orders_schedule_id_seq', 1, false);


--
-- Name: orders_schedule_number_seq; Type: SEQUENCE SET; Schema: public; Owner: -
--

SELECT pg_catalog.setval('public.orders_schedule_number_seq', 1, false);


--
-- Name: orders_scheduleposition_id_seq; Type: SEQUENCE SET; Schema: public; Owner: -
--

SELECT pg_catalog.setval('public.orders_scheduleposition_id_seq', 1, false);


--
-- Name: orders_schedulepositiondto_id_seq; Type: SEQUENCE SET; Schema: public; Owner: -
--

SELECT pg_catalog.setval('public.orders_schedulepositiondto_id_seq', 1, false);


--
-- Name: orders_schedulestatechange_id_seq; Type: SEQUENCE SET; Schema: public; Owner: -
--

SELECT pg_catalog.setval('public.orders_schedulestatechange_id_seq', 1, false);


--
-- Name: orders_setcategory_id_seq; Type: SEQUENCE SET; Schema: public; Owner: -
--

SELECT pg_catalog.setval('public.orders_setcategory_id_seq', 1, false);


--
-- Name: orders_splitorderchild_id_seq; Type: SEQUENCE SET; Schema: public; Owner: -
--

SELECT pg_catalog.setval('public.orders_splitorderchild_id_seq', 1, false);


--
-- Name: orders_splitorderhelper_id_seq; Type: SEQUENCE SET; Schema: public; Owner: -
--

SELECT pg_catalog.setval('public.orders_splitorderhelper_id_seq', 1, false);


--
-- Name: orders_splitorderparent_id_seq; Type: SEQUENCE SET; Schema: public; Owner: -
--

SELECT pg_catalog.setval('public.orders_splitorderparent_id_seq', 1, false);


--
-- Name: orders_typeofcorrectioncauses_id_seq; Type: SEQUENCE SET; Schema: public; Owner: -
--

SELECT pg_catalog.setval('public.orders_typeofcorrectioncauses_id_seq', 1, false);


--
-- Name: orders_workstationchangeoverforoperationaltask_id_seq; Type: SEQUENCE SET; Schema: public; Owner: -
--

SELECT pg_catalog.setval('public.orders_workstationchangeoverforoperationaltask_id_seq', 1, false);


--
-- Name: orders_workstationchangeoverforoperationaltaskdto_id_seq; Type: SEQUENCE SET; Schema: public; Owner: -
--

SELECT pg_catalog.setval('public.orders_workstationchangeoverforoperationaltaskdto_id_seq', 1, false);


--
-- Name: orders_workstationchangeoverforscheduleposition_id_seq; Type: SEQUENCE SET; Schema: public; Owner: -
--

SELECT pg_catalog.setval('public.orders_workstationchangeoverforscheduleposition_id_seq', 1, false);


--
-- Name: ordersforsubproductsgeneration_relatedorderdto_id_seq; Type: SEQUENCE SET; Schema: public; Owner: -
--

SELECT pg_catalog.setval('public.ordersforsubproductsgeneration_relatedorderdto_id_seq', 1, false);


--
-- Name: ordersforsubproductsgeneration_suborders_id_seq; Type: SEQUENCE SET; Schema: public; Owner: -
--

SELECT pg_catalog.setval('public.ordersforsubproductsgeneration_suborders_id_seq', 1, false);


--
-- Name: ordersgantt_ordersganttparameters_id_seq; Type: SEQUENCE SET; Schema: public; Owner: -
--

SELECT pg_catalog.setval('public.ordersgantt_ordersganttparameters_id_seq', 2, false);


--
-- Name: ordersgroups_drafrptquantitydto_id_seq; Type: SEQUENCE SET; Schema: public; Owner: -
--

SELECT pg_catalog.setval('public.ordersgroups_drafrptquantitydto_id_seq', 1, false);


--
-- Name: ordersgroups_ordersgroup_id_seq; Type: SEQUENCE SET; Schema: public; Owner: -
--

SELECT pg_catalog.setval('public.ordersgroups_ordersgroup_id_seq', 1, false);


--
-- Name: ordersgroups_ordersgroupdto_id_seq; Type: SEQUENCE SET; Schema: public; Owner: -
--

SELECT pg_catalog.setval('public.ordersgroups_ordersgroupdto_id_seq', 1, false);


--
-- Name: ordersgroups_ordersgroupissuedmaterial_id_seq; Type: SEQUENCE SET; Schema: public; Owner: -
--

SELECT pg_catalog.setval('public.ordersgroups_ordersgroupissuedmaterial_id_seq', 1, false);


--
-- Name: ordersgroups_ordersgroupissuedmaterialposition_id_seq; Type: SEQUENCE SET; Schema: public; Owner: -
--

SELECT pg_catalog.setval('public.ordersgroups_ordersgroupissuedmaterialposition_id_seq', 1, false);


--
-- Name: ordersgroups_ordersgroupmaterialrequirement_id_seq; Type: SEQUENCE SET; Schema: public; Owner: -
--

SELECT pg_catalog.setval('public.ordersgroups_ordersgroupmaterialrequirement_id_seq', 1, false);


--
-- Name: ordersgroups_ordersgroupmaterialrequirementproduct_id_seq; Type: SEQUENCE SET; Schema: public; Owner: -
--

SELECT pg_catalog.setval('public.ordersgroups_ordersgroupmaterialrequirementproduct_id_seq', 1, false);


--
-- Name: ordersgroups_ordersgroupproducedproduct_id_seq; Type: SEQUENCE SET; Schema: public; Owner: -
--

SELECT pg_catalog.setval('public.ordersgroups_ordersgroupproducedproduct_id_seq', 1, false);


--
-- Name: ordersgroups_ordersgroupproductstoissueentryhelper_id_seq; Type: SEQUENCE SET; Schema: public; Owner: -
--

SELECT pg_catalog.setval('public.ordersgroups_ordersgroupproductstoissueentryhelper_id_seq', 1, false);


--
-- Name: ordersgroups_ordersgroupproductstoissuehelper_id_seq; Type: SEQUENCE SET; Schema: public; Owner: -
--

SELECT pg_catalog.setval('public.ordersgroups_ordersgroupproductstoissuehelper_id_seq', 1, false);


--
-- Name: ordersgroups_plannedworkingtimeanalysisdto_id_seq; Type: SEQUENCE SET; Schema: public; Owner: -
--

SELECT pg_catalog.setval('public.ordersgroups_plannedworkingtimeanalysisdto_id_seq', 1, false);


--
-- Name: ordersgroups_productionbalance_id_seq; Type: SEQUENCE SET; Schema: public; Owner: -
--

SELECT pg_catalog.setval('public.ordersgroups_productionbalance_id_seq', 1, false);


--
-- Name: ordersgroups_sizegroupcolor_id_seq; Type: SEQUENCE SET; Schema: public; Owner: -
--

SELECT pg_catalog.setval('public.ordersgroups_sizegroupcolor_id_seq', 1, false);


--
-- Name: ordersupplies_columnforcoverages_id_seq; Type: SEQUENCE SET; Schema: public; Owner: -
--

SELECT pg_catalog.setval('public.ordersupplies_columnforcoverages_id_seq', 13, false);


--
-- Name: ordersupplies_coverageanalysisfororder_id_seq; Type: SEQUENCE SET; Schema: public; Owner: -
--

SELECT pg_catalog.setval('public.ordersupplies_coverageanalysisfororder_id_seq', 1, false);


--
-- Name: ordersupplies_coverageanalysisfororderdto_id_seq; Type: SEQUENCE SET; Schema: public; Owner: -
--

SELECT pg_catalog.setval('public.ordersupplies_coverageanalysisfororderdto_id_seq', 1, false);


--
-- Name: ordersupplies_coveragelocation_id_seq; Type: SEQUENCE SET; Schema: public; Owner: -
--

SELECT pg_catalog.setval('public.ordersupplies_coveragelocation_id_seq', 1, false);


--
-- Name: ordersupplies_coverageorderstate_id_seq; Type: SEQUENCE SET; Schema: public; Owner: -
--

SELECT pg_catalog.setval('public.ordersupplies_coverageorderstate_id_seq', 1, false);


--
-- Name: ordersupplies_coverageproduct_id_seq; Type: SEQUENCE SET; Schema: public; Owner: -
--

SELECT pg_catalog.setval('public.ordersupplies_coverageproduct_id_seq', 1, false);


--
-- Name: ordersupplies_coverageproductdto_id_seq; Type: SEQUENCE SET; Schema: public; Owner: -
--

SELECT pg_catalog.setval('public.ordersupplies_coverageproductdto_id_seq', 1, false);


--
-- Name: ordersupplies_coverageproductgenerated_id_seq; Type: SEQUENCE SET; Schema: public; Owner: -
--

SELECT pg_catalog.setval('public.ordersupplies_coverageproductgenerated_id_seq', 1, false);


--
-- Name: ordersupplies_coverageproductlogging_id_seq; Type: SEQUENCE SET; Schema: public; Owner: -
--

SELECT pg_catalog.setval('public.ordersupplies_coverageproductlogging_id_seq', 1, false);


--
-- Name: ordersupplies_coverageproductselected_id_seq; Type: SEQUENCE SET; Schema: public; Owner: -
--

SELECT pg_catalog.setval('public.ordersupplies_coverageproductselected_id_seq', 1, false);


--
-- Name: ordersupplies_materialrequirementcoverage_id_seq; Type: SEQUENCE SET; Schema: public; Owner: -
--

SELECT pg_catalog.setval('public.ordersupplies_materialrequirementcoverage_id_seq', 1, false);


--
-- Name: ordersupplies_materialrequirementcoveragedto_id_seq; Type: SEQUENCE SET; Schema: public; Owner: -
--

SELECT pg_catalog.setval('public.ordersupplies_materialrequirementcoveragedto_id_seq', 1, false);


--
-- Name: ordersupplies_orderdto_id_seq; Type: SEQUENCE SET; Schema: public; Owner: -
--

SELECT pg_catalog.setval('public.ordersupplies_orderdto_id_seq', 1, false);


--
-- Name: ordersupplies_productioncountingquantityinput_id_seq; Type: SEQUENCE SET; Schema: public; Owner: -
--

SELECT pg_catalog.setval('public.ordersupplies_productioncountingquantityinput_id_seq', 1, false);


--
-- Name: ordersupplies_productioncountingquantityoutput_id_seq; Type: SEQUENCE SET; Schema: public; Owner: -
--

SELECT pg_catalog.setval('public.ordersupplies_productioncountingquantityoutput_id_seq', 1, false);


--
-- Name: productcatalognumbers_productcatalognumbers_id_seq; Type: SEQUENCE SET; Schema: public; Owner: -
--

SELECT pg_catalog.setval('public.productcatalognumbers_productcatalognumbers_id_seq', 1, false);


--
-- Name: productflowthrudivision_issue_id_seq; Type: SEQUENCE SET; Schema: public; Owner: -
--

SELECT pg_catalog.setval('public.productflowthrudivision_issue_id_seq', 1, false);


--
-- Name: productflowthrudivision_issuedto_id_seq; Type: SEQUENCE SET; Schema: public; Owner: -
--

SELECT pg_catalog.setval('public.productflowthrudivision_issuedto_id_seq', 1, false);


--
-- Name: productflowthrudivision_materialavailability_id_seq; Type: SEQUENCE SET; Schema: public; Owner: -
--

SELECT pg_catalog.setval('public.productflowthrudivision_materialavailability_id_seq', 1, false);


--
-- Name: productflowthrudivision_materialavailabilitydto_id_seq; Type: SEQUENCE SET; Schema: public; Owner: -
--

SELECT pg_catalog.setval('public.productflowthrudivision_materialavailabilitydto_id_seq', 1, false);


--
-- Name: productflowthrudivision_modelcard_id_seq; Type: SEQUENCE SET; Schema: public; Owner: -
--

SELECT pg_catalog.setval('public.productflowthrudivision_modelcard_id_seq', 1, false);


--
-- Name: productflowthrudivision_modelcardproduct_id_seq; Type: SEQUENCE SET; Schema: public; Owner: -
--

SELECT pg_catalog.setval('public.productflowthrudivision_modelcardproduct_id_seq', 1, false);


--
-- Name: productflowthrudivision_opertaskmaterialavailability_id_seq; Type: SEQUENCE SET; Schema: public; Owner: -
--

SELECT pg_catalog.setval('public.productflowthrudivision_opertaskmaterialavailability_id_seq', 1, false);


--
-- Name: productflowthrudivision_opertaskmaterialavailabilitydto_id_seq; Type: SEQUENCE SET; Schema: public; Owner: -
--

SELECT pg_catalog.setval('public.productflowthrudivision_opertaskmaterialavailabilitydto_id_seq', 1, false);


--
-- Name: productflowthrudivision_orderproductresourcereservation_id_seq; Type: SEQUENCE SET; Schema: public; Owner: -
--

SELECT pg_catalog.setval('public.productflowthrudivision_orderproductresourcereservation_id_seq', 1, false);


--
-- Name: productflowthrudivision_plannedconsumptioninorderdto_id_seq; Type: SEQUENCE SET; Schema: public; Owner: -
--

SELECT pg_catalog.setval('public.productflowthrudivision_plannedconsumptioninorderdto_id_seq', 1, false);


--
-- Name: productflowthrudivision_productandquantityhelper_id_seq; Type: SEQUENCE SET; Schema: public; Owner: -
--

SELECT pg_catalog.setval('public.productflowthrudivision_productandquantityhelper_id_seq', 1, false);


--
-- Name: productflowthrudivision_productstoissue_id_seq; Type: SEQUENCE SET; Schema: public; Owner: -
--

SELECT pg_catalog.setval('public.productflowthrudivision_productstoissue_id_seq', 1, false);


--
-- Name: productflowthrudivision_productstoissuehelper_id_seq; Type: SEQUENCE SET; Schema: public; Owner: -
--

SELECT pg_catalog.setval('public.productflowthrudivision_productstoissuehelper_id_seq', 1, false);


--
-- Name: productflowthrudivision_producttoissuecorrection_id_seq; Type: SEQUENCE SET; Schema: public; Owner: -
--

SELECT pg_catalog.setval('public.productflowthrudivision_producttoissuecorrection_id_seq', 1, false);


--
-- Name: productflowthrudivision_producttoissuecorrectionhelper_id_seq; Type: SEQUENCE SET; Schema: public; Owner: -
--

SELECT pg_catalog.setval('public.productflowthrudivision_producttoissuecorrectionhelper_id_seq', 1, false);


--
-- Name: productflowthrudivision_producttoissuedto_id_seq; Type: SEQUENCE SET; Schema: public; Owner: -
--

SELECT pg_catalog.setval('public.productflowthrudivision_producttoissuedto_id_seq', 1, false);


--
-- Name: productflowthrudivision_producttoissuedto_internal_id_seq; Type: SEQUENCE SET; Schema: public; Owner: -
--

SELECT pg_catalog.setval('public.productflowthrudivision_producttoissuedto_internal_id_seq', 1, false);


--
-- Name: productflowthrudivision_trackingproductresourcereservation_id_s; Type: SEQUENCE SET; Schema: public; Owner: -
--

SELECT pg_catalog.setval('public.productflowthrudivision_trackingproductresourcereservation_id_s', 1, false);


--
-- Name: productflowthrudivision_warehouseissue_id_seq; Type: SEQUENCE SET; Schema: public; Owner: -
--

SELECT pg_catalog.setval('public.productflowthrudivision_warehouseissue_id_seq', 1, false);


--
-- Name: productflowthrudivision_warehouseissue_number_seq; Type: SEQUENCE SET; Schema: public; Owner: -
--

SELECT pg_catalog.setval('public.productflowthrudivision_warehouseissue_number_seq', 1, false);


--
-- Name: productflowthrudivision_warehouseissuestatechange_id_seq; Type: SEQUENCE SET; Schema: public; Owner: -
--

SELECT pg_catalog.setval('public.productflowthrudivision_warehouseissuestatechange_id_seq', 1, false);


--
-- Name: productioncounting_anomaly_id_seq; Type: SEQUENCE SET; Schema: public; Owner: -
--

SELECT pg_catalog.setval('public.productioncounting_anomaly_id_seq', 1, false);


--
-- Name: productioncounting_anomalydto_id_seq; Type: SEQUENCE SET; Schema: public; Owner: -
--

SELECT pg_catalog.setval('public.productioncounting_anomalydto_id_seq', 1, false);


--
-- Name: productioncounting_anomalyexplanation_id_seq; Type: SEQUENCE SET; Schema: public; Owner: -
--

SELECT pg_catalog.setval('public.productioncounting_anomalyexplanation_id_seq', 1, false);


--
-- Name: productioncounting_anomalyexplanationdto_id_seq; Type: SEQUENCE SET; Schema: public; Owner: -
--

SELECT pg_catalog.setval('public.productioncounting_anomalyexplanationdto_id_seq', 1, false);


--
-- Name: productioncounting_anomalyproductiontrackingentryhelper_id_seq; Type: SEQUENCE SET; Schema: public; Owner: -
--

SELECT pg_catalog.setval('public.productioncounting_anomalyproductiontrackingentryhelper_id_seq', 1, false);


--
-- Name: productioncounting_anomalyproductiontrackinghelper_id_seq; Type: SEQUENCE SET; Schema: public; Owner: -
--

SELECT pg_catalog.setval('public.productioncounting_anomalyproductiontrackinghelper_id_seq', 1, false);


--
-- Name: productioncounting_anomalyreason_id_seq; Type: SEQUENCE SET; Schema: public; Owner: -
--

SELECT pg_catalog.setval('public.productioncounting_anomalyreason_id_seq', 1, false);


--
-- Name: productioncounting_anomalyreasoncontainer_id_seq; Type: SEQUENCE SET; Schema: public; Owner: -
--

SELECT pg_catalog.setval('public.productioncounting_anomalyreasoncontainer_id_seq', 1, false);


--
-- Name: productioncounting_beforeadditionalactionsanalysisentry_id_seq; Type: SEQUENCE SET; Schema: public; Owner: -
--

SELECT pg_catalog.setval('public.productioncounting_beforeadditionalactionsanalysisentry_id_seq', 1, false);


--
-- Name: productioncounting_finalproductanalysisentry_id_seq; Type: SEQUENCE SET; Schema: public; Owner: -
--

SELECT pg_catalog.setval('public.productioncounting_finalproductanalysisentry_id_seq', 1, false);


--
-- Name: productioncounting_lack_id_seq; Type: SEQUENCE SET; Schema: public; Owner: -
--

SELECT pg_catalog.setval('public.productioncounting_lack_id_seq', 1, false);


--
-- Name: productioncounting_lackdto_id_seq; Type: SEQUENCE SET; Schema: public; Owner: -
--

SELECT pg_catalog.setval('public.productioncounting_lackdto_id_seq', 1, false);


--
-- Name: productioncounting_lackreason_id_seq; Type: SEQUENCE SET; Schema: public; Owner: -
--

SELECT pg_catalog.setval('public.productioncounting_lackreason_id_seq', 1, false);


--
-- Name: productioncounting_orderbalance_id_seq; Type: SEQUENCE SET; Schema: public; Owner: -
--

SELECT pg_catalog.setval('public.productioncounting_orderbalance_id_seq', 1, false);


--
-- Name: productioncounting_performanceanalysisdetaildto_id_seq; Type: SEQUENCE SET; Schema: public; Owner: -
--

SELECT pg_catalog.setval('public.productioncounting_performanceanalysisdetaildto_id_seq', 1, false);


--
-- Name: productioncounting_performanceanalysisdto_id_seq; Type: SEQUENCE SET; Schema: public; Owner: -
--

SELECT pg_catalog.setval('public.productioncounting_performanceanalysisdto_id_seq', 1, false);


--
-- Name: productioncounting_performanceanalysismv_id_seq; Type: SEQUENCE SET; Schema: public; Owner: -
--

SELECT pg_catalog.setval('public.productioncounting_performanceanalysismv_id_seq', 1, false);


--
-- Name: productioncounting_prodoutresourceattrval_id_seq; Type: SEQUENCE SET; Schema: public; Owner: -
--

SELECT pg_catalog.setval('public.productioncounting_prodoutresourceattrval_id_seq', 1, false);


--
-- Name: productioncounting_productionanalysisdto_id_seq; Type: SEQUENCE SET; Schema: public; Owner: -
--

SELECT pg_catalog.setval('public.productioncounting_productionanalysisdto_id_seq', 1, false);


--
-- Name: productioncounting_productionbalance_id_seq; Type: SEQUENCE SET; Schema: public; Owner: -
--

SELECT pg_catalog.setval('public.productioncounting_productionbalance_id_seq', 1, false);


--
-- Name: productioncounting_productiontracking_id_seq; Type: SEQUENCE SET; Schema: public; Owner: -
--

SELECT pg_catalog.setval('public.productioncounting_productiontracking_id_seq', 1, false);


--
-- Name: productioncounting_productiontracking_number_seq; Type: SEQUENCE SET; Schema: public; Owner: -
--

SELECT pg_catalog.setval('public.productioncounting_productiontracking_number_seq', 1, false);


--
-- Name: productioncounting_productiontrackingattachment_id_seq; Type: SEQUENCE SET; Schema: public; Owner: -
--

SELECT pg_catalog.setval('public.productioncounting_productiontrackingattachment_id_seq', 1, false);


--
-- Name: productioncounting_productiontrackingdraftdto_id_seq; Type: SEQUENCE SET; Schema: public; Owner: -
--

SELECT pg_catalog.setval('public.productioncounting_productiontrackingdraftdto_id_seq', 1, false);


--
-- Name: productioncounting_productiontrackingdto_id_seq; Type: SEQUENCE SET; Schema: public; Owner: -
--

SELECT pg_catalog.setval('public.productioncounting_productiontrackingdto_id_seq', 1, false);


--
-- Name: productioncounting_productiontrackingforproductdto_id_seq; Type: SEQUENCE SET; Schema: public; Owner: -
--

SELECT pg_catalog.setval('public.productioncounting_productiontrackingforproductdto_id_seq', 1, false);


--
-- Name: productioncounting_productiontrackingforproductgroupeddto_id_se; Type: SEQUENCE SET; Schema: public; Owner: -
--

SELECT pg_catalog.setval('public.productioncounting_productiontrackingforproductgroupeddto_id_se', 1, false);


--
-- Name: productioncounting_productiontrackingstatechange_id_seq; Type: SEQUENCE SET; Schema: public; Owner: -
--

SELECT pg_catalog.setval('public.productioncounting_productiontrackingstatechange_id_seq', 1, false);


--
-- Name: productioncounting_staffworktime_id_seq; Type: SEQUENCE SET; Schema: public; Owner: -
--

SELECT pg_catalog.setval('public.productioncounting_staffworktime_id_seq', 1, false);


--
-- Name: productioncounting_trackinginproductreplacementhelper_id_seq; Type: SEQUENCE SET; Schema: public; Owner: -
--

SELECT pg_catalog.setval('public.productioncounting_trackinginproductreplacementhelper_id_seq', 1, false);


--
-- Name: productioncounting_trackingoperationproductcomponentdto_id_seq; Type: SEQUENCE SET; Schema: public; Owner: -
--

SELECT pg_catalog.setval('public.productioncounting_trackingoperationproductcomponentdto_id_seq', 1, false);


--
-- Name: productioncounting_trackingoperationproductincomponent_id_seq; Type: SEQUENCE SET; Schema: public; Owner: -
--

SELECT pg_catalog.setval('public.productioncounting_trackingoperationproductincomponent_id_seq', 1, false);


--
-- Name: productioncounting_trackingoperationproductincomponentdto_id_se; Type: SEQUENCE SET; Schema: public; Owner: -
--

SELECT pg_catalog.setval('public.productioncounting_trackingoperationproductincomponentdto_id_se', 1, false);


--
-- Name: productioncounting_trackingoperationproductincomponenthelper_id; Type: SEQUENCE SET; Schema: public; Owner: -
--

SELECT pg_catalog.setval('public.productioncounting_trackingoperationproductincomponenthelper_id', 1, false);


--
-- Name: productioncounting_trackingoperationproductoutcomponent_id_seq; Type: SEQUENCE SET; Schema: public; Owner: -
--

SELECT pg_catalog.setval('public.productioncounting_trackingoperationproductoutcomponent_id_seq', 1, false);


--
-- Name: productioncounting_trackingoperationproductoutcomponentdto_id_s; Type: SEQUENCE SET; Schema: public; Owner: -
--

SELECT pg_catalog.setval('public.productioncounting_trackingoperationproductoutcomponentdto_id_s', 1, false);


--
-- Name: productioncounting_trackingoperationproductoutcomponenthelper_i; Type: SEQUENCE SET; Schema: public; Owner: -
--

SELECT pg_catalog.setval('public.productioncounting_trackingoperationproductoutcomponenthelper_i', 1, false);


--
-- Name: productioncounting_usedbatch_id_seq; Type: SEQUENCE SET; Schema: public; Owner: -
--

SELECT pg_catalog.setval('public.productioncounting_usedbatch_id_seq', 1, false);


--
-- Name: productionlines_factorystructureelement_id_seq; Type: SEQUENCE SET; Schema: public; Owner: -
--

SELECT pg_catalog.setval('public.productionlines_factorystructureelement_id_seq', 1, false);


--
-- Name: productionlines_productionline_id_seq; Type: SEQUENCE SET; Schema: public; Owner: -
--

SELECT pg_catalog.setval('public.productionlines_productionline_id_seq', 2, false);


--
-- Name: productionlines_workstationtypecomponent_id_seq; Type: SEQUENCE SET; Schema: public; Owner: -
--

SELECT pg_catalog.setval('public.productionlines_workstationtypecomponent_id_seq', 1, false);


--
-- Name: productionpershift_balance_id_seq; Type: SEQUENCE SET; Schema: public; Owner: -
--

SELECT pg_catalog.setval('public.productionpershift_balance_id_seq', 1, false);


--
-- Name: productionpershift_balancecontext_id_seq; Type: SEQUENCE SET; Schema: public; Owner: -
--

SELECT pg_catalog.setval('public.productionpershift_balancecontext_id_seq', 1, false);


--
-- Name: productionpershift_dailyprogress_id_seq; Type: SEQUENCE SET; Schema: public; Owner: -
--

SELECT pg_catalog.setval('public.productionpershift_dailyprogress_id_seq', 1, false);


--
-- Name: productionpershift_plandailyprogress_id_seq; Type: SEQUENCE SET; Schema: public; Owner: -
--

SELECT pg_catalog.setval('public.productionpershift_plandailyprogress_id_seq', 1, false);


--
-- Name: productionpershift_planproductionpershift_id_seq; Type: SEQUENCE SET; Schema: public; Owner: -
--

SELECT pg_catalog.setval('public.productionpershift_planproductionpershift_id_seq', 1, false);


--
-- Name: productionpershift_planprogressforday_id_seq; Type: SEQUENCE SET; Schema: public; Owner: -
--

SELECT pg_catalog.setval('public.productionpershift_planprogressforday_id_seq', 1, false);


--
-- Name: productionpershift_ppsreport_id_seq; Type: SEQUENCE SET; Schema: public; Owner: -
--

SELECT pg_catalog.setval('public.productionpershift_ppsreport_id_seq', 1, false);


--
-- Name: productionpershift_productionpershift_id_seq; Type: SEQUENCE SET; Schema: public; Owner: -
--

SELECT pg_catalog.setval('public.productionpershift_productionpershift_id_seq', 1, false);


--
-- Name: productionpershift_progressforday_id_seq; Type: SEQUENCE SET; Schema: public; Owner: -
--

SELECT pg_catalog.setval('public.productionpershift_progressforday_id_seq', 1, false);


--
-- Name: productionpershift_reasontypeofcorrectionplan_id_seq; Type: SEQUENCE SET; Schema: public; Owner: -
--

SELECT pg_catalog.setval('public.productionpershift_reasontypeofcorrectionplan_id_seq', 1, false);


--
-- Name: productionplans_dimensioncontrolattribute_id_seq; Type: SEQUENCE SET; Schema: public; Owner: -
--

SELECT pg_catalog.setval('public.productionplans_dimensioncontrolattribute_id_seq', 1, false);


--
-- Name: productionscheduling_opercomptimecalculation_id_seq; Type: SEQUENCE SET; Schema: public; Owner: -
--

SELECT pg_catalog.setval('public.productionscheduling_opercomptimecalculation_id_seq', 1, false);


--
-- Name: productionscheduling_ordertimecalculation_id_seq; Type: SEQUENCE SET; Schema: public; Owner: -
--

SELECT pg_catalog.setval('public.productionscheduling_ordertimecalculation_id_seq', 1, false);


--
-- Name: productionscheduling_planopercomptimecalculation_id_seq; Type: SEQUENCE SET; Schema: public; Owner: -
--

SELECT pg_catalog.setval('public.productionscheduling_planopercomptimecalculation_id_seq', 1, false);


--
-- Name: productionscheduling_planordertimecalculation_id_seq; Type: SEQUENCE SET; Schema: public; Owner: -
--

SELECT pg_catalog.setval('public.productionscheduling_planordertimecalculation_id_seq', 1, false);


--
-- Name: qcadoocustomtranslation_customtranslation_id_seq; Type: SEQUENCE SET; Schema: public; Owner: -
--

SELECT pg_catalog.setval('public.qcadoocustomtranslation_customtranslation_id_seq', 1, false);


--
-- Name: qcadoomodel_dictionary_id_seq; Type: SEQUENCE SET; Schema: public; Owner: -
--

SELECT pg_catalog.setval('public.qcadoomodel_dictionary_id_seq', 25, true);


--
-- Name: qcadoomodel_dictionaryitem_id_seq; Type: SEQUENCE SET; Schema: public; Owner: -
--

SELECT pg_catalog.setval('public.qcadoomodel_dictionaryitem_id_seq', 42, false);


--
-- Name: qcadoomodel_globalunitconversionsaggregate_id_seq; Type: SEQUENCE SET; Schema: public; Owner: -
--

SELECT pg_catalog.setval('public.qcadoomodel_globalunitconversionsaggregate_id_seq', 2, false);


--
-- Name: qcadoomodel_unitconversionitem_id_seq; Type: SEQUENCE SET; Schema: public; Owner: -
--

SELECT pg_catalog.setval('public.qcadoomodel_unitconversionitem_id_seq', 10, false);


--
-- Name: qcadooplugin_plugin_id_seq; Type: SEQUENCE SET; Schema: public; Owner: -
--

SELECT pg_catalog.setval('public.qcadooplugin_plugin_id_seq', 163, true);


--
-- Name: qcadoosecurity_group_id_seq; Type: SEQUENCE SET; Schema: public; Owner: -
--

SELECT pg_catalog.setval('public.qcadoosecurity_group_id_seq', 42, true);


--
-- Name: qcadoosecurity_passwordresettoken_id_seq; Type: SEQUENCE SET; Schema: public; Owner: -
--

SELECT pg_catalog.setval('public.qcadoosecurity_passwordresettoken_id_seq', 1, false);


--
-- Name: qcadoosecurity_persistenttoken_id_seq; Type: SEQUENCE SET; Schema: public; Owner: -
--

SELECT pg_catalog.setval('public.qcadoosecurity_persistenttoken_id_seq', 1, false);


--
-- Name: qcadoosecurity_role_id_seq; Type: SEQUENCE SET; Schema: public; Owner: -
--

SELECT pg_catalog.setval('public.qcadoosecurity_role_id_seq', 171, true);


--
-- Name: qcadoosecurity_user_id_seq; Type: SEQUENCE SET; Schema: public; Owner: -
--

SELECT pg_catalog.setval('public.qcadoosecurity_user_id_seq', 3, true);


--
-- Name: qcadooview_alert_id_seq; Type: SEQUENCE SET; Schema: public; Owner: -
--

SELECT pg_catalog.setval('public.qcadooview_alert_id_seq', 1, false);


--
-- Name: qcadooview_category_id_seq; Type: SEQUENCE SET; Schema: public; Owner: -
--

SELECT pg_catalog.setval('public.qcadooview_category_id_seq', 23, true);


--
-- Name: qcadooview_item_id_seq; Type: SEQUENCE SET; Schema: public; Owner: -
--

SELECT pg_catalog.setval('public.qcadooview_item_id_seq', 222, true);


--
-- Name: qcadooview_systeminfo_id_seq; Type: SEQUENCE SET; Schema: public; Owner: -
--

SELECT pg_catalog.setval('public.qcadooview_systeminfo_id_seq', 1, false);


--
-- Name: qcadooview_view_id_seq; Type: SEQUENCE SET; Schema: public; Owner: -
--

SELECT pg_catalog.setval('public.qcadooview_view_id_seq', 221, true);


--
-- Name: qcadooview_viewedalert_id_seq; Type: SEQUENCE SET; Schema: public; Owner: -
--

SELECT pg_catalog.setval('public.qcadooview_viewedalert_id_seq', 1, false);


--
-- Name: qualitycontrol_changequalitycards_id_seq; Type: SEQUENCE SET; Schema: public; Owner: -
--

SELECT pg_catalog.setval('public.qualitycontrol_changequalitycards_id_seq', 1, false);


--
-- Name: qualitycontrol_deliveryqualitycontrol_id_seq; Type: SEQUENCE SET; Schema: public; Owner: -
--

SELECT pg_catalog.setval('public.qualitycontrol_deliveryqualitycontrol_id_seq', 1, false);


--
-- Name: qualitycontrol_qualitycardattachment_id_seq; Type: SEQUENCE SET; Schema: public; Owner: -
--

SELECT pg_catalog.setval('public.qualitycontrol_qualitycardattachment_id_seq', 1, false);


--
-- Name: qualitycontrol_qualitycarddto_id_seq; Type: SEQUENCE SET; Schema: public; Owner: -
--

SELECT pg_catalog.setval('public.qualitycontrol_qualitycarddto_id_seq', 1, false);


--
-- Name: qualitycontrol_qualitycontrol_id_seq; Type: SEQUENCE SET; Schema: public; Owner: -
--

SELECT pg_catalog.setval('public.qualitycontrol_qualitycontrol_id_seq', 1, false);


--
-- Name: qualitycontrol_qualitycontrol_number_seq; Type: SEQUENCE SET; Schema: public; Owner: -
--

SELECT pg_catalog.setval('public.qualitycontrol_qualitycontrol_number_seq', 1, false);


--
-- Name: qualitycontrol_qualitycontrolattachment_id_seq; Type: SEQUENCE SET; Schema: public; Owner: -
--

SELECT pg_catalog.setval('public.qualitycontrol_qualitycontrolattachment_id_seq', 1, false);


--
-- Name: qualitycontrol_qualitycontrolattribute_id_seq; Type: SEQUENCE SET; Schema: public; Owner: -
--

SELECT pg_catalog.setval('public.qualitycontrol_qualitycontrolattribute_id_seq', 1, false);


--
-- Name: qualitycontrol_qualitycontrolattributedeliveredprod_id_seq; Type: SEQUENCE SET; Schema: public; Owner: -
--

SELECT pg_catalog.setval('public.qualitycontrol_qualitycontrolattributedeliveredprod_id_seq', 1, false);


--
-- Name: qualitycontrol_qualitycontrolattributeprodtracking_id_seq; Type: SEQUENCE SET; Schema: public; Owner: -
--

SELECT pg_catalog.setval('public.qualitycontrol_qualitycontrolattributeprodtracking_id_seq', 1, false);


--
-- Name: qualitycontrol_qualitycontrolattributetoc_id_seq; Type: SEQUENCE SET; Schema: public; Owner: -
--

SELECT pg_catalog.setval('public.qualitycontrol_qualitycontrolattributetoc_id_seq', 1, false);


--
-- Name: qualitycontrol_qualitycontrolattributetocdto_id_seq; Type: SEQUENCE SET; Schema: public; Owner: -
--

SELECT pg_catalog.setval('public.qualitycontrol_qualitycontrolattributetocdto_id_seq', 1, false);


--
-- Name: qualitycontrol_qualitycontrolattributevalue_id_seq; Type: SEQUENCE SET; Schema: public; Owner: -
--

SELECT pg_catalog.setval('public.qualitycontrol_qualitycontrolattributevalue_id_seq', 1, false);


--
-- Name: qualitycontrol_qualitycontroldto_id_seq; Type: SEQUENCE SET; Schema: public; Owner: -
--

SELECT pg_catalog.setval('public.qualitycontrol_qualitycontroldto_id_seq', 1, false);


--
-- Name: qualitycontrol_qualitycontrolresource_id_seq; Type: SEQUENCE SET; Schema: public; Owner: -
--

SELECT pg_catalog.setval('public.qualitycontrol_qualitycontrolresource_id_seq', 1, false);


--
-- Name: qualitycontrol_qualitycontrolstatechange_id_seq; Type: SEQUENCE SET; Schema: public; Owner: -
--

SELECT pg_catalog.setval('public.qualitycontrol_qualitycontrolstatechange_id_seq', 1, false);


--
-- Name: qualitycontrol_qualitydeliveredproduct_id_seq; Type: SEQUENCE SET; Schema: public; Owner: -
--

SELECT pg_catalog.setval('public.qualitycontrol_qualitydeliveredproduct_id_seq', 1, false);


--
-- Name: repairs_repairorder_id_seq; Type: SEQUENCE SET; Schema: public; Owner: -
--

SELECT pg_catalog.setval('public.repairs_repairorder_id_seq', 1, false);


--
-- Name: repairs_repairorder_number_seq; Type: SEQUENCE SET; Schema: public; Owner: -
--

SELECT pg_catalog.setval('public.repairs_repairorder_number_seq', 1, false);


--
-- Name: repairs_repairorderdto_id_seq; Type: SEQUENCE SET; Schema: public; Owner: -
--

SELECT pg_catalog.setval('public.repairs_repairorderdto_id_seq', 1, false);


--
-- Name: repairs_repairorderproduct_id_seq; Type: SEQUENCE SET; Schema: public; Owner: -
--

SELECT pg_catalog.setval('public.repairs_repairorderproduct_id_seq', 1, false);


--
-- Name: repairs_repairorderstatechange_id_seq; Type: SEQUENCE SET; Schema: public; Owner: -
--

SELECT pg_catalog.setval('public.repairs_repairorderstatechange_id_seq', 1, false);


--
-- Name: repairs_repairorderworktime_id_seq; Type: SEQUENCE SET; Schema: public; Owner: -
--

SELECT pg_catalog.setval('public.repairs_repairorderworktime_id_seq', 1, false);


--
-- Name: states_message_id_seq; Type: SEQUENCE SET; Schema: public; Owner: -
--

SELECT pg_catalog.setval('public.states_message_id_seq', 1, false);


--
-- Name: stoppage_stoppage_id_seq; Type: SEQUENCE SET; Schema: public; Owner: -
--

SELECT pg_catalog.setval('public.stoppage_stoppage_id_seq', 1, false);


--
-- Name: stoppage_stoppagedto_id_seq; Type: SEQUENCE SET; Schema: public; Owner: -
--

SELECT pg_catalog.setval('public.stoppage_stoppagedto_id_seq', 1, false);


--
-- Name: stoppage_stoppagereason_id_seq; Type: SEQUENCE SET; Schema: public; Owner: -
--

SELECT pg_catalog.setval('public.stoppage_stoppagereason_id_seq', 2, false);


--
-- Name: sub_order_number_seq; Type: SEQUENCE SET; Schema: public; Owner: -
--

SELECT pg_catalog.setval('public.sub_order_number_seq', 1, false);


--
-- Name: subcontractorportal_cost_id_seq; Type: SEQUENCE SET; Schema: public; Owner: -
--

SELECT pg_catalog.setval('public.subcontractorportal_cost_id_seq', 1, false);


--
-- Name: subcontractorportal_event_id_seq; Type: SEQUENCE SET; Schema: public; Owner: -
--

SELECT pg_catalog.setval('public.subcontractorportal_event_id_seq', 1, false);


--
-- Name: subcontractorportal_message_id_seq; Type: SEQUENCE SET; Schema: public; Owner: -
--

SELECT pg_catalog.setval('public.subcontractorportal_message_id_seq', 1, false);


--
-- Name: subcontractorportal_operation_id_seq; Type: SEQUENCE SET; Schema: public; Owner: -
--

SELECT pg_catalog.setval('public.subcontractorportal_operation_id_seq', 1, false);


--
-- Name: subcontractorportal_realisation_id_seq; Type: SEQUENCE SET; Schema: public; Owner: -
--

SELECT pg_catalog.setval('public.subcontractorportal_realisation_id_seq', 1, false);


--
-- Name: subcontractorportal_suborder_id_seq; Type: SEQUENCE SET; Schema: public; Owner: -
--

SELECT pg_catalog.setval('public.subcontractorportal_suborder_id_seq', 1, false);


--
-- Name: subcontractorportal_suborderattachment_id_seq; Type: SEQUENCE SET; Schema: public; Owner: -
--

SELECT pg_catalog.setval('public.subcontractorportal_suborderattachment_id_seq', 1, false);


--
-- Name: subcontractorportal_subordercost_id_seq; Type: SEQUENCE SET; Schema: public; Owner: -
--

SELECT pg_catalog.setval('public.subcontractorportal_subordercost_id_seq', 1, false);


--
-- Name: subcontractorportal_suborderdto_id_seq; Type: SEQUENCE SET; Schema: public; Owner: -
--

SELECT pg_catalog.setval('public.subcontractorportal_suborderdto_id_seq', 1, false);


--
-- Name: subcontractorportal_suborderevent_id_seq; Type: SEQUENCE SET; Schema: public; Owner: -
--

SELECT pg_catalog.setval('public.subcontractorportal_suborderevent_id_seq', 1, false);


--
-- Name: subcontractorportal_suborderinput_id_seq; Type: SEQUENCE SET; Schema: public; Owner: -
--

SELECT pg_catalog.setval('public.subcontractorportal_suborderinput_id_seq', 1, false);


--
-- Name: subcontractorportal_suborderissuedproductsreport_id_seq; Type: SEQUENCE SET; Schema: public; Owner: -
--

SELECT pg_catalog.setval('public.subcontractorportal_suborderissuedproductsreport_id_seq', 1, false);


--
-- Name: subcontractorportal_suborderissuedproductsreport_number_seq; Type: SEQUENCE SET; Schema: public; Owner: -
--

SELECT pg_catalog.setval('public.subcontractorportal_suborderissuedproductsreport_number_seq', 1, false);


--
-- Name: subcontractorportal_subordermessage_id_seq; Type: SEQUENCE SET; Schema: public; Owner: -
--

SELECT pg_catalog.setval('public.subcontractorportal_subordermessage_id_seq', 1, false);


--
-- Name: subcontractorportal_suborderoperation_id_seq; Type: SEQUENCE SET; Schema: public; Owner: -
--

SELECT pg_catalog.setval('public.subcontractorportal_suborderoperation_id_seq', 1, false);


--
-- Name: subcontractorportal_suborderoutput_id_seq; Type: SEQUENCE SET; Schema: public; Owner: -
--

SELECT pg_catalog.setval('public.subcontractorportal_suborderoutput_id_seq', 1, false);


--
-- Name: subcontractorportal_suborderrealisation_id_seq; Type: SEQUENCE SET; Schema: public; Owner: -
--

SELECT pg_catalog.setval('public.subcontractorportal_suborderrealisation_id_seq', 1, false);


--
-- Name: subcontractorportal_suborderstatechange_id_seq; Type: SEQUENCE SET; Schema: public; Owner: -
--

SELECT pg_catalog.setval('public.subcontractorportal_suborderstatechange_id_seq', 1, false);


--
-- Name: subcontractorportal_subordertmp_id_seq; Type: SEQUENCE SET; Schema: public; Owner: -
--

SELECT pg_catalog.setval('public.subcontractorportal_subordertmp_id_seq', 1, false);


--
-- Name: supplynegotiations_columnforoffers_id_seq; Type: SEQUENCE SET; Schema: public; Owner: -
--

SELECT pg_catalog.setval('public.supplynegotiations_columnforoffers_id_seq', 10, false);


--
-- Name: supplynegotiations_columnforrequests_id_seq; Type: SEQUENCE SET; Schema: public; Owner: -
--

SELECT pg_catalog.setval('public.supplynegotiations_columnforrequests_id_seq', 9, false);


--
-- Name: supplynegotiations_negotiation_id_seq; Type: SEQUENCE SET; Schema: public; Owner: -
--

SELECT pg_catalog.setval('public.supplynegotiations_negotiation_id_seq', 1, false);


--
-- Name: supplynegotiations_negotiationproduct_id_seq; Type: SEQUENCE SET; Schema: public; Owner: -
--

SELECT pg_catalog.setval('public.supplynegotiations_negotiationproduct_id_seq', 1, false);


--
-- Name: supplynegotiations_negotiationstatechange_id_seq; Type: SEQUENCE SET; Schema: public; Owner: -
--

SELECT pg_catalog.setval('public.supplynegotiations_negotiationstatechange_id_seq', 1, false);


--
-- Name: supplynegotiations_offer_id_seq; Type: SEQUENCE SET; Schema: public; Owner: -
--

SELECT pg_catalog.setval('public.supplynegotiations_offer_id_seq', 1, false);


--
-- Name: supplynegotiations_offerproduct_id_seq; Type: SEQUENCE SET; Schema: public; Owner: -
--

SELECT pg_catalog.setval('public.supplynegotiations_offerproduct_id_seq', 1, false);


--
-- Name: supplynegotiations_offerstatechange_id_seq; Type: SEQUENCE SET; Schema: public; Owner: -
--

SELECT pg_catalog.setval('public.supplynegotiations_offerstatechange_id_seq', 1, false);


--
-- Name: supplynegotiations_parametercolumnforoffers_id_seq; Type: SEQUENCE SET; Schema: public; Owner: -
--

SELECT pg_catalog.setval('public.supplynegotiations_parametercolumnforoffers_id_seq', 10, false);


--
-- Name: supplynegotiations_parametercolumnforrequests_id_seq; Type: SEQUENCE SET; Schema: public; Owner: -
--

SELECT pg_catalog.setval('public.supplynegotiations_parametercolumnforrequests_id_seq', 9, false);


--
-- Name: supplynegotiations_requestforquotation_id_seq; Type: SEQUENCE SET; Schema: public; Owner: -
--

SELECT pg_catalog.setval('public.supplynegotiations_requestforquotation_id_seq', 1, false);


--
-- Name: supplynegotiations_requestforquotationproduct_id_seq; Type: SEQUENCE SET; Schema: public; Owner: -
--

SELECT pg_catalog.setval('public.supplynegotiations_requestforquotationproduct_id_seq', 1, false);


--
-- Name: supplynegotiations_requestforquotationstatechange_id_seq; Type: SEQUENCE SET; Schema: public; Owner: -
--

SELECT pg_catalog.setval('public.supplynegotiations_requestforquotationstatechange_id_seq', 1, false);


--
-- Name: technologies_barcodeoperationcomponent_id_seq; Type: SEQUENCE SET; Schema: public; Owner: -
--

SELECT pg_catalog.setval('public.technologies_barcodeoperationcomponent_id_seq', 1, false);


--
-- Name: technologies_barcodeoperationcomponent_number_seq; Type: SEQUENCE SET; Schema: public; Owner: -
--

SELECT pg_catalog.setval('public.technologies_barcodeoperationcomponent_number_seq', 1, false);


--
-- Name: technologies_changetechnologyparameters_id_seq; Type: SEQUENCE SET; Schema: public; Owner: -
--

SELECT pg_catalog.setval('public.technologies_changetechnologyparameters_id_seq', 1, false);


--
-- Name: technologies_dimensioncontrolattribute_id_seq; Type: SEQUENCE SET; Schema: public; Owner: -
--

SELECT pg_catalog.setval('public.technologies_dimensioncontrolattribute_id_seq', 1, false);


--
-- Name: technologies_modifytechnologyaddproducthelper_id_seq; Type: SEQUENCE SET; Schema: public; Owner: -
--

SELECT pg_catalog.setval('public.technologies_modifytechnologyaddproducthelper_id_seq', 1, false);


--
-- Name: technologies_modifytechnologyhelper_id_seq; Type: SEQUENCE SET; Schema: public; Owner: -
--

SELECT pg_catalog.setval('public.technologies_modifytechnologyhelper_id_seq', 1, false);


--
-- Name: technologies_operation_id_seq; Type: SEQUENCE SET; Schema: public; Owner: -
--

SELECT pg_catalog.setval('public.technologies_operation_id_seq', 1, false);


--
-- Name: technologies_operationgroup_id_seq; Type: SEQUENCE SET; Schema: public; Owner: -
--

SELECT pg_catalog.setval('public.technologies_operationgroup_id_seq', 1, false);


--
-- Name: technologies_operationproductincomponent_id_seq; Type: SEQUENCE SET; Schema: public; Owner: -
--

SELECT pg_catalog.setval('public.technologies_operationproductincomponent_id_seq', 1, false);


--
-- Name: technologies_operationproductincomponentdto_id_seq; Type: SEQUENCE SET; Schema: public; Owner: -
--

SELECT pg_catalog.setval('public.technologies_operationproductincomponentdto_id_seq', 1, false);


--
-- Name: technologies_operationproductinproductdto_id_seq; Type: SEQUENCE SET; Schema: public; Owner: -
--

SELECT pg_catalog.setval('public.technologies_operationproductinproductdto_id_seq', 1, false);


--
-- Name: technologies_operationproductoutcomponent_id_seq; Type: SEQUENCE SET; Schema: public; Owner: -
--

SELECT pg_catalog.setval('public.technologies_operationproductoutcomponent_id_seq', 1, false);


--
-- Name: technologies_operationskill_id_seq; Type: SEQUENCE SET; Schema: public; Owner: -
--

SELECT pg_catalog.setval('public.technologies_operationskill_id_seq', 1, false);


--
-- Name: technologies_operationtechnologydto_id_seq; Type: SEQUENCE SET; Schema: public; Owner: -
--

SELECT pg_catalog.setval('public.technologies_operationtechnologydto_id_seq', 1, false);


--
-- Name: technologies_pieceratetechnologydto_id_seq; Type: SEQUENCE SET; Schema: public; Owner: -
--

SELECT pg_catalog.setval('public.technologies_pieceratetechnologydto_id_seq', 1, false);


--
-- Name: technologies_productbysizegroup_id_seq; Type: SEQUENCE SET; Schema: public; Owner: -
--

SELECT pg_catalog.setval('public.technologies_productbysizegroup_id_seq', 1, false);


--
-- Name: technologies_productcomponent_id_seq; Type: SEQUENCE SET; Schema: public; Owner: -
--

SELECT pg_catalog.setval('public.technologies_productcomponent_id_seq', 1, false);


--
-- Name: technologies_productdata_id_seq; Type: SEQUENCE SET; Schema: public; Owner: -
--

SELECT pg_catalog.setval('public.technologies_productdata_id_seq', 1, false);


--
-- Name: technologies_productdataattachment_id_seq; Type: SEQUENCE SET; Schema: public; Owner: -
--

SELECT pg_catalog.setval('public.technologies_productdataattachment_id_seq', 1, false);


--
-- Name: technologies_productdatainput_id_seq; Type: SEQUENCE SET; Schema: public; Owner: -
--

SELECT pg_catalog.setval('public.technologies_productdatainput_id_seq', 1, false);


--
-- Name: technologies_productdataoperation_id_seq; Type: SEQUENCE SET; Schema: public; Owner: -
--

SELECT pg_catalog.setval('public.technologies_productdataoperation_id_seq', 1, false);


--
-- Name: technologies_productionlinetechnologygroup_id_seq; Type: SEQUENCE SET; Schema: public; Owner: -
--

SELECT pg_catalog.setval('public.technologies_productionlinetechnologygroup_id_seq', 1, false);


--
-- Name: technologies_productstructuretreenode_id_seq; Type: SEQUENCE SET; Schema: public; Owner: -
--

SELECT pg_catalog.setval('public.technologies_productstructuretreenode_id_seq', 1, false);


--
-- Name: technologies_producttoproductgrouptechnology_id_seq; Type: SEQUENCE SET; Schema: public; Owner: -
--

SELECT pg_catalog.setval('public.technologies_producttoproductgrouptechnology_id_seq', 1, false);


--
-- Name: technologies_section_id_seq; Type: SEQUENCE SET; Schema: public; Owner: -
--

SELECT pg_catalog.setval('public.technologies_section_id_seq', 1, false);


--
-- Name: technologies_technological_process_list_number_seq; Type: SEQUENCE SET; Schema: public; Owner: -
--

SELECT pg_catalog.setval('public.technologies_technological_process_list_number_seq', 1, false);


--
-- Name: technologies_technologicalprocess_id_seq; Type: SEQUENCE SET; Schema: public; Owner: -
--

SELECT pg_catalog.setval('public.technologies_technologicalprocess_id_seq', 1, false);


--
-- Name: technologies_technologicalprocesscomponent_id_seq; Type: SEQUENCE SET; Schema: public; Owner: -
--

SELECT pg_catalog.setval('public.technologies_technologicalprocesscomponent_id_seq', 1, false);


--
-- Name: technologies_technologicalprocesslist_id_seq; Type: SEQUENCE SET; Schema: public; Owner: -
--

SELECT pg_catalog.setval('public.technologies_technologicalprocesslist_id_seq', 1, false);


--
-- Name: technologies_technology_id_seq; Type: SEQUENCE SET; Schema: public; Owner: -
--

SELECT pg_catalog.setval('public.technologies_technology_id_seq', 1, false);


--
-- Name: technologies_technologyattachment_id_seq; Type: SEQUENCE SET; Schema: public; Owner: -
--

SELECT pg_catalog.setval('public.technologies_technologyattachment_id_seq', 1, false);


--
-- Name: technologies_technologydto_id_seq; Type: SEQUENCE SET; Schema: public; Owner: -
--

SELECT pg_catalog.setval('public.technologies_technologydto_id_seq', 1, false);


--
-- Name: technologies_technologygroup_id_seq; Type: SEQUENCE SET; Schema: public; Owner: -
--

SELECT pg_catalog.setval('public.technologies_technologygroup_id_seq', 1, false);


--
-- Name: technologies_technologyinputproducttype_id_seq; Type: SEQUENCE SET; Schema: public; Owner: -
--

SELECT pg_catalog.setval('public.technologies_technologyinputproducttype_id_seq', 1, false);


--
-- Name: technologies_technologyoperationcomponent_id_seq; Type: SEQUENCE SET; Schema: public; Owner: -
--

SELECT pg_catalog.setval('public.technologies_technologyoperationcomponent_id_seq', 1, false);


--
-- Name: technologies_technologyoperationcomponentdto_id_seq; Type: SEQUENCE SET; Schema: public; Owner: -
--

SELECT pg_catalog.setval('public.technologies_technologyoperationcomponentdto_id_seq', 1, false);


--
-- Name: technologies_technologyproductionline_id_seq; Type: SEQUENCE SET; Schema: public; Owner: -
--

SELECT pg_catalog.setval('public.technologies_technologyproductionline_id_seq', 1, false);


--
-- Name: technologies_technologystatechange_id_seq; Type: SEQUENCE SET; Schema: public; Owner: -
--

SELECT pg_catalog.setval('public.technologies_technologystatechange_id_seq', 1, false);


--
-- Name: technologies_technologytocreationhelper_id_seq; Type: SEQUENCE SET; Schema: public; Owner: -
--

SELECT pg_catalog.setval('public.technologies_technologytocreationhelper_id_seq', 1, false);


--
-- Name: technologies_workstationchangeovernorm_id_seq; Type: SEQUENCE SET; Schema: public; Owner: -
--

SELECT pg_catalog.setval('public.technologies_workstationchangeovernorm_id_seq', 1, false);


--
-- Name: technologies_workstationchangeovernormdto_id_seq; Type: SEQUENCE SET; Schema: public; Owner: -
--

SELECT pg_catalog.setval('public.technologies_workstationchangeovernormdto_id_seq', 1, false);


--
-- Name: technologies_workstationstatechange_id_seq; Type: SEQUENCE SET; Schema: public; Owner: -
--

SELECT pg_catalog.setval('public.technologies_workstationstatechange_id_seq', 1, false);


--
-- Name: technologiesgenerator_generatorcontext_id_seq; Type: SEQUENCE SET; Schema: public; Owner: -
--

SELECT pg_catalog.setval('public.technologiesgenerator_generatorcontext_id_seq', 1, false);


--
-- Name: technologiesgenerator_generatorcontext_number_seq; Type: SEQUENCE SET; Schema: public; Owner: -
--

SELECT pg_catalog.setval('public.technologiesgenerator_generatorcontext_number_seq', 1, false);


--
-- Name: technologiesgenerator_generatortechnologiesforproduct_id_seq; Type: SEQUENCE SET; Schema: public; Owner: -
--

SELECT pg_catalog.setval('public.technologiesgenerator_generatortechnologiesforproduct_id_seq', 1, false);


--
-- Name: technologiesgenerator_generatortreenode_id_seq; Type: SEQUENCE SET; Schema: public; Owner: -
--

SELECT pg_catalog.setval('public.technologiesgenerator_generatortreenode_id_seq', 1, false);


--
-- Name: techsubcontracting_companyoperation_id_seq; Type: SEQUENCE SET; Schema: public; Owner: -
--

SELECT pg_catalog.setval('public.techsubcontracting_companyoperation_id_seq', 1, false);


--
-- Name: techsubcontracting_companyoperationgroup_id_seq; Type: SEQUENCE SET; Schema: public; Owner: -
--

SELECT pg_catalog.setval('public.techsubcontracting_companyoperationgroup_id_seq', 1, false);


--
-- Name: techsubcontracting_orderexternalservicecost_id_seq; Type: SEQUENCE SET; Schema: public; Owner: -
--

SELECT pg_catalog.setval('public.techsubcontracting_orderexternalservicecost_id_seq', 1, false);


--
-- Name: timegapspreview_timegap_id_seq; Type: SEQUENCE SET; Schema: public; Owner: -
--

SELECT pg_catalog.setval('public.timegapspreview_timegap_id_seq', 1, false);


--
-- Name: timegapspreview_timegapscontext_id_seq; Type: SEQUENCE SET; Schema: public; Owner: -
--

SELECT pg_catalog.setval('public.timegapspreview_timegapscontext_id_seq', 1, false);


--
-- Name: timenormsforoperations_operationworkstationtime_id_seq; Type: SEQUENCE SET; Schema: public; Owner: -
--

SELECT pg_catalog.setval('public.timenormsforoperations_operationworkstationtime_id_seq', 1, false);


--
-- Name: timenormsforoperations_techopercomptimecalculation_id_seq; Type: SEQUENCE SET; Schema: public; Owner: -
--

SELECT pg_catalog.setval('public.timenormsforoperations_techopercomptimecalculation_id_seq', 1, false);


--
-- Name: timenormsforoperations_techopercompworkstationtime_id_seq; Type: SEQUENCE SET; Schema: public; Owner: -
--

SELECT pg_catalog.setval('public.timenormsforoperations_techopercompworkstationtime_id_seq', 1, false);


--
-- Name: urccore_lastsynchronizationdate_id_seq; Type: SEQUENCE SET; Schema: public; Owner: -
--

SELECT pg_catalog.setval('public.urccore_lastsynchronizationdate_id_seq', 1, false);


--
-- Name: urccore_synchronizationstatus_id_seq; Type: SEQUENCE SET; Schema: public; Owner: -
--

SELECT pg_catalog.setval('public.urccore_synchronizationstatus_id_seq', 1, false);


--
-- Name: urcmaterialavailability_requiredcomponent_id_seq; Type: SEQUENCE SET; Schema: public; Owner: -
--

SELECT pg_catalog.setval('public.urcmaterialavailability_requiredcomponent_id_seq', 1, false);


--
-- Name: urcproductioncounting_requestrepair_id_seq; Type: SEQUENCE SET; Schema: public; Owner: -
--

SELECT pg_catalog.setval('public.urcproductioncounting_requestrepair_id_seq', 1, false);


--
-- Name: wagegroups_wagegroup_id_seq; Type: SEQUENCE SET; Schema: public; Owner: -
--

SELECT pg_catalog.setval('public.wagegroups_wagegroup_id_seq', 1, false);


--
-- Name: walusiak_exportdocumenthistory_id_seq; Type: SEQUENCE SET; Schema: public; Owner: -
--

SELECT pg_catalog.setval('public.walusiak_exportdocumenthistory_id_seq', 1, false);


--
-- Name: warehouseminimalstate_warehouseminimumstate_id_seq; Type: SEQUENCE SET; Schema: public; Owner: -
--

SELECT pg_catalog.setval('public.warehouseminimalstate_warehouseminimumstate_id_seq', 1, false);


--
-- Name: warehouseminimalstate_warehouseminimumstatemulti_id_seq; Type: SEQUENCE SET; Schema: public; Owner: -
--

SELECT pg_catalog.setval('public.warehouseminimalstate_warehouseminimumstatemulti_id_seq', 1, false);


--
-- Name: workplans_columnforinputproducts_id_seq; Type: SEQUENCE SET; Schema: public; Owner: -
--

SELECT pg_catalog.setval('public.workplans_columnforinputproducts_id_seq', 9, false);


--
-- Name: workplans_columnfororders_id_seq; Type: SEQUENCE SET; Schema: public; Owner: -
--

SELECT pg_catalog.setval('public.workplans_columnfororders_id_seq', 7, false);


--
-- Name: workplans_columnforoutputproducts_id_seq; Type: SEQUENCE SET; Schema: public; Owner: -
--

SELECT pg_catalog.setval('public.workplans_columnforoutputproducts_id_seq', 7, false);


--
-- Name: workplans_parameterinputcolumn_id_seq; Type: SEQUENCE SET; Schema: public; Owner: -
--

SELECT pg_catalog.setval('public.workplans_parameterinputcolumn_id_seq', 7, false);


--
-- Name: workplans_parameterordercolumn_id_seq; Type: SEQUENCE SET; Schema: public; Owner: -
--

SELECT pg_catalog.setval('public.workplans_parameterordercolumn_id_seq', 6, false);


--
-- Name: workplans_parameteroutputcolumn_id_seq; Type: SEQUENCE SET; Schema: public; Owner: -
--

SELECT pg_catalog.setval('public.workplans_parameteroutputcolumn_id_seq', 7, false);


--
-- Name: workplans_workplan_id_seq; Type: SEQUENCE SET; Schema: public; Owner: -
--

SELECT pg_catalog.setval('public.workplans_workplan_id_seq', 1, false);


--
-- Name: workplans_workplanordercolumn_id_seq; Type: SEQUENCE SET; Schema: public; Owner: -
--

SELECT pg_catalog.setval('public.workplans_workplanordercolumn_id_seq', 1, false);


--
-- Name: workstation_changeover_for_operational_task_number_seq; Type: SEQUENCE SET; Schema: public; Owner: -
--

SELECT pg_catalog.setval('public.workstation_changeover_for_operational_task_number_seq', 1, false);


--
-- Name: arch_masterorders_masterorder arc2_masterorders_masterorder_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.arch_masterorders_masterorder
    ADD CONSTRAINT arc2_masterorders_masterorder_pkey PRIMARY KEY (id);


--
-- Name: arch_orders_order arc2_orders_order_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.arch_orders_order
    ADD CONSTRAINT arc2_orders_order_pkey PRIMARY KEY (id);


--
-- Name: basic_assortment basic_assortment_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.basic_assortment
    ADD CONSTRAINT basic_assortment_pkey PRIMARY KEY (id);


--
-- Name: basic_company basic_company_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.basic_company
    ADD CONSTRAINT basic_company_pkey PRIMARY KEY (id);


--
-- Name: basic_product basic_product_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.basic_product
    ADD CONSTRAINT basic_product_pkey PRIMARY KEY (id);


--
-- Name: basic_shift basic_shift_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.basic_shift
    ADD CONSTRAINT basic_shift_pkey PRIMARY KEY (id);


--
-- Name: basic_staff basic_staff_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.basic_staff
    ADD CONSTRAINT basic_staff_pkey PRIMARY KEY (id);


--
-- Name: masterorders_masterorder masterorders_masterorder_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.masterorders_masterorder
    ADD CONSTRAINT masterorders_masterorder_pkey PRIMARY KEY (id);


--
-- Name: orders_order orders_order_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.orders_order
    ADD CONSTRAINT orders_order_pkey PRIMARY KEY (id);


--
-- Name: productionlines_productionline productionlines_productionline_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.productionlines_productionline
    ADD CONSTRAINT productionlines_productionline_pkey PRIMARY KEY (id);


--
-- Name: technologiesgenerator_generatorcontext technologiesgenerator_generatorcontext_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.technologiesgenerator_generatorcontext
    ADD CONSTRAINT technologiesgenerator_generatorcontext_pkey PRIMARY KEY (id);


--
-- Name: mv_productioncounting_productionanalysisdto; Type: MATERIALIZED VIEW; Schema: public; Owner: -
--

CREATE MATERIALIZED VIEW public.mv_productioncounting_productionanalysisdto AS
 SELECT row_number() OVER () AS id,
    bool_or(productiontracking.active) AS active,
    (productionline.id)::integer AS productionline_id,
    productionline.number AS productionlinenumber,
    (basiccompany.id)::integer AS company_id,
    basiccompany.number AS companynumber,
    (staff.id)::integer AS staff_id,
    (((staff.surname)::text || ' '::text) || (staff.name)::text) AS staffname,
    (assortment.id)::integer AS assortment_id,
    assortment.name AS assortmentname,
    (product.id)::integer AS product_id,
    product.number AS productnumber,
    product.name AS productname,
    product.unit AS productunit,
    size.number AS sizenumber,
    sum((COALESCE(trackingoperationproductoutcomponent.usedquantity, (0)::numeric))::numeric(14,5)) AS usedquantity,
    sum((COALESCE(trackingoperationproductoutcomponent.wastesquantity, (0)::numeric))::numeric(14,5)) AS wastesquantity,
    sum(((COALESCE(trackingoperationproductoutcomponent.usedquantity, (0)::numeric) + COALESCE(trackingoperationproductoutcomponent.wastesquantity, (0)::numeric)))::numeric(14,5)) AS donequantity,
    trackingoperationproductoutcomponent.causeofwastes,
    (shift.id)::integer AS shift_id,
    shift.name AS shiftname,
    (productiontracking.timerangefrom)::date AS timerangefrom,
    (productiontracking.timerangeto)::date AS timerangeto,
    (tcontext.id)::integer AS generator_id,
    tcontext.number AS generatorname,
    (ordersorder.id)::integer AS order_id,
    ordersorder.number AS ordernumber,
    COALESCE(masterorder.number, groupmasterorder.number) AS obtainedmasterordernumber,
    technologygroup.number AS technologygroupnumber,
    trackingoperationproductoutcomponent.typeofmaterial
   FROM (((((((((((((((public.productioncounting_productiontracking productiontracking
     LEFT JOIN public.orders_order ordersorder ON ((ordersorder.id = productiontracking.order_id)))
     LEFT JOIN public.basic_company basiccompany ON ((basiccompany.id = ordersorder.company_id)))
     LEFT JOIN public.productionlines_productionline productionline ON ((productionline.id = ordersorder.productionline_id)))
     LEFT JOIN public.basic_staff staff ON ((staff.id = productiontracking.staff_id)))
     LEFT JOIN public.productioncounting_trackingoperationproductoutcomponent trackingoperationproductoutcomponent ON ((trackingoperationproductoutcomponent.productiontracking_id = productiontracking.id)))
     LEFT JOIN public.basic_product product ON ((product.id = trackingoperationproductoutcomponent.product_id)))
     LEFT JOIN public.basic_assortment assortment ON ((assortment.id = product.assortment_id)))
     LEFT JOIN public.basic_size size ON ((size.id = product.size_id)))
     LEFT JOIN public.basic_shift shift ON ((shift.id = productiontracking.shift_id)))
     LEFT JOIN public.technologies_technology technologyprototype ON ((ordersorder.technology_id = technologyprototype.id)))
     LEFT JOIN public.technologiesgenerator_generatorcontext tcontext ON ((tcontext.id = technologyprototype.generatorcontext_id)))
     LEFT JOIN public.masterorders_masterorder masterorder ON ((masterorder.id = ordersorder.masterorder_id)))
     LEFT JOIN public.ordersgroups_ordersgroup ordersgroup ON ((ordersgroup.id = ordersorder.ordersgroup_id)))
     LEFT JOIN public.masterorders_masterorder groupmasterorder ON ((groupmasterorder.id = ordersgroup.masterorder_id)))
     LEFT JOIN public.technologies_technologygroup technologygroup ON ((technologyprototype.technologygroup_id = technologygroup.id)))
  WHERE ((productiontracking.state)::text = ANY (ARRAY[('01draft'::character varying)::text, ('02accepted'::character varying)::text]))
  GROUP BY productionline.id, basiccompany.id, staff.id, assortment.id, size.number, product.id, shift.id, trackingoperationproductoutcomponent.causeofwastes, ((productiontracking.timerangefrom)::date), ((productiontracking.timerangeto)::date), ordersorder.id, tcontext.id, masterorder.id, groupmasterorder.id, technologygroup.number, trackingoperationproductoutcomponent.typeofmaterial
UNION ALL
 SELECT row_number() OVER () AS id,
    bool_or(productiontracking.active) AS active,
    (productionline.id)::integer AS productionline_id,
    productionline.number AS productionlinenumber,
    (basiccompany.id)::integer AS company_id,
    basiccompany.number AS companynumber,
    (staff.id)::integer AS staff_id,
    (((staff.surname)::text || ' '::text) || (staff.name)::text) AS staffname,
    (assortment.id)::integer AS assortment_id,
    assortment.name AS assortmentname,
    (product.id)::integer AS product_id,
    product.number AS productnumber,
    product.name AS productname,
    product.unit AS productunit,
    size.number AS sizenumber,
    sum((COALESCE(trackingoperationproductoutcomponent.usedquantity, (0)::numeric))::numeric(14,5)) AS usedquantity,
    sum((COALESCE(trackingoperationproductoutcomponent.wastesquantity, (0)::numeric))::numeric(14,5)) AS wastesquantity,
    sum(((COALESCE(trackingoperationproductoutcomponent.usedquantity, (0)::numeric) + COALESCE(trackingoperationproductoutcomponent.wastesquantity, (0)::numeric)))::numeric(14,5)) AS donequantity,
    trackingoperationproductoutcomponent.causeofwastes,
    (shift.id)::integer AS shift_id,
    shift.name AS shiftname,
    (productiontracking.timerangefrom)::date AS timerangefrom,
    (productiontracking.timerangeto)::date AS timerangeto,
    (tcontext.id)::integer AS generator_id,
    tcontext.number AS generatorname,
    (ordersorder.id)::integer AS order_id,
    ordersorder.number AS ordernumber,
    COALESCE(masterorder.number, groupmasterorder.number) AS obtainedmasterordernumber,
    technologygroup.number AS technologygroupnumber,
    trackingoperationproductoutcomponent.typeofmaterial
   FROM (((((((((((((((public.arch_productioncounting_productiontracking productiontracking
     LEFT JOIN public.arch_orders_order ordersorder ON ((ordersorder.id = productiontracking.order_id)))
     LEFT JOIN public.basic_company basiccompany ON ((basiccompany.id = ordersorder.company_id)))
     LEFT JOIN public.productionlines_productionline productionline ON ((productionline.id = ordersorder.productionline_id)))
     LEFT JOIN public.basic_staff staff ON ((staff.id = productiontracking.staff_id)))
     LEFT JOIN public.arch_productioncounting_trackingoperationproductoutcomponent trackingoperationproductoutcomponent ON ((trackingoperationproductoutcomponent.productiontracking_id = productiontracking.id)))
     LEFT JOIN public.basic_product product ON ((product.id = trackingoperationproductoutcomponent.product_id)))
     LEFT JOIN public.basic_assortment assortment ON ((assortment.id = product.assortment_id)))
     LEFT JOIN public.basic_size size ON ((size.id = product.size_id)))
     LEFT JOIN public.basic_shift shift ON ((shift.id = productiontracking.shift_id)))
     LEFT JOIN public.technologies_technology technologyprototype ON ((ordersorder.technology_id = technologyprototype.id)))
     LEFT JOIN public.technologiesgenerator_generatorcontext tcontext ON ((tcontext.id = technologyprototype.generatorcontext_id)))
     LEFT JOIN public.arch_masterorders_masterorder masterorder ON ((masterorder.id = ordersorder.masterorder_id)))
     LEFT JOIN public.arch_ordersgroups_ordersgroup ordersgroup ON ((ordersgroup.id = ordersorder.ordersgroup_id)))
     LEFT JOIN public.arch_masterorders_masterorder groupmasterorder ON ((groupmasterorder.id = ordersgroup.masterorder_id)))
     LEFT JOIN public.technologies_technologygroup technologygroup ON ((technologyprototype.technologygroup_id = technologygroup.id)))
  WHERE ((productiontracking.state)::text = ANY (ARRAY[('01draft'::character varying)::text, ('02accepted'::character varying)::text]))
  GROUP BY productionline.id, basiccompany.id, staff.id, assortment.id, size.number, product.id, shift.id, trackingoperationproductoutcomponent.causeofwastes, ((productiontracking.timerangefrom)::date), ((productiontracking.timerangeto)::date), ordersorder.id, tcontext.id, masterorder.id, groupmasterorder.id, technologygroup.number, trackingoperationproductoutcomponent.typeofmaterial
  WITH NO DATA;


--
-- Name: basic_address address_externalnumber_unique; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.basic_address
    ADD CONSTRAINT address_externalnumber_unique UNIQUE (externalnumber);


--
-- Name: advancedgenealogy_batch advancedgenealogy_batch_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.advancedgenealogy_batch
    ADD CONSTRAINT advancedgenealogy_batch_pkey PRIMARY KEY (id);


--
-- Name: advancedgenealogy_batchattachment advancedgenealogy_batchattachment_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.advancedgenealogy_batchattachment
    ADD CONSTRAINT advancedgenealogy_batchattachment_pkey PRIMARY KEY (id);


--
-- Name: advancedgenealogy_batchstatechange advancedgenealogy_batchlogging_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.advancedgenealogy_batchstatechange
    ADD CONSTRAINT advancedgenealogy_batchlogging_pkey PRIMARY KEY (id);


--
-- Name: advancedgenealogy_genealogyreport advancedgenealogy_genealogyreport_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.advancedgenealogy_genealogyreport
    ADD CONSTRAINT advancedgenealogy_genealogyreport_pkey PRIMARY KEY (id);


--
-- Name: advancedgenealogy_trackingrecord advancedgenealogy_trackingrecord_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.advancedgenealogy_trackingrecord
    ADD CONSTRAINT advancedgenealogy_trackingrecord_pkey PRIMARY KEY (id);


--
-- Name: advancedgenealogy_trackingrecordstatechange advancedgenealogy_trackingrecordlogging_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.advancedgenealogy_trackingrecordstatechange
    ADD CONSTRAINT advancedgenealogy_trackingrecordlogging_pkey PRIMARY KEY (id);


--
-- Name: advancedgenealogy_usedbatchsimple advancedgenealogy_usedbatchsimple_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.advancedgenealogy_usedbatchsimple
    ADD CONSTRAINT advancedgenealogy_usedbatchsimple_pkey PRIMARY KEY (id);


--
-- Name: advancedgenealogyfororders_genealogyproductinbatch advancedgenealogyfororders_genealogyproductinbatch_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.advancedgenealogyfororders_genealogyproductinbatch
    ADD CONSTRAINT advancedgenealogyfororders_genealogyproductinbatch_pkey PRIMARY KEY (id);


--
-- Name: advancedgenealogyfororders_genealogyproductincomponent advancedgenealogyfororders_genealogyproductincomponent_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.advancedgenealogyfororders_genealogyproductincomponent
    ADD CONSTRAINT advancedgenealogyfororders_genealogyproductincomponent_pkey PRIMARY KEY (id);


--
-- Name: arch_advancedgenealogy_trackingrecord arc2_advancedgenealogy_trackingrecord_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.arch_advancedgenealogy_trackingrecord
    ADD CONSTRAINT arc2_advancedgenealogy_trackingrecord_pkey PRIMARY KEY (id);


--
-- Name: arch_advancedgenealogy_trackingrecordstatechange arc2_advancedgenealogy_trackingrecordstatechange_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.arch_advancedgenealogy_trackingrecordstatechange
    ADD CONSTRAINT arc2_advancedgenealogy_trackingrecordstatechange_pkey PRIMARY KEY (id);


--
-- Name: arch_advancedgenealogy_usedbatchsimple arc2_advancedgenealogy_usedbatchsimple_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.arch_advancedgenealogy_usedbatchsimple
    ADD CONSTRAINT arc2_advancedgenealogy_usedbatchsimple_pkey PRIMARY KEY (id);


--
-- Name: arch_advancedgenealogyfororders_genealogyproductinbatch arc2_advancedgenealogyfororders_genealogyproductinbatch_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.arch_advancedgenealogyfororders_genealogyproductinbatch
    ADD CONSTRAINT arc2_advancedgenealogyfororders_genealogyproductinbatch_pkey PRIMARY KEY (id);


--
-- Name: arch_advancedgenealogyfororders_genealogyproductincomponent arc2_advancedgenealogyfororders_genealogyproductincomponen_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.arch_advancedgenealogyfororders_genealogyproductincomponent
    ADD CONSTRAINT arc2_advancedgenealogyfororders_genealogyproductincomponen_pkey PRIMARY KEY (id);


--
-- Name: arch_assignmenttoshift_multiassignmenttoshift arc2_assignmenttoshift_multiassignmenttoshift_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.arch_assignmenttoshift_multiassignmenttoshift
    ADD CONSTRAINT arc2_assignmenttoshift_multiassignmenttoshift_pkey PRIMARY KEY (id);


--
-- Name: arch_assignmenttoshift_staffassignmenttoshift arc2_assignmenttoshift_staffassignmenttoshift_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.arch_assignmenttoshift_staffassignmenttoshift
    ADD CONSTRAINT arc2_assignmenttoshift_staffassignmenttoshift_pkey PRIMARY KEY (id);


--
-- Name: arch_avglaborcostcalcfororder_assignmentworkertoshift arc2_avglaborcostcalcfororder_assignmentworkertoshift_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.arch_avglaborcostcalcfororder_assignmentworkertoshift
    ADD CONSTRAINT arc2_avglaborcostcalcfororder_assignmentworkertoshift_pkey PRIMARY KEY (id);


--
-- Name: arch_avglaborcostcalcfororder_avglaborcostcalcfororder arc2_avglaborcostcalcfororder_avglaborcostcalcfororder_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.arch_avglaborcostcalcfororder_avglaborcostcalcfororder
    ADD CONSTRAINT arc2_avglaborcostcalcfororder_avglaborcostcalcfororder_pkey PRIMARY KEY (id);


--
-- Name: arch_basicproductioncounting_productioncountingquantity arc2_basicproductioncounting__order_id_technologyoperationc_key; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.arch_basicproductioncounting_productioncountingquantity
    ADD CONSTRAINT arc2_basicproductioncounting__order_id_technologyoperationc_key UNIQUE (order_id, technologyoperationcomponent_id, product_id, technologyinputproducttype_id, role, typeofmaterial);


--
-- Name: arch_basicproductioncounting_basicproductioncounting arc2_basicproductioncounting_basicproductioncounting_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.arch_basicproductioncounting_basicproductioncounting
    ADD CONSTRAINT arc2_basicproductioncounting_basicproductioncounting_pkey PRIMARY KEY (id);


--
-- Name: arch_basicproductioncounting_productioncountingattributevalue arc2_basicproductioncounting_productioncountingattributeva_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.arch_basicproductioncounting_productioncountingattributevalue
    ADD CONSTRAINT arc2_basicproductioncounting_productioncountingattributeva_pkey PRIMARY KEY (id);


--
-- Name: arch_basicproductioncounting_productioncountingoperationrun arc2_basicproductioncounting_productioncountingoperationru_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.arch_basicproductioncounting_productioncountingoperationrun
    ADD CONSTRAINT arc2_basicproductioncounting_productioncountingoperationru_pkey PRIMARY KEY (id);


--
-- Name: arch_basicproductioncounting_productioncountingquantity arc2_basicproductioncounting_productioncountingquantity_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.arch_basicproductioncounting_productioncountingquantity
    ADD CONSTRAINT arc2_basicproductioncounting_productioncountingquantity_pkey PRIMARY KEY (id);


--
-- Name: arch_cdnrcgoodfood_cancelprotocol arc2_cdnrcgoodfood_cancelprotocol_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.arch_cdnrcgoodfood_cancelprotocol
    ADD CONSTRAINT arc2_cdnrcgoodfood_cancelprotocol_pkey PRIMARY KEY (id);


--
-- Name: arch_costnormsformaterials_technologyinstoperproductincomp arc2_costnormsformaterials_technologyinstoperproductincomp_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.arch_costnormsformaterials_technologyinstoperproductincomp
    ADD CONSTRAINT arc2_costnormsformaterials_technologyinstoperproductincomp_pkey PRIMARY KEY (id);


--
-- Name: arch_goodfood_confectionadditionalinputproduct arc2_goodfood_confectionadditionalinputproduct_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.arch_goodfood_confectionadditionalinputproduct
    ADD CONSTRAINT arc2_goodfood_confectionadditionalinputproduct_pkey PRIMARY KEY (id);


--
-- Name: arch_goodfood_confectionfilmproduct arc2_goodfood_confectionfilmproduct_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.arch_goodfood_confectionfilmproduct
    ADD CONSTRAINT arc2_goodfood_confectionfilmproduct_pkey PRIMARY KEY (id);


--
-- Name: arch_goodfood_confectionfilmproductentry arc2_goodfood_confectionfilmproductentry_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.arch_goodfood_confectionfilmproductentry
    ADD CONSTRAINT arc2_goodfood_confectionfilmproductentry_pkey PRIMARY KEY (id);


--
-- Name: arch_goodfood_confectioninputproduct arc2_goodfood_confectioninputproduct_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.arch_goodfood_confectioninputproduct
    ADD CONSTRAINT arc2_goodfood_confectioninputproduct_pkey PRIMARY KEY (id);


--
-- Name: arch_goodfood_confectionprotocol arc2_goodfood_confectionprotocol_externalnumber_key; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.arch_goodfood_confectionprotocol
    ADD CONSTRAINT arc2_goodfood_confectionprotocol_externalnumber_key UNIQUE (externalnumber);


--
-- Name: arch_goodfood_confectionprotocol arc2_goodfood_confectionprotocol_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.arch_goodfood_confectionprotocol
    ADD CONSTRAINT arc2_goodfood_confectionprotocol_pkey PRIMARY KEY (id);


--
-- Name: arch_goodfood_confectionprotocolcorrect arc2_goodfood_confectionprotocolcorrect_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.arch_goodfood_confectionprotocolcorrect
    ADD CONSTRAINT arc2_goodfood_confectionprotocolcorrect_pkey PRIMARY KEY (id);


--
-- Name: arch_goodfood_confectionprotocolstatechange arc2_goodfood_confectionprotocolstatechange_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.arch_goodfood_confectionprotocolstatechange
    ADD CONSTRAINT arc2_goodfood_confectionprotocolstatechange_pkey PRIMARY KEY (id);


--
-- Name: arch_goodfood_confectionremainderinputproduct arc2_goodfood_confectionremainderinputproduct_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.arch_goodfood_confectionremainderinputproduct
    ADD CONSTRAINT arc2_goodfood_confectionremainderinputproduct_pkey PRIMARY KEY (id);


--
-- Name: arch_goodfood_confectionstaff arc2_goodfood_confectionstaff_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.arch_goodfood_confectionstaff
    ADD CONSTRAINT arc2_goodfood_confectionstaff_pkey PRIMARY KEY (id);


--
-- Name: arch_goodfood_extrusionaddedmixentry arc2_goodfood_extrusionaddedmixentry_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.arch_goodfood_extrusionaddedmixentry
    ADD CONSTRAINT arc2_goodfood_extrusionaddedmixentry_pkey PRIMARY KEY (id);


--
-- Name: arch_goodfood_extrusionaddedmixingredient arc2_goodfood_extrusionaddedmixingredient_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.arch_goodfood_extrusionaddedmixingredient
    ADD CONSTRAINT arc2_goodfood_extrusionaddedmixingredient_pkey PRIMARY KEY (id);


--
-- Name: arch_goodfood_extrusionpouring arc2_goodfood_extrusionpouring_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.arch_goodfood_extrusionpouring
    ADD CONSTRAINT arc2_goodfood_extrusionpouring_pkey PRIMARY KEY (id);


--
-- Name: arch_goodfood_extrusionpouringingredient arc2_goodfood_extrusionpouringingredient_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.arch_goodfood_extrusionpouringingredient
    ADD CONSTRAINT arc2_goodfood_extrusionpouringingredient_pkey PRIMARY KEY (id);


--
-- Name: arch_goodfood_extrusionpouringmix arc2_goodfood_extrusionpouringmix_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.arch_goodfood_extrusionpouringmix
    ADD CONSTRAINT arc2_goodfood_extrusionpouringmix_pkey PRIMARY KEY (id);


--
-- Name: arch_goodfood_extrusionprotocol arc2_goodfood_extrusionprotocol_externalnumber_key; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.arch_goodfood_extrusionprotocol
    ADD CONSTRAINT arc2_goodfood_extrusionprotocol_externalnumber_key UNIQUE (externalnumber);


--
-- Name: arch_goodfood_extrusionprotocol arc2_goodfood_extrusionprotocol_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.arch_goodfood_extrusionprotocol
    ADD CONSTRAINT arc2_goodfood_extrusionprotocol_pkey PRIMARY KEY (id);


--
-- Name: arch_goodfood_extrusionprotocolcorrect arc2_goodfood_extrusionprotocolcorrect_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.arch_goodfood_extrusionprotocolcorrect
    ADD CONSTRAINT arc2_goodfood_extrusionprotocolcorrect_pkey PRIMARY KEY (id);


--
-- Name: arch_goodfood_extrusionprotocolstatechange arc2_goodfood_extrusionprotocolstatechange_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.arch_goodfood_extrusionprotocolstatechange
    ADD CONSTRAINT arc2_goodfood_extrusionprotocolstatechange_pkey PRIMARY KEY (id);


--
-- Name: arch_goodfood_extrusionsouse arc2_goodfood_extrusionsouse_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.arch_goodfood_extrusionsouse
    ADD CONSTRAINT arc2_goodfood_extrusionsouse_pkey PRIMARY KEY (id);


--
-- Name: arch_goodfood_extrusiontakenoffmixentry arc2_goodfood_extrusiontakenoffmixentry_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.arch_goodfood_extrusiontakenoffmixentry
    ADD CONSTRAINT arc2_goodfood_extrusiontakenoffmixentry_pkey PRIMARY KEY (id);


--
-- Name: arch_goodfood_extrusiontakenoffmixingredient arc2_goodfood_extrusiontakenoffmixingredient_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.arch_goodfood_extrusiontakenoffmixingredient
    ADD CONSTRAINT arc2_goodfood_extrusiontakenoffmixingredient_pkey PRIMARY KEY (id);


--
-- Name: arch_goodfood_pallet arc2_goodfood_pallet_externalnumber_key; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.arch_goodfood_pallet
    ADD CONSTRAINT arc2_goodfood_pallet_externalnumber_key UNIQUE (externalnumber);


--
-- Name: arch_goodfood_pallet arc2_goodfood_pallet_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.arch_goodfood_pallet
    ADD CONSTRAINT arc2_goodfood_pallet_pkey PRIMARY KEY (id);


--
-- Name: arch_goodfood_palletlabel arc2_goodfood_palletlabel_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.arch_goodfood_palletlabel
    ADD CONSTRAINT arc2_goodfood_palletlabel_pkey PRIMARY KEY (id);


--
-- Name: arch_goodfood_palletlabelstatechange arc2_goodfood_palletlabelstatechange_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.arch_goodfood_palletlabelstatechange
    ADD CONSTRAINT arc2_goodfood_palletlabelstatechange_pkey PRIMARY KEY (id);


--
-- Name: arch_goodfood_palletstatechange arc2_goodfood_palletstatechange_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.arch_goodfood_palletstatechange
    ADD CONSTRAINT arc2_goodfood_palletstatechange_pkey PRIMARY KEY (id);


--
-- Name: arch_goodfood_printedlabel arc2_goodfood_printedlabel_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.arch_goodfood_printedlabel
    ADD CONSTRAINT arc2_goodfood_printedlabel_pkey PRIMARY KEY (id);


--
-- Name: arch_integrationbartender_printlabelshelper arc2_integrationbartender_printlabelshelper_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.arch_integrationbartender_printlabelshelper
    ADD CONSTRAINT arc2_integrationbartender_printlabelshelper_pkey PRIMARY KEY (id);


--
-- Name: arch_integrationbartender_sendtoprint arc2_integrationbartender_sendtoprint_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.arch_integrationbartender_sendtoprint
    ADD CONSTRAINT arc2_integrationbartender_sendtoprint_pkey PRIMARY KEY (id);


--
-- Name: arch_masterorders_masterorder arc2_masterorders_masterorder_externalnumber_key; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.arch_masterorders_masterorder
    ADD CONSTRAINT arc2_masterorders_masterorder_externalnumber_key UNIQUE (externalnumber);


--
-- Name: arch_masterorders_masterorderproduct arc2_masterorders_masterorderproduct_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.arch_masterorders_masterorderproduct
    ADD CONSTRAINT arc2_masterorders_masterorderproduct_pkey PRIMARY KEY (id);


--
-- Name: arch_masterorders_masterorderproductattrvalue arc2_masterorders_masterorderproductattrvalue_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.arch_masterorders_masterorderproductattrvalue
    ADD CONSTRAINT arc2_masterorders_masterorderproductattrvalue_pkey PRIMARY KEY (id);


--
-- Name: arch_masterorders_productsbysizeentryhelper arc2_masterorders_productsbysizeentryhelper_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.arch_masterorders_productsbysizeentryhelper
    ADD CONSTRAINT arc2_masterorders_productsbysizeentryhelper_pkey PRIMARY KEY (id);


--
-- Name: arch_masterorders_productsbysizehelper arc2_masterorders_productsbysizehelper_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.arch_masterorders_productsbysizehelper
    ADD CONSTRAINT arc2_masterorders_productsbysizehelper_pkey PRIMARY KEY (id);


--
-- Name: arch_materialflowresources_document arc2_materialflowresources_document_number_key; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.arch_materialflowresources_document
    ADD CONSTRAINT arc2_materialflowresources_document_number_key UNIQUE (number);


--
-- Name: arch_materialflowresources_document arc2_materialflowresources_document_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.arch_materialflowresources_document
    ADD CONSTRAINT arc2_materialflowresources_document_pkey PRIMARY KEY (id);


--
-- Name: arch_materialflowresources_documentstatechange arc2_materialflowresources_documentstatechange_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.arch_materialflowresources_documentstatechange
    ADD CONSTRAINT arc2_materialflowresources_documentstatechange_pkey PRIMARY KEY (id);


--
-- Name: arch_materialflowresources_position arc2_materialflowresources_position_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.arch_materialflowresources_position
    ADD CONSTRAINT arc2_materialflowresources_position_pkey PRIMARY KEY (id);


--
-- Name: arch_materialflowresources_positionattributevalue arc2_materialflowresources_positionattributevalue_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.arch_materialflowresources_positionattributevalue
    ADD CONSTRAINT arc2_materialflowresources_positionattributevalue_pkey PRIMARY KEY (id);


--
-- Name: arch_materialflowresources_reservation arc2_materialflowresources_reservation_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.arch_materialflowresources_reservation
    ADD CONSTRAINT arc2_materialflowresources_reservation_pkey PRIMARY KEY (id);


--
-- Name: arch_materialrequirementcoveragefororder_coveragefororder arc2_materialrequirementcoveragefororder_coveragefororder_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.arch_materialrequirementcoveragefororder_coveragefororder
    ADD CONSTRAINT arc2_materialrequirementcoveragefororder_coveragefororder_pkey PRIMARY KEY (id);


--
-- Name: arch_materialrequirementcoveragefororder_coveragelocation arc2_materialrequirementcoveragefororder_coveragelocation_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.arch_materialrequirementcoveragefororder_coveragelocation
    ADD CONSTRAINT arc2_materialrequirementcoveragefororder_coveragelocation_pkey PRIMARY KEY (id);


--
-- Name: arch_materialrequirementcoveragefororder_coverageproduct arc2_materialrequirementcoveragefororder_coverageproduct_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.arch_materialrequirementcoveragefororder_coverageproduct
    ADD CONSTRAINT arc2_materialrequirementcoveragefororder_coverageproduct_pkey PRIMARY KEY (id);


--
-- Name: arch_materialrequirementcoveragefororder_coverageproductlogging arc2_materialrequirementcoveragefororder_coverageproductlo_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.arch_materialrequirementcoveragefororder_coverageproductlogging
    ADD CONSTRAINT arc2_materialrequirementcoveragefororder_coverageproductlo_pkey PRIMARY KEY (id);


--
-- Name: arch_orders_operationaltask arc2_orders_operationaltask_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.arch_orders_operationaltask
    ADD CONSTRAINT arc2_orders_operationaltask_pkey PRIMARY KEY (id);


--
-- Name: arch_orders_operationaltaskstatechange arc2_orders_operationaltaskstatechange_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.arch_orders_operationaltaskstatechange
    ADD CONSTRAINT arc2_orders_operationaltaskstatechange_pkey PRIMARY KEY (id);


--
-- Name: arch_orders_orderpack arc2_orders_orderpack_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.arch_orders_orderpack
    ADD CONSTRAINT arc2_orders_orderpack_pkey PRIMARY KEY (id);


--
-- Name: arch_orders_orderpackstatechange arc2_orders_orderpackstatechange_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.arch_orders_orderpackstatechange
    ADD CONSTRAINT arc2_orders_orderpackstatechange_pkey PRIMARY KEY (id);


--
-- Name: arch_orders_orderstatechange arc2_orders_orderstatechange_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.arch_orders_orderstatechange
    ADD CONSTRAINT arc2_orders_orderstatechange_pkey PRIMARY KEY (id);


--
-- Name: arch_orders_ordertechnologicalprocess arc2_orders_ordertechnologicalprocess_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.arch_orders_ordertechnologicalprocess
    ADD CONSTRAINT arc2_orders_ordertechnologicalprocess_pkey PRIMARY KEY (id);


--
-- Name: arch_orders_ordertechnologicalprocesspart arc2_orders_ordertechnologicalprocesspart_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.arch_orders_ordertechnologicalprocesspart
    ADD CONSTRAINT arc2_orders_ordertechnologicalprocesspart_pkey PRIMARY KEY (id);


--
-- Name: arch_orders_ordertechnologicalprocesswaste arc2_orders_ordertechnologicalprocesswaste_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.arch_orders_ordertechnologicalprocesswaste
    ADD CONSTRAINT arc2_orders_ordertechnologicalprocesswaste_pkey PRIMARY KEY (id);


--
-- Name: arch_orders_productionlinescheduleposition arc2_orders_productionlinescheduleposition_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.arch_orders_productionlinescheduleposition
    ADD CONSTRAINT arc2_orders_productionlinescheduleposition_pkey PRIMARY KEY (id);


--
-- Name: arch_orders_reasontypecorrectiondatefrom arc2_orders_reasontypecorrectiondatefrom_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.arch_orders_reasontypecorrectiondatefrom
    ADD CONSTRAINT arc2_orders_reasontypecorrectiondatefrom_pkey PRIMARY KEY (id);


--
-- Name: arch_orders_reasontypecorrectiondateto arc2_orders_reasontypecorrectiondateto_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.arch_orders_reasontypecorrectiondateto
    ADD CONSTRAINT arc2_orders_reasontypecorrectiondateto_pkey PRIMARY KEY (id);


--
-- Name: arch_orders_reasontypedeviationeffectiveend arc2_orders_reasontypedeviationeffectiveend_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.arch_orders_reasontypedeviationeffectiveend
    ADD CONSTRAINT arc2_orders_reasontypedeviationeffectiveend_pkey PRIMARY KEY (id);


--
-- Name: arch_orders_reasontypedeviationeffectivestart arc2_orders_reasontypedeviationeffectivestart_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.arch_orders_reasontypedeviationeffectivestart
    ADD CONSTRAINT arc2_orders_reasontypedeviationeffectivestart_pkey PRIMARY KEY (id);


--
-- Name: arch_orders_reasontypeofchangingorderstate arc2_orders_reasontypeofchangingorderstate_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.arch_orders_reasontypeofchangingorderstate
    ADD CONSTRAINT arc2_orders_reasontypeofchangingorderstate_pkey PRIMARY KEY (id);


--
-- Name: arch_orders_scheduleposition arc2_orders_scheduleposition_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.arch_orders_scheduleposition
    ADD CONSTRAINT arc2_orders_scheduleposition_pkey PRIMARY KEY (id);


--
-- Name: arch_orders_typeofcorrectioncauses arc2_orders_typeofcorrectioncauses_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.arch_orders_typeofcorrectioncauses
    ADD CONSTRAINT arc2_orders_typeofcorrectioncauses_pkey PRIMARY KEY (id);


--
-- Name: arch_ordersforsubproductsgeneration_suborders arc2_ordersforsubproductsgeneration_suborders_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.arch_ordersforsubproductsgeneration_suborders
    ADD CONSTRAINT arc2_ordersforsubproductsgeneration_suborders_pkey PRIMARY KEY (id);


--
-- Name: arch_ordersgroups_ordersgroup arc2_ordersgroups_ordersgroup_number_key; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.arch_ordersgroups_ordersgroup
    ADD CONSTRAINT arc2_ordersgroups_ordersgroup_number_key UNIQUE (number);


--
-- Name: arch_ordersgroups_ordersgroup arc2_ordersgroups_ordersgroup_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.arch_ordersgroups_ordersgroup
    ADD CONSTRAINT arc2_ordersgroups_ordersgroup_pkey PRIMARY KEY (id);


--
-- Name: arch_ordersgroups_ordersgroupissuedmaterial arc2_ordersgroups_ordersgroupissuedmaterial_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.arch_ordersgroups_ordersgroupissuedmaterial
    ADD CONSTRAINT arc2_ordersgroups_ordersgroupissuedmaterial_pkey PRIMARY KEY (id);


--
-- Name: arch_ordersgroups_ordersgroupissuedmaterialposition arc2_ordersgroups_ordersgroupissuedmaterialposition_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.arch_ordersgroups_ordersgroupissuedmaterialposition
    ADD CONSTRAINT arc2_ordersgroups_ordersgroupissuedmaterialposition_pkey PRIMARY KEY (id);


--
-- Name: arch_ordersgroups_ordersgroupmaterialrequirement arc2_ordersgroups_ordersgroupmaterialrequirement_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.arch_ordersgroups_ordersgroupmaterialrequirement
    ADD CONSTRAINT arc2_ordersgroups_ordersgroupmaterialrequirement_pkey PRIMARY KEY (id);


--
-- Name: arch_ordersgroups_ordersgroupmaterialrequirementproduct arc2_ordersgroups_ordersgroupmaterialrequirementproduct_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.arch_ordersgroups_ordersgroupmaterialrequirementproduct
    ADD CONSTRAINT arc2_ordersgroups_ordersgroupmaterialrequirementproduct_pkey PRIMARY KEY (id);


--
-- Name: arch_ordersgroups_ordersgroupproducedproduct arc2_ordersgroups_ordersgroupproducedproduct_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.arch_ordersgroups_ordersgroupproducedproduct
    ADD CONSTRAINT arc2_ordersgroups_ordersgroupproducedproduct_pkey PRIMARY KEY (id);


--
-- Name: arch_ordersgroups_ordersgroupproductstoissueentryhelper arc2_ordersgroups_ordersgroupproductstoissueentryhelper_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.arch_ordersgroups_ordersgroupproductstoissueentryhelper
    ADD CONSTRAINT arc2_ordersgroups_ordersgroupproductstoissueentryhelper_pkey PRIMARY KEY (id);


--
-- Name: arch_ordersgroups_ordersgroupproductstoissuehelper arc2_ordersgroups_ordersgroupproductstoissuehelper_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.arch_ordersgroups_ordersgroupproductstoissuehelper
    ADD CONSTRAINT arc2_ordersgroups_ordersgroupproductstoissuehelper_pkey PRIMARY KEY (id);


--
-- Name: arch_ordersgroups_productionbalance arc2_ordersgroups_productionbalance_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.arch_ordersgroups_productionbalance
    ADD CONSTRAINT arc2_ordersgroups_productionbalance_pkey PRIMARY KEY (id);


--
-- Name: arch_ordersupplies_coverageanalysisfororder arc2_ordersupplies_coverageanalysisfororder_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.arch_ordersupplies_coverageanalysisfororder
    ADD CONSTRAINT arc2_ordersupplies_coverageanalysisfororder_pkey PRIMARY KEY (id);


--
-- Name: arch_ordersupplies_coveragelocation arc2_ordersupplies_coveragelocation_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.arch_ordersupplies_coveragelocation
    ADD CONSTRAINT arc2_ordersupplies_coveragelocation_pkey PRIMARY KEY (id);


--
-- Name: arch_ordersupplies_coverageorderstate arc2_ordersupplies_coverageorderstate_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.arch_ordersupplies_coverageorderstate
    ADD CONSTRAINT arc2_ordersupplies_coverageorderstate_pkey PRIMARY KEY (id);


--
-- Name: arch_ordersupplies_coverageproduct arc2_ordersupplies_coverageproduct_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.arch_ordersupplies_coverageproduct
    ADD CONSTRAINT arc2_ordersupplies_coverageproduct_pkey PRIMARY KEY (id);


--
-- Name: arch_ordersupplies_coverageproductlogging arc2_ordersupplies_coverageproductlogging_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.arch_ordersupplies_coverageproductlogging
    ADD CONSTRAINT arc2_ordersupplies_coverageproductlogging_pkey PRIMARY KEY (id);


--
-- Name: arch_ordersupplies_coverageproductselected arc2_ordersupplies_coverageproductselected_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.arch_ordersupplies_coverageproductselected
    ADD CONSTRAINT arc2_ordersupplies_coverageproductselected_pkey PRIMARY KEY (id);


--
-- Name: arch_ordersupplies_materialrequirementcoverage arc2_ordersupplies_materialrequirementcoverage_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.arch_ordersupplies_materialrequirementcoverage
    ADD CONSTRAINT arc2_ordersupplies_materialrequirementcoverage_pkey PRIMARY KEY (id);


--
-- Name: arch_productflowthrudivision_issue arc2_productflowthrudivision_issue_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.arch_productflowthrudivision_issue
    ADD CONSTRAINT arc2_productflowthrudivision_issue_pkey PRIMARY KEY (id);


--
-- Name: arch_productflowthrudivision_materialavailability arc2_productflowthrudivision_materialavailability_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.arch_productflowthrudivision_materialavailability
    ADD CONSTRAINT arc2_productflowthrudivision_materialavailability_pkey PRIMARY KEY (id);


--
-- Name: arch_productflowthrudivision_productstoissue arc2_productflowthrudivision_productstoissue_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.arch_productflowthrudivision_productstoissue
    ADD CONSTRAINT arc2_productflowthrudivision_productstoissue_pkey PRIMARY KEY (id);


--
-- Name: arch_productflowthrudivision_producttoissuecorrection arc2_productflowthrudivision_producttoissuecorrection_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.arch_productflowthrudivision_producttoissuecorrection
    ADD CONSTRAINT arc2_productflowthrudivision_producttoissuecorrection_pkey PRIMARY KEY (id);


--
-- Name: arch_productflowthrudivision_warehouseissue arc2_productflowthrudivision_warehouseissue_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.arch_productflowthrudivision_warehouseissue
    ADD CONSTRAINT arc2_productflowthrudivision_warehouseissue_pkey PRIMARY KEY (id);


--
-- Name: arch_productflowthrudivision_warehouseissuestatechange arc2_productflowthrudivision_warehouseissuestatechange_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.arch_productflowthrudivision_warehouseissuestatechange
    ADD CONSTRAINT arc2_productflowthrudivision_warehouseissuestatechange_pkey PRIMARY KEY (id);


--
-- Name: arch_productioncounting_anomaly arc2_productioncounting_anomaly_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.arch_productioncounting_anomaly
    ADD CONSTRAINT arc2_productioncounting_anomaly_pkey PRIMARY KEY (id);


--
-- Name: arch_productioncounting_anomalyexplanation arc2_productioncounting_anomalyexplanation_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.arch_productioncounting_anomalyexplanation
    ADD CONSTRAINT arc2_productioncounting_anomalyexplanation_pkey PRIMARY KEY (id);


--
-- Name: arch_productioncounting_anomalyproductiontrackingentryhelper arc2_productioncounting_anomalyproductiontrackingentryhelp_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.arch_productioncounting_anomalyproductiontrackingentryhelper
    ADD CONSTRAINT arc2_productioncounting_anomalyproductiontrackingentryhelp_pkey PRIMARY KEY (id);


--
-- Name: arch_productioncounting_anomalyreasoncontainer arc2_productioncounting_anomalyreasoncontainer_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.arch_productioncounting_anomalyreasoncontainer
    ADD CONSTRAINT arc2_productioncounting_anomalyreasoncontainer_pkey PRIMARY KEY (id);


--
-- Name: arch_productioncounting_lack arc2_productioncounting_lack_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.arch_productioncounting_lack
    ADD CONSTRAINT arc2_productioncounting_lack_pkey PRIMARY KEY (id);


--
-- Name: arch_productioncounting_prodoutresourceattrval arc2_productioncounting_prodoutresourceattrval_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.arch_productioncounting_prodoutresourceattrval
    ADD CONSTRAINT arc2_productioncounting_prodoutresourceattrval_pkey PRIMARY KEY (id);


--
-- Name: arch_productioncounting_productiontracking arc2_productioncounting_productiontracking_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.arch_productioncounting_productiontracking
    ADD CONSTRAINT arc2_productioncounting_productiontracking_pkey PRIMARY KEY (id);


--
-- Name: arch_productioncounting_productiontrackingattachment arc2_productioncounting_productiontrackingattachment_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.arch_productioncounting_productiontrackingattachment
    ADD CONSTRAINT arc2_productioncounting_productiontrackingattachment_pkey PRIMARY KEY (id);


--
-- Name: arch_productioncounting_productiontrackingstatechange arc2_productioncounting_productiontrackingstatechange_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.arch_productioncounting_productiontrackingstatechange
    ADD CONSTRAINT arc2_productioncounting_productiontrackingstatechange_pkey PRIMARY KEY (id);


--
-- Name: arch_productioncounting_staffworktime arc2_productioncounting_staffworktime_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.arch_productioncounting_staffworktime
    ADD CONSTRAINT arc2_productioncounting_staffworktime_pkey PRIMARY KEY (id);


--
-- Name: arch_productioncounting_trackinginproductreplacementhelper arc2_productioncounting_trackinginproductreplacementhelper_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.arch_productioncounting_trackinginproductreplacementhelper
    ADD CONSTRAINT arc2_productioncounting_trackinginproductreplacementhelper_pkey PRIMARY KEY (id);


--
-- Name: arch_productioncounting_trackingoperationproductincomponent arc2_productioncounting_trackingoperationproductincomponen_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.arch_productioncounting_trackingoperationproductincomponent
    ADD CONSTRAINT arc2_productioncounting_trackingoperationproductincomponen_pkey PRIMARY KEY (id);


--
-- Name: arch_productioncounting_trackingoperationproductoutcomponent arc2_productioncounting_trackingoperationproductoutcompone_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.arch_productioncounting_trackingoperationproductoutcomponent
    ADD CONSTRAINT arc2_productioncounting_trackingoperationproductoutcompone_pkey PRIMARY KEY (id);


--
-- Name: arch_productioncounting_usedbatch arc2_productioncounting_usedbatch_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.arch_productioncounting_usedbatch
    ADD CONSTRAINT arc2_productioncounting_usedbatch_pkey PRIMARY KEY (id);


--
-- Name: arch_productionpershift_dailyprogress arc2_productionpershift_dailyprogress_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.arch_productionpershift_dailyprogress
    ADD CONSTRAINT arc2_productionpershift_dailyprogress_pkey PRIMARY KEY (id);


--
-- Name: arch_productionpershift_productionpershift arc2_productionpershift_productionpershift_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.arch_productionpershift_productionpershift
    ADD CONSTRAINT arc2_productionpershift_productionpershift_pkey PRIMARY KEY (id);


--
-- Name: arch_productionpershift_progressforday arc2_productionpershift_progressforday_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.arch_productionpershift_progressforday
    ADD CONSTRAINT arc2_productionpershift_progressforday_pkey PRIMARY KEY (id);


--
-- Name: arch_productionpershift_reasontypeofcorrectionplan arc2_productionpershift_reasontypeofcorrectionplan_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.arch_productionpershift_reasontypeofcorrectionplan
    ADD CONSTRAINT arc2_productionpershift_reasontypeofcorrectionplan_pkey PRIMARY KEY (id);


--
-- Name: arch_productionscheduling_opercomptimecalculation arc2_productionscheduling_opercomptimecalculation_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.arch_productionscheduling_opercomptimecalculation
    ADD CONSTRAINT arc2_productionscheduling_opercomptimecalculation_pkey PRIMARY KEY (id);


--
-- Name: arch_productionscheduling_ordertimecalculation arc2_productionscheduling_ordertimecalculation_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.arch_productionscheduling_ordertimecalculation
    ADD CONSTRAINT arc2_productionscheduling_ordertimecalculation_pkey PRIMARY KEY (id);


--
-- Name: arch_qualitycontrol_qualitycontrol arc2_qualitycontrol_qualitycontrol_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.arch_qualitycontrol_qualitycontrol
    ADD CONSTRAINT arc2_qualitycontrol_qualitycontrol_pkey PRIMARY KEY (id);


--
-- Name: arch_qualitycontrol_qualitycontrolattachment arc2_qualitycontrol_qualitycontrolattachment_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.arch_qualitycontrol_qualitycontrolattachment
    ADD CONSTRAINT arc2_qualitycontrol_qualitycontrolattachment_pkey PRIMARY KEY (id);


--
-- Name: arch_qualitycontrol_qualitycontrolattributeprodtracking arc2_qualitycontrol_qualitycontrolattributeprodtracking_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.arch_qualitycontrol_qualitycontrolattributeprodtracking
    ADD CONSTRAINT arc2_qualitycontrol_qualitycontrolattributeprodtracking_pkey PRIMARY KEY (id);


--
-- Name: arch_qualitycontrol_qualitycontrolattributevalue arc2_qualitycontrol_qualitycontrolattributevalue_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.arch_qualitycontrol_qualitycontrolattributevalue
    ADD CONSTRAINT arc2_qualitycontrol_qualitycontrolattributevalue_pkey PRIMARY KEY (id);


--
-- Name: arch_qualitycontrol_qualitycontrolresource arc2_qualitycontrol_qualitycontrolresource_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.arch_qualitycontrol_qualitycontrolresource
    ADD CONSTRAINT arc2_qualitycontrol_qualitycontrolresource_pkey PRIMARY KEY (id);


--
-- Name: arch_qualitycontrol_qualitycontrolstatechange arc2_qualitycontrol_qualitycontrolstatechange_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.arch_qualitycontrol_qualitycontrolstatechange
    ADD CONSTRAINT arc2_qualitycontrol_qualitycontrolstatechange_pkey PRIMARY KEY (id);


--
-- Name: arch_repairs_repairorder arc2_repairs_repairorder_number_key; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.arch_repairs_repairorder
    ADD CONSTRAINT arc2_repairs_repairorder_number_key UNIQUE (number);


--
-- Name: arch_repairs_repairorder arc2_repairs_repairorder_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.arch_repairs_repairorder
    ADD CONSTRAINT arc2_repairs_repairorder_pkey PRIMARY KEY (id);


--
-- Name: arch_repairs_repairorderproduct arc2_repairs_repairorderproduct_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.arch_repairs_repairorderproduct
    ADD CONSTRAINT arc2_repairs_repairorderproduct_pkey PRIMARY KEY (id);


--
-- Name: arch_repairs_repairorderstatechange arc2_repairs_repairorderstatechange_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.arch_repairs_repairorderstatechange
    ADD CONSTRAINT arc2_repairs_repairorderstatechange_pkey PRIMARY KEY (id);


--
-- Name: arch_repairs_repairorderworktime arc2_repairs_repairorderworktime_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.arch_repairs_repairorderworktime
    ADD CONSTRAINT arc2_repairs_repairorderworktime_pkey PRIMARY KEY (id);


--
-- Name: arch_states_message arc2_states_message_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.arch_states_message
    ADD CONSTRAINT arc2_states_message_pkey PRIMARY KEY (id);


--
-- Name: arch_stoppage_stoppage arc2_stoppage_stoppage_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.arch_stoppage_stoppage
    ADD CONSTRAINT arc2_stoppage_stoppage_pkey PRIMARY KEY (id);


--
-- Name: arch_technologies_barcodeoperationcomponent arc2_technologies_barcodeoperationcomponent_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.arch_technologies_barcodeoperationcomponent
    ADD CONSTRAINT arc2_technologies_barcodeoperationcomponent_pkey PRIMARY KEY (id);


--
-- Name: arch_urcmaterialavailability_requiredcomponent arc2_urcmaterialavailability_requiredcomponent_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.arch_urcmaterialavailability_requiredcomponent
    ADD CONSTRAINT arc2_urcmaterialavailability_requiredcomponent_pkey PRIMARY KEY (id);


--
-- Name: arch_archiving arch_archiving_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.arch_archiving
    ADD CONSTRAINT arch_archiving_pkey PRIMARY KEY (id);


--
-- Name: assignmenttoshift_assignmenttoshift assignmenttoshift_assignmenttoshift_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.assignmenttoshift_assignmenttoshift
    ADD CONSTRAINT assignmenttoshift_assignmenttoshift_pkey PRIMARY KEY (id);


--
-- Name: assignmenttoshift_assignmenttoshiftreport assignmenttoshift_assignmenttoshiftreport_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.assignmenttoshift_assignmenttoshiftreport
    ADD CONSTRAINT assignmenttoshift_assignmenttoshiftreport_pkey PRIMARY KEY (id);


--
-- Name: assignmenttoshift_assignmenttoshiftstatechange assignmenttoshift_assignmenttoshiftstatechange_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.assignmenttoshift_assignmenttoshiftstatechange
    ADD CONSTRAINT assignmenttoshift_assignmenttoshiftstatechange_pkey PRIMARY KEY (id);


--
-- Name: assignmenttoshift_assignmenttoshift assignmenttoshift_externalnumber_unique; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.assignmenttoshift_assignmenttoshift
    ADD CONSTRAINT assignmenttoshift_externalnumber_unique UNIQUE (externalnumber);


--
-- Name: assignmenttoshift_multiassignmenttoshift assignmenttoshift_multiassignmenttoshift_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.assignmenttoshift_multiassignmenttoshift
    ADD CONSTRAINT assignmenttoshift_multiassignmenttoshift_pkey PRIMARY KEY (id);


--
-- Name: assignmenttoshift_staffassignmenttoshift assignmenttoshift_staffassignmenttoshift_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.assignmenttoshift_staffassignmenttoshift
    ADD CONSTRAINT assignmenttoshift_staffassignmenttoshift_pkey PRIMARY KEY (id);


--
-- Name: avglaborcostcalcfororder_assignmentworkertoshift avglaborcostcalcfororder_assignmentworkertoshift_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.avglaborcostcalcfororder_assignmentworkertoshift
    ADD CONSTRAINT avglaborcostcalcfororder_assignmentworkertoshift_pkey PRIMARY KEY (id);


--
-- Name: avglaborcostcalcfororder_avglaborcostcalcfororder avglaborcostcalcfororder_avglaborcostcalcfororder_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.avglaborcostcalcfororder_avglaborcostcalcfororder
    ADD CONSTRAINT avglaborcostcalcfororder_avglaborcostcalcfororder_pkey PRIMARY KEY (id);


--
-- Name: basic_address basic_address_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.basic_address
    ADD CONSTRAINT basic_address_pkey PRIMARY KEY (id);


--
-- Name: basic_assortmentelement basic_assortmentelement_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.basic_assortmentelement
    ADD CONSTRAINT basic_assortmentelement_pkey PRIMARY KEY (id);


--
-- Name: basic_attribute basic_attribute_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.basic_attribute
    ADD CONSTRAINT basic_attribute_pkey PRIMARY KEY (id);


--
-- Name: basic_attributevalue basic_attributevalue_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.basic_attributevalue
    ADD CONSTRAINT basic_attributevalue_pkey PRIMARY KEY (id);


--
-- Name: basic_country basic_country_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.basic_country
    ADD CONSTRAINT basic_country_pkey PRIMARY KEY (id);


--
-- Name: basic_crew basic_crew_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.basic_crew
    ADD CONSTRAINT basic_crew_pkey PRIMARY KEY (id);


--
-- Name: basic_currency basic_currency_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.basic_currency
    ADD CONSTRAINT basic_currency_pkey PRIMARY KEY (id);


--
-- Name: basic_dashboardbutton basic_dashboardbutton_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.basic_dashboardbutton
    ADD CONSTRAINT basic_dashboardbutton_pkey PRIMARY KEY (id);


--
-- Name: basic_division basic_division_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.basic_division
    ADD CONSTRAINT basic_division_pkey PRIMARY KEY (id);


--
-- Name: basic_factory basic_factory_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.basic_factory
    ADD CONSTRAINT basic_factory_pkey PRIMARY KEY (id);


--
-- Name: basic_faulttype basic_faulttype_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.basic_faulttype
    ADD CONSTRAINT basic_faulttype_pkey PRIMARY KEY (id);


--
-- Name: basic_forms basic_forms_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.basic_forms
    ADD CONSTRAINT basic_forms_pkey PRIMARY KEY (id);


--
-- Name: basic_label basic_label_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.basic_label
    ADD CONSTRAINT basic_label_pkey PRIMARY KEY (id);


--
-- Name: basic_licenseusage basic_licenseusage_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.basic_licenseusage
    ADD CONSTRAINT basic_licenseusage_pkey PRIMARY KEY (id);


--
-- Name: basic_log basic_log_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.basic_log
    ADD CONSTRAINT basic_log_pkey PRIMARY KEY (id);


--
-- Name: basic_machineworkingperiod basic_machineworkingperiod_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.basic_machineworkingperiod
    ADD CONSTRAINT basic_machineworkingperiod_pkey PRIMARY KEY (id);


--
-- Name: basic_model basic_model_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.basic_model
    ADD CONSTRAINT basic_model_pkey PRIMARY KEY (id);


--
-- Name: basic_numberpattern basic_numberpattern_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.basic_numberpattern
    ADD CONSTRAINT basic_numberpattern_pkey PRIMARY KEY (id);


--
-- Name: basic_numberpatternelement basic_numberpatternelement_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.basic_numberpatternelement
    ADD CONSTRAINT basic_numberpatternelement_pkey PRIMARY KEY (id);


--
-- Name: basic_palletnumber basic_palletnumber_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.basic_palletnumber
    ADD CONSTRAINT basic_palletnumber_pkey PRIMARY KEY (id);


--
-- Name: basic_palletnumberhelper basic_palletnumberhelper_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.basic_palletnumberhelper
    ADD CONSTRAINT basic_palletnumberhelper_pkey PRIMARY KEY (id);


--
-- Name: basic_parameter basic_parameter_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.basic_parameter
    ADD CONSTRAINT basic_parameter_pkey PRIMARY KEY (id);


--
-- Name: basic_piecerate basic_piecerate_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.basic_piecerate
    ADD CONSTRAINT basic_piecerate_pkey PRIMARY KEY (id);


--
-- Name: basic_piecerateitem basic_piecerateitem_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.basic_piecerateitem
    ADD CONSTRAINT basic_piecerateitem_pkey PRIMARY KEY (id);


--
-- Name: basic_productattachment basic_productattachment_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.basic_productattachment
    ADD CONSTRAINT basic_productattachment_pkey PRIMARY KEY (id);


--
-- Name: basic_productattributevalue basic_productattributevalue_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.basic_productattributevalue
    ADD CONSTRAINT basic_productattributevalue_pkey PRIMARY KEY (id);


--
-- Name: basic_qualitycard basic_qualitycard_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.basic_qualitycard
    ADD CONSTRAINT basic_qualitycard_pkey PRIMARY KEY (id);


--
-- Name: basic_qualitycardstatechange basic_qualitycardstatechange_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.basic_qualitycardstatechange
    ADD CONSTRAINT basic_qualitycardstatechange_pkey PRIMARY KEY (id);


--
-- Name: basic_reportcolumnwidth basic_reportcolumnwidth_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.basic_reportcolumnwidth
    ADD CONSTRAINT basic_reportcolumnwidth_pkey PRIMARY KEY (id);


--
-- Name: basic_shifttimetableexception basic_shifttimetableexception_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.basic_shifttimetableexception
    ADD CONSTRAINT basic_shifttimetableexception_pkey PRIMARY KEY (id);


--
-- Name: basic_size basic_size_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.basic_size
    ADD CONSTRAINT basic_size_pkey PRIMARY KEY (id);


--
-- Name: basic_sizegroup basic_sizegroup_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.basic_sizegroup
    ADD CONSTRAINT basic_sizegroup_pkey PRIMARY KEY (id);


--
-- Name: basic_skill basic_skill_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.basic_skill
    ADD CONSTRAINT basic_skill_pkey PRIMARY KEY (id);


--
-- Name: basic_staffskill basic_staffkill_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.basic_staffskill
    ADD CONSTRAINT basic_staffkill_pkey PRIMARY KEY (id);


--
-- Name: basic_subassembly basic_subassembly_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.basic_subassembly
    ADD CONSTRAINT basic_subassembly_pkey PRIMARY KEY (id);


--
-- Name: basic_subassemblyattachment basic_subassemblyattachment_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.basic_subassemblyattachment
    ADD CONSTRAINT basic_subassemblyattachment_pkey PRIMARY KEY (id);


--
-- Name: basic_subassemblytoworkstationhelper basic_subassemblytoworkstationhelper_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.basic_subassemblytoworkstationhelper
    ADD CONSTRAINT basic_subassemblytoworkstationhelper_pkey PRIMARY KEY (id);


--
-- Name: basic_substitutecomponent basic_substitutecomponent_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.basic_substitutecomponent
    ADD CONSTRAINT basic_substitutecomponent_pkey PRIMARY KEY (id);


--
-- Name: basic_technologicalprocessrate basic_technologicalprocessrate_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.basic_technologicalprocessrate
    ADD CONSTRAINT basic_technologicalprocessrate_pkey PRIMARY KEY (id);


--
-- Name: basic_technologicalprocessrateitem basic_technologicalprocessrateitem_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.basic_technologicalprocessrateitem
    ADD CONSTRAINT basic_technologicalprocessrateitem_pkey PRIMARY KEY (id);


--
-- Name: basic_viewedactivity basic_viewedactivity_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.basic_viewedactivity
    ADD CONSTRAINT basic_viewedactivity_pkey PRIMARY KEY (id);


--
-- Name: basic_workstation basic_workstation_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.basic_workstation
    ADD CONSTRAINT basic_workstation_pkey PRIMARY KEY (id);


--
-- Name: basic_workstationattachment basic_workstationattachment_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.basic_workstationattachment
    ADD CONSTRAINT basic_workstationattachment_pkey PRIMARY KEY (id);


--
-- Name: basic_workstationtype basic_workstationtype_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.basic_workstationtype
    ADD CONSTRAINT basic_workstationtype_pkey PRIMARY KEY (id);


--
-- Name: basicproductioncounting_basicproductioncounting basicproductioncounting_basicproductioncounting_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.basicproductioncounting_basicproductioncounting
    ADD CONSTRAINT basicproductioncounting_basicproductioncounting_pkey PRIMARY KEY (id);


--
-- Name: basicproductioncounting_productioncountingattributevalue basicproductioncounting_productioncountingattributevalue_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.basicproductioncounting_productioncountingattributevalue
    ADD CONSTRAINT basicproductioncounting_productioncountingattributevalue_pkey PRIMARY KEY (id);


--
-- Name: basicproductioncounting_productioncountingoperationrun basicproductioncounting_productioncountingoperationrun_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.basicproductioncounting_productioncountingoperationrun
    ADD CONSTRAINT basicproductioncounting_productioncountingoperationrun_pkey PRIMARY KEY (id);


--
-- Name: basicproductioncounting_productioncountingquantity basicproductioncounting_productioncountingquantity_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.basicproductioncounting_productioncountingquantity
    ADD CONSTRAINT basicproductioncounting_productioncountingquantity_pkey PRIMARY KEY (id);


--
-- Name: basicproductioncounting_productioncountingquantitychange basicproductioncounting_productioncountingquantitychange_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.basicproductioncounting_productioncountingquantitychange
    ADD CONSTRAINT basicproductioncounting_productioncountingquantitychange_pkey PRIMARY KEY (id);


--
-- Name: basicproductioncounting_productioncountingreplacementhelper basicproductioncounting_productioncountingreplacementhelpe_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.basicproductioncounting_productioncountingreplacementhelper
    ADD CONSTRAINT basicproductioncounting_productioncountingreplacementhelpe_pkey PRIMARY KEY (id);


--
-- Name: basicproductioncounting_section basicproductioncounting_section_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.basicproductioncounting_section
    ADD CONSTRAINT basicproductioncounting_section_pkey PRIMARY KEY (id);


--
-- Name: advancedgenealogy_batch batch_externalnumber_unique; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.advancedgenealogy_batch
    ADD CONSTRAINT batch_externalnumber_unique UNIQUE (externalnumber);


--
-- Name: cdnrcgoodfood_cancelprotocol cdnrcgoodfood_cancelprotocol_fkey; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.cdnrcgoodfood_cancelprotocol
    ADD CONSTRAINT cdnrcgoodfood_cancelprotocol_fkey PRIMARY KEY (id);


--
-- Name: cdnrcgoodfood_highestmasterordernum cdnrcgoodfood_highestmasterordernum_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.cdnrcgoodfood_highestmasterordernum
    ADD CONSTRAINT cdnrcgoodfood_highestmasterordernum_pkey PRIMARY KEY (id);


--
-- Name: cmmsmachineparts_action cmmsmachineparts_action_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.cmmsmachineparts_action
    ADD CONSTRAINT cmmsmachineparts_action_pkey PRIMARY KEY (id);


--
-- Name: cmmsmachineparts_actionforplannedevent cmmsmachineparts_actionforplannedevent_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.cmmsmachineparts_actionforplannedevent
    ADD CONSTRAINT cmmsmachineparts_actionforplannedevent_pkey PRIMARY KEY (id);


--
-- Name: cmmsmachineparts_eventattachment cmmsmachineparts_eventattachment_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.cmmsmachineparts_eventattachment
    ADD CONSTRAINT cmmsmachineparts_eventattachment_pkey PRIMARY KEY (id);


--
-- Name: cmmsmachineparts_machinepartattachment cmmsmachineparts_machinepartattachment_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.cmmsmachineparts_machinepartattachment
    ADD CONSTRAINT cmmsmachineparts_machinepartattachment_pkey PRIMARY KEY (id);


--
-- Name: cmmsmachineparts_machinepartforevent cmmsmachineparts_machinepartforevent_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.cmmsmachineparts_machinepartforevent
    ADD CONSTRAINT cmmsmachineparts_machinepartforevent_pkey PRIMARY KEY (id);


--
-- Name: cmmsmachineparts_maintenanceevent cmmsmachineparts_maintenanceevent_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.cmmsmachineparts_maintenanceevent
    ADD CONSTRAINT cmmsmachineparts_maintenanceevent_pkey PRIMARY KEY (id);


--
-- Name: cmmsmachineparts_maintenanceeventcontext cmmsmachineparts_maintenanceeventcontext_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.cmmsmachineparts_maintenanceeventcontext
    ADD CONSTRAINT cmmsmachineparts_maintenanceeventcontext_pkey PRIMARY KEY (id);


--
-- Name: cmmsmachineparts_maintenanceeventstatechange cmmsmachineparts_maintenanceeventstatechange_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.cmmsmachineparts_maintenanceeventstatechange
    ADD CONSTRAINT cmmsmachineparts_maintenanceeventstatechange_pkey PRIMARY KEY (id);


--
-- Name: cmmsmachineparts_maintenanceeventxlshelper cmmsmachineparts_maintenanceeventxlshelper_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.cmmsmachineparts_maintenanceeventxlshelper
    ADD CONSTRAINT cmmsmachineparts_maintenanceeventxlshelper_pkey PRIMARY KEY (id);


--
-- Name: cmmsmachineparts_operationtool cmmsmachineparts_operationtool_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.cmmsmachineparts_operationtool
    ADD CONSTRAINT cmmsmachineparts_operationtool_pkey PRIMARY KEY (id);


--
-- Name: cmmsmachineparts_orderstoolrequirement cmmsmachineparts_orderstoolrequirement_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.cmmsmachineparts_orderstoolrequirement
    ADD CONSTRAINT cmmsmachineparts_orderstoolrequirement_pkey PRIMARY KEY (id);


--
-- Name: cmmsmachineparts_orderstoolrequirementtool cmmsmachineparts_orderstoolrequirementtool_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.cmmsmachineparts_orderstoolrequirementtool
    ADD CONSTRAINT cmmsmachineparts_orderstoolrequirementtool_pkey PRIMARY KEY (id);


--
-- Name: cmmsmachineparts_plannedevent cmmsmachineparts_plannedevent_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.cmmsmachineparts_plannedevent
    ADD CONSTRAINT cmmsmachineparts_plannedevent_pkey PRIMARY KEY (id);


--
-- Name: cmmsmachineparts_plannedeventattachment cmmsmachineparts_plannedeventattachment_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.cmmsmachineparts_plannedeventattachment
    ADD CONSTRAINT cmmsmachineparts_plannedeventattachment_pkey PRIMARY KEY (id);


--
-- Name: cmmsmachineparts_plannedeventcontext cmmsmachineparts_plannedeventcontext_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.cmmsmachineparts_plannedeventcontext
    ADD CONSTRAINT cmmsmachineparts_plannedeventcontext_pkey PRIMARY KEY (id);


--
-- Name: cmmsmachineparts_plannedeventrealization cmmsmachineparts_plannedeventrealization_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.cmmsmachineparts_plannedeventrealization
    ADD CONSTRAINT cmmsmachineparts_plannedeventrealization_pkey PRIMARY KEY (id);


--
-- Name: cmmsmachineparts_plannedeventstatechange cmmsmachineparts_plannedeventstatechange_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.cmmsmachineparts_plannedeventstatechange
    ADD CONSTRAINT cmmsmachineparts_plannedeventstatechange_pkey PRIMARY KEY (id);


--
-- Name: cmmsmachineparts_plannedeventxlshelper cmmsmachineparts_plannedeventxlshelper_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.cmmsmachineparts_plannedeventxlshelper
    ADD CONSTRAINT cmmsmachineparts_plannedeventxlshelper_pkey PRIMARY KEY (id);


--
-- Name: cmmsmachineparts_sourcecost cmmsmachineparts_sourcecost_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.cmmsmachineparts_sourcecost
    ADD CONSTRAINT cmmsmachineparts_sourcecost_pkey PRIMARY KEY (id);


--
-- Name: cmmsmachineparts_sourcecostreportfilter cmmsmachineparts_sourcecostreportfilter_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.cmmsmachineparts_sourcecostreportfilter
    ADD CONSTRAINT cmmsmachineparts_sourcecostreportfilter_pkey PRIMARY KEY (id);


--
-- Name: cmmsmachineparts_staffworktime cmmsmachineparts_staffworktime_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.cmmsmachineparts_staffworktime
    ADD CONSTRAINT cmmsmachineparts_staffworktime_pkey PRIMARY KEY (id);


--
-- Name: cmmsmachineparts_technologyoperationtool cmmsmachineparts_technologyoperationtool_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.cmmsmachineparts_technologyoperationtool
    ADD CONSTRAINT cmmsmachineparts_technologyoperationtool_pkey PRIMARY KEY (id);


--
-- Name: cmmsmachineparts_timeusagereportfilter cmmsmachineparts_timeusagereportfilter_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.cmmsmachineparts_timeusagereportfilter
    ADD CONSTRAINT cmmsmachineparts_timeusagereportfilter_pkey PRIMARY KEY (id);


--
-- Name: cmmsmachineparts_tool cmmsmachineparts_tool_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.cmmsmachineparts_tool
    ADD CONSTRAINT cmmsmachineparts_tool_pkey PRIMARY KEY (id);


--
-- Name: cmmsmachineparts_toolattachment cmmsmachineparts_toolattachment_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.cmmsmachineparts_toolattachment
    ADD CONSTRAINT cmmsmachineparts_toolattachment_pkey PRIMARY KEY (id);


--
-- Name: cmmsscheduler_actionforrecurringevent cmmsscheduler_actionforrecurringevent_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.cmmsscheduler_actionforrecurringevent
    ADD CONSTRAINT cmmsscheduler_actionforrecurringevent_pkey PRIMARY KEY (id);


--
-- Name: cmmsscheduler_recurringevent cmmsscheduler_recurringevent_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.cmmsscheduler_recurringevent
    ADD CONSTRAINT cmmsscheduler_recurringevent_pkey PRIMARY KEY (id);


--
-- Name: cmmsscheduler_recurringeventattachment cmmsscheduler_recurringeventattachment_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.cmmsscheduler_recurringeventattachment
    ADD CONSTRAINT cmmsscheduler_recurringeventattachment_pkey PRIMARY KEY (id);


--
-- Name: cmmsscheduler_recurringeventcontext cmmsscheduler_recurringeventcontext_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.cmmsscheduler_recurringeventcontext
    ADD CONSTRAINT cmmsscheduler_recurringeventcontext_pkey PRIMARY KEY (id);


--
-- Name: cmmsscheduler_recurringeventstatechange cmmsscheduler_recurringeventstatechange_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.cmmsscheduler_recurringeventstatechange
    ADD CONSTRAINT cmmsscheduler_recurringeventstatechange_pkey PRIMARY KEY (id);


--
-- Name: basic_company company_externalnumber_unique; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.basic_company
    ADD CONSTRAINT company_externalnumber_unique UNIQUE (externalnumber);


--
-- Name: goodfood_confectionprotocol confectionprotocol_externalnumber_unique; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.goodfood_confectionprotocol
    ADD CONSTRAINT confectionprotocol_externalnumber_unique UNIQUE (externalnumber);


--
-- Name: costcalculation_additionaldirectcost costcalculation_additionaldirectcost_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.costcalculation_additionaldirectcost
    ADD CONSTRAINT costcalculation_additionaldirectcost_pkey PRIMARY KEY (id);


--
-- Name: costcalculation_additionaldirectcostitem costcalculation_additionaldirectcostitem_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.costcalculation_additionaldirectcostitem
    ADD CONSTRAINT costcalculation_additionaldirectcostitem_pkey PRIMARY KEY (id);


--
-- Name: costcalculation_calculationresult costcalculation_calculationresult_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.costcalculation_calculationresult
    ADD CONSTRAINT costcalculation_calculationresult_pkey PRIMARY KEY (id);


--
-- Name: costcalculation_componentcost costcalculation_componentcost_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.costcalculation_componentcost
    ADD CONSTRAINT costcalculation_componentcost_pkey PRIMARY KEY (id);


--
-- Name: costcalculation_costcalculation costcalculation_costcalculation_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.costcalculation_costcalculation
    ADD CONSTRAINT costcalculation_costcalculation_pkey PRIMARY KEY (id);


--
-- Name: costcalculation_standardlaborcost costcalculation_standardlaborcost_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.costcalculation_standardlaborcost
    ADD CONSTRAINT costcalculation_standardlaborcost_pkey PRIMARY KEY (id);


--
-- Name: costnormsforoperation_calculationoperationcomponent costnormsforoperation_calculationoperationcomponent_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.costnormsforoperation_calculationoperationcomponent
    ADD CONSTRAINT costnormsforoperation_calculationoperationcomponent_pkey PRIMARY KEY (id);


--
-- Name: costnormsformaterials_technologyinstoperproductincomp costnormsforproduct_orderoperationproductincomponent_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.costnormsformaterials_technologyinstoperproductincomp
    ADD CONSTRAINT costnormsforproduct_orderoperationproductincomponent_pkey PRIMARY KEY (id);


--
-- Name: deliveries_columnfordeliveries deliveries_columnfordeliveries_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.deliveries_columnfordeliveries
    ADD CONSTRAINT deliveries_columnfordeliveries_pkey PRIMARY KEY (id);


--
-- Name: deliveries_columnfororders deliveries_columnfororders_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.deliveries_columnfororders
    ADD CONSTRAINT deliveries_columnfororders_pkey PRIMARY KEY (id);


--
-- Name: deliveries_companyproduct deliveries_companyproduct_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.deliveries_companyproduct
    ADD CONSTRAINT deliveries_companyproduct_pkey PRIMARY KEY (id);


--
-- Name: deliveries_deliveredpackage deliveries_deliveredpackage_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.deliveries_deliveredpackage
    ADD CONSTRAINT deliveries_deliveredpackage_pkey PRIMARY KEY (id);


--
-- Name: deliveries_deliveredproduct deliveries_deliveredproduct_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.deliveries_deliveredproduct
    ADD CONSTRAINT deliveries_deliveredproduct_pkey PRIMARY KEY (id);


--
-- Name: deliveries_deliveredproductattributeval deliveries_deliveredproductattributeval_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.deliveries_deliveredproductattributeval
    ADD CONSTRAINT deliveries_deliveredproductattributeval_pkey PRIMARY KEY (id);


--
-- Name: deliveries_deliveredproductmulti deliveries_deliveredproductmulti_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.deliveries_deliveredproductmulti
    ADD CONSTRAINT deliveries_deliveredproductmulti_pkey PRIMARY KEY (id);


--
-- Name: deliveries_deliveredproductmultiposition deliveries_deliveredproductmultiposition_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.deliveries_deliveredproductmultiposition
    ADD CONSTRAINT deliveries_deliveredproductmultiposition_pkey PRIMARY KEY (id);


--
-- Name: deliveries_delivery deliveries_delivery_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.deliveries_delivery
    ADD CONSTRAINT deliveries_delivery_pkey PRIMARY KEY (id);


--
-- Name: deliveries_deliveryattachment deliveries_deliveryattachment_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.deliveries_deliveryattachment
    ADD CONSTRAINT deliveries_deliveryattachment_pkey PRIMARY KEY (id);


--
-- Name: deliveries_deliverybypallettypereport deliveries_deliverybypallettypereport_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.deliveries_deliverybypallettypereport
    ADD CONSTRAINT deliveries_deliverybypallettypereport_pkey PRIMARY KEY (id);


--
-- Name: deliveries_deliverystatechange deliveries_deliverystatechange_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.deliveries_deliverystatechange
    ADD CONSTRAINT deliveries_deliverystatechange_pkey PRIMARY KEY (id);


--
-- Name: deliveries_orderedproduct deliveries_orderedproduct_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.deliveries_orderedproduct
    ADD CONSTRAINT deliveries_orderedproduct_pkey PRIMARY KEY (id);


--
-- Name: deliveries_parameterdeliveryordercolumn deliveries_parameterdeliveryordercolumn_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.deliveries_parameterdeliveryordercolumn
    ADD CONSTRAINT deliveries_parameterdeliveryordercolumn_pkey PRIMARY KEY (id);


--
-- Name: qcadoomodel_dictionaryitem dictionaryitem_externalnumber_unique; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.qcadoomodel_dictionaryitem
    ADD CONSTRAINT dictionaryitem_externalnumber_unique UNIQUE (dictionary_id, externalnumber);


--
-- Name: materialflowresources_document document_id_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.materialflowresources_document
    ADD CONSTRAINT document_id_pkey PRIMARY KEY (id);


--
-- Name: materialflowresources_document document_number_unique; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.materialflowresources_document
    ADD CONSTRAINT document_number_unique UNIQUE (number);


--
-- Name: emailnotifications_staffnotification emailnotifications_staffnotification_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.emailnotifications_staffnotification
    ADD CONSTRAINT emailnotifications_staffnotification_pkey PRIMARY KEY (id);


--
-- Name: mobilewms_wmsdocumentpart esilco_wmsdocumentpart_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.mobilewms_wmsdocumentpart
    ADD CONSTRAINT esilco_wmsdocumentpart_pkey PRIMARY KEY (id);


--
-- Name: goodfood_extrusionprotocol extrusionprotocol_externalnumber_unique; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.goodfood_extrusionprotocol
    ADD CONSTRAINT extrusionprotocol_externalnumber_unique UNIQUE (externalnumber);


--
-- Name: goodfood_confectionadditionalinputproduct goodfood_confectionadditionalinputproduct_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.goodfood_confectionadditionalinputproduct
    ADD CONSTRAINT goodfood_confectionadditionalinputproduct_pkey PRIMARY KEY (id);


--
-- Name: goodfood_confectioncontext goodfood_confectioncontext_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.goodfood_confectioncontext
    ADD CONSTRAINT goodfood_confectioncontext_pkey PRIMARY KEY (id);


--
-- Name: goodfood_confectionfilmproduct goodfood_confectionfilmproduct_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.goodfood_confectionfilmproduct
    ADD CONSTRAINT goodfood_confectionfilmproduct_pkey PRIMARY KEY (id);


--
-- Name: goodfood_confectionfilmproductentry goodfood_confectionfilmproductentry_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.goodfood_confectionfilmproductentry
    ADD CONSTRAINT goodfood_confectionfilmproductentry_pkey PRIMARY KEY (id);


--
-- Name: goodfood_confectioninputproduct goodfood_confectioninputproduct_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.goodfood_confectioninputproduct
    ADD CONSTRAINT goodfood_confectioninputproduct_pkey PRIMARY KEY (id);


--
-- Name: goodfood_confectionprotocol goodfood_confectionprotocol_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.goodfood_confectionprotocol
    ADD CONSTRAINT goodfood_confectionprotocol_pkey PRIMARY KEY (id);


--
-- Name: goodfood_confectionprotocolcorrect goodfood_confectionprotocolcorrect_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.goodfood_confectionprotocolcorrect
    ADD CONSTRAINT goodfood_confectionprotocolcorrect_pkey PRIMARY KEY (id);


--
-- Name: goodfood_confectionprotocolstatechange goodfood_confectionprotocolstatechange_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.goodfood_confectionprotocolstatechange
    ADD CONSTRAINT goodfood_confectionprotocolstatechange_pkey PRIMARY KEY (id);


--
-- Name: goodfood_confectionremainderinputproduct goodfood_confectionremainderinputproduct_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.goodfood_confectionremainderinputproduct
    ADD CONSTRAINT goodfood_confectionremainderinputproduct_pkey PRIMARY KEY (id);


--
-- Name: goodfood_confectionstaff goodfood_confectionstaff_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.goodfood_confectionstaff
    ADD CONSTRAINT goodfood_confectionstaff_pkey PRIMARY KEY (id);


--
-- Name: goodfood_eventlog goodfood_eventlog_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.goodfood_eventlog
    ADD CONSTRAINT goodfood_eventlog_pkey PRIMARY KEY (id);


--
-- Name: goodfood_extrusionaddedmixentry goodfood_extrusionaddedmixentry_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.goodfood_extrusionaddedmixentry
    ADD CONSTRAINT goodfood_extrusionaddedmixentry_pkey PRIMARY KEY (id);


--
-- Name: goodfood_extrusionaddedmixingredient goodfood_extrusionaddedmixingredient_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.goodfood_extrusionaddedmixingredient
    ADD CONSTRAINT goodfood_extrusionaddedmixingredient_pkey PRIMARY KEY (id);


--
-- Name: goodfood_extrusioncontext goodfood_extrusioncontext_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.goodfood_extrusioncontext
    ADD CONSTRAINT goodfood_extrusioncontext_pkey PRIMARY KEY (id);


--
-- Name: goodfood_extrusionmix goodfood_extrusionmix_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.goodfood_extrusionmix
    ADD CONSTRAINT goodfood_extrusionmix_pkey PRIMARY KEY (id);


--
-- Name: goodfood_extrusionmixingredient goodfood_extrusionmixingredient_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.goodfood_extrusionmixingredient
    ADD CONSTRAINT goodfood_extrusionmixingredient_pkey PRIMARY KEY (id);


--
-- Name: goodfood_extrusionpouring goodfood_extrusionpouring_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.goodfood_extrusionpouring
    ADD CONSTRAINT goodfood_extrusionpouring_pkey PRIMARY KEY (id);


--
-- Name: goodfood_extrusionpouringingredient goodfood_extrusionpouringingredient_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.goodfood_extrusionpouringingredient
    ADD CONSTRAINT goodfood_extrusionpouringingredient_pkey PRIMARY KEY (id);


--
-- Name: goodfood_extrusionpouringmix goodfood_extrusionpouringmix_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.goodfood_extrusionpouringmix
    ADD CONSTRAINT goodfood_extrusionpouringmix_pkey PRIMARY KEY (id);


--
-- Name: goodfood_extrusionprotocol goodfood_extrusionprotocol_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.goodfood_extrusionprotocol
    ADD CONSTRAINT goodfood_extrusionprotocol_pkey PRIMARY KEY (id);


--
-- Name: goodfood_extrusionprotocolcorrect goodfood_extrusionprotocolcorrect_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.goodfood_extrusionprotocolcorrect
    ADD CONSTRAINT goodfood_extrusionprotocolcorrect_pkey PRIMARY KEY (id);


--
-- Name: goodfood_extrusionprotocolstatechange goodfood_extrusionprotocolstatechange_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.goodfood_extrusionprotocolstatechange
    ADD CONSTRAINT goodfood_extrusionprotocolstatechange_pkey PRIMARY KEY (id);


--
-- Name: goodfood_extrusionsouse goodfood_extrusionsouse_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.goodfood_extrusionsouse
    ADD CONSTRAINT goodfood_extrusionsouse_pkey PRIMARY KEY (id);


--
-- Name: goodfood_extrusiontakenoffmixentry goodfood_extrusiontakenoffmixentry_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.goodfood_extrusiontakenoffmixentry
    ADD CONSTRAINT goodfood_extrusiontakenoffmixentry_pkey PRIMARY KEY (id);


--
-- Name: goodfood_extrusiontakenoffmixingredient goodfood_extrusiontakenoffmixingredient_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.goodfood_extrusiontakenoffmixingredient
    ADD CONSTRAINT goodfood_extrusiontakenoffmixingredient_pkey PRIMARY KEY (id);


--
-- Name: goodfood_goodfoodreport goodfood_goodfoodreport_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.goodfood_goodfoodreport
    ADD CONSTRAINT goodfood_goodfoodreport_pkey PRIMARY KEY (id);


--
-- Name: goodfood_pallet goodfood_pallet_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.goodfood_pallet
    ADD CONSTRAINT goodfood_pallet_pkey PRIMARY KEY (id);


--
-- Name: goodfood_palletcontext goodfood_palletcontext_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.goodfood_palletcontext
    ADD CONSTRAINT goodfood_palletcontext_pkey PRIMARY KEY (id);


--
-- Name: goodfood_palletlabel goodfood_palletlabel_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.goodfood_palletlabel
    ADD CONSTRAINT goodfood_palletlabel_pkey PRIMARY KEY (id);


--
-- Name: goodfood_palletlabelstatechange goodfood_palletlabelstatechange_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.goodfood_palletlabelstatechange
    ADD CONSTRAINT goodfood_palletlabelstatechange_pkey PRIMARY KEY (id);


--
-- Name: goodfood_palletstatechange goodfood_palletstatechange_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.goodfood_palletstatechange
    ADD CONSTRAINT goodfood_palletstatechange_pkey PRIMARY KEY (id);


--
-- Name: goodfood_palnumber goodfood_palnumber_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.goodfood_palnumber
    ADD CONSTRAINT goodfood_palnumber_pkey PRIMARY KEY (id);


--
-- Name: goodfood_printedlabel goodfood_printedlabel_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.goodfood_printedlabel
    ADD CONSTRAINT goodfood_printedlabel_pkey PRIMARY KEY (id);


--
-- Name: goodfood_ssccnumber goodfood_ssccnumber_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.goodfood_ssccnumber
    ADD CONSTRAINT goodfood_ssccnumber_pkey PRIMARY KEY (id);


--
-- Name: integrationbartender_printer integrationbartender_printer_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.integrationbartender_printer
    ADD CONSTRAINT integrationbartender_printer_pkey PRIMARY KEY (id);


--
-- Name: integrationbartender_printlabelshelper integrationbartender_printlabelshelper_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.integrationbartender_printlabelshelper
    ADD CONSTRAINT integrationbartender_printlabelshelper_pkey PRIMARY KEY (id);


--
-- Name: integrationbartender_sendtoprint integrationbartender_sendtoprint_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.integrationbartender_sendtoprint
    ADD CONSTRAINT integrationbartender_sendtoprint_pkey PRIMARY KEY (id);


--
-- Name: integrationbaselinker_baselinkerparameters integrationbaselinker_baselinkerparameters_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.integrationbaselinker_baselinkerparameters
    ADD CONSTRAINT integrationbaselinker_baselinkerparameters_pkey PRIMARY KEY (id);


--
-- Name: integrationbaselinker_statusesfordocument integrationbaselinker_statusesfordocument_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.integrationbaselinker_statusesfordocument
    ADD CONSTRAINT integrationbaselinker_statusesfordocument_pkey PRIMARY KEY (id);


--
-- Name: integrationbaselinker_statusesformasterorder integrationbaselinker_statusesformasterorder_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.integrationbaselinker_statusesformasterorder
    ADD CONSTRAINT integrationbaselinker_statusesformasterorder_pkey PRIMARY KEY (id);


--
-- Name: integrationscales_productionlineforscale integrationscales_productionlineforscale_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.integrationscales_productionlineforscale
    ADD CONSTRAINT integrationscales_productionlineforscale_pkey PRIMARY KEY (id);


--
-- Name: integrationscales_scale integrationscales_scale_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.integrationscales_scale
    ADD CONSTRAINT integrationscales_scale_pkey PRIMARY KEY (id);


--
-- Name: costcalculation_orderadditionaldirectcost jcostcalculation_orderadditionaldirectcost_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.costcalculation_orderadditionaldirectcost
    ADD CONSTRAINT jcostcalculation_orderadditionaldirectcost_pkey PRIMARY KEY (id);


--
-- Name: jointable_action_subassembly jointable_action_subassembly_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.jointable_action_subassembly
    ADD CONSTRAINT jointable_action_subassembly_pkey PRIMARY KEY (subassembly_id, action_id);


--
-- Name: jointable_action_workstation jointable_action_workstation_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.jointable_action_workstation
    ADD CONSTRAINT jointable_action_workstation_pkey PRIMARY KEY (workstation_id, action_id);


--
-- Name: jointable_action_workstationtype jointable_action_workstationtype_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.jointable_action_workstationtype
    ADD CONSTRAINT jointable_action_workstationtype_pkey PRIMARY KEY (workstationtype_id, action_id);


--
-- Name: jointable_additionaldirectcost_technology jointable_additionaldirectcost_technology_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.jointable_additionaldirectcost_technology
    ADD CONSTRAINT jointable_additionaldirectcost_technology_pkey PRIMARY KEY (additionaldirectcost_id, technology_id);


--
-- Name: jointable_anomaly_anomalyreason jointable_anomaly_anomalyreason_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.jointable_anomaly_anomalyreason
    ADD CONSTRAINT jointable_anomaly_anomalyreason_pkey PRIMARY KEY (anomaly_id, anomalyreason_id);


--
-- Name: jointable_batch_productioncountingquantity jointable_batch_productioncountingquantity_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.jointable_batch_productioncountingquantity
    ADD CONSTRAINT jointable_batch_productioncountingquantity_pkey PRIMARY KEY (batch_id, productioncountingquantity_id);


--
-- Name: jointable_company_negotiation jointable_company_negotiation_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.jointable_company_negotiation
    ADD CONSTRAINT jointable_company_negotiation_pkey PRIMARY KEY (company_id, negotiation_id);


--
-- Name: jointable_company_subassembly jointable_company_subassembly_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.jointable_company_subassembly
    ADD CONSTRAINT jointable_company_subassembly_pkey PRIMARY KEY (subassembly_id, company_id);


--
-- Name: jointable_company_workstation jointable_company_workstation_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.jointable_company_workstation
    ADD CONSTRAINT jointable_company_workstation_pkey PRIMARY KEY (workstation_id, company_id);


--
-- Name: jointable_costcalculation_technology jointable_costcalculation_technology_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.jointable_costcalculation_technology
    ADD CONSTRAINT jointable_costcalculation_technology_pkey PRIMARY KEY (costcalculation_id, technology_id);


--
-- Name: jointable_division_productionline jointable_division_productionline_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.jointable_division_productionline
    ADD CONSTRAINT jointable_division_productionline_pkey PRIMARY KEY (division_id, productionline_id);


--
-- Name: jointable_faulttype_subassembly jointable_faulttype_subassembly_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.jointable_faulttype_subassembly
    ADD CONSTRAINT jointable_faulttype_subassembly_pkey PRIMARY KEY (subassembly_id, faulttype_id);


--
-- Name: jointable_faulttype_workstation jointable_faulttype_workstation_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.jointable_faulttype_workstation
    ADD CONSTRAINT jointable_faulttype_workstation_pkey PRIMARY KEY (faulttype_id, workstation_id);


--
-- Name: jointable_faulttype_workstationtype jointable_faulttype_workstationtype_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.jointable_faulttype_workstationtype
    ADD CONSTRAINT jointable_faulttype_workstationtype_pkey PRIMARY KEY (faulttype_id, workstationtype_id);


--
-- Name: jointable_group_role jointable_group_role_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.jointable_group_role
    ADD CONSTRAINT jointable_group_role_pkey PRIMARY KEY (role_id, group_id);


--
-- Name: jointable_issue_productstoissuehelper jointable_issue_productstoissuehelper_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.jointable_issue_productstoissuehelper
    ADD CONSTRAINT jointable_issue_productstoissuehelper_pkey PRIMARY KEY (issue_id, productstoissuehelper_id);


--
-- Name: jointable_masterorder_masterordersmaterialrequirement jointable_masterorder_masterordersmaterialrequirement_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.jointable_masterorder_masterordersmaterialrequirement
    ADD CONSTRAINT jointable_masterorder_masterordersmaterialrequirement_pkey PRIMARY KEY (masterorder_id, masterordersmaterialrequirement_id);


--
-- Name: jointable_materialrequirement_order jointable_materialrequirement_order_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.jointable_materialrequirement_order
    ADD CONSTRAINT jointable_materialrequirement_order_pkey PRIMARY KEY (materialrequirement_id, order_id);


--
-- Name: jointable_materialrequirementcoverage_order jointable_materialrequirementcoverage_order_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.jointable_materialrequirementcoverage_order
    ADD CONSTRAINT jointable_materialrequirementcoverage_order_pkey PRIMARY KEY (materialrequirementcoverage_id, order_id);


--
-- Name: jointable_multiassignmenttoshift_staff jointable_multiassignmenttoshift_staff_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.jointable_multiassignmenttoshift_staff
    ADD CONSTRAINT jointable_multiassignmenttoshift_staff_pkey PRIMARY KEY (multiassignmenttoshift_id, staff_id);


--
-- Name: jointable_oee_productionline jointable_oee_productionline_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.jointable_oee_productionline
    ADD CONSTRAINT jointable_oee_productionline_pkey PRIMARY KEY (oee_id, productionline_id);


--
-- Name: jointable_oee_workstation jointable_oee_workstation_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.jointable_oee_workstation
    ADD CONSTRAINT jointable_oee_workstation_pkey PRIMARY KEY (oee_id, workstation_id);


--
-- Name: jointable_operation_workstation jointable_operation_workstation_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.jointable_operation_workstation
    ADD CONSTRAINT jointable_operation_workstation_pkey PRIMARY KEY (operation_id, workstation_id);


--
-- Name: jointable_operationaltask_staff jointable_operationaltask_staff_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.jointable_operationaltask_staff
    ADD CONSTRAINT jointable_operationaltask_staff_pkey PRIMARY KEY (staff_id, operationaltask_id);


--
-- Name: jointable_order_orderstoolrequirement jointable_order_orderstoolrequirement_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.jointable_order_orderstoolrequirement
    ADD CONSTRAINT jointable_order_orderstoolrequirement_pkey PRIMARY KEY (order_id, orderstoolrequirement_id);


--
-- Name: jointable_order_printlabelshelper jointable_order_printlabelshelper_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.jointable_order_printlabelshelper
    ADD CONSTRAINT jointable_order_printlabelshelper_pkey PRIMARY KEY (order_id, printlabelshelper_id);


--
-- Name: jointable_order_productionbalance jointable_order_productionbalance_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.jointable_order_productionbalance
    ADD CONSTRAINT jointable_order_productionbalance_pkey PRIMARY KEY (productionbalance_id, order_id);


--
-- Name: jointable_order_productionlineschedule jointable_order_productionlineschedule_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.jointable_order_productionlineschedule
    ADD CONSTRAINT jointable_order_productionlineschedule_pkey PRIMARY KEY (productionlineschedule_id, order_id);


--
-- Name: jointable_order_schedule jointable_order_schedule_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.jointable_order_schedule
    ADD CONSTRAINT jointable_order_schedule_pkey PRIMARY KEY (schedule_id, order_id);


--
-- Name: jointable_order_staff jointable_order_staff_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.jointable_order_staff
    ADD CONSTRAINT jointable_order_staff_pkey PRIMARY KEY (staff_id, order_id);


--
-- Name: jointable_order_workplan jointable_order_workplan_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.jointable_order_workplan
    ADD CONSTRAINT jointable_order_workplan_pkey PRIMARY KEY (workplan_id, order_id);


--
-- Name: jointable_palletlabel_printlabelshelper jointable_palletlabel_printlabelshelper_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.jointable_palletlabel_printlabelshelper
    ADD CONSTRAINT jointable_palletlabel_printlabelshelper_pkey PRIMARY KEY (palletlabel_id, printlabelshelper_id);


--
-- Name: jointable_palletnumber_palletnumberhelper jointable_palletnumber_palletnumberhelper_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.jointable_palletnumber_palletnumberhelper
    ADD CONSTRAINT jointable_palletnumber_palletnumberhelper_pkey PRIMARY KEY (palletnumber_id, palletnumberhelper_id);


--
-- Name: jointable_parameter_productionline jointable_parameter_productionline_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.jointable_parameter_productionline
    ADD CONSTRAINT jointable_parameter_productionline_pkey PRIMARY KEY (productionline_id, parameter_id);


--
-- Name: jointable_plannedevent_plannedevent jointable_plannedevent_plannedevent_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.jointable_plannedevent_plannedevent
    ADD CONSTRAINT jointable_plannedevent_plannedevent_pkey PRIMARY KEY (plannedevent_id, relatedevent_id);


--
-- Name: jointable_plannedevent_staff jointable_plannedevent_staff_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.jointable_plannedevent_staff
    ADD CONSTRAINT jointable_plannedevent_staff_pkey PRIMARY KEY (staff_id, plannedevent_id);


--
-- Name: jointable_printlabelshelper_printedlabel jointable_printlabelshelper_printedlabel_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.jointable_printlabelshelper_printedlabel
    ADD CONSTRAINT jointable_printlabelshelper_printedlabel_pkey PRIMARY KEY (printlabelshelper_id, printedlabel_id);


--
-- Name: jointable_product_qualitycard jointable_product_qualitycard_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.jointable_product_qualitycard
    ADD CONSTRAINT jointable_product_qualitycard_pkey PRIMARY KEY (qualitycard_id, product_id);


--
-- Name: jointable_product_salesvolumemulti jointable_product_salesvolumemulti_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.jointable_product_salesvolumemulti
    ADD CONSTRAINT jointable_product_salesvolumemulti_pkey PRIMARY KEY (product_id, salesvolumemulti_id);


--
-- Name: jointable_product_scale jointable_product_scale_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.jointable_product_scale
    ADD CONSTRAINT jointable_product_scale_pkey PRIMARY KEY (scale_id, product_id);


--
-- Name: jointable_product_storagelocation jointable_product_storagelocation_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.jointable_product_storagelocation
    ADD CONSTRAINT jointable_product_storagelocation_pkey PRIMARY KEY (storagelocation_id, product_id);


--
-- Name: jointable_product_warehouseminimumstatemulti jointable_product_warehouseminimumstatemulti_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.jointable_product_warehouseminimumstatemulti
    ADD CONSTRAINT jointable_product_warehouseminimumstatemulti_pkey PRIMARY KEY (warehouseminimumstatemulti_id, product_id);


--
-- Name: jointable_productionline_scale jointable_productionline_scale_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.jointable_productionline_scale
    ADD CONSTRAINT jointable_productionline_scale_pkey PRIMARY KEY (scale_id, productionline_id);


--
-- Name: jointable_productionline_shift jointable_productionline_shift_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.jointable_productionline_shift
    ADD CONSTRAINT jointable_productionline_shift_pkey PRIMARY KEY (productionline_id, shift_id);


--
-- Name: jointable_productionline_shifttimetableexception jointable_productionline_shifttimetableexception_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.jointable_productionline_shifttimetableexception
    ADD CONSTRAINT jointable_productionline_shifttimetableexception_pkey PRIMARY KEY (shifttimetableexception_id, productionline_id);


--
-- Name: jointable_productionline_technology jointable_productionline_technology_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.jointable_productionline_technology
    ADD CONSTRAINT jointable_productionline_technology_pkey PRIMARY KEY (productionline_id, technology_id);


--
-- Name: jointable_productionline_technologygroup jointable_productionline_technologygroup_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.jointable_productionline_technologygroup
    ADD CONSTRAINT jointable_productionline_technologygroup_pkey PRIMARY KEY (productionline_id, technologygroup_id);


--
-- Name: jointable_shift_shifttimetableexception jointable_shift_shifttimetableexception_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.jointable_shift_shifttimetableexception
    ADD CONSTRAINT jointable_shift_shifttimetableexception_pkey PRIMARY KEY (shifttimetableexception_id, shift_id);


--
-- Name: jointable_size_sizegroup jointable_size_sizegroup_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.jointable_size_sizegroup
    ADD CONSTRAINT jointable_size_sizegroup_pkey PRIMARY KEY (size_id, sizegroup_id);


--
-- Name: jointable_staff_timeusagereportfilter jointable_staff_timeusagereportfilter_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.jointable_staff_timeusagereportfilter
    ADD CONSTRAINT jointable_staff_timeusagereportfilter_pkey PRIMARY KEY (timeusagereportfilter_id, staff_id);


--
-- Name: jointable_stocktaking_storagelocation jointable_stocktaking_storagelocation_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.jointable_stocktaking_storagelocation
    ADD CONSTRAINT jointable_stocktaking_storagelocation_pkey PRIMARY KEY (stocktaking_id, storagelocation_id);


--
-- Name: jointable_storagelocation_storagelocationnumberhelper jointable_storagelocation_storagelocationnumberhelper_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.jointable_storagelocation_storagelocationnumberhelper
    ADD CONSTRAINT jointable_storagelocation_storagelocationnumberhelper_pkey PRIMARY KEY (storagelocation_id, storagelocationnumberhelper_id);


--
-- Name: jointable_storagelocation_warehousestockreport jointable_storagelocation_warehousestockreport_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.jointable_storagelocation_warehousestockreport
    ADD CONSTRAINT jointable_storagelocation_warehousestockreport_pkey PRIMARY KEY (warehousestockreport_id, storagelocation_id);


--
-- Name: jointable_technologyoperationcomponent_workstation jointable_technologyoperationcomponent_workstation_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.jointable_technologyoperationcomponent_workstation
    ADD CONSTRAINT jointable_technologyoperationcomponent_workstation_pkey PRIMARY KEY (workstation_id, technologyoperationcomponent_id);


--
-- Name: linechangeovernorms_linechangeovernorms linechangeovernorms_linechangeovernorms_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.linechangeovernorms_linechangeovernorms
    ADD CONSTRAINT linechangeovernorms_linechangeovernorms_pkey PRIMARY KEY (id);


--
-- Name: cmmsmachineparts_maintenanceevent maintenanceevent_number_unique; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.cmmsmachineparts_maintenanceevent
    ADD CONSTRAINT maintenanceevent_number_unique UNIQUE (number);


--
-- Name: masterorders_masterorder masterorder_externalnumber_unique; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.masterorders_masterorder
    ADD CONSTRAINT masterorder_externalnumber_unique UNIQUE (externalnumber);


--
-- Name: masterorders_generatingordershelper masterorders_generatingordershelper_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.masterorders_generatingordershelper
    ADD CONSTRAINT masterorders_generatingordershelper_pkey PRIMARY KEY (id);


--
-- Name: masterorders_masterorderdefinition masterorders_masterorderdefinition_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.masterorders_masterorderdefinition
    ADD CONSTRAINT masterorders_masterorderdefinition_pkey PRIMARY KEY (id);


--
-- Name: masterorders_masterorderproduct masterorders_masterorderproduct_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.masterorders_masterorderproduct
    ADD CONSTRAINT masterorders_masterorderproduct_pkey PRIMARY KEY (id);


--
-- Name: masterorders_masterorderproductattrvalue masterorders_masterorderproductattrvalue_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.masterorders_masterorderproductattrvalue
    ADD CONSTRAINT masterorders_masterorderproductattrvalue_pkey PRIMARY KEY (id);


--
-- Name: masterorders_masterordersmaterialrequirement masterorders_masterordersmaterialrequirement_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.masterorders_masterordersmaterialrequirement
    ADD CONSTRAINT masterorders_masterordersmaterialrequirement_pkey PRIMARY KEY (id);


--
-- Name: masterorders_masterordersmaterialrequirementproduct masterorders_masterordersmaterialrequirementproduct_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.masterorders_masterordersmaterialrequirementproduct
    ADD CONSTRAINT masterorders_masterordersmaterialrequirementproduct_pkey PRIMARY KEY (id);


--
-- Name: masterorders_orderedproductconfigurator masterorders_orderedproductconfigurator_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.masterorders_orderedproductconfigurator
    ADD CONSTRAINT masterorders_orderedproductconfigurator_pkey PRIMARY KEY (id);


--
-- Name: masterorders_orderedproductconfiguratorattribute masterorders_orderedproductconfiguratorattribute_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.masterorders_orderedproductconfiguratorattribute
    ADD CONSTRAINT masterorders_orderedproductconfiguratorattribute_pkey PRIMARY KEY (id);


--
-- Name: masterorders_position_deliveryproductquantityhelper masterorders_position_deliveryproductquantityhelper_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.masterorders_position_deliveryproductquantityhelper
    ADD CONSTRAINT masterorders_position_deliveryproductquantityhelper_pkey PRIMARY KEY (id);


--
-- Name: masterorders_position_warehousestatehelper masterorders_position_warehousestatehelper_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.masterorders_position_warehousestatehelper
    ADD CONSTRAINT masterorders_position_warehousestatehelper_pkey PRIMARY KEY (id);


--
-- Name: masterorders_priceslist masterorders_priceslist_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.masterorders_priceslist
    ADD CONSTRAINT masterorders_priceslist_pkey PRIMARY KEY (id);


--
-- Name: masterorders_productsbyattributeentryhelper masterorders_productsbyattributeentryhelper_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.masterorders_productsbyattributeentryhelper
    ADD CONSTRAINT masterorders_productsbyattributeentryhelper_pkey PRIMARY KEY (id);


--
-- Name: masterorders_productsbyattributehelper masterorders_productsbyattributehelper_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.masterorders_productsbyattributehelper
    ADD CONSTRAINT masterorders_productsbyattributehelper_pkey PRIMARY KEY (id);


--
-- Name: masterorders_productsbysizeentryhelper masterorders_productsbysizeentryhelper_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.masterorders_productsbysizeentryhelper
    ADD CONSTRAINT masterorders_productsbysizeentryhelper_pkey PRIMARY KEY (id);


--
-- Name: masterorders_productsbysizehelper masterorders_productsbysizehelper_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.masterorders_productsbysizehelper
    ADD CONSTRAINT masterorders_productsbysizehelper_pkey PRIMARY KEY (id);


--
-- Name: masterorders_salesplan masterorders_salesplan_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.masterorders_salesplan
    ADD CONSTRAINT masterorders_salesplan_pkey PRIMARY KEY (id);


--
-- Name: masterorders_salesplanmaterialrequirement masterorders_salesplanmaterialrequirement_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.masterorders_salesplanmaterialrequirement
    ADD CONSTRAINT masterorders_salesplanmaterialrequirement_pkey PRIMARY KEY (id);


--
-- Name: masterorders_salesplanmaterialrequirementproduct masterorders_salesplanmaterialrequirementproduct_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.masterorders_salesplanmaterialrequirementproduct
    ADD CONSTRAINT masterorders_salesplanmaterialrequirementproduct_pkey PRIMARY KEY (id);


--
-- Name: masterorders_salesplanordersgroupentryhelper masterorders_salesplanordersgroupentryhelper_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.masterorders_salesplanordersgroupentryhelper
    ADD CONSTRAINT masterorders_salesplanordersgroupentryhelper_pkey PRIMARY KEY (id);


--
-- Name: masterorders_salesplanordersgrouphelper masterorders_salesplanordersgrouphelper_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.masterorders_salesplanordersgrouphelper
    ADD CONSTRAINT masterorders_salesplanordersgrouphelper_pkey PRIMARY KEY (id);


--
-- Name: masterorders_salesplanproduct masterorders_salesplanproduct_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.masterorders_salesplanproduct
    ADD CONSTRAINT masterorders_salesplanproduct_pkey PRIMARY KEY (id);


--
-- Name: masterorders_salesplanstatechange masterorders_salesplanstatechange_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.masterorders_salesplanstatechange
    ADD CONSTRAINT masterorders_salesplanstatechange_pkey PRIMARY KEY (id);


--
-- Name: masterorders_salesvolume masterorders_salesvolume_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.masterorders_salesvolume
    ADD CONSTRAINT masterorders_salesvolume_pkey PRIMARY KEY (id);


--
-- Name: masterorders_salesvolumemulti masterorders_salesvolumemulti_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.masterorders_salesvolumemulti
    ADD CONSTRAINT masterorders_salesvolumemulti_pkey PRIMARY KEY (id);


--
-- Name: materialflow_location materialflow_location_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.materialflow_location
    ADD CONSTRAINT materialflow_location_pkey PRIMARY KEY (id);


--
-- Name: materialflow_userlocation materialflow_userlocation_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.materialflow_userlocation
    ADD CONSTRAINT materialflow_userlocation_pkey PRIMARY KEY (id);


--
-- Name: materialflowresources_costnormsgenerator materialflowresources_costnormsgenerator_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.materialflowresources_costnormsgenerator
    ADD CONSTRAINT materialflowresources_costnormsgenerator_pkey PRIMARY KEY (id);


--
-- Name: materialflowresources_costnormslocation materialflowresources_costnormslocation_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.materialflowresources_costnormslocation
    ADD CONSTRAINT materialflowresources_costnormslocation_pkey PRIMARY KEY (id);


--
-- Name: materialflowresources_documentpositionparameters materialflowresources_documentpositionparameters_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.materialflowresources_documentpositionparameters
    ADD CONSTRAINT materialflowresources_documentpositionparameters_pkey PRIMARY KEY (id);


--
-- Name: materialflowresources_documentpositionparametersitem materialflowresources_documentpositionparametersitem_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.materialflowresources_documentpositionparametersitem
    ADD CONSTRAINT materialflowresources_documentpositionparametersitem_pkey PRIMARY KEY (id);


--
-- Name: materialflowresources_documentstatechange materialflowresources_documentstatechange_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.materialflowresources_documentstatechange
    ADD CONSTRAINT materialflowresources_documentstatechange_pkey PRIMARY KEY (id);


--
-- Name: materialflowresources_importstoragelocation materialflowresources_importstoragelocation_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.materialflowresources_importstoragelocation
    ADD CONSTRAINT materialflowresources_importstoragelocation_pkey PRIMARY KEY (id);


--
-- Name: materialflowresources_palletbalance materialflowresources_palletbalance_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.materialflowresources_palletbalance
    ADD CONSTRAINT materialflowresources_palletbalance_pkey PRIMARY KEY (id);


--
-- Name: materialflowresources_palletmovehelper materialflowresources_palletmovehelper_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.materialflowresources_palletmovehelper
    ADD CONSTRAINT materialflowresources_palletmovehelper_pkey PRIMARY KEY (id);


--
-- Name: materialflowresources_positionaddmultihelper materialflowresources_positionaddmultihelper_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.materialflowresources_positionaddmultihelper
    ADD CONSTRAINT materialflowresources_positionaddmultihelper_pkey PRIMARY KEY (id);


--
-- Name: materialflowresources_positionattributevalue materialflowresources_positionattributevalue_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.materialflowresources_positionattributevalue
    ADD CONSTRAINT materialflowresources_positionattributevalue_pkey PRIMARY KEY (id);


--
-- Name: materialflowresources_reservation materialflowresources_reservation_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.materialflowresources_reservation
    ADD CONSTRAINT materialflowresources_reservation_pkey PRIMARY KEY (id);


--
-- Name: materialflowresources_resource materialflowresources_resource_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.materialflowresources_resource
    ADD CONSTRAINT materialflowresources_resource_pkey PRIMARY KEY (id);


--
-- Name: materialflowresources_resourceattributevalue materialflowresources_resourceattributevalue_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.materialflowresources_resourceattributevalue
    ADD CONSTRAINT materialflowresources_resourceattributevalue_pkey PRIMARY KEY (id);


--
-- Name: materialflowresources_resourceattributevalueaftercorrection materialflowresources_resourceattributevalueaftercorrectio_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.materialflowresources_resourceattributevalueaftercorrection
    ADD CONSTRAINT materialflowresources_resourceattributevalueaftercorrectio_pkey PRIMARY KEY (id);


--
-- Name: materialflowresources_resourceattributevaluebeforecorrection materialflowresources_resourceattributevaluebeforecorrecti_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.materialflowresources_resourceattributevaluebeforecorrection
    ADD CONSTRAINT materialflowresources_resourceattributevaluebeforecorrecti_pkey PRIMARY KEY (id);


--
-- Name: materialflowresources_resourcecorrection materialflowresources_resourcecorrection_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.materialflowresources_resourcecorrection
    ADD CONSTRAINT materialflowresources_resourcecorrection_pkey PRIMARY KEY (id);


--
-- Name: materialflowresources_resourcestock materialflowresources_resourcestock_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.materialflowresources_resourcestock
    ADD CONSTRAINT materialflowresources_resourcestock_pkey PRIMARY KEY (id);


--
-- Name: materialflowresources_stocktaking materialflowresources_stocktaking_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.materialflowresources_stocktaking
    ADD CONSTRAINT materialflowresources_stocktaking_pkey PRIMARY KEY (id);


--
-- Name: materialflowresources_storagelocation materialflowresources_storagelocation_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.materialflowresources_storagelocation
    ADD CONSTRAINT materialflowresources_storagelocation_pkey PRIMARY KEY (id);


--
-- Name: materialflowresources_storagelocationhelper materialflowresources_storagelocationhelper_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.materialflowresources_storagelocationhelper
    ADD CONSTRAINT materialflowresources_storagelocationhelper_pkey PRIMARY KEY (id);


--
-- Name: materialflowresources_storagelocationnumberhelper materialflowresources_storagelocationnumberhelper_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.materialflowresources_storagelocationnumberhelper
    ADD CONSTRAINT materialflowresources_storagelocationnumberhelper_pkey PRIMARY KEY (id);


--
-- Name: materialflowresources_warehousestockreport materialflowresources_warehousestockreport_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.materialflowresources_warehousestockreport
    ADD CONSTRAINT materialflowresources_warehousestockreport_pkey PRIMARY KEY (id);


--
-- Name: materialrequirementcoveragefororder_columnforcoveragesfororder materialrequirementcoveragefororder_columnforcoveragesforo_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.materialrequirementcoveragefororder_columnforcoveragesfororder
    ADD CONSTRAINT materialrequirementcoveragefororder_columnforcoveragesforo_pkey PRIMARY KEY (id);


--
-- Name: materialrequirementcoveragefororder_coveragefororder materialrequirementcoveragefororder_coveragefororder_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.materialrequirementcoveragefororder_coveragefororder
    ADD CONSTRAINT materialrequirementcoveragefororder_coveragefororder_pkey PRIMARY KEY (id);


--
-- Name: materialrequirementcoveragefororder_coveragelocation materialrequirementcoveragefororder_coveragelocation_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.materialrequirementcoveragefororder_coveragelocation
    ADD CONSTRAINT materialrequirementcoveragefororder_coveragelocation_pkey PRIMARY KEY (id);


--
-- Name: materialrequirementcoveragefororder_coverageproduct materialrequirementcoveragefororder_coverageproduct_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.materialrequirementcoveragefororder_coverageproduct
    ADD CONSTRAINT materialrequirementcoveragefororder_coverageproduct_pkey PRIMARY KEY (id);


--
-- Name: materialrequirementcoveragefororder_coverageproductlogging materialrequirementcoveragefororder_coverageproductlogging_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.materialrequirementcoveragefororder_coverageproductlogging
    ADD CONSTRAINT materialrequirementcoveragefororder_coverageproductlogging_pkey PRIMARY KEY (id);


--
-- Name: materialrequirements_materialrequirement materialrequirements_materialrequirement_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.materialrequirements_materialrequirement
    ADD CONSTRAINT materialrequirements_materialrequirement_pkey PRIMARY KEY (id);


--
-- Name: materialrequirements_materialrequirementproduct materialrequirements_materialrequirementproduct_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.materialrequirements_materialrequirementproduct
    ADD CONSTRAINT materialrequirements_materialrequirementproduct_pkey PRIMARY KEY (id);


--
-- Name: nutritionfacts_nutrientcalculation nutrientcalculation_id_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.nutritionfacts_nutrientcalculation
    ADD CONSTRAINT nutrientcalculation_id_pkey PRIMARY KEY (id);


--
-- Name: nutritionfacts_nutrition nutrition_id_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.nutritionfacts_nutrition
    ADD CONSTRAINT nutrition_id_pkey PRIMARY KEY (id);


--
-- Name: nutritionfacts_nutritionelement nutritionelement_id_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.nutritionfacts_nutritionelement
    ADD CONSTRAINT nutritionelement_id_pkey PRIMARY KEY (id);


--
-- Name: nutritionfacts_prototypeproduct nutritionfacts_prototypeproduct_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.nutritionfacts_prototypeproduct
    ADD CONSTRAINT nutritionfacts_prototypeproduct_pkey PRIMARY KEY (id);


--
-- Name: nutritionfacts_prototypeproductcomponent nutritionfacts_prototypeproductcomponent_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.nutritionfacts_prototypeproductcomponent
    ADD CONSTRAINT nutritionfacts_prototypeproductcomponent_pkey PRIMARY KEY (id);


--
-- Name: nutritionfacts_nutritiongroup nutritiongroup_id_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.nutritionfacts_nutritiongroup
    ADD CONSTRAINT nutritiongroup_id_pkey PRIMARY KEY (id);


--
-- Name: oee_oee oee_oee_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.oee_oee
    ADD CONSTRAINT oee_oee_pkey PRIMARY KEY (id);


--
-- Name: oee_oeevalue oee_oeevalue_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.oee_oeevalue
    ADD CONSTRAINT oee_oeevalue_pkey PRIMARY KEY (id);


--
-- Name: orders_changedateshelper orders_changedateshelper_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.orders_changedateshelper
    ADD CONSTRAINT orders_changedateshelper_pkey PRIMARY KEY (id);


--
-- Name: orders_dimensioncontrolattribute orders_dimensioncontrolattribute_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.orders_dimensioncontrolattribute
    ADD CONSTRAINT orders_dimensioncontrolattribute_pkey PRIMARY KEY (id);


--
-- Name: orders_operationaltask orders_operationaltask_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.orders_operationaltask
    ADD CONSTRAINT orders_operationaltask_pkey PRIMARY KEY (id);


--
-- Name: orders_operationaltaskstatechange orders_operationaltaskstatechange_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.orders_operationaltaskstatechange
    ADD CONSTRAINT orders_operationaltaskstatechange_pkey PRIMARY KEY (id);


--
-- Name: orders_orderattachment orders_orderattachment_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.orders_orderattachment
    ADD CONSTRAINT orders_orderattachment_pkey PRIMARY KEY (id);


--
-- Name: orders_ordercategorycolor orders_ordercategorycolor_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.orders_ordercategorycolor
    ADD CONSTRAINT orders_ordercategorycolor_pkey PRIMARY KEY (id);


--
-- Name: orders_orderpack orders_orderpack_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.orders_orderpack
    ADD CONSTRAINT orders_orderpack_pkey PRIMARY KEY (id);


--
-- Name: orders_orderpackstatechange orders_orderpackstatechange_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.orders_orderpackstatechange
    ADD CONSTRAINT orders_orderpackstatechange_pkey PRIMARY KEY (id);


--
-- Name: masterorders_ordersgenerationhelper orders_ordersgenerationhelper_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.masterorders_ordersgenerationhelper
    ADD CONSTRAINT orders_ordersgenerationhelper_pkey PRIMARY KEY (id);


--
-- Name: orders_orderstatechange orders_orderstatechange_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.orders_orderstatechange
    ADD CONSTRAINT orders_orderstatechange_pkey PRIMARY KEY (id);


--
-- Name: orders_ordertechnologicalprocess orders_ordertechnologicalprocess_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.orders_ordertechnologicalprocess
    ADD CONSTRAINT orders_ordertechnologicalprocess_pkey PRIMARY KEY (id);


--
-- Name: orders_ordertechnologicalprocesspart orders_ordertechnologicalprocesspart_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.orders_ordertechnologicalprocesspart
    ADD CONSTRAINT orders_ordertechnologicalprocesspart_pkey PRIMARY KEY (id);


--
-- Name: orders_ordertechnologicalprocesswaste orders_ordertechnologicalprocesswaste_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.orders_ordertechnologicalprocesswaste
    ADD CONSTRAINT orders_ordertechnologicalprocesswaste_pkey PRIMARY KEY (id);


--
-- Name: orders_productionlineschedule orders_productionlineschedule_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.orders_productionlineschedule
    ADD CONSTRAINT orders_productionlineschedule_pkey PRIMARY KEY (id);


--
-- Name: orders_productionlinescheduleposition orders_productionlinescheduleposition_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.orders_productionlinescheduleposition
    ADD CONSTRAINT orders_productionlinescheduleposition_pkey PRIMARY KEY (id);


--
-- Name: orders_productionlineschedulestatechange orders_productionlineschedulestatechange_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.orders_productionlineschedulestatechange
    ADD CONSTRAINT orders_productionlineschedulestatechange_pkey PRIMARY KEY (id);


--
-- Name: orders_reasontypecorrectiondatefrom orders_reasontypecorrectiondatefrom_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.orders_reasontypecorrectiondatefrom
    ADD CONSTRAINT orders_reasontypecorrectiondatefrom_pkey PRIMARY KEY (id);


--
-- Name: orders_reasontypecorrectiondateto orders_reasontypecorrectiondateto_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.orders_reasontypecorrectiondateto
    ADD CONSTRAINT orders_reasontypecorrectiondateto_pkey PRIMARY KEY (id);


--
-- Name: orders_reasontypedeviationeffectiveend orders_reasontypedeviationeffectiveend_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.orders_reasontypedeviationeffectiveend
    ADD CONSTRAINT orders_reasontypedeviationeffectiveend_pkey PRIMARY KEY (id);


--
-- Name: orders_reasontypedeviationeffectivestart orders_reasontypedeviationeffectivestart_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.orders_reasontypedeviationeffectivestart
    ADD CONSTRAINT orders_reasontypedeviationeffectivestart_pkey PRIMARY KEY (id);


--
-- Name: orders_reasontypeofchangingorderstate orders_reasontypeofchangingorderstate_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.orders_reasontypeofchangingorderstate
    ADD CONSTRAINT orders_reasontypeofchangingorderstate_pkey PRIMARY KEY (id);


--
-- Name: orders_schedule orders_schedule_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.orders_schedule
    ADD CONSTRAINT orders_schedule_pkey PRIMARY KEY (id);


--
-- Name: orders_scheduleposition orders_scheduleposition_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.orders_scheduleposition
    ADD CONSTRAINT orders_scheduleposition_pkey PRIMARY KEY (id);


--
-- Name: orders_schedulestatechange orders_schedulestatechange_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.orders_schedulestatechange
    ADD CONSTRAINT orders_schedulestatechange_pkey PRIMARY KEY (id);


--
-- Name: orders_setcategory orders_setcategory_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.orders_setcategory
    ADD CONSTRAINT orders_setcategory_pkey PRIMARY KEY (id);


--
-- Name: orders_splitorderchild orders_splitorderchild_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.orders_splitorderchild
    ADD CONSTRAINT orders_splitorderchild_pkey PRIMARY KEY (id);


--
-- Name: orders_splitorderhelper orders_splitorderhelper_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.orders_splitorderhelper
    ADD CONSTRAINT orders_splitorderhelper_pkey PRIMARY KEY (id);


--
-- Name: orders_splitorderparent orders_splitorderparent_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.orders_splitorderparent
    ADD CONSTRAINT orders_splitorderparent_pkey PRIMARY KEY (id);


--
-- Name: orders_typeofcorrectioncauses orders_typeofcorrectioncauses_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.orders_typeofcorrectioncauses
    ADD CONSTRAINT orders_typeofcorrectioncauses_pkey PRIMARY KEY (id);


--
-- Name: orders_workstationchangeoverforoperationaltask orders_workstationchangeoverforoperationaltask_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.orders_workstationchangeoverforoperationaltask
    ADD CONSTRAINT orders_workstationchangeoverforoperationaltask_pkey PRIMARY KEY (id);


--
-- Name: orders_workstationchangeoverforscheduleposition orders_workstationchangeoverforscheduleposition_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.orders_workstationchangeoverforscheduleposition
    ADD CONSTRAINT orders_workstationchangeoverforscheduleposition_pkey PRIMARY KEY (id);


--
-- Name: ordersforsubproductsgeneration_suborders ordersforsubproductsgeneration_suborders_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.ordersforsubproductsgeneration_suborders
    ADD CONSTRAINT ordersforsubproductsgeneration_suborders_pkey PRIMARY KEY (id);


--
-- Name: ordersgantt_ordersganttparameters ordersgantt_ordersganttparameters_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.ordersgantt_ordersganttparameters
    ADD CONSTRAINT ordersgantt_ordersganttparameters_pkey PRIMARY KEY (id);


--
-- Name: ordersgroups_ordersgroup ordersgroup_number_unique; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.ordersgroups_ordersgroup
    ADD CONSTRAINT ordersgroup_number_unique UNIQUE (number);


--
-- Name: ordersgroups_ordersgroup ordersgroups_ordersgroup_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.ordersgroups_ordersgroup
    ADD CONSTRAINT ordersgroups_ordersgroup_pkey PRIMARY KEY (id);


--
-- Name: ordersgroups_ordersgroupissuedmaterial ordersgroups_ordersgroupissuedmaterial_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.ordersgroups_ordersgroupissuedmaterial
    ADD CONSTRAINT ordersgroups_ordersgroupissuedmaterial_pkey PRIMARY KEY (id);


--
-- Name: ordersgroups_ordersgroupissuedmaterialposition ordersgroups_ordersgroupissuedmaterialposition_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.ordersgroups_ordersgroupissuedmaterialposition
    ADD CONSTRAINT ordersgroups_ordersgroupissuedmaterialposition_pkey PRIMARY KEY (id);


--
-- Name: ordersgroups_ordersgroupmaterialrequirement ordersgroups_ordersgroupmaterialrequirement_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.ordersgroups_ordersgroupmaterialrequirement
    ADD CONSTRAINT ordersgroups_ordersgroupmaterialrequirement_pkey PRIMARY KEY (id);


--
-- Name: ordersgroups_ordersgroupmaterialrequirementproduct ordersgroups_ordersgroupmaterialrequirementproduct_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.ordersgroups_ordersgroupmaterialrequirementproduct
    ADD CONSTRAINT ordersgroups_ordersgroupmaterialrequirementproduct_pkey PRIMARY KEY (id);


--
-- Name: ordersgroups_ordersgroupproducedproduct ordersgroups_ordersgroupproducedproduct_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.ordersgroups_ordersgroupproducedproduct
    ADD CONSTRAINT ordersgroups_ordersgroupproducedproduct_pkey PRIMARY KEY (id);


--
-- Name: ordersgroups_ordersgroupproductstoissueentryhelper ordersgroups_ordersgroupproductstoissueentryhelper_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.ordersgroups_ordersgroupproductstoissueentryhelper
    ADD CONSTRAINT ordersgroups_ordersgroupproductstoissueentryhelper_pkey PRIMARY KEY (id);


--
-- Name: ordersgroups_ordersgroupproductstoissuehelper ordersgroups_ordersgroupproductstoissuehelper_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.ordersgroups_ordersgroupproductstoissuehelper
    ADD CONSTRAINT ordersgroups_ordersgroupproductstoissuehelper_pkey PRIMARY KEY (id);


--
-- Name: ordersgroups_productionbalance ordersgroups_productionbalance_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.ordersgroups_productionbalance
    ADD CONSTRAINT ordersgroups_productionbalance_pkey PRIMARY KEY (id);


--
-- Name: ordersgroups_sizegroupcolor ordersgroups_sizegroupcolor_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.ordersgroups_sizegroupcolor
    ADD CONSTRAINT ordersgroups_sizegroupcolor_pkey PRIMARY KEY (id);


--
-- Name: ordersupplies_columnforcoverages ordersupplies_columnforcoverages_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.ordersupplies_columnforcoverages
    ADD CONSTRAINT ordersupplies_columnforcoverages_pkey PRIMARY KEY (id);


--
-- Name: ordersupplies_coverageanalysisfororder ordersupplies_coverageanalysisfororder_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.ordersupplies_coverageanalysisfororder
    ADD CONSTRAINT ordersupplies_coverageanalysisfororder_pkey PRIMARY KEY (id);


--
-- Name: ordersupplies_coveragelocation ordersupplies_coveragelocation_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.ordersupplies_coveragelocation
    ADD CONSTRAINT ordersupplies_coveragelocation_pkey PRIMARY KEY (id);


--
-- Name: ordersupplies_coverageorderstate ordersupplies_coverageorderstate_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.ordersupplies_coverageorderstate
    ADD CONSTRAINT ordersupplies_coverageorderstate_pkey PRIMARY KEY (id);


--
-- Name: ordersupplies_coverageproduct ordersupplies_coverageproduct_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.ordersupplies_coverageproduct
    ADD CONSTRAINT ordersupplies_coverageproduct_pkey PRIMARY KEY (id);


--
-- Name: ordersupplies_coverageproductgenerated ordersupplies_coverageproductgenerated_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.ordersupplies_coverageproductgenerated
    ADD CONSTRAINT ordersupplies_coverageproductgenerated_pkey PRIMARY KEY (id);


--
-- Name: ordersupplies_coverageproductlogging ordersupplies_coverageproductlogging_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.ordersupplies_coverageproductlogging
    ADD CONSTRAINT ordersupplies_coverageproductlogging_pkey PRIMARY KEY (id);


--
-- Name: ordersupplies_coverageproductselected ordersupplies_coverageproductselected_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.ordersupplies_coverageproductselected
    ADD CONSTRAINT ordersupplies_coverageproductselected_pkey PRIMARY KEY (id);


--
-- Name: ordersupplies_materialrequirementcoverage ordersupplies_materialrequirementcoverage_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.ordersupplies_materialrequirementcoverage
    ADD CONSTRAINT ordersupplies_materialrequirementcoverage_pkey PRIMARY KEY (id);


--
-- Name: goodfood_pallet pallet_externalnumber_unique; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.goodfood_pallet
    ADD CONSTRAINT pallet_externalnumber_unique UNIQUE (externalnumber);


--
-- Name: materialflowresources_position position_id_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.materialflowresources_position
    ADD CONSTRAINT position_id_pkey PRIMARY KEY (id);


--
-- Name: basic_product product_externalnumber_unique; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.basic_product
    ADD CONSTRAINT product_externalnumber_unique UNIQUE (externalnumber);


--
-- Name: productcatalognumbers_productcatalognumbers productcatalognumbers_productcatalognumbers_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.productcatalognumbers_productcatalognumbers
    ADD CONSTRAINT productcatalognumbers_productcatalognumbers_pkey PRIMARY KEY (id);


--
-- Name: technologies_productdata productdata_productdata_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.technologies_productdata
    ADD CONSTRAINT productdata_productdata_pkey PRIMARY KEY (id);


--
-- Name: technologies_productdataattachment productdata_productdataattachment_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.technologies_productdataattachment
    ADD CONSTRAINT productdata_productdataattachment_pkey PRIMARY KEY (id);


--
-- Name: technologies_productdatainput productdata_productdatainput_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.technologies_productdatainput
    ADD CONSTRAINT productdata_productdatainput_pkey PRIMARY KEY (id);


--
-- Name: technologies_productdataoperation productdata_productdataoperation_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.technologies_productdataoperation
    ADD CONSTRAINT productdata_productdataoperation_pkey PRIMARY KEY (id);


--
-- Name: productflowthrudivision_issue productflowthrudivision_issue_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.productflowthrudivision_issue
    ADD CONSTRAINT productflowthrudivision_issue_pkey PRIMARY KEY (id);


--
-- Name: productflowthrudivision_materialavailability productflowthrudivision_materialavailability_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.productflowthrudivision_materialavailability
    ADD CONSTRAINT productflowthrudivision_materialavailability_pkey PRIMARY KEY (id);


--
-- Name: productflowthrudivision_modelcard productflowthrudivision_modelcard_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.productflowthrudivision_modelcard
    ADD CONSTRAINT productflowthrudivision_modelcard_pkey PRIMARY KEY (id);


--
-- Name: productflowthrudivision_modelcardproduct productflowthrudivision_modelcardproduct_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.productflowthrudivision_modelcardproduct
    ADD CONSTRAINT productflowthrudivision_modelcardproduct_pkey PRIMARY KEY (id);


--
-- Name: productflowthrudivision_opertaskmaterialavailability productflowthrudivision_opertaskmaterialavailability_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.productflowthrudivision_opertaskmaterialavailability
    ADD CONSTRAINT productflowthrudivision_opertaskmaterialavailability_pkey PRIMARY KEY (id);


--
-- Name: productflowthrudivision_orderproductresourcereservation productflowthrudivision_orderproductresourcereservation_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.productflowthrudivision_orderproductresourcereservation
    ADD CONSTRAINT productflowthrudivision_orderproductresourcereservation_pkey PRIMARY KEY (id);


--
-- Name: productflowthrudivision_productandquantityhelper productflowthrudivision_productandquantityhelper_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.productflowthrudivision_productandquantityhelper
    ADD CONSTRAINT productflowthrudivision_productandquantityhelper_pkey PRIMARY KEY (id);


--
-- Name: productflowthrudivision_productstoissue productflowthrudivision_productstoissue_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.productflowthrudivision_productstoissue
    ADD CONSTRAINT productflowthrudivision_productstoissue_pkey PRIMARY KEY (id);


--
-- Name: productflowthrudivision_productstoissuehelper productflowthrudivision_productstoissuehelper_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.productflowthrudivision_productstoissuehelper
    ADD CONSTRAINT productflowthrudivision_productstoissuehelper_pkey PRIMARY KEY (id);


--
-- Name: productflowthrudivision_producttoissuecorrection productflowthrudivision_producttoissuecorrection_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.productflowthrudivision_producttoissuecorrection
    ADD CONSTRAINT productflowthrudivision_producttoissuecorrection_pkey PRIMARY KEY (id);


--
-- Name: productflowthrudivision_producttoissuecorrectionhelper productflowthrudivision_producttoissuecorrectionhelper_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.productflowthrudivision_producttoissuecorrectionhelper
    ADD CONSTRAINT productflowthrudivision_producttoissuecorrectionhelper_pkey PRIMARY KEY (id);


--
-- Name: technologies_technologyproductionline productflowthrudivision_technologyproductionline_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.technologies_technologyproductionline
    ADD CONSTRAINT productflowthrudivision_technologyproductionline_pkey PRIMARY KEY (id);


--
-- Name: productflowthrudivision_trackingproductresourcereservation productflowthrudivision_trackingproductresourcereservation_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.productflowthrudivision_trackingproductresourcereservation
    ADD CONSTRAINT productflowthrudivision_trackingproductresourcereservation_pkey PRIMARY KEY (id);


--
-- Name: productflowthrudivision_warehouseissue productflowthrudivision_warehouseissue_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.productflowthrudivision_warehouseissue
    ADD CONSTRAINT productflowthrudivision_warehouseissue_pkey PRIMARY KEY (id);


--
-- Name: productflowthrudivision_warehouseissuestatechange productflowthrudivision_warehouseissuestatechange_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.productflowthrudivision_warehouseissuestatechange
    ADD CONSTRAINT productflowthrudivision_warehouseissuestatechange_pkey PRIMARY KEY (id);


--
-- Name: productioncounting_anomaly productioncounting_anomaly_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.productioncounting_anomaly
    ADD CONSTRAINT productioncounting_anomaly_pkey PRIMARY KEY (id);


--
-- Name: productioncounting_anomalyexplanation productioncounting_anomalyexplanation_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.productioncounting_anomalyexplanation
    ADD CONSTRAINT productioncounting_anomalyexplanation_pkey PRIMARY KEY (id);


--
-- Name: productioncounting_anomalyproductiontrackingentryhelper productioncounting_anomalyproductiontrackingentryhelper_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.productioncounting_anomalyproductiontrackingentryhelper
    ADD CONSTRAINT productioncounting_anomalyproductiontrackingentryhelper_pkey PRIMARY KEY (id);


--
-- Name: productioncounting_anomalyproductiontrackinghelper productioncounting_anomalyproductiontrackinghelper_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.productioncounting_anomalyproductiontrackinghelper
    ADD CONSTRAINT productioncounting_anomalyproductiontrackinghelper_pkey PRIMARY KEY (id);


--
-- Name: productioncounting_anomalyreason productioncounting_anomalyreason_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.productioncounting_anomalyreason
    ADD CONSTRAINT productioncounting_anomalyreason_pkey PRIMARY KEY (id);


--
-- Name: productioncounting_anomalyreasoncontainer productioncounting_anomalyreasoncontainer_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.productioncounting_anomalyreasoncontainer
    ADD CONSTRAINT productioncounting_anomalyreasoncontainer_pkey PRIMARY KEY (id);


--
-- Name: productioncounting_lack productioncounting_lack_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.productioncounting_lack
    ADD CONSTRAINT productioncounting_lack_pkey PRIMARY KEY (id);


--
-- Name: productioncounting_lackreason productioncounting_lackreason_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.productioncounting_lackreason
    ADD CONSTRAINT productioncounting_lackreason_pkey PRIMARY KEY (id);


--
-- Name: productioncounting_orderbalance productioncounting_orderbalance_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.productioncounting_orderbalance
    ADD CONSTRAINT productioncounting_orderbalance_pkey PRIMARY KEY (id);


--
-- Name: productioncounting_prodoutresourceattrval productioncounting_prodoutresourceattrval_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.productioncounting_prodoutresourceattrval
    ADD CONSTRAINT productioncounting_prodoutresourceattrval_pkey PRIMARY KEY (id);


--
-- Name: productioncounting_productionbalance productioncounting_productionbalance_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.productioncounting_productionbalance
    ADD CONSTRAINT productioncounting_productionbalance_pkey PRIMARY KEY (id);


--
-- Name: productioncounting_productiontracking productioncounting_productionrecord_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.productioncounting_productiontracking
    ADD CONSTRAINT productioncounting_productionrecord_pkey PRIMARY KEY (id);


--
-- Name: productioncounting_productiontrackingstatechange productioncounting_productionrecordstatechange_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.productioncounting_productiontrackingstatechange
    ADD CONSTRAINT productioncounting_productionrecordstatechange_pkey PRIMARY KEY (id);


--
-- Name: productioncounting_productiontrackingattachment productioncounting_productiontrackingattachment_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.productioncounting_productiontrackingattachment
    ADD CONSTRAINT productioncounting_productiontrackingattachment_pkey PRIMARY KEY (id);


--
-- Name: productioncounting_trackingoperationproductincomponent productioncounting_recordoperationproductincomponent_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.productioncounting_trackingoperationproductincomponent
    ADD CONSTRAINT productioncounting_recordoperationproductincomponent_pkey PRIMARY KEY (id);


--
-- Name: productioncounting_trackingoperationproductoutcomponent productioncounting_recordoperationproductoutcomponent_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.productioncounting_trackingoperationproductoutcomponent
    ADD CONSTRAINT productioncounting_recordoperationproductoutcomponent_pkey PRIMARY KEY (id);


--
-- Name: productioncounting_staffworktime productioncounting_staffworktime_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.productioncounting_staffworktime
    ADD CONSTRAINT productioncounting_staffworktime_pkey PRIMARY KEY (id);


--
-- Name: productioncounting_trackinginproductreplacementhelper productioncounting_trackinginproductreplacementhelper_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.productioncounting_trackinginproductreplacementhelper
    ADD CONSTRAINT productioncounting_trackinginproductreplacementhelper_pkey PRIMARY KEY (id);


--
-- Name: productioncounting_usedbatch productioncounting_usedbatch_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.productioncounting_usedbatch
    ADD CONSTRAINT productioncounting_usedbatch_pkey PRIMARY KEY (id);


--
-- Name: basicproductioncounting_productioncountingquantity productioncountingquantity_unique; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.basicproductioncounting_productioncountingquantity
    ADD CONSTRAINT productioncountingquantity_unique UNIQUE (order_id, technologyoperationcomponent_id, product_id, technologyinputproducttype_id, role, typeofmaterial);


--
-- Name: productionlines_factorystructureelement productionlines_factorystructureelement_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.productionlines_factorystructureelement
    ADD CONSTRAINT productionlines_factorystructureelement_pkey PRIMARY KEY (id);


--
-- Name: productionlines_workstationtypecomponent productionlines_workstationtypecomponent_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.productionlines_workstationtypecomponent
    ADD CONSTRAINT productionlines_workstationtypecomponent_pkey PRIMARY KEY (id);


--
-- Name: productionpershift_balance productionpershift_balance_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.productionpershift_balance
    ADD CONSTRAINT productionpershift_balance_pkey PRIMARY KEY (id);


--
-- Name: productionpershift_balancecontext productionpershift_balancecontext_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.productionpershift_balancecontext
    ADD CONSTRAINT productionpershift_balancecontext_pkey PRIMARY KEY (id);


--
-- Name: productionpershift_dailyprogress productionpershift_dailyprogress_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.productionpershift_dailyprogress
    ADD CONSTRAINT productionpershift_dailyprogress_pkey PRIMARY KEY (id);


--
-- Name: productionpershift_plandailyprogress productionpershift_plandailyprogress_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.productionpershift_plandailyprogress
    ADD CONSTRAINT productionpershift_plandailyprogress_pkey PRIMARY KEY (id);


--
-- Name: productionpershift_planproductionpershift productionpershift_planproductionpershift_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.productionpershift_planproductionpershift
    ADD CONSTRAINT productionpershift_planproductionpershift_pkey PRIMARY KEY (id);


--
-- Name: productionpershift_planprogressforday productionpershift_planprogressforday_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.productionpershift_planprogressforday
    ADD CONSTRAINT productionpershift_planprogressforday_pkey PRIMARY KEY (id);


--
-- Name: productionpershift_ppsreport productionpershift_ppsreport_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.productionpershift_ppsreport
    ADD CONSTRAINT productionpershift_ppsreport_pkey PRIMARY KEY (id);


--
-- Name: productionpershift_productionpershift productionpershift_productionpershift_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.productionpershift_productionpershift
    ADD CONSTRAINT productionpershift_productionpershift_pkey PRIMARY KEY (id);


--
-- Name: productionpershift_progressforday productionpershift_progressforday_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.productionpershift_progressforday
    ADD CONSTRAINT productionpershift_progressforday_pkey PRIMARY KEY (id);


--
-- Name: productionpershift_reasontypeofcorrectionplan productionpershift_reasontypeofcorrectionplan_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.productionpershift_reasontypeofcorrectionplan
    ADD CONSTRAINT productionpershift_reasontypeofcorrectionplan_pkey PRIMARY KEY (id);


--
-- Name: productionplans_dimensioncontrolattribute productionplans_dimensioncontrolattribute_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.productionplans_dimensioncontrolattribute
    ADD CONSTRAINT productionplans_dimensioncontrolattribute_pkey PRIMARY KEY (id);


--
-- Name: productionscheduling_opercomptimecalculation productionscheduling_opercomptimecalculation_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.productionscheduling_opercomptimecalculation
    ADD CONSTRAINT productionscheduling_opercomptimecalculation_pkey PRIMARY KEY (id);


--
-- Name: productionscheduling_ordertimecalculation productionscheduling_ordertimecalculation_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.productionscheduling_ordertimecalculation
    ADD CONSTRAINT productionscheduling_ordertimecalculation_pkey PRIMARY KEY (id);


--
-- Name: productionscheduling_planopercomptimecalculation productionscheduling_planopercomptimecalculation_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.productionscheduling_planopercomptimecalculation
    ADD CONSTRAINT productionscheduling_planopercomptimecalculation_pkey PRIMARY KEY (id);


--
-- Name: productionscheduling_planordertimecalculation productionscheduling_planordertimecalculation_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.productionscheduling_planordertimecalculation
    ADD CONSTRAINT productionscheduling_planordertimecalculation_pkey PRIMARY KEY (id);


--
-- Name: qcadoocustomtranslation_customtranslation qcadoocustomtranslation_customtranslation_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.qcadoocustomtranslation_customtranslation
    ADD CONSTRAINT qcadoocustomtranslation_customtranslation_pkey PRIMARY KEY (id);


--
-- Name: qcadoomodel_dictionary qcadoomodel_dictionary_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.qcadoomodel_dictionary
    ADD CONSTRAINT qcadoomodel_dictionary_pkey PRIMARY KEY (id);


--
-- Name: qcadoomodel_dictionaryitem qcadoomodel_dictionaryitem_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.qcadoomodel_dictionaryitem
    ADD CONSTRAINT qcadoomodel_dictionaryitem_pkey PRIMARY KEY (id);


--
-- Name: qcadoomodel_globalunitconversionsaggregate qcadoomodel_globalunitconversionsaggregate_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.qcadoomodel_globalunitconversionsaggregate
    ADD CONSTRAINT qcadoomodel_globalunitconversionsaggregate_pkey PRIMARY KEY (id);


--
-- Name: qcadoomodel_unitconversionitem qcadoomodel_unitconv_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.qcadoomodel_unitconversionitem
    ADD CONSTRAINT qcadoomodel_unitconv_pkey PRIMARY KEY (id);


--
-- Name: qcadooplugin_plugin qcadooplugin_plugin_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.qcadooplugin_plugin
    ADD CONSTRAINT qcadooplugin_plugin_pkey PRIMARY KEY (id);


--
-- Name: qcadoosecurity_group qcadoosecurity_group_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.qcadoosecurity_group
    ADD CONSTRAINT qcadoosecurity_group_pkey PRIMARY KEY (id);


--
-- Name: qcadoosecurity_passwordresettoken qcadoosecurity_passwordresettoken_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.qcadoosecurity_passwordresettoken
    ADD CONSTRAINT qcadoosecurity_passwordresettoken_pkey PRIMARY KEY (id);


--
-- Name: qcadoosecurity_persistenttoken qcadoosecurity_persistenttoken_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.qcadoosecurity_persistenttoken
    ADD CONSTRAINT qcadoosecurity_persistenttoken_pkey PRIMARY KEY (id);


--
-- Name: qcadoosecurity_role qcadoosecurity_role_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.qcadoosecurity_role
    ADD CONSTRAINT qcadoosecurity_role_pkey PRIMARY KEY (id);


--
-- Name: qcadoosecurity_user qcadoosecurity_user_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.qcadoosecurity_user
    ADD CONSTRAINT qcadoosecurity_user_pkey PRIMARY KEY (id);


--
-- Name: qcadooview_alert qcadooview_alert_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.qcadooview_alert
    ADD CONSTRAINT qcadooview_alert_pkey PRIMARY KEY (id);


--
-- Name: qcadooview_category qcadooview_category_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.qcadooview_category
    ADD CONSTRAINT qcadooview_category_pkey PRIMARY KEY (id);


--
-- Name: qcadooview_item qcadooview_item_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.qcadooview_item
    ADD CONSTRAINT qcadooview_item_pkey PRIMARY KEY (id);


--
-- Name: qcadooview_systeminfo qcadooview_systeminfo_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.qcadooview_systeminfo
    ADD CONSTRAINT qcadooview_systeminfo_pkey PRIMARY KEY (id);


--
-- Name: qcadooview_view qcadooview_view_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.qcadooview_view
    ADD CONSTRAINT qcadooview_view_pkey PRIMARY KEY (id);


--
-- Name: qcadooview_viewedalert qcadooview_viewedalert_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.qcadooview_viewedalert
    ADD CONSTRAINT qcadooview_viewedalert_pkey PRIMARY KEY (id);


--
-- Name: qualitycontrol_changequalitycards qualitycontrol_changequalitycards_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.qualitycontrol_changequalitycards
    ADD CONSTRAINT qualitycontrol_changequalitycards_pkey PRIMARY KEY (id);


--
-- Name: qualitycontrol_deliveryqualitycontrol qualitycontrol_deliveryqualitycontrol_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.qualitycontrol_deliveryqualitycontrol
    ADD CONSTRAINT qualitycontrol_deliveryqualitycontrol_pkey PRIMARY KEY (id);


--
-- Name: qualitycontrol_qualitycardattachment qualitycontrol_qualitycardattachment_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.qualitycontrol_qualitycardattachment
    ADD CONSTRAINT qualitycontrol_qualitycardattachment_pkey PRIMARY KEY (id);


--
-- Name: qualitycontrol_qualitycontrol qualitycontrol_qualitycontrol_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.qualitycontrol_qualitycontrol
    ADD CONSTRAINT qualitycontrol_qualitycontrol_pkey PRIMARY KEY (id);


--
-- Name: qualitycontrol_qualitycontrolattachment qualitycontrol_qualitycontrolattachment_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.qualitycontrol_qualitycontrolattachment
    ADD CONSTRAINT qualitycontrol_qualitycontrolattachment_pkey PRIMARY KEY (id);


--
-- Name: qualitycontrol_qualitycontrolattribute qualitycontrol_qualitycontrolattribute_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.qualitycontrol_qualitycontrolattribute
    ADD CONSTRAINT qualitycontrol_qualitycontrolattribute_pkey PRIMARY KEY (id);


--
-- Name: qualitycontrol_qualitycontrolattributedeliveredprod qualitycontrol_qualitycontrolattributedeliveredprod_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.qualitycontrol_qualitycontrolattributedeliveredprod
    ADD CONSTRAINT qualitycontrol_qualitycontrolattributedeliveredprod_pkey PRIMARY KEY (id);


--
-- Name: qualitycontrol_qualitycontrolattributeprodtracking qualitycontrol_qualitycontrolattributeprodtracking_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.qualitycontrol_qualitycontrolattributeprodtracking
    ADD CONSTRAINT qualitycontrol_qualitycontrolattributeprodtracking_pkey PRIMARY KEY (id);


--
-- Name: qualitycontrol_qualitycontrolattributetoc qualitycontrol_qualitycontrolattributetoc_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.qualitycontrol_qualitycontrolattributetoc
    ADD CONSTRAINT qualitycontrol_qualitycontrolattributetoc_pkey PRIMARY KEY (id);


--
-- Name: qualitycontrol_qualitycontrolattributevalue qualitycontrol_qualitycontrolattributevalue_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.qualitycontrol_qualitycontrolattributevalue
    ADD CONSTRAINT qualitycontrol_qualitycontrolattributevalue_pkey PRIMARY KEY (id);


--
-- Name: qualitycontrol_qualitycontrolresource qualitycontrol_qualitycontrolresource_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.qualitycontrol_qualitycontrolresource
    ADD CONSTRAINT qualitycontrol_qualitycontrolresource_pkey PRIMARY KEY (id);


--
-- Name: qualitycontrol_qualitycontrolstatechange qualitycontrol_qualitycontrolstatechange_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.qualitycontrol_qualitycontrolstatechange
    ADD CONSTRAINT qualitycontrol_qualitycontrolstatechange_pkey PRIMARY KEY (id);


--
-- Name: qualitycontrol_qualitydeliveredproduct qualitycontrol_qualitydeliveredproduct_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.qualitycontrol_qualitydeliveredproduct
    ADD CONSTRAINT qualitycontrol_qualitydeliveredproduct_pkey PRIMARY KEY (id);


--
-- Name: repairs_repairorder repairorder_number_unique; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.repairs_repairorder
    ADD CONSTRAINT repairorder_number_unique UNIQUE (number);


--
-- Name: repairs_repairorder repairs_repairorder_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.repairs_repairorder
    ADD CONSTRAINT repairs_repairorder_pkey PRIMARY KEY (id);


--
-- Name: repairs_repairorderproduct repairs_repairorderproduct_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.repairs_repairorderproduct
    ADD CONSTRAINT repairs_repairorderproduct_pkey PRIMARY KEY (id);


--
-- Name: repairs_repairorderstatechange repairs_repairorderstatechange_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.repairs_repairorderstatechange
    ADD CONSTRAINT repairs_repairorderstatechange_pkey PRIMARY KEY (id);


--
-- Name: repairs_repairorderworktime repairs_repairorderworktime_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.repairs_repairorderworktime
    ADD CONSTRAINT repairs_repairorderworktime_pkey PRIMARY KEY (id);


--
-- Name: materialflowresources_resource resource_number_unique; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.materialflowresources_resource
    ADD CONSTRAINT resource_number_unique UNIQUE (number);


--
-- Name: states_message states_message_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.states_message
    ADD CONSTRAINT states_message_pkey PRIMARY KEY (id);


--
-- Name: stoppage_stoppage stoppage_stoppage_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.stoppage_stoppage
    ADD CONSTRAINT stoppage_stoppage_pkey PRIMARY KEY (id);


--
-- Name: stoppage_stoppagereason stoppage_stoppagereason_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.stoppage_stoppagereason
    ADD CONSTRAINT stoppage_stoppagereason_pkey PRIMARY KEY (id);


--
-- Name: subcontractorportal_subordercost subcontractorportal_cost_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.subcontractorportal_subordercost
    ADD CONSTRAINT subcontractorportal_cost_pkey PRIMARY KEY (id);


--
-- Name: subcontractorportal_suborderevent subcontractorportal_event_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.subcontractorportal_suborderevent
    ADD CONSTRAINT subcontractorportal_event_pkey PRIMARY KEY (id);


--
-- Name: subcontractorportal_subordermessage subcontractorportal_message_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.subcontractorportal_subordermessage
    ADD CONSTRAINT subcontractorportal_message_pkey PRIMARY KEY (id);


--
-- Name: subcontractorportal_operation subcontractorportal_operation_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.subcontractorportal_operation
    ADD CONSTRAINT subcontractorportal_operation_pkey PRIMARY KEY (id);


--
-- Name: subcontractorportal_suborderrealisation subcontractorportal_realisation_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.subcontractorportal_suborderrealisation
    ADD CONSTRAINT subcontractorportal_realisation_pkey PRIMARY KEY (id);


--
-- Name: subcontractorportal_suborder subcontractorportal_suborder_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.subcontractorportal_suborder
    ADD CONSTRAINT subcontractorportal_suborder_pkey PRIMARY KEY (id);


--
-- Name: subcontractorportal_suborderattachment subcontractorportal_suborderattachment_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.subcontractorportal_suborderattachment
    ADD CONSTRAINT subcontractorportal_suborderattachment_pkey PRIMARY KEY (id);


--
-- Name: subcontractorportal_suborderinput subcontractorportal_suborderinput_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.subcontractorportal_suborderinput
    ADD CONSTRAINT subcontractorportal_suborderinput_pkey PRIMARY KEY (id);


--
-- Name: subcontractorportal_suborderissuedproductsreport subcontractorportal_suborderissuedproductsreport_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.subcontractorportal_suborderissuedproductsreport
    ADD CONSTRAINT subcontractorportal_suborderissuedproductsreport_pkey PRIMARY KEY (id);


--
-- Name: subcontractorportal_suborderoperation subcontractorportal_suborderoperation_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.subcontractorportal_suborderoperation
    ADD CONSTRAINT subcontractorportal_suborderoperation_pkey PRIMARY KEY (id);


--
-- Name: subcontractorportal_suborderoutput subcontractorportal_suborderoutput_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.subcontractorportal_suborderoutput
    ADD CONSTRAINT subcontractorportal_suborderoutput_pkey PRIMARY KEY (id);


--
-- Name: subcontractorportal_subordertmp subcontractorportal_subordertmp_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.subcontractorportal_subordertmp
    ADD CONSTRAINT subcontractorportal_subordertmp_pkey PRIMARY KEY (id);


--
-- Name: subcontractorportal_suborderstatechange suborderstatechange_suborderstatechange_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.subcontractorportal_suborderstatechange
    ADD CONSTRAINT suborderstatechange_suborderstatechange_pkey PRIMARY KEY (id);


--
-- Name: supplynegotiations_columnforoffers supplynegotiations_columnforoffers_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.supplynegotiations_columnforoffers
    ADD CONSTRAINT supplynegotiations_columnforoffers_pkey PRIMARY KEY (id);


--
-- Name: supplynegotiations_columnforrequests supplynegotiations_columnforrequests_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.supplynegotiations_columnforrequests
    ADD CONSTRAINT supplynegotiations_columnforrequests_pkey PRIMARY KEY (id);


--
-- Name: supplynegotiations_negotiation supplynegotiations_negotiation_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.supplynegotiations_negotiation
    ADD CONSTRAINT supplynegotiations_negotiation_pkey PRIMARY KEY (id);


--
-- Name: supplynegotiations_negotiationproduct supplynegotiations_negotiationproduct_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.supplynegotiations_negotiationproduct
    ADD CONSTRAINT supplynegotiations_negotiationproduct_pkey PRIMARY KEY (id);


--
-- Name: supplynegotiations_negotiationstatechange supplynegotiations_negotiationstatechange_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.supplynegotiations_negotiationstatechange
    ADD CONSTRAINT supplynegotiations_negotiationstatechange_pkey PRIMARY KEY (id);


--
-- Name: supplynegotiations_offer supplynegotiations_offer_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.supplynegotiations_offer
    ADD CONSTRAINT supplynegotiations_offer_pkey PRIMARY KEY (id);


--
-- Name: supplynegotiations_offerproduct supplynegotiations_offerproduct_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.supplynegotiations_offerproduct
    ADD CONSTRAINT supplynegotiations_offerproduct_pkey PRIMARY KEY (id);


--
-- Name: supplynegotiations_offerstatechange supplynegotiations_offerstatechange_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.supplynegotiations_offerstatechange
    ADD CONSTRAINT supplynegotiations_offerstatechange_pkey PRIMARY KEY (id);


--
-- Name: supplynegotiations_parametercolumnforoffers supplynegotiations_parametercolumnforoffers_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.supplynegotiations_parametercolumnforoffers
    ADD CONSTRAINT supplynegotiations_parametercolumnforoffers_pkey PRIMARY KEY (id);


--
-- Name: supplynegotiations_parametercolumnforrequests supplynegotiations_parametercolumnforrequests_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.supplynegotiations_parametercolumnforrequests
    ADD CONSTRAINT supplynegotiations_parametercolumnforrequests_pkey PRIMARY KEY (id);


--
-- Name: supplynegotiations_requestforquotation supplynegotiations_requestforquotation_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.supplynegotiations_requestforquotation
    ADD CONSTRAINT supplynegotiations_requestforquotation_pkey PRIMARY KEY (id);


--
-- Name: supplynegotiations_requestforquotationproduct supplynegotiations_requestforquotationproduct_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.supplynegotiations_requestforquotationproduct
    ADD CONSTRAINT supplynegotiations_requestforquotationproduct_pkey PRIMARY KEY (id);


--
-- Name: supplynegotiations_requestforquotationstatechange supplynegotiations_requestforquotationstatechange_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.supplynegotiations_requestforquotationstatechange
    ADD CONSTRAINT supplynegotiations_requestforquotationstatechange_pkey PRIMARY KEY (id);


--
-- Name: technologies_barcodeoperationcomponent technologies_barcodeoperationcomponent_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.technologies_barcodeoperationcomponent
    ADD CONSTRAINT technologies_barcodeoperationcomponent_pkey PRIMARY KEY (id);


--
-- Name: technologies_changetechnologyparameters technologies_changetechnologyparameters_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.technologies_changetechnologyparameters
    ADD CONSTRAINT technologies_changetechnologyparameters_pkey PRIMARY KEY (id);


--
-- Name: technologies_dimensioncontrolattribute technologies_dimensioncontrolattribute_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.technologies_dimensioncontrolattribute
    ADD CONSTRAINT technologies_dimensioncontrolattribute_pkey PRIMARY KEY (id);


--
-- Name: technologies_modifytechnologyaddproducthelper technologies_modifytechnologyaddproducthelper_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.technologies_modifytechnologyaddproducthelper
    ADD CONSTRAINT technologies_modifytechnologyaddproducthelper_pkey PRIMARY KEY (id);


--
-- Name: technologies_modifytechnologyhelper technologies_modifytechnologyhelper_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.technologies_modifytechnologyhelper
    ADD CONSTRAINT technologies_modifytechnologyhelper_pkey PRIMARY KEY (id);


--
-- Name: technologies_operation technologies_operation_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.technologies_operation
    ADD CONSTRAINT technologies_operation_pkey PRIMARY KEY (id);


--
-- Name: technologies_operationgroup technologies_operationgroup_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.technologies_operationgroup
    ADD CONSTRAINT technologies_operationgroup_pkey PRIMARY KEY (id);


--
-- Name: technologies_operationproductincomponent technologies_operationproductincomponent_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.technologies_operationproductincomponent
    ADD CONSTRAINT technologies_operationproductincomponent_pkey PRIMARY KEY (id);


--
-- Name: technologies_operationproductoutcomponent technologies_operationproductoutcomponent_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.technologies_operationproductoutcomponent
    ADD CONSTRAINT technologies_operationproductoutcomponent_pkey PRIMARY KEY (id);


--
-- Name: technologies_operationskill technologies_operationskill_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.technologies_operationskill
    ADD CONSTRAINT technologies_operationskill_pkey PRIMARY KEY (id);


--
-- Name: technologies_productbysizegroup technologies_productbysizegroup_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.technologies_productbysizegroup
    ADD CONSTRAINT technologies_productbysizegroup_pkey PRIMARY KEY (id);


--
-- Name: technologies_productcomponent technologies_productcomponent_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.technologies_productcomponent
    ADD CONSTRAINT technologies_productcomponent_pkey PRIMARY KEY (id);


--
-- Name: technologies_productionlinetechnologygroup technologies_productionlinetechnologygroup_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.technologies_productionlinetechnologygroup
    ADD CONSTRAINT technologies_productionlinetechnologygroup_pkey PRIMARY KEY (id);


--
-- Name: technologies_productstructuretreenode technologies_productstructuretreenode_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.technologies_productstructuretreenode
    ADD CONSTRAINT technologies_productstructuretreenode_pkey PRIMARY KEY (id);


--
-- Name: technologies_producttoproductgrouptechnology technologies_producttoproductgrouptechnology_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.technologies_producttoproductgrouptechnology
    ADD CONSTRAINT technologies_producttoproductgrouptechnology_pkey PRIMARY KEY (id);


--
-- Name: technologies_section technologies_section_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.technologies_section
    ADD CONSTRAINT technologies_section_pkey PRIMARY KEY (id);


--
-- Name: technologies_technologicalprocess technologies_technologicalprocess_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.technologies_technologicalprocess
    ADD CONSTRAINT technologies_technologicalprocess_pkey PRIMARY KEY (id);


--
-- Name: technologies_technologicalprocesscomponent technologies_technologicalprocesscomponent_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.technologies_technologicalprocesscomponent
    ADD CONSTRAINT technologies_technologicalprocesscomponent_pkey PRIMARY KEY (id);


--
-- Name: technologies_technologicalprocesslist technologies_technologicalprocesslist_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.technologies_technologicalprocesslist
    ADD CONSTRAINT technologies_technologicalprocesslist_pkey PRIMARY KEY (id);


--
-- Name: technologies_technology technologies_technology_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.technologies_technology
    ADD CONSTRAINT technologies_technology_pkey PRIMARY KEY (id);


--
-- Name: technologies_technologyattachment technologies_technologyattachment_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.technologies_technologyattachment
    ADD CONSTRAINT technologies_technologyattachment_pkey PRIMARY KEY (id);


--
-- Name: technologies_technologygroup technologies_technologygroup_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.technologies_technologygroup
    ADD CONSTRAINT technologies_technologygroup_pkey PRIMARY KEY (id);


--
-- Name: technologies_technologyinputproducttype technologies_technologyinputproducttype_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.technologies_technologyinputproducttype
    ADD CONSTRAINT technologies_technologyinputproducttype_pkey PRIMARY KEY (id);


--
-- Name: technologies_technologyoperationcomponent technologies_technologyoperationcomponent_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.technologies_technologyoperationcomponent
    ADD CONSTRAINT technologies_technologyoperationcomponent_pkey PRIMARY KEY (id);


--
-- Name: technologies_technologystatechange technologies_technologystatechange_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.technologies_technologystatechange
    ADD CONSTRAINT technologies_technologystatechange_pkey PRIMARY KEY (id);


--
-- Name: technologies_technologytocreationhelper technologies_technologytocreationhelper_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.technologies_technologytocreationhelper
    ADD CONSTRAINT technologies_technologytocreationhelper_pkey PRIMARY KEY (id);


--
-- Name: technologies_workstationchangeovernorm technologies_workstationchangeovernorm_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.technologies_workstationchangeovernorm
    ADD CONSTRAINT technologies_workstationchangeovernorm_pkey PRIMARY KEY (id);


--
-- Name: technologies_workstationstatechange technologies_workstationstatechange_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.technologies_workstationstatechange
    ADD CONSTRAINT technologies_workstationstatechange_pkey PRIMARY KEY (id);


--
-- Name: technologiesgenerator_generatortechnologiesforproduct technologiesgenerator_generatortechnologiesforproduct_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.technologiesgenerator_generatortechnologiesforproduct
    ADD CONSTRAINT technologiesgenerator_generatortechnologiesforproduct_pkey PRIMARY KEY (id);


--
-- Name: technologiesgenerator_generatortreenode technologiesgenerator_generatortreenode_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.technologiesgenerator_generatortreenode
    ADD CONSTRAINT technologiesgenerator_generatortreenode_pkey PRIMARY KEY (id);


--
-- Name: techsubcontracting_companyoperation techsubcontracting_companyoperation_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.techsubcontracting_companyoperation
    ADD CONSTRAINT techsubcontracting_companyoperation_pkey PRIMARY KEY (id);


--
-- Name: techsubcontracting_companyoperationgroup techsubcontracting_companyoperationgroup_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.techsubcontracting_companyoperationgroup
    ADD CONSTRAINT techsubcontracting_companyoperationgroup_pkey PRIMARY KEY (id);


--
-- Name: techsubcontracting_orderexternalservicecost techsubcontracting_orderexternalservicecost_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.techsubcontracting_orderexternalservicecost
    ADD CONSTRAINT techsubcontracting_orderexternalservicecost_pkey PRIMARY KEY (id);


--
-- Name: timegapspreview_timegap timegapspreview_timegap_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.timegapspreview_timegap
    ADD CONSTRAINT timegapspreview_timegap_pkey PRIMARY KEY (id);


--
-- Name: timegapspreview_timegapscontext timegapspreview_timegapscontext_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.timegapspreview_timegapscontext
    ADD CONSTRAINT timegapspreview_timegapscontext_pkey PRIMARY KEY (id);


--
-- Name: timenormsforoperations_operationworkstationtime timenormsforoperations_operationworkstationtime_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.timenormsforoperations_operationworkstationtime
    ADD CONSTRAINT timenormsforoperations_operationworkstationtime_pkey PRIMARY KEY (id);


--
-- Name: timenormsforoperations_techopercomptimecalculation timenormsforoperations_techopercomptimecalculation_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.timenormsforoperations_techopercomptimecalculation
    ADD CONSTRAINT timenormsforoperations_techopercomptimecalculation_pkey PRIMARY KEY (id);


--
-- Name: timenormsforoperations_techopercompworkstationtime timenormsforoperations_techopercompworkstationtime_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.timenormsforoperations_techopercompworkstationtime
    ADD CONSTRAINT timenormsforoperations_techopercompworkstationtime_pkey PRIMARY KEY (id);


--
-- Name: urccore_lastsynchronizationdate universalrestconnectorbase_lastsynchronizationdate_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.urccore_lastsynchronizationdate
    ADD CONSTRAINT universalrestconnectorbase_lastsynchronizationdate_pkey PRIMARY KEY (id);


--
-- Name: urcmaterialavailability_requiredcomponent universalrestconnectormaterialavailability_orderrequiredco_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.urcmaterialavailability_requiredcomponent
    ADD CONSTRAINT universalrestconnectormaterialavailability_orderrequiredco_pkey PRIMARY KEY (id);


--
-- Name: urccore_synchronizationstatus urccore_synchronizationstatus_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.urccore_synchronizationstatus
    ADD CONSTRAINT urccore_synchronizationstatus_pkey PRIMARY KEY (id);


--
-- Name: urcproductioncounting_requestrepair urcproductioncounting_requestrepair_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.urcproductioncounting_requestrepair
    ADD CONSTRAINT urcproductioncounting_requestrepair_pkey PRIMARY KEY (id);


--
-- Name: wagegroups_wagegroup wagegroups_wagegroup_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.wagegroups_wagegroup
    ADD CONSTRAINT wagegroups_wagegroup_pkey PRIMARY KEY (id);


--
-- Name: walusiak_exportdocumenthistory walusiak_exportdocumenthistory_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.walusiak_exportdocumenthistory
    ADD CONSTRAINT walusiak_exportdocumenthistory_pkey PRIMARY KEY (id);


--
-- Name: warehouseminimalstate_warehouseminimumstate warehouseminimalstate_warehouseminimumstate_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.warehouseminimalstate_warehouseminimumstate
    ADD CONSTRAINT warehouseminimalstate_warehouseminimumstate_pkey PRIMARY KEY (id);


--
-- Name: warehouseminimalstate_warehouseminimumstatemulti warehouseminimalstate_warehouseminimumstatemulti_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.warehouseminimalstate_warehouseminimumstatemulti
    ADD CONSTRAINT warehouseminimalstate_warehouseminimumstatemulti_pkey PRIMARY KEY (id);


--
-- Name: workplans_columnforinputproducts workplans_columnforinputproducts_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.workplans_columnforinputproducts
    ADD CONSTRAINT workplans_columnforinputproducts_pkey PRIMARY KEY (id);


--
-- Name: workplans_columnfororders workplans_columnfororders_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.workplans_columnfororders
    ADD CONSTRAINT workplans_columnfororders_pkey PRIMARY KEY (id);


--
-- Name: workplans_columnforoutputproducts workplans_columnforoutputproducts_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.workplans_columnforoutputproducts
    ADD CONSTRAINT workplans_columnforoutputproducts_pkey PRIMARY KEY (id);


--
-- Name: workplans_parameterinputcolumn workplans_parameterinputcolumn_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.workplans_parameterinputcolumn
    ADD CONSTRAINT workplans_parameterinputcolumn_pkey PRIMARY KEY (id);


--
-- Name: workplans_parameterordercolumn workplans_parameterordercolumn_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.workplans_parameterordercolumn
    ADD CONSTRAINT workplans_parameterordercolumn_pkey PRIMARY KEY (id);


--
-- Name: workplans_parameteroutputcolumn workplans_parameteroutputcolumn_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.workplans_parameteroutputcolumn
    ADD CONSTRAINT workplans_parameteroutputcolumn_pkey PRIMARY KEY (id);


--
-- Name: workplans_workplan workplans_workplan_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.workplans_workplan
    ADD CONSTRAINT workplans_workplan_pkey PRIMARY KEY (id);


--
-- Name: workplans_workplanordercolumn workplans_workplanordercolumn_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.workplans_workplanordercolumn
    ADD CONSTRAINT workplans_workplanordercolumn_pkey PRIMARY KEY (id);


--
-- Name: arc2_assignmenttoshift_staffassignmenttoshif_masterorder_id_idx; Type: INDEX; Schema: public; Owner: -
--

CREATE INDEX arc2_assignmenttoshift_staffassignmenttoshif_masterorder_id_idx ON public.arch_assignmenttoshift_staffassignmenttoshift USING btree (masterorder_id);


--
-- Name: arc2_basicproductioncounting__technologyoperationcomponent__idx; Type: INDEX; Schema: public; Owner: -
--

CREATE INDEX arc2_basicproductioncounting__technologyoperationcomponent__idx ON public.arch_basicproductioncounting_productioncountingquantity USING btree (technologyoperationcomponent_id);


--
-- Name: arc2_basicproductioncounting__technologyoperationcomponent_idx1; Type: INDEX; Schema: public; Owner: -
--

CREATE INDEX arc2_basicproductioncounting__technologyoperationcomponent_idx1 ON public.arch_basicproductioncounting_productioncountingoperationrun USING btree (technologyoperationcomponent_id);


--
-- Name: arc2_basicproductioncounting_basicproductioncoun_product_id_idx; Type: INDEX; Schema: public; Owner: -
--

CREATE INDEX arc2_basicproductioncounting_basicproductioncoun_product_id_idx ON public.arch_basicproductioncounting_basicproductioncounting USING btree (product_id);


--
-- Name: arc2_basicproductioncounting_basicproductioncounti_order_id_idx; Type: INDEX; Schema: public; Owner: -
--

CREATE INDEX arc2_basicproductioncounting_basicproductioncounti_order_id_idx ON public.arch_basicproductioncounting_basicproductioncounting USING btree (order_id);


--
-- Name: arc2_basicproductioncounting_pro_basicproductioncounting_id_idx; Type: INDEX; Schema: public; Owner: -
--

CREATE INDEX arc2_basicproductioncounting_pro_basicproductioncounting_id_idx ON public.arch_basicproductioncounting_productioncountingquantity USING btree (basicproductioncounting_id);


--
-- Name: arc2_basicproductioncounting_productioncou_replacementto_id_idx; Type: INDEX; Schema: public; Owner: -
--

CREATE INDEX arc2_basicproductioncounting_productioncou_replacementto_id_idx ON public.arch_basicproductioncounting_productioncountingquantity USING btree (replacementto_id);


--
-- Name: arc2_basicproductioncounting_productioncount_typeofmaterial_idx; Type: INDEX; Schema: public; Owner: -
--

CREATE INDEX arc2_basicproductioncounting_productioncount_typeofmaterial_idx ON public.arch_basicproductioncounting_productioncountingquantity USING btree (typeofmaterial);


--
-- Name: arc2_basicproductioncounting_productioncountingope_order_id_idx; Type: INDEX; Schema: public; Owner: -
--

CREATE INDEX arc2_basicproductioncounting_productioncountingope_order_id_idx ON public.arch_basicproductioncounting_productioncountingoperationrun USING btree (order_id);


--
-- Name: arc2_basicproductioncounting_productioncountingq_product_id_idx; Type: INDEX; Schema: public; Owner: -
--

CREATE INDEX arc2_basicproductioncounting_productioncountingq_product_id_idx ON public.arch_basicproductioncounting_productioncountingquantity USING btree (product_id);


--
-- Name: arc2_basicproductioncounting_productioncountingqua_order_id_idx; Type: INDEX; Schema: public; Owner: -
--

CREATE INDEX arc2_basicproductioncounting_productioncountingqua_order_id_idx ON public.arch_basicproductioncounting_productioncountingquantity USING btree (order_id);


--
-- Name: arc2_costnormsformaterials_technologyinstoperpro_product_id_idx; Type: INDEX; Schema: public; Owner: -
--

CREATE INDEX arc2_costnormsformaterials_technologyinstoperpro_product_id_idx ON public.arch_costnormsformaterials_technologyinstoperproductincomp USING btree (product_id);


--
-- Name: arc2_costnormsformaterials_technologyinstoperprodu_order_id_idx; Type: INDEX; Schema: public; Owner: -
--

CREATE INDEX arc2_costnormsformaterials_technologyinstoperprodu_order_id_idx ON public.arch_costnormsformaterials_technologyinstoperproductincomp USING btree (order_id);


--
-- Name: arc2_goodfood_confectioninputproduct_batch_id_idx; Type: INDEX; Schema: public; Owner: -
--

CREATE INDEX arc2_goodfood_confectioninputproduct_batch_id_idx ON public.arch_goodfood_confectioninputproduct USING btree (batch_id);


--
-- Name: arc2_goodfood_confectioninputproduct_confectionprotocol_id_idx; Type: INDEX; Schema: public; Owner: -
--

CREATE INDEX arc2_goodfood_confectioninputproduct_confectionprotocol_id_idx ON public.arch_goodfood_confectioninputproduct USING btree (confectionprotocol_id);


--
-- Name: arc2_goodfood_confectionprotocol_confectioncontext_id_idx; Type: INDEX; Schema: public; Owner: -
--

CREATE INDEX arc2_goodfood_confectionprotocol_confectioncontext_id_idx ON public.arch_goodfood_confectionprotocol USING btree (confectioncontext_id);


--
-- Name: arc2_goodfood_confectionprotocol_order_id_idx; Type: INDEX; Schema: public; Owner: -
--

CREATE INDEX arc2_goodfood_confectionprotocol_order_id_idx ON public.arch_goodfood_confectionprotocol USING btree (order_id);


--
-- Name: arc2_goodfood_confectionprotocolstate_confectionprotocol_id_idx; Type: INDEX; Schema: public; Owner: -
--

CREATE INDEX arc2_goodfood_confectionprotocolstate_confectionprotocol_id_idx ON public.arch_goodfood_confectionprotocolstatechange USING btree (confectionprotocol_id);


--
-- Name: arc2_goodfood_confectionremainderinpu_confectionprotocol_id_idx; Type: INDEX; Schema: public; Owner: -
--

CREATE INDEX arc2_goodfood_confectionremainderinpu_confectionprotocol_id_idx ON public.arch_goodfood_confectionremainderinputproduct USING btree (confectionprotocol_id);


--
-- Name: arc2_goodfood_confectionstaff_confectionprotocol_id_idx; Type: INDEX; Schema: public; Owner: -
--

CREATE INDEX arc2_goodfood_confectionstaff_confectionprotocol_id_idx ON public.arch_goodfood_confectionstaff USING btree (confectionprotocol_id);


--
-- Name: arc2_goodfood_extrusionpouring_extrusionprotocol_id_idx; Type: INDEX; Schema: public; Owner: -
--

CREATE INDEX arc2_goodfood_extrusionpouring_extrusionprotocol_id_idx ON public.arch_goodfood_extrusionpouring USING btree (extrusionprotocol_id);


--
-- Name: arc2_goodfood_extrusionpouringingredien_extrusionpouring_id_idx; Type: INDEX; Schema: public; Owner: -
--

CREATE INDEX arc2_goodfood_extrusionpouringingredien_extrusionpouring_id_idx ON public.arch_goodfood_extrusionpouringingredient USING btree (extrusionpouring_id);


--
-- Name: arc2_goodfood_extrusionpouringingredient_batch_id_idx; Type: INDEX; Schema: public; Owner: -
--

CREATE INDEX arc2_goodfood_extrusionpouringingredient_batch_id_idx ON public.arch_goodfood_extrusionpouringingredient USING btree (batch_id);


--
-- Name: arc2_goodfood_extrusionprotocol_extrusioncontext_id_idx; Type: INDEX; Schema: public; Owner: -
--

CREATE INDEX arc2_goodfood_extrusionprotocol_extrusioncontext_id_idx ON public.arch_goodfood_extrusionprotocol USING btree (extrusioncontext_id);


--
-- Name: arc2_goodfood_extrusionprotocol_order_id_idx; Type: INDEX; Schema: public; Owner: -
--

CREATE INDEX arc2_goodfood_extrusionprotocol_order_id_idx ON public.arch_goodfood_extrusionprotocol USING btree (order_id);


--
-- Name: arc2_goodfood_extrusionprotocolstatech_extrusionprotocol_id_idx; Type: INDEX; Schema: public; Owner: -
--

CREATE INDEX arc2_goodfood_extrusionprotocolstatech_extrusionprotocol_id_idx ON public.arch_goodfood_extrusionprotocolstatechange USING btree (extrusionprotocol_id);


--
-- Name: arc2_goodfood_pallet_palletcontext_id_idx; Type: INDEX; Schema: public; Owner: -
--

CREATE INDEX arc2_goodfood_pallet_palletcontext_id_idx ON public.arch_goodfood_pallet USING btree (palletcontext_id);


--
-- Name: arc2_goodfood_pallet_palletlabel_id_idx; Type: INDEX; Schema: public; Owner: -
--

CREATE INDEX arc2_goodfood_pallet_palletlabel_id_idx ON public.arch_goodfood_pallet USING btree (palletlabel_id);


--
-- Name: arc2_goodfood_pallet_secondpallet_id_idx; Type: INDEX; Schema: public; Owner: -
--

CREATE INDEX arc2_goodfood_pallet_secondpallet_id_idx ON public.arch_goodfood_pallet USING btree (secondpallet_id);


--
-- Name: arc2_goodfood_palletlabel_batch_id_idx; Type: INDEX; Schema: public; Owner: -
--

CREATE INDEX arc2_goodfood_palletlabel_batch_id_idx ON public.arch_goodfood_palletlabel USING btree (batch_id);


--
-- Name: arc2_goodfood_palletlabel_masterorder_id_idx; Type: INDEX; Schema: public; Owner: -
--

CREATE INDEX arc2_goodfood_palletlabel_masterorder_id_idx ON public.arch_goodfood_palletlabel USING btree (masterorder_id);


--
-- Name: arc2_goodfood_palletlabel_palletcontext_id_idx; Type: INDEX; Schema: public; Owner: -
--

CREATE INDEX arc2_goodfood_palletlabel_palletcontext_id_idx ON public.arch_goodfood_palletlabel USING btree (palletcontext_id);


--
-- Name: arc2_goodfood_palletlabelstatechange_palletlabel_id_idx; Type: INDEX; Schema: public; Owner: -
--

CREATE INDEX arc2_goodfood_palletlabelstatechange_palletlabel_id_idx ON public.arch_goodfood_palletlabelstatechange USING btree (palletlabel_id);


--
-- Name: arc2_goodfood_palletstatechange_pallet_id_idx; Type: INDEX; Schema: public; Owner: -
--

CREATE INDEX arc2_goodfood_palletstatechange_pallet_id_idx ON public.arch_goodfood_palletstatechange USING btree (pallet_id);


--
-- Name: arc2_goodfood_printedlabel_masterorder_id_idx; Type: INDEX; Schema: public; Owner: -
--

CREATE INDEX arc2_goodfood_printedlabel_masterorder_id_idx ON public.arch_goodfood_printedlabel USING btree (masterorder_id);


--
-- Name: arc2_goodfood_printedlabel_palletcontext_id_idx; Type: INDEX; Schema: public; Owner: -
--

CREATE INDEX arc2_goodfood_printedlabel_palletcontext_id_idx ON public.arch_goodfood_printedlabel USING btree (palletcontext_id);


--
-- Name: arc2_integrationbartender_printlabelshelper_masterorder_id_idx; Type: INDEX; Schema: public; Owner: -
--

CREATE INDEX arc2_integrationbartender_printlabelshelper_masterorder_id_idx ON public.arch_integrationbartender_printlabelshelper USING btree (masterorder_id);


--
-- Name: arc2_integrationbartender_sendtoprint_printlabelshelper_id_idx; Type: INDEX; Schema: public; Owner: -
--

CREATE INDEX arc2_integrationbartender_sendtoprint_printlabelshelper_id_idx ON public.arch_integrationbartender_sendtoprint USING btree (printlabelshelper_id);


--
-- Name: arc2_masterorders_masterorder_batch_id_idx; Type: INDEX; Schema: public; Owner: -
--

CREATE INDEX arc2_masterorders_masterorder_batch_id_idx ON public.arch_masterorders_masterorder USING btree (batch_id);


--
-- Name: arc2_masterorders_masterorderproduct_masterorder_id_idx; Type: INDEX; Schema: public; Owner: -
--

CREATE INDEX arc2_masterorders_masterorderproduct_masterorder_id_idx ON public.arch_masterorders_masterorderproduct USING btree (masterorder_id);


--
-- Name: arc2_masterorders_masterorderproduct_product_id_idx; Type: INDEX; Schema: public; Owner: -
--

CREATE INDEX arc2_masterorders_masterorderproduct_product_id_idx ON public.arch_masterorders_masterorderproduct USING btree (product_id);


--
-- Name: arc2_masterorders_masterorderproduct_technology_id_idx; Type: INDEX; Schema: public; Owner: -
--

CREATE INDEX arc2_masterorders_masterorderproduct_technology_id_idx ON public.arch_masterorders_masterorderproduct USING btree (technology_id);


--
-- Name: arc2_materialflowresources_document_delivery_id_idx; Type: INDEX; Schema: public; Owner: -
--

CREATE INDEX arc2_materialflowresources_document_delivery_id_idx ON public.arch_materialflowresources_document USING btree (delivery_id);


--
-- Name: arc2_materialflowresources_document_dispositionshift_id_idx; Type: INDEX; Schema: public; Owner: -
--

CREATE INDEX arc2_materialflowresources_document_dispositionshift_id_idx ON public.arch_materialflowresources_document USING btree (dispositionshift_id);


--
-- Name: arc2_materialflowresources_document_order_id_idx; Type: INDEX; Schema: public; Owner: -
--

CREATE INDEX arc2_materialflowresources_document_order_id_idx ON public.arch_materialflowresources_document USING btree (order_id);


--
-- Name: arc2_materialflowresources_position_document_id_idx; Type: INDEX; Schema: public; Owner: -
--

CREATE INDEX arc2_materialflowresources_position_document_id_idx ON public.arch_materialflowresources_position USING btree (document_id);


--
-- Name: arc2_materialflowresources_position_palletnumber_id_idx; Type: INDEX; Schema: public; Owner: -
--

CREATE INDEX arc2_materialflowresources_position_palletnumber_id_idx ON public.arch_materialflowresources_position USING btree (palletnumber_id);


--
-- Name: arc2_materialflowresources_position_product_id_idx; Type: INDEX; Schema: public; Owner: -
--

CREATE INDEX arc2_materialflowresources_position_product_id_idx ON public.arch_materialflowresources_position USING btree (product_id);


--
-- Name: arc2_materialflowresources_position_resource_id_idx; Type: INDEX; Schema: public; Owner: -
--

CREATE INDEX arc2_materialflowresources_position_resource_id_idx ON public.arch_materialflowresources_position USING btree (resource_id);


--
-- Name: arc2_materialrequirementcoveragefororder_covera_delivery_id_idx; Type: INDEX; Schema: public; Owner: -
--

CREATE INDEX arc2_materialrequirementcoveragefororder_covera_delivery_id_idx ON public.arch_materialrequirementcoveragefororder_coverageproductlogging USING btree (delivery_id);


--
-- Name: arc2_materialrequirementcoveragefororder_coverag_product_id_idx; Type: INDEX; Schema: public; Owner: -
--

CREATE INDEX arc2_materialrequirementcoveragefororder_coverag_product_id_idx ON public.arch_materialrequirementcoveragefororder_coverageproduct USING btree (product_id);


--
-- Name: arc2_materialrequirementcoveragefororder_coverage_order_id_idx1; Type: INDEX; Schema: public; Owner: -
--

CREATE INDEX arc2_materialrequirementcoveragefororder_coverage_order_id_idx1 ON public.arch_materialrequirementcoveragefororder_coverageproductlogging USING btree (order_id);


--
-- Name: arc2_materialrequirementcoveragefororder_coveragep_order_id_idx; Type: INDEX; Schema: public; Owner: -
--

CREATE INDEX arc2_materialrequirementcoveragefororder_coveragep_order_id_idx ON public.arch_materialrequirementcoveragefororder_coverageproduct USING btree (order_id);


--
-- Name: arc2_materialrequirementcoveragefororder_coverageproduct_id_idx; Type: INDEX; Schema: public; Owner: -
--

CREATE INDEX arc2_materialrequirementcoveragefororder_coverageproduct_id_idx ON public.arch_materialrequirementcoveragefororder_coverageproductlogging USING btree (coverageproduct_id);


--
-- Name: arc2_orders_order_masterorder_id_idx; Type: INDEX; Schema: public; Owner: -
--

CREATE INDEX arc2_orders_order_masterorder_id_idx ON public.arch_orders_order USING btree (masterorder_id);


--
-- Name: arc2_orders_order_masterorderproductcomponent_id_idx; Type: INDEX; Schema: public; Owner: -
--

CREATE INDEX arc2_orders_order_masterorderproductcomponent_id_idx ON public.arch_orders_order USING btree (masterorderproductcomponent_id);


--
-- Name: arc2_orders_order_number_idx; Type: INDEX; Schema: public; Owner: -
--

CREATE INDEX arc2_orders_order_number_idx ON public.arch_orders_order USING btree (number);


--
-- Name: arc2_orders_order_ordersgroup_id_idx; Type: INDEX; Schema: public; Owner: -
--

CREATE INDEX arc2_orders_order_ordersgroup_id_idx ON public.arch_orders_order USING btree (ordersgroup_id);


--
-- Name: arc2_orders_order_parent_id_idx; Type: INDEX; Schema: public; Owner: -
--

CREATE INDEX arc2_orders_order_parent_id_idx ON public.arch_orders_order USING btree (parent_id);


--
-- Name: arc2_orders_order_product_id_idx; Type: INDEX; Schema: public; Owner: -
--

CREATE INDEX arc2_orders_order_product_id_idx ON public.arch_orders_order USING btree (product_id);


--
-- Name: arc2_orders_order_productionline_id_idx; Type: INDEX; Schema: public; Owner: -
--

CREATE INDEX arc2_orders_order_productionline_id_idx ON public.arch_orders_order USING btree (productionline_id);


--
-- Name: arc2_orders_order_root_id_idx; Type: INDEX; Schema: public; Owner: -
--

CREATE INDEX arc2_orders_order_root_id_idx ON public.arch_orders_order USING btree (root_id);


--
-- Name: arc2_orders_order_state_idx; Type: INDEX; Schema: public; Owner: -
--

CREATE INDEX arc2_orders_order_state_idx ON public.arch_orders_order USING btree (state);


--
-- Name: arc2_orders_order_technology_id_idx; Type: INDEX; Schema: public; Owner: -
--

CREATE INDEX arc2_orders_order_technology_id_idx ON public.arch_orders_order USING btree (technology_id);


--
-- Name: arc2_orders_order_technologyprototype_id_idx; Type: INDEX; Schema: public; Owner: -
--

CREATE INDEX arc2_orders_order_technologyprototype_id_idx ON public.arch_orders_order USING btree (technologyprototype_id);


--
-- Name: arc2_orders_orderstatechange_order_id_idx; Type: INDEX; Schema: public; Owner: -
--

CREATE INDEX arc2_orders_orderstatechange_order_id_idx ON public.arch_orders_orderstatechange USING btree (order_id);


--
-- Name: arc2_ordersforsubproductsgeneration_suborder_ordersgroup_id_idx; Type: INDEX; Schema: public; Owner: -
--

CREATE INDEX arc2_ordersforsubproductsgeneration_suborder_ordersgroup_id_idx ON public.arch_ordersforsubproductsgeneration_suborders USING btree (ordersgroup_id);


--
-- Name: arc2_ordersgroups_ordersgroup_assortment_id_idx; Type: INDEX; Schema: public; Owner: -
--

CREATE INDEX arc2_ordersgroups_ordersgroup_assortment_id_idx ON public.arch_ordersgroups_ordersgroup USING btree (assortment_id);


--
-- Name: arc2_ordersgroups_ordersgroup_masterorder_id_idx; Type: INDEX; Schema: public; Owner: -
--

CREATE INDEX arc2_ordersgroups_ordersgroup_masterorder_id_idx ON public.arch_ordersgroups_ordersgroup USING btree (masterorder_id);


--
-- Name: arc2_ordersgroups_ordersgroup_number_idx; Type: INDEX; Schema: public; Owner: -
--

CREATE INDEX arc2_ordersgroups_ordersgroup_number_idx ON public.arch_ordersgroups_ordersgroup USING btree (number);


--
-- Name: arc2_ordersgroups_ordersgroup_parent_id_idx; Type: INDEX; Schema: public; Owner: -
--

CREATE INDEX arc2_ordersgroups_ordersgroup_parent_id_idx ON public.arch_ordersgroups_ordersgroup USING btree (parent_id);


--
-- Name: arc2_ordersupplies_coverageproduct_product_id_idx; Type: INDEX; Schema: public; Owner: -
--

CREATE INDEX arc2_ordersupplies_coverageproduct_product_id_idx ON public.arch_ordersupplies_coverageproduct USING btree (product_id);


--
-- Name: arc2_ordersupplies_coverageproductlogging_delivery_id_idx; Type: INDEX; Schema: public; Owner: -
--

CREATE INDEX arc2_ordersupplies_coverageproductlogging_delivery_id_idx ON public.arch_ordersupplies_coverageproductlogging USING btree (delivery_id);


--
-- Name: arc2_ordersupplies_coverageproductlogging_order_id_idx; Type: INDEX; Schema: public; Owner: -
--

CREATE INDEX arc2_ordersupplies_coverageproductlogging_order_id_idx ON public.arch_ordersupplies_coverageproductlogging USING btree (order_id);


--
-- Name: arc2_productflowthrudivision_issue_document_id_idx; Type: INDEX; Schema: public; Owner: -
--

CREATE INDEX arc2_productflowthrudivision_issue_document_id_idx ON public.arch_productflowthrudivision_issue USING btree (document_id);


--
-- Name: arc2_productflowthrudivision_issue_product_id_idx; Type: INDEX; Schema: public; Owner: -
--

CREATE INDEX arc2_productflowthrudivision_issue_product_id_idx ON public.arch_productflowthrudivision_issue USING btree (product_id);


--
-- Name: arc2_productflowthrudivision_issue_productincomponent_id_idx; Type: INDEX; Schema: public; Owner: -
--

CREATE INDEX arc2_productflowthrudivision_issue_productincomponent_id_idx ON public.arch_productflowthrudivision_issue USING btree (productincomponent_id);


--
-- Name: arc2_productflowthrudivision_materialavailabilit_product_id_idx; Type: INDEX; Schema: public; Owner: -
--

CREATE INDEX arc2_productflowthrudivision_materialavailabilit_product_id_idx ON public.arch_productflowthrudivision_materialavailability USING btree (product_id);


--
-- Name: arc2_productflowthrudivision_materialavailability_order_id_idx; Type: INDEX; Schema: public; Owner: -
--

CREATE INDEX arc2_productflowthrudivision_materialavailability_order_id_idx ON public.arch_productflowthrudivision_materialavailability USING btree (order_id);


--
-- Name: arc2_productflowthrudivision_products_productincomponent_id_idx; Type: INDEX; Schema: public; Owner: -
--

CREATE INDEX arc2_productflowthrudivision_products_productincomponent_id_idx ON public.arch_productflowthrudivision_productstoissue USING btree (productincomponent_id);


--
-- Name: arc2_productflowthrudivision_productstoissue_product_id_idx; Type: INDEX; Schema: public; Owner: -
--

CREATE INDEX arc2_productflowthrudivision_productstoissue_product_id_idx ON public.arch_productflowthrudivision_productstoissue USING btree (product_id);


--
-- Name: arc2_productioncounting_produ_technologyoperationcomponent__idx; Type: INDEX; Schema: public; Owner: -
--

CREATE INDEX arc2_productioncounting_produ_technologyoperationcomponent__idx ON public.arch_productioncounting_productiontracking USING btree (technologyoperationcomponent_id);


--
-- Name: arc2_productioncounting_productiontra_productiontracking_id_idx; Type: INDEX; Schema: public; Owner: -
--

CREATE INDEX arc2_productioncounting_productiontra_productiontracking_id_idx ON public.arch_productioncounting_productiontrackingstatechange USING btree (productiontracking_id);


--
-- Name: arc2_productioncounting_productiontracking_correction_id_idx; Type: INDEX; Schema: public; Owner: -
--

CREATE INDEX arc2_productioncounting_productiontracking_correction_id_idx ON public.arch_productioncounting_productiontracking USING btree (correction_id);


--
-- Name: arc2_productioncounting_productiontracking_number_idx; Type: INDEX; Schema: public; Owner: -
--

CREATE INDEX arc2_productioncounting_productiontracking_number_idx ON public.arch_productioncounting_productiontracking USING btree (number);


--
-- Name: arc2_productioncounting_productiontracking_order_id_idx; Type: INDEX; Schema: public; Owner: -
--

CREATE INDEX arc2_productioncounting_productiontracking_order_id_idx ON public.arch_productioncounting_productiontracking USING btree (order_id);


--
-- Name: arc2_productioncounting_productiontracking_state_idx; Type: INDEX; Schema: public; Owner: -
--

CREATE INDEX arc2_productioncounting_productiontracking_state_idx ON public.arch_productioncounting_productiontracking USING btree (state);


--
-- Name: arc2_productioncounting_staffworktime_productionrecord_id_idx; Type: INDEX; Schema: public; Owner: -
--

CREATE INDEX arc2_productioncounting_staffworktime_productionrecord_id_idx ON public.arch_productioncounting_staffworktime USING btree (productionrecord_id);


--
-- Name: arc2_productioncounting_trackingoper_productiontracking_id_idx1; Type: INDEX; Schema: public; Owner: -
--

CREATE INDEX arc2_productioncounting_trackingoper_productiontracking_id_idx1 ON public.arch_productioncounting_trackingoperationproductoutcomponent USING btree (productiontracking_id);


--
-- Name: arc2_productioncounting_trackingopera_productiontracking_id_idx; Type: INDEX; Schema: public; Owner: -
--

CREATE INDEX arc2_productioncounting_trackingopera_productiontracking_id_idx ON public.arch_productioncounting_trackingoperationproductincomponent USING btree (productiontracking_id);


--
-- Name: arc2_productioncounting_trackingoperationproduc_product_id_idx1; Type: INDEX; Schema: public; Owner: -
--

CREATE INDEX arc2_productioncounting_trackingoperationproduc_product_id_idx1 ON public.arch_productioncounting_trackingoperationproductoutcomponent USING btree (product_id);


--
-- Name: arc2_productioncounting_trackingoperationproduct_product_id_idx; Type: INDEX; Schema: public; Owner: -
--

CREATE INDEX arc2_productioncounting_trackingoperationproduct_product_id_idx ON public.arch_productioncounting_trackingoperationproductincomponent USING btree (product_id);


--
-- Name: arc2_productioncounting_trackingoperationproductou_batch_id_idx; Type: INDEX; Schema: public; Owner: -
--

CREATE INDEX arc2_productioncounting_trackingoperationproductou_batch_id_idx ON public.arch_productioncounting_trackingoperationproductoutcomponent USING btree (batch_id);


--
-- Name: arc2_productionpershift_dailyprogress_progressforday_id_idx; Type: INDEX; Schema: public; Owner: -
--

CREATE INDEX arc2_productionpershift_dailyprogress_progressforday_id_idx ON public.arch_productionpershift_dailyprogress USING btree (progressforday_id);


--
-- Name: arc2_productionpershift_productionpershift_order_id_idx; Type: INDEX; Schema: public; Owner: -
--

CREATE INDEX arc2_productionpershift_productionpershift_order_id_idx ON public.arch_productionpershift_productionpershift USING btree (order_id);


--
-- Name: arc2_productionpershift_progressforda_productionpershift_id_idx; Type: INDEX; Schema: public; Owner: -
--

CREATE INDEX arc2_productionpershift_progressforda_productionpershift_id_idx ON public.arch_productionpershift_progressforday USING btree (productionpershift_id);


--
-- Name: arc2_productionscheduling_ope_technologyoperationcomponent__idx; Type: INDEX; Schema: public; Owner: -
--

CREATE INDEX arc2_productionscheduling_ope_technologyoperationcomponent__idx ON public.arch_productionscheduling_opercomptimecalculation USING btree (technologyoperationcomponent_id);


--
-- Name: arc2_technologies_barcodeoperationcom_operationcomponent_id_idx; Type: INDEX; Schema: public; Owner: -
--

CREATE INDEX arc2_technologies_barcodeoperationcom_operationcomponent_id_idx ON public.arch_technologies_barcodeoperationcomponent USING btree (operationcomponent_id);


--
-- Name: arc2_technologies_barcodeoperationcomponent_order_id_idx; Type: INDEX; Schema: public; Owner: -
--

CREATE INDEX arc2_technologies_barcodeoperationcomponent_order_id_idx ON public.arch_technologies_barcodeoperationcomponent USING btree (order_id);


--
-- Name: basicproductioncounting_productioncountingqu_typeofmaterial_idx; Type: INDEX; Schema: public; Owner: -
--

CREATE INDEX basicproductioncounting_productioncountingqu_typeofmaterial_idx ON public.basicproductioncounting_productioncountingquantity USING btree (typeofmaterial);


--
-- Name: idx_adv_atchstatechange_batch_id; Type: INDEX; Schema: public; Owner: -
--

CREATE INDEX idx_adv_atchstatechange_batch_id ON public.advancedgenealogy_batchstatechange USING btree (batch_id);


--
-- Name: idx_ass_signmenttoshift_masterorder_id; Type: INDEX; Schema: public; Owner: -
--

CREATE INDEX idx_ass_signmenttoshift_masterorder_id ON public.assignmenttoshift_staffassignmenttoshift USING btree (masterorder_id);


--
-- Name: idx_bas_asic_assortment_assortment_id; Type: INDEX; Schema: public; Owner: -
--

CREATE INDEX idx_bas_asic_assortment_assortment_id ON public.basic_product USING btree (assortment_id);


--
-- Name: idx_bas_ductioncounting_order_id; Type: INDEX; Schema: public; Owner: -
--

CREATE INDEX idx_bas_ductioncounting_order_id ON public.basicproductioncounting_basicproductioncounting USING btree (order_id);


--
-- Name: idx_bas_ductioncounting_product_id; Type: INDEX; Schema: public; Owner: -
--

CREATE INDEX idx_bas_ductioncounting_product_id ON public.basicproductioncounting_basicproductioncounting USING btree (product_id);


--
-- Name: idx_bas_ingoperationrun_order_id; Type: INDEX; Schema: public; Owner: -
--

CREATE INDEX idx_bas_ingoperationrun_order_id ON public.basicproductioncounting_productioncountingoperationrun USING btree (order_id);


--
-- Name: idx_bas_ingoperationrun_technologyoperationcomponent_id; Type: INDEX; Schema: public; Owner: -
--

CREATE INDEX idx_bas_ingoperationrun_technologyoperationcomponent_id ON public.basicproductioncounting_productioncountingoperationrun USING btree (technologyoperationcomponent_id);


--
-- Name: idx_bas_oductattachment_product_id; Type: INDEX; Schema: public; Owner: -
--

CREATE INDEX idx_bas_oductattachment_product_id ON public.basic_productattachment USING btree (product_id);


--
-- Name: idx_bas_ountingquantity_basicproductioncounting_id; Type: INDEX; Schema: public; Owner: -
--

CREATE INDEX idx_bas_ountingquantity_basicproductioncounting_id ON public.basicproductioncounting_productioncountingquantity USING btree (basicproductioncounting_id);


--
-- Name: idx_bas_ountingquantity_order_id; Type: INDEX; Schema: public; Owner: -
--

CREATE INDEX idx_bas_ountingquantity_order_id ON public.basicproductioncounting_productioncountingquantity USING btree (order_id);


--
-- Name: idx_bas_ountingquantity_product_id; Type: INDEX; Schema: public; Owner: -
--

CREATE INDEX idx_bas_ountingquantity_product_id ON public.basicproductioncounting_productioncountingquantity USING btree (product_id);


--
-- Name: idx_bas_ountingquantity_replacementto_id; Type: INDEX; Schema: public; Owner: -
--

CREATE INDEX idx_bas_ountingquantity_replacementto_id ON public.basicproductioncounting_productioncountingquantity USING btree (replacementto_id);


--
-- Name: idx_bas_ountingquantity_technologyoperationcomponent_id; Type: INDEX; Schema: public; Owner: -
--

CREATE INDEX idx_bas_ountingquantity_technologyoperationcomponent_id ON public.basicproductioncounting_productioncountingquantity USING btree (technologyoperationcomponent_id);


--
-- Name: idx_bas_product_parent_id; Type: INDEX; Schema: public; Owner: -
--

CREATE INDEX idx_bas_product_parent_id ON public.basic_product USING btree (parent_id);


--
-- Name: idx_cmm_staffworktime_maintenanceevent_id; Type: INDEX; Schema: public; Owner: -
--

CREATE INDEX idx_cmm_staffworktime_maintenanceevent_id ON public.cmmsmachineparts_staffworktime USING btree (maintenanceevent_id);


--
-- Name: idx_cmm_ventrealization_action_id; Type: INDEX; Schema: public; Owner: -
--

CREATE INDEX idx_cmm_ventrealization_action_id ON public.cmmsmachineparts_plannedeventrealization USING btree (action_id);


--
-- Name: idx_cmm_ventstatechange_maintenanceevent_id; Type: INDEX; Schema: public; Owner: -
--

CREATE INDEX idx_cmm_ventstatechange_maintenanceevent_id ON public.cmmsmachineparts_maintenanceeventstatechange USING btree (maintenanceevent_id);


--
-- Name: idx_cos_erproductincomp_order_id; Type: INDEX; Schema: public; Owner: -
--

CREATE INDEX idx_cos_erproductincomp_order_id ON public.costnormsformaterials_technologyinstoperproductincomp USING btree (order_id);


--
-- Name: idx_cos_erproductincomp_product_id; Type: INDEX; Schema: public; Owner: -
--

CREATE INDEX idx_cos_erproductincomp_product_id ON public.costnormsformaterials_technologyinstoperproductincomp USING btree (product_id);


--
-- Name: idx_cos_rationcomponent_parent_id; Type: INDEX; Schema: public; Owner: -
--

CREATE INDEX idx_cos_rationcomponent_parent_id ON public.costnormsforoperation_calculationoperationcomponent USING btree (parent_id);


--
-- Name: idx_cos_rationcomponent_technologyoperationcomponent_id; Type: INDEX; Schema: public; Owner: -
--

CREATE INDEX idx_cos_rationcomponent_technologyoperationcomponent_id ON public.costnormsforoperation_calculationoperationcomponent USING btree (technologyoperationcomponent_id);


--
-- Name: idx_del_delivery_relateddelivery_id; Type: INDEX; Schema: public; Owner: -
--

CREATE INDEX idx_del_delivery_relateddelivery_id ON public.deliveries_delivery USING btree (relateddelivery_id);


--
-- Name: idx_del_eliveredproduct_delivery_id; Type: INDEX; Schema: public; Owner: -
--

CREATE INDEX idx_del_eliveredproduct_delivery_id ON public.deliveries_deliveredproduct USING btree (delivery_id);


--
-- Name: idx_del_eliveredproduct_palletnumber_id; Type: INDEX; Schema: public; Owner: -
--

CREATE INDEX idx_del_eliveredproduct_palletnumber_id ON public.deliveries_deliveredproduct USING btree (palletnumber_id);


--
-- Name: idx_del_eliveredproduct_product_id; Type: INDEX; Schema: public; Owner: -
--

CREATE INDEX idx_del_eliveredproduct_product_id ON public.deliveries_deliveredproduct USING btree (product_id);


--
-- Name: idx_del_orderedproduct_delivery_id; Type: INDEX; Schema: public; Owner: -
--

CREATE INDEX idx_del_orderedproduct_delivery_id ON public.deliveries_orderedproduct USING btree (delivery_id);


--
-- Name: idx_del_orderedproduct_product_id; Type: INDEX; Schema: public; Owner: -
--

CREATE INDEX idx_del_orderedproduct_product_id ON public.deliveries_orderedproduct USING btree (product_id);


--
-- Name: idx_del_verystatechange_delivery_id; Type: INDEX; Schema: public; Owner: -
--

CREATE INDEX idx_del_verystatechange_delivery_id ON public.deliveries_deliverystatechange USING btree (delivery_id);


--
-- Name: idx_goo_abelstatechange_label_id; Type: INDEX; Schema: public; Owner: -
--

CREATE INDEX idx_goo_abelstatechange_label_id ON public.goodfood_palletlabelstatechange USING btree (palletlabel_id);


--
-- Name: idx_goo_confectionstaff_confectionprotocol_id; Type: INDEX; Schema: public; Owner: -
--

CREATE INDEX idx_goo_confectionstaff_confectionprotocol_id ON public.goodfood_confectionstaff USING btree (confectionprotocol_id);


--
-- Name: idx_goo_derinputproduct_confectionprotocol_id; Type: INDEX; Schema: public; Owner: -
--

CREATE INDEX idx_goo_derinputproduct_confectionprotocol_id ON public.goodfood_confectionremainderinputproduct USING btree (confectionprotocol_id);


--
-- Name: idx_goo_fectionprotocol_confectioncontext_id; Type: INDEX; Schema: public; Owner: -
--

CREATE INDEX idx_goo_fectionprotocol_confectioncontext_id ON public.goodfood_confectionprotocol USING btree (confectioncontext_id);


--
-- Name: idx_goo_fectionprotocol_order_id; Type: INDEX; Schema: public; Owner: -
--

CREATE INDEX idx_goo_fectionprotocol_order_id ON public.goodfood_confectionprotocol USING btree (order_id);


--
-- Name: idx_goo_ioninputproduct_batch_id; Type: INDEX; Schema: public; Owner: -
--

CREATE INDEX idx_goo_ioninputproduct_batch_id ON public.goodfood_confectioninputproduct USING btree (batch_id);


--
-- Name: idx_goo_ioninputproduct_confectionprotocol_id; Type: INDEX; Schema: public; Owner: -
--

CREATE INDEX idx_goo_ioninputproduct_confectionprotocol_id ON public.goodfood_confectioninputproduct USING btree (confectionprotocol_id);


--
-- Name: idx_goo_label_batch_id; Type: INDEX; Schema: public; Owner: -
--

CREATE INDEX idx_goo_label_batch_id ON public.goodfood_palletlabel USING btree (batch_id);


--
-- Name: idx_goo_label_masterorder_id; Type: INDEX; Schema: public; Owner: -
--

CREATE INDEX idx_goo_label_masterorder_id ON public.goodfood_palletlabel USING btree (masterorder_id);


--
-- Name: idx_goo_label_palletcontext_id; Type: INDEX; Schema: public; Owner: -
--

CREATE INDEX idx_goo_label_palletcontext_id ON public.goodfood_palletlabel USING btree (palletcontext_id);


--
-- Name: idx_goo_lletstatechange_pallet_id; Type: INDEX; Schema: public; Owner: -
--

CREATE INDEX idx_goo_lletstatechange_pallet_id ON public.goodfood_palletstatechange USING btree (pallet_id);


--
-- Name: idx_goo_ocolstatechange_confectionprotocol_id; Type: INDEX; Schema: public; Owner: -
--

CREATE INDEX idx_goo_ocolstatechange_confectionprotocol_id ON public.goodfood_confectionprotocolstatechange USING btree (confectionprotocol_id);


--
-- Name: idx_goo_ocolstatechange_extrusionprotocol_id; Type: INDEX; Schema: public; Owner: -
--

CREATE INDEX idx_goo_ocolstatechange_extrusionprotocol_id ON public.goodfood_extrusionprotocolstatechange USING btree (extrusionprotocol_id);


--
-- Name: idx_goo_pallet_label_id; Type: INDEX; Schema: public; Owner: -
--

CREATE INDEX idx_goo_pallet_label_id ON public.goodfood_pallet USING btree (palletlabel_id);


--
-- Name: idx_goo_pallet_palletcontext_id; Type: INDEX; Schema: public; Owner: -
--

CREATE INDEX idx_goo_pallet_palletcontext_id ON public.goodfood_pallet USING btree (palletcontext_id);


--
-- Name: idx_goo_pallet_secondpallet_id; Type: INDEX; Schema: public; Owner: -
--

CREATE INDEX idx_goo_pallet_secondpallet_id ON public.goodfood_pallet USING btree (secondpallet_id);


--
-- Name: idx_goo_printedlabel_masterorder_id; Type: INDEX; Schema: public; Owner: -
--

CREATE INDEX idx_goo_printedlabel_masterorder_id ON public.goodfood_printedlabel USING btree (masterorder_id);


--
-- Name: idx_goo_printedlabel_palletcontext_id; Type: INDEX; Schema: public; Owner: -
--

CREATE INDEX idx_goo_printedlabel_palletcontext_id ON public.goodfood_printedlabel USING btree (palletcontext_id);


--
-- Name: idx_goo_trusionprotocol_extrusioncontext_id; Type: INDEX; Schema: public; Owner: -
--

CREATE INDEX idx_goo_trusionprotocol_extrusioncontext_id ON public.goodfood_extrusionprotocol USING btree (extrusioncontext_id);


--
-- Name: idx_goo_trusionprotocol_order_id; Type: INDEX; Schema: public; Owner: -
--

CREATE INDEX idx_goo_trusionprotocol_order_id ON public.goodfood_extrusionprotocol USING btree (order_id);


--
-- Name: idx_goo_uringingredient_batch_id; Type: INDEX; Schema: public; Owner: -
--

CREATE INDEX idx_goo_uringingredient_batch_id ON public.goodfood_extrusionpouringingredient USING btree (batch_id);


--
-- Name: idx_goo_uringingredient_extrusionpouring_id; Type: INDEX; Schema: public; Owner: -
--

CREATE INDEX idx_goo_uringingredient_extrusionpouring_id ON public.goodfood_extrusionpouringingredient USING btree (extrusionpouring_id);


--
-- Name: idx_goo_xtrusionpouring_extrusionprotocol_id; Type: INDEX; Schema: public; Owner: -
--

CREATE INDEX idx_goo_xtrusionpouring_extrusionprotocol_id ON public.goodfood_extrusionpouring USING btree (extrusionprotocol_id);


--
-- Name: idx_int_intlabelshelper_masterorder_id; Type: INDEX; Schema: public; Owner: -
--

CREATE INDEX idx_int_intlabelshelper_masterorder_id ON public.integrationbartender_printlabelshelper USING btree (masterorder_id);


--
-- Name: idx_int_sendtoprint_printlabelshelper_id; Type: INDEX; Schema: public; Owner: -
--

CREATE INDEX idx_int_sendtoprint_printlabelshelper_id ON public.integrationbartender_sendtoprint USING btree (printlabelshelper_id);


--
-- Name: idx_lcn_linechangeovernorms_fromtechnology_id; Type: INDEX; Schema: public; Owner: -
--

CREATE INDEX idx_lcn_linechangeovernorms_fromtechnology_id ON public.linechangeovernorms_linechangeovernorms USING btree (fromtechnology_id);


--
-- Name: idx_lcn_linechangeovernorms_fromtechnologygroup_id; Type: INDEX; Schema: public; Owner: -
--

CREATE INDEX idx_lcn_linechangeovernorms_fromtechnologygroup_id ON public.linechangeovernorms_linechangeovernorms USING btree (fromtechnologygroup_id);


--
-- Name: idx_lcn_linechangeovernorms_productionline_id; Type: INDEX; Schema: public; Owner: -
--

CREATE INDEX idx_lcn_linechangeovernorms_productionline_id ON public.linechangeovernorms_linechangeovernorms USING btree (productionline_id);


--
-- Name: idx_lcn_linechangeovernorms_totechnology_id; Type: INDEX; Schema: public; Owner: -
--

CREATE INDEX idx_lcn_linechangeovernorms_totechnology_id ON public.linechangeovernorms_linechangeovernorms USING btree (totechnology_id);


--
-- Name: idx_lcn_linechangeovernorms_totechnologygroup_id; Type: INDEX; Schema: public; Owner: -
--

CREATE INDEX idx_lcn_linechangeovernorms_totechnologygroup_id ON public.linechangeovernorms_linechangeovernorms USING btree (totechnologygroup_id);


--
-- Name: idx_mas_masterorder_batch_id; Type: INDEX; Schema: public; Owner: -
--

CREATE INDEX idx_mas_masterorder_batch_id ON public.masterorders_masterorder USING btree (batch_id);


--
-- Name: idx_mas_terorderproduct_masterorder_id; Type: INDEX; Schema: public; Owner: -
--

CREATE INDEX idx_mas_terorderproduct_masterorder_id ON public.masterorders_masterorderproduct USING btree (masterorder_id);


--
-- Name: idx_mas_terorderproduct_product_id; Type: INDEX; Schema: public; Owner: -
--

CREATE INDEX idx_mas_terorderproduct_product_id ON public.masterorders_masterorderproduct USING btree (product_id);


--
-- Name: idx_mas_terorderproduct_technology_id; Type: INDEX; Schema: public; Owner: -
--

CREATE INDEX idx_mas_terorderproduct_technology_id ON public.masterorders_masterorderproduct USING btree (technology_id);


--
-- Name: idx_mat_coverageproduct_order_id; Type: INDEX; Schema: public; Owner: -
--

CREATE INDEX idx_mat_coverageproduct_order_id ON public.materialrequirementcoveragefororder_coverageproduct USING btree (order_id);


--
-- Name: idx_mat_coverageproduct_product_id; Type: INDEX; Schema: public; Owner: -
--

CREATE INDEX idx_mat_coverageproduct_product_id ON public.materialrequirementcoveragefororder_coverageproduct USING btree (product_id);


--
-- Name: idx_mat_document_delivery_id; Type: INDEX; Schema: public; Owner: -
--

CREATE INDEX idx_mat_document_delivery_id ON public.materialflowresources_document USING btree (delivery_id);


--
-- Name: idx_mat_document_order_id; Type: INDEX; Schema: public; Owner: -
--

CREATE INDEX idx_mat_document_order_id ON public.materialflowresources_document USING btree (order_id);


--
-- Name: idx_mat_eproductlogging_coverageproduct_id; Type: INDEX; Schema: public; Owner: -
--

CREATE INDEX idx_mat_eproductlogging_coverageproduct_id ON public.materialrequirementcoveragefororder_coverageproductlogging USING btree (coverageproduct_id);


--
-- Name: idx_mat_eproductlogging_delivery_id; Type: INDEX; Schema: public; Owner: -
--

CREATE INDEX idx_mat_eproductlogging_delivery_id ON public.materialrequirementcoveragefororder_coverageproductlogging USING btree (delivery_id);


--
-- Name: idx_mat_eproductlogging_order_id; Type: INDEX; Schema: public; Owner: -
--

CREATE INDEX idx_mat_eproductlogging_order_id ON public.materialrequirementcoveragefororder_coverageproductlogging USING btree (order_id);


--
-- Name: idx_mat_ourcecorrection_newpalletnumber_id; Type: INDEX; Schema: public; Owner: -
--

CREATE INDEX idx_mat_ourcecorrection_newpalletnumber_id ON public.materialflowresources_resourcecorrection USING btree (newpalletnumber_id);


--
-- Name: idx_mat_ourcecorrection_oldpalletnumber_id; Type: INDEX; Schema: public; Owner: -
--

CREATE INDEX idx_mat_ourcecorrection_oldpalletnumber_id ON public.materialflowresources_resourcecorrection USING btree (oldpalletnumber_id);


--
-- Name: idx_mat_ourcecorrection_product_id; Type: INDEX; Schema: public; Owner: -
--

CREATE INDEX idx_mat_ourcecorrection_product_id ON public.materialflowresources_resourcecorrection USING btree (product_id);


--
-- Name: idx_mat_ourcecorrection_resource_id; Type: INDEX; Schema: public; Owner: -
--

CREATE INDEX idx_mat_ourcecorrection_resource_id ON public.materialflowresources_resourcecorrection USING btree (resource_id);


--
-- Name: idx_mat_position_document_id; Type: INDEX; Schema: public; Owner: -
--

CREATE INDEX idx_mat_position_document_id ON public.materialflowresources_position USING btree (document_id);


--
-- Name: idx_mat_position_palletnumber_id; Type: INDEX; Schema: public; Owner: -
--

CREATE INDEX idx_mat_position_palletnumber_id ON public.materialflowresources_position USING btree (palletnumber_id);


--
-- Name: idx_mat_position_product_id; Type: INDEX; Schema: public; Owner: -
--

CREATE INDEX idx_mat_position_product_id ON public.materialflowresources_position USING btree (product_id);


--
-- Name: idx_mat_position_resource_id; Type: INDEX; Schema: public; Owner: -
--

CREATE INDEX idx_mat_position_resource_id ON public.materialflowresources_position USING btree (resource_id);


--
-- Name: idx_mat_resource_palletnumber_id; Type: INDEX; Schema: public; Owner: -
--

CREATE INDEX idx_mat_resource_palletnumber_id ON public.materialflowresources_resource USING btree (palletnumber_id);


--
-- Name: idx_mat_resource_product_id; Type: INDEX; Schema: public; Owner: -
--

CREATE INDEX idx_mat_resource_product_id ON public.materialflowresources_resource USING btree (product_id);


--
-- Name: idx_mat_resourcestock_product_id; Type: INDEX; Schema: public; Owner: -
--

CREATE INDEX idx_mat_resourcestock_product_id ON public.materialflowresources_resourcestock USING btree (product_id);


--
-- Name: idx_ord_coverageproduct_product_id; Type: INDEX; Schema: public; Owner: -
--

CREATE INDEX idx_ord_coverageproduct_product_id ON public.ordersupplies_coverageproduct USING btree (product_id);


--
-- Name: idx_ord_eproductlogging_delivery_id; Type: INDEX; Schema: public; Owner: -
--

CREATE INDEX idx_ord_eproductlogging_delivery_id ON public.ordersupplies_coverageproductlogging USING btree (delivery_id);


--
-- Name: idx_ord_eproductlogging_order_id; Type: INDEX; Schema: public; Owner: -
--

CREATE INDEX idx_ord_eproductlogging_order_id ON public.ordersupplies_coverageproductlogging USING btree (order_id);


--
-- Name: idx_ord_order_masterorder_id; Type: INDEX; Schema: public; Owner: -
--

CREATE INDEX idx_ord_order_masterorder_id ON public.orders_order USING btree (masterorder_id);


--
-- Name: idx_ord_order_masterorderproductcomponent_id; Type: INDEX; Schema: public; Owner: -
--

CREATE INDEX idx_ord_order_masterorderproductcomponent_id ON public.orders_order USING btree (masterorderproductcomponent_id);


--
-- Name: idx_ord_order_number; Type: INDEX; Schema: public; Owner: -
--

CREATE INDEX idx_ord_order_number ON public.orders_order USING btree (number);


--
-- Name: idx_ord_order_ordersgroup_id; Type: INDEX; Schema: public; Owner: -
--

CREATE INDEX idx_ord_order_ordersgroup_id ON public.orders_order USING btree (ordersgroup_id);


--
-- Name: idx_ord_order_parent_id; Type: INDEX; Schema: public; Owner: -
--

CREATE INDEX idx_ord_order_parent_id ON public.orders_order USING btree (parent_id);


--
-- Name: idx_ord_order_product_id; Type: INDEX; Schema: public; Owner: -
--

CREATE INDEX idx_ord_order_product_id ON public.orders_order USING btree (product_id);


--
-- Name: idx_ord_order_productionline_id; Type: INDEX; Schema: public; Owner: -
--

CREATE INDEX idx_ord_order_productionline_id ON public.orders_order USING btree (productionline_id);


--
-- Name: idx_ord_order_root_id; Type: INDEX; Schema: public; Owner: -
--

CREATE INDEX idx_ord_order_root_id ON public.orders_order USING btree (root_id);


--
-- Name: idx_ord_order_state; Type: INDEX; Schema: public; Owner: -
--

CREATE INDEX idx_ord_order_state ON public.orders_order USING btree (state);


--
-- Name: idx_ord_order_technology_id; Type: INDEX; Schema: public; Owner: -
--

CREATE INDEX idx_ord_order_technology_id ON public.orders_order USING btree (technology_id);


--
-- Name: idx_ord_order_technologyprototype_id; Type: INDEX; Schema: public; Owner: -
--

CREATE INDEX idx_ord_order_technologyprototype_id ON public.orders_order USING btree (technologyprototype_id);


--
-- Name: idx_ord_ordersgroup_assortment_id; Type: INDEX; Schema: public; Owner: -
--

CREATE INDEX idx_ord_ordersgroup_assortment_id ON public.ordersgroups_ordersgroup USING btree (assortment_id);


--
-- Name: idx_ord_ordersgroup_masterorder_id; Type: INDEX; Schema: public; Owner: -
--

CREATE INDEX idx_ord_ordersgroup_masterorder_id ON public.ordersgroups_ordersgroup USING btree (masterorder_id);


--
-- Name: idx_ord_ordersgroup_number; Type: INDEX; Schema: public; Owner: -
--

CREATE INDEX idx_ord_ordersgroup_number ON public.ordersgroups_ordersgroup USING btree (number);


--
-- Name: idx_ord_ordersgroup_parent_id; Type: INDEX; Schema: public; Owner: -
--

CREATE INDEX idx_ord_ordersgroup_parent_id ON public.ordersgroups_ordersgroup USING btree (parent_id);


--
-- Name: idx_ord_rderstatechange_order_id; Type: INDEX; Schema: public; Owner: -
--

CREATE INDEX idx_ord_rderstatechange_order_id ON public.orders_orderstatechange USING btree (order_id);


--
-- Name: idx_ord_suborders_ordersgroup_id; Type: INDEX; Schema: public; Owner: -
--

CREATE INDEX idx_ord_suborders_ordersgroup_id ON public.ordersforsubproductsgeneration_suborders USING btree (ordersgroup_id);


--
-- Name: idx_pro_dailyprogress_progressforday_id; Type: INDEX; Schema: public; Owner: -
--

CREATE INDEX idx_pro_dailyprogress_progressforday_id ON public.productionpershift_dailyprogress USING btree (progressforday_id);


--
-- Name: idx_pro_ductincomponent_product_id; Type: INDEX; Schema: public; Owner: -
--

CREATE INDEX idx_pro_ductincomponent_product_id ON public.productioncounting_trackingoperationproductincomponent USING btree (product_id);


--
-- Name: idx_pro_ductincomponent_productiontracking_id; Type: INDEX; Schema: public; Owner: -
--

CREATE INDEX idx_pro_ductincomponent_productiontracking_id ON public.productioncounting_trackingoperationproductincomponent USING btree (productiontracking_id);


--
-- Name: idx_pro_ductionpershift_order_id; Type: INDEX; Schema: public; Owner: -
--

CREATE INDEX idx_pro_ductionpershift_order_id ON public.productionpershift_productionpershift USING btree (order_id);


--
-- Name: idx_pro_ductiontracking_correction_id; Type: INDEX; Schema: public; Owner: -
--

CREATE INDEX idx_pro_ductiontracking_correction_id ON public.productioncounting_productiontracking USING btree (correction_id);


--
-- Name: idx_pro_ductiontracking_number; Type: INDEX; Schema: public; Owner: -
--

CREATE INDEX idx_pro_ductiontracking_number ON public.productioncounting_productiontracking USING btree (number);


--
-- Name: idx_pro_ductiontracking_order_id; Type: INDEX; Schema: public; Owner: -
--

CREATE INDEX idx_pro_ductiontracking_order_id ON public.productioncounting_productiontracking USING btree (order_id);


--
-- Name: idx_pro_ductiontracking_state; Type: INDEX; Schema: public; Owner: -
--

CREATE INDEX idx_pro_ductiontracking_state ON public.productioncounting_productiontracking USING btree (state);


--
-- Name: idx_pro_ductiontracking_technologyoperationcomponent_id; Type: INDEX; Schema: public; Owner: -
--

CREATE INDEX idx_pro_ductiontracking_technologyoperationcomponent_id ON public.productioncounting_productiontracking USING btree (technologyoperationcomponent_id);


--
-- Name: idx_pro_ialavailability_order_id; Type: INDEX; Schema: public; Owner: -
--

CREATE INDEX idx_pro_ialavailability_order_id ON public.productflowthrudivision_materialavailability USING btree (order_id);


--
-- Name: idx_pro_ialavailability_product_id; Type: INDEX; Schema: public; Owner: -
--

CREATE INDEX idx_pro_ialavailability_product_id ON public.productflowthrudivision_materialavailability USING btree (product_id);


--
-- Name: idx_pro_issue_document_id; Type: INDEX; Schema: public; Owner: -
--

CREATE INDEX idx_pro_issue_document_id ON public.productflowthrudivision_issue USING btree (document_id);


--
-- Name: idx_pro_issue_product_id; Type: INDEX; Schema: public; Owner: -
--

CREATE INDEX idx_pro_issue_product_id ON public.productflowthrudivision_issue USING btree (product_id);


--
-- Name: idx_pro_issue_productincomponent_id; Type: INDEX; Schema: public; Owner: -
--

CREATE INDEX idx_pro_issue_productincomponent_id ON public.productflowthrudivision_issue USING btree (productincomponent_id);


--
-- Name: idx_pro_kingstatechange_productiontracking_id; Type: INDEX; Schema: public; Owner: -
--

CREATE INDEX idx_pro_kingstatechange_productiontracking_id ON public.productioncounting_productiontrackingstatechange USING btree (productiontracking_id);


--
-- Name: idx_pro_productstoissue_product_id; Type: INDEX; Schema: public; Owner: -
--

CREATE INDEX idx_pro_productstoissue_product_id ON public.productflowthrudivision_productstoissue USING btree (product_id);


--
-- Name: idx_pro_productstoissue_productincomponent_id; Type: INDEX; Schema: public; Owner: -
--

CREATE INDEX idx_pro_productstoissue_productincomponent_id ON public.productflowthrudivision_productstoissue USING btree (productincomponent_id);


--
-- Name: idx_pro_progressforday_productionpershift_id; Type: INDEX; Schema: public; Owner: -
--

CREATE INDEX idx_pro_progressforday_productionpershift_id ON public.productionpershift_progressforday USING btree (productionpershift_id);


--
-- Name: idx_pro_staffworktime_productionrecord_id; Type: INDEX; Schema: public; Owner: -
--

CREATE INDEX idx_pro_staffworktime_productionrecord_id ON public.productioncounting_staffworktime USING btree (productionrecord_id);


--
-- Name: idx_pro_timecalculation_technologyoperationcomponent_id; Type: INDEX; Schema: public; Owner: -
--

CREATE INDEX idx_pro_timecalculation_technologyoperationcomponent_id ON public.productionscheduling_opercomptimecalculation USING btree (technologyoperationcomponent_id);


--
-- Name: idx_pro_uctoutcomponent_batch_id; Type: INDEX; Schema: public; Owner: -
--

CREATE INDEX idx_pro_uctoutcomponent_batch_id ON public.productioncounting_trackingoperationproductoutcomponent USING btree (batch_id);


--
-- Name: idx_pro_uctoutcomponent_product_id; Type: INDEX; Schema: public; Owner: -
--

CREATE INDEX idx_pro_uctoutcomponent_product_id ON public.productioncounting_trackingoperationproductoutcomponent USING btree (product_id);


--
-- Name: idx_pro_uctoutcomponent_productiontracking_id; Type: INDEX; Schema: public; Owner: -
--

CREATE INDEX idx_pro_uctoutcomponent_productiontracking_id ON public.productioncounting_trackingoperationproductoutcomponent USING btree (productiontracking_id);


--
-- Name: idx_qca_tconversionitem_product_id; Type: INDEX; Schema: public; Owner: -
--

CREATE INDEX idx_qca_tconversionitem_product_id ON public.qcadoomodel_unitconversionitem USING btree (product_id);


--
-- Name: idx_sup_offerproduct_product_id; Type: INDEX; Schema: public; Owner: -
--

CREATE INDEX idx_sup_offerproduct_product_id ON public.supplynegotiations_offerproduct USING btree (product_id);


--
-- Name: idx_sup_otiationproduct_product_id; Type: INDEX; Schema: public; Owner: -
--

CREATE INDEX idx_sup_otiationproduct_product_id ON public.supplynegotiations_negotiationproduct USING btree (product_id);


--
-- Name: idx_sup_tionstatechange_requestforquotation_id; Type: INDEX; Schema: public; Owner: -
--

CREATE INDEX idx_sup_tionstatechange_requestforquotation_id ON public.supplynegotiations_requestforquotationstatechange USING btree (requestforquotation_id);


--
-- Name: idx_sup_uotationproduct_product_id; Type: INDEX; Schema: public; Owner: -
--

CREATE INDEX idx_sup_uotationproduct_product_id ON public.supplynegotiations_requestforquotationproduct USING btree (product_id);


--
-- Name: idx_sup_uotationproduct_requestforquotation_id; Type: INDEX; Schema: public; Owner: -
--

CREATE INDEX idx_sup_uotationproduct_requestforquotation_id ON public.supplynegotiations_requestforquotationproduct USING btree (requestforquotation_id);


--
-- Name: idx_tec_ductincomponent_operationcomponent_id; Type: INDEX; Schema: public; Owner: -
--

CREATE INDEX idx_tec_ductincomponent_operationcomponent_id ON public.technologies_operationproductincomponent USING btree (operationcomponent_id);


--
-- Name: idx_tec_ductincomponent_product_id; Type: INDEX; Schema: public; Owner: -
--

CREATE INDEX idx_tec_ductincomponent_product_id ON public.technologies_operationproductincomponent USING btree (product_id);


--
-- Name: idx_tec_logystatechange_technology_id; Type: INDEX; Schema: public; Owner: -
--

CREATE INDEX idx_tec_logystatechange_technology_id ON public.technologies_technologystatechange USING btree (technology_id);


--
-- Name: idx_tec_rationcomponent_operationcomponent_id; Type: INDEX; Schema: public; Owner: -
--

CREATE INDEX idx_tec_rationcomponent_operationcomponent_id ON public.technologies_barcodeoperationcomponent USING btree (operationcomponent_id);


--
-- Name: idx_tec_rationcomponent_order_id; Type: INDEX; Schema: public; Owner: -
--

CREATE INDEX idx_tec_rationcomponent_order_id ON public.technologies_barcodeoperationcomponent USING btree (order_id);


--
-- Name: idx_tec_rationcomponent_parent_id; Type: INDEX; Schema: public; Owner: -
--

CREATE INDEX idx_tec_rationcomponent_parent_id ON public.technologies_technologyoperationcomponent USING btree (parent_id);


--
-- Name: idx_tec_rationcomponent_technology_id; Type: INDEX; Schema: public; Owner: -
--

CREATE INDEX idx_tec_rationcomponent_technology_id ON public.technologies_technologyoperationcomponent USING btree (technology_id);


--
-- Name: idx_tec_rationcomponent_techopercomptimecalculation_id; Type: INDEX; Schema: public; Owner: -
--

CREATE INDEX idx_tec_rationcomponent_techopercomptimecalculation_id ON public.technologies_technologyoperationcomponent USING btree (techopercomptimecalculation_id);


--
-- Name: idx_tec_ructuretreenode_maintechnology_id; Type: INDEX; Schema: public; Owner: -
--

CREATE INDEX idx_tec_ructuretreenode_maintechnology_id ON public.technologies_productstructuretreenode USING btree (maintechnology_id);


--
-- Name: idx_tec_ructuretreenode_operation_id; Type: INDEX; Schema: public; Owner: -
--

CREATE INDEX idx_tec_ructuretreenode_operation_id ON public.technologies_productstructuretreenode USING btree (operation_id);


--
-- Name: idx_tec_ructuretreenode_parent_id; Type: INDEX; Schema: public; Owner: -
--

CREATE INDEX idx_tec_ructuretreenode_parent_id ON public.technologies_productstructuretreenode USING btree (parent_id);


--
-- Name: idx_tec_ructuretreenode_product_id; Type: INDEX; Schema: public; Owner: -
--

CREATE INDEX idx_tec_ructuretreenode_product_id ON public.technologies_productstructuretreenode USING btree (product_id);


--
-- Name: idx_tec_ructuretreenode_technology_id; Type: INDEX; Schema: public; Owner: -
--

CREATE INDEX idx_tec_ructuretreenode_technology_id ON public.technologies_productstructuretreenode USING btree (technology_id);


--
-- Name: idx_tec_technology_product_id; Type: INDEX; Schema: public; Owner: -
--

CREATE INDEX idx_tec_technology_product_id ON public.technologies_technology USING btree (product_id);


--
-- Name: idx_tec_technology_technologyprototype_id; Type: INDEX; Schema: public; Owner: -
--

CREATE INDEX idx_tec_technology_technologyprototype_id ON public.technologies_technology USING btree (technologyprototype_id);


--
-- Name: idx_tec_uctoutcomponent_operationcomponent_id; Type: INDEX; Schema: public; Owner: -
--

CREATE INDEX idx_tec_uctoutcomponent_operationcomponent_id ON public.technologies_operationproductoutcomponent USING btree (operationcomponent_id);


--
-- Name: idx_tec_uctoutcomponent_product_id; Type: INDEX; Schema: public; Owner: -
--

CREATE INDEX idx_tec_uctoutcomponent_product_id ON public.technologies_operationproductoutcomponent USING btree (product_id);


--
-- Name: idx_wor_planordercolumn_workplan_id; Type: INDEX; Schema: public; Owner: -
--

CREATE INDEX idx_wor_planordercolumn_workplan_id ON public.workplans_workplanordercolumn USING btree (workplan_id);


--
-- Name: advancedgenealogy_batchdto _RETURN; Type: RULE; Schema: public; Owner: -
--

CREATE OR REPLACE VIEW public.advancedgenealogy_batchdto AS
 SELECT batch.id,
    batch.number AS batchnumber,
    batch.state,
    batch.createuser,
    batch.createdate,
    batch.externalnumber,
    batch.active,
    product.number AS productnumber,
    product.name AS productname,
    company.name AS suppliername,
    (count(attachment.id) <> 0) AS hasattachments
   FROM (((public.advancedgenealogy_batch batch
     LEFT JOIN public.advancedgenealogy_batchattachment attachment ON ((batch.id = attachment.batch_id)))
     LEFT JOIN public.basic_product product ON ((batch.product_id = product.id)))
     LEFT JOIN public.basic_company company ON ((batch.supplier_id = company.id)))
  GROUP BY batch.id, product.number, product.name, company.name;


--
-- Name: arch_masterorders_masterorderposition_manyproducts _RETURN; Type: RULE; Schema: public; Owner: -
--

CREATE OR REPLACE VIEW public.arch_masterorders_masterorderposition_manyproducts AS
 SELECT masterorderproduct.id,
    masterorderdefinition.number AS masterorderdefinitionnumber,
    (masterorder.id)::integer AS masterorderid,
    (masterorderproduct.product_id)::integer AS productid,
    (masterorderproduct.id)::integer AS masterorderproductid,
    masterorder.name,
    masterorder.number,
    masterorder.deadline,
    masterorder.masterorderstate AS masterorderstatus,
    masterorderproduct.masterorderpositionstatus,
    COALESCE(masterorderproduct.masterorderquantity, (0)::numeric) AS masterorderquantity,
    COALESCE(( SELECT sum(orders.plannedquantity) AS sum), (0)::numeric) AS cumulatedmasterorderquantity,
    COALESCE(( SELECT sum(orders.donequantity) AS sum), (0)::numeric) AS producedorderquantity,
        CASE
            WHEN ((COALESCE(masterorderproduct.masterorderquantity, (0)::numeric) - COALESCE(( SELECT sum(orders.donequantity) AS sum), (0)::numeric)) > (0)::numeric) THEN (COALESCE(masterorderproduct.masterorderquantity, (0)::numeric) - COALESCE(( SELECT sum(orders.donequantity) AS sum), (0)::numeric))
            ELSE (0)::numeric
        END AS lefttorelease,
    masterorderproduct.comments,
    _product.number AS productnumber,
    _product.name AS productname,
    _product.unit,
    technology.number AS technologyname,
    company.name AS companyname,
    masterorder.active,
    companypayer.name AS companypayer,
    assortment.name AS assortmentname,
    masterorder.state,
    masterorder.description
   FROM ((((((((public.arch_masterorders_masterorderproduct masterorderproduct
     LEFT JOIN public.arch_masterorders_masterorder masterorder ON ((masterorderproduct.masterorder_id = masterorder.id)))
     LEFT JOIN public.masterorders_masterorderdefinition masterorderdefinition ON ((masterorderdefinition.id = masterorder.masterorderdefinition_id)))
     LEFT JOIN public.basic_product _product ON ((_product.id = masterorderproduct.product_id)))
     LEFT JOIN public.basic_company company ON ((company.id = masterorder.company_id)))
     LEFT JOIN public.technologies_technology technology ON ((technology.id = masterorderproduct.technology_id)))
     LEFT JOIN public.arch_orders_order orders ON (((orders.masterorder_id = masterorderproduct.masterorder_id) AND (orders.product_id = masterorderproduct.product_id))))
     LEFT JOIN public.basic_company companypayer ON ((companypayer.id = masterorder.companypayer_id)))
     LEFT JOIN public.basic_assortment assortment ON ((assortment.id = _product.assortment_id)))
  GROUP BY masterorderdefinition.number, masterorder.id, masterorderproduct.product_id, masterorderproduct.id, masterorder.name, masterorder.deadline, masterorder.masterorderstate, masterorderproduct.masterorderpositionstatus, masterorderproduct.comments, _product.number, _product.name, _product.unit, technology.number, company.name, masterorder.active, companypayer.name, assortment.name;


--
-- Name: arch_ordersgroups_drafrptquantitydto _RETURN; Type: RULE; Schema: public; Owner: -
--

CREATE OR REPLACE VIEW public.arch_ordersgroups_drafrptquantitydto AS
 SELECT DISTINCT ordersgroup.id,
    ordersgroup.number,
    COALESCE(sum(topoc.usedquantity), (0)::numeric) AS sum
   FROM ((((public.arch_productioncounting_trackingoperationproductoutcomponent topoc
     JOIN public.arch_productioncounting_productiontracking pt ON ((pt.id = topoc.productiontracking_id)))
     JOIN public.arch_orders_order ord ON ((ord.id = pt.order_id)))
     JOIN public.arch_ordersgroups_ordersgroup ordersgroup ON ((ord.ordersgroup_id = ordersgroup.id)))
     JOIN public.basic_product product ON ((topoc.product_id = product.id)))
  WHERE ((pt.state)::text = '01draft'::text)
  GROUP BY ordersgroup.id;


--
-- Name: basic_productdto _RETURN; Type: RULE; Schema: public; Owner: -
--

CREATE OR REPLACE VIEW public.basic_productdto AS
 SELECT product.id,
    product.number,
    product.name,
    product.globaltypeofmaterial,
    product.category,
    parent.name AS parentname,
    product.ean,
    product.externalnumber,
    assortment.name AS assortmentname,
    model.name AS modelname,
    product.norm,
    size.number AS sizenumber,
    (count(attachment.id) <> 0) AS hasattachments,
    product.active,
    product.unit,
    product.additionalunit,
    product.entitytype,
    cmp.number AS supplier,
    product.nominalcost,
    product.lastpurchasecost,
    np.number AS batchnumberpattern,
    product.description
   FROM (((((((public.basic_product product
     LEFT JOIN public.basic_product parent ON ((product.parent_id = parent.id)))
     LEFT JOIN public.basic_assortment assortment ON ((product.assortment_id = assortment.id)))
     LEFT JOIN public.basic_model model ON ((product.model_id = model.id)))
     LEFT JOIN public.basic_productattachment attachment ON ((attachment.product_id = product.id)))
     LEFT JOIN public.basic_size size ON ((size.id = product.size_id)))
     LEFT JOIN public.basic_company cmp ON ((cmp.id = product.supplier_id)))
     LEFT JOIN public.basic_numberpattern np ON ((np.id = product.batchnumberpattern_id)))
  GROUP BY product.id, parent.name, assortment.name, model.name, size.number, cmp.number, np.number, product.description;


--
-- Name: goodfood_extrusionbatchingredientdto _RETURN; Type: RULE; Schema: public; Owner: -
--

CREATE OR REPLACE VIEW public.goodfood_extrusionbatchingredientdto AS
 WITH ingredients AS (
         SELECT e.extrusionprotocol_id,
            i_1.product_id,
            i_1.batch_id,
            i_1.quantity
           FROM (public.goodfood_extrusionaddedmixingredient i_1
             JOIN public.goodfood_extrusionaddedmixentry e ON ((i_1.extrusionaddedmixentry_id = e.id)))
        UNION ALL
         SELECT e.extrusionprotocol_id,
            i_1.product_id,
            i_1.batch_id,
            (- i_1.quantity)
           FROM (public.goodfood_extrusiontakenoffmixingredient i_1
             JOIN public.goodfood_extrusiontakenoffmixentry e ON ((i_1.extrusiontakenoffmixentry_id = e.id)))
        UNION ALL
         SELECT e.extrusionprotocol_id,
            i_1.product_id,
            i_1.batch_id,
            i_1.quantity
           FROM (public.goodfood_extrusionpouringingredient i_1
             JOIN public.goodfood_extrusionpouring e ON ((i_1.extrusionpouring_id = e.id)))
        )
 SELECT row_number() OVER () AS id,
    i.extrusionprotocol_id,
    p.number AS productnumber,
    p.unit,
    b.number AS batchnumber,
    sum(COALESCE(i.quantity, (0)::numeric)) AS quantity
   FROM ((ingredients i
     JOIN public.basic_product p ON ((p.id = i.product_id)))
     LEFT JOIN public.advancedgenealogy_batch b ON ((b.id = i.batch_id)))
  GROUP BY i.extrusionprotocol_id, p.id, b.number, b.product_id;


--
-- Name: goodfood_extrusionusedbatchingredientdto _RETURN; Type: RULE; Schema: public; Owner: -
--

CREATE OR REPLACE VIEW public.goodfood_extrusionusedbatchingredientdto AS
 SELECT row_number() OVER () AS id,
    extrusionpouring.extrusionprotocol_id,
    p.number AS productnumber,
    p.unit,
    b.number AS batchnumber,
    extrusionpouring.priority,
    sum(COALESCE(extrusionpouringingredient.quantity, (0)::numeric)) AS quantity
   FROM (((public.goodfood_extrusionpouringingredient extrusionpouringingredient
     JOIN public.goodfood_extrusionpouring extrusionpouring ON ((extrusionpouringingredient.extrusionpouring_id = extrusionpouring.id)))
     JOIN public.basic_product p ON ((p.id = extrusionpouringingredient.product_id)))
     LEFT JOIN public.advancedgenealogy_batch b ON ((b.id = extrusionpouringingredient.batch_id)))
  GROUP BY extrusionpouring.extrusionprotocol_id, extrusionpouring.priority, p.id, b.number, b.product_id;


--
-- Name: integrationscales_scaledto _RETURN; Type: RULE; Schema: public; Owner: -
--

CREATE OR REPLACE VIEW public.integrationscales_scaledto AS
 SELECT scale.id,
    scale.name,
    scale.comment,
    scale.type,
    concat_ws(':'::text, scale.ip, scale.port) AS ip,
    string_agg((pl.number)::text, ', '::text) AS productionlines
   FROM ((public.integrationscales_scale scale
     LEFT JOIN public.integrationscales_productionlineforscale ps ON ((ps.scale_id = scale.id)))
     LEFT JOIN public.productionlines_productionline pl ON ((ps.productionline_id = pl.id)))
  GROUP BY scale.id;


--
-- Name: masterorders_masterorderposition_manyproducts _RETURN; Type: RULE; Schema: public; Owner: -
--

CREATE OR REPLACE VIEW public.masterorders_masterorderposition_manyproducts AS
 WITH warehousestatehelper AS (
         SELECT mopwsh.product_id,
            sum(mopwsh.quantity) AS quantity
           FROM public.masterorders_position_warehousestatehelper mopwsh
          GROUP BY mopwsh.product_id
        ), productioncountingquantityoutput AS (
         SELECT ospcqo.productid,
            sum(ospcqo.quantity) AS quantity
           FROM public.ordersupplies_productioncountingquantityoutput ospcqo
          GROUP BY ospcqo.productid
        )
 SELECT masterorderproduct.id,
    masterorderdefinition.number AS masterorderdefinitionnumber,
    (masterorder.id)::integer AS masterorderid,
    (masterorderproduct.product_id)::integer AS productid,
    (masterorderproduct.id)::integer AS masterorderproductid,
    masterorder.name,
    masterorder.number,
    masterorder.deadline,
    masterorder.masterorderstate AS masterorderstatus,
    masterorderproduct.masterorderpositionstatus,
    COALESCE(masterorderproduct.masterorderquantity, (0)::numeric) AS masterorderquantity,
    COALESCE(( SELECT sum(orders.plannedquantity) AS sum), (0)::numeric) AS cumulatedmasterorderquantity,
    COALESCE(( SELECT sum(orders.donequantity) AS sum), (0)::numeric) AS producedorderquantity,
        CASE
            WHEN ((COALESCE(masterorderproduct.masterorderquantity, (0)::numeric) - COALESCE(( SELECT sum(orders.donequantity) AS sum), (0)::numeric)) > (0)::numeric) THEN (COALESCE(masterorderproduct.masterorderquantity, (0)::numeric) - COALESCE(( SELECT sum(orders.donequantity) AS sum), (0)::numeric))
            ELSE (0)::numeric
        END AS lefttorelease,
    masterorderproduct.comments,
    _product.number AS productnumber,
    _product.name AS productname,
    _product.unit,
    technology.number AS technologyname,
    company.name AS companyname,
    masterorder.active,
    companypayer.name AS companypayer,
    assortment.name AS assortmentname,
    masterorder.state,
    masterorder.description,
    masterorderproduct.quantitytakenfromwarehouse,
    GREATEST((((COALESCE(masterorderproduct.masterorderquantity, (0)::numeric) - COALESCE(( SELECT sum(orders.plannedquantity) AS sum), (0)::numeric)) - COALESCE(masterorderproduct.quantitytakenfromwarehouse, (0)::numeric)))::numeric(14,5), (0)::numeric(14,5)) AS quantityremainingtoorder,
    ((COALESCE(masterorderproduct.masterorderquantity, (0)::numeric) - COALESCE(( SELECT sum(orders.plannedquantity) AS sum), (0)::numeric)))::numeric(14,5) AS quantityremainingtoorderwithoutstock,
    model.name AS modelname,
    company.contractorcategory AS companycategory,
    salesplan.number AS salesplannumber,
    salesplan.name AS salesplanname,
    ( SELECT sum(warehouseminimumstate.minimumstate) AS sum
           FROM public.warehouseminimalstate_warehouseminimumstate warehouseminimumstate
          WHERE (warehouseminimumstate.product_id = masterorderproduct.product_id)) AS warehouseminimumstatequantity,
    masterorder.warehouseorder,
    COALESCE(min(wsh.quantity), (0)::numeric) AS warehousestate,
    COALESCE(min(mopdpqh.quantity), (0)::numeric) AS deliveredquantity,
    COALESCE(min(pcqo.quantity), (0)::numeric) AS producequantity,
    masterorderproduct.price
   FROM (((((((((((((public.masterorders_masterorderproduct masterorderproduct
     LEFT JOIN public.masterorders_masterorder masterorder ON ((masterorderproduct.masterorder_id = masterorder.id)))
     LEFT JOIN public.masterorders_masterorderdefinition masterorderdefinition ON ((masterorderdefinition.id = masterorder.masterorderdefinition_id)))
     LEFT JOIN public.basic_product _product ON ((_product.id = masterorderproduct.product_id)))
     LEFT JOIN public.basic_model model ON ((model.id = _product.model_id)))
     LEFT JOIN public.basic_company company ON ((company.id = masterorder.company_id)))
     LEFT JOIN public.technologies_technology technology ON ((technology.id = masterorderproduct.technology_id)))
     LEFT JOIN public.orders_order orders ON (((orders.masterorder_id = masterorderproduct.masterorder_id) AND (orders.product_id = masterorderproduct.product_id) AND (orders.vendorinfo IS NULL))))
     LEFT JOIN public.basic_company companypayer ON ((companypayer.id = masterorder.companypayer_id)))
     LEFT JOIN public.basic_assortment assortment ON ((assortment.id = _product.assortment_id)))
     LEFT JOIN public.masterorders_salesplan salesplan ON ((salesplan.id = masterorder.salesplan_id)))
     LEFT JOIN warehousestatehelper wsh ON ((wsh.product_id = masterorderproduct.product_id)))
     LEFT JOIN public.masterorders_position_deliveryproductquantityhelper mopdpqh ON ((mopdpqh.product_id = masterorderproduct.product_id)))
     LEFT JOIN productioncountingquantityoutput pcqo ON ((pcqo.productid = masterorderproduct.product_id)))
  WHERE (masterorderproduct.vendorinfo IS NULL)
  GROUP BY masterorderdefinition.number, masterorder.id, masterorderproduct.product_id, masterorderproduct.id, masterorder.name, masterorder.deadline, masterorder.masterorderstate, masterorderproduct.masterorderpositionstatus, masterorderproduct.comments, _product.number, _product.name, _product.unit, technology.number, company.name, masterorder.active, companypayer.name, assortment.name, model.name, company.contractorcategory, salesplan.number, salesplan.name, masterorder.warehouseorder
UNION ALL
 SELECT masterorderproduct.id,
    masterorderdefinition.number AS masterorderdefinitionnumber,
    (masterorder.id)::integer AS masterorderid,
    (masterorderproduct.product_id)::integer AS productid,
    (masterorderproduct.id)::integer AS masterorderproductid,
    masterorder.name,
    masterorder.number,
    masterorder.deadline,
    masterorder.masterorderstate AS masterorderstatus,
    masterorderproduct.masterorderpositionstatus,
    COALESCE(masterorderproduct.masterorderquantity, (0)::numeric) AS masterorderquantity,
    COALESCE(( SELECT sum(orders.plannedquantity) AS sum), (0)::numeric) AS cumulatedmasterorderquantity,
    COALESCE(( SELECT sum(orders.donequantity) AS sum), (0)::numeric) AS producedorderquantity,
        CASE
            WHEN ((COALESCE(masterorderproduct.masterorderquantity, (0)::numeric) - COALESCE(( SELECT sum(orders.donequantity) AS sum), (0)::numeric)) > (0)::numeric) THEN (COALESCE(masterorderproduct.masterorderquantity, (0)::numeric) - COALESCE(( SELECT sum(orders.donequantity) AS sum), (0)::numeric))
            ELSE (0)::numeric
        END AS lefttorelease,
    masterorderproduct.comments,
    _product.number AS productnumber,
    _product.name AS productname,
    _product.unit,
    technology.number AS technologyname,
    company.name AS companyname,
    masterorder.active,
    companypayer.name AS companypayer,
    assortment.name AS assortmentname,
    masterorder.state,
    masterorder.description,
    masterorderproduct.quantitytakenfromwarehouse,
    GREATEST((((COALESCE(masterorderproduct.masterorderquantity, (0)::numeric) - COALESCE(( SELECT sum(orders.plannedquantity) AS sum), (0)::numeric)) - COALESCE(masterorderproduct.quantitytakenfromwarehouse, (0)::numeric)))::numeric(14,5), (0)::numeric(14,5)) AS quantityremainingtoorder,
    ((COALESCE(masterorderproduct.masterorderquantity, (0)::numeric) - COALESCE(( SELECT sum(orders.plannedquantity) AS sum), (0)::numeric)))::numeric(14,5) AS quantityremainingtoorderwithoutstock,
    model.name AS modelname,
    company.contractorcategory AS companycategory,
    salesplan.number AS salesplannumber,
    salesplan.name AS salesplanname,
    ( SELECT sum(warehouseminimumstate.minimumstate) AS sum
           FROM public.warehouseminimalstate_warehouseminimumstate warehouseminimumstate
          WHERE (warehouseminimumstate.product_id = masterorderproduct.product_id)) AS warehouseminimumstatequantity,
    masterorder.warehouseorder,
    COALESCE(min(wsh.quantity), (0)::numeric) AS warehousestate,
    COALESCE(min(mopdpqh.quantity), (0)::numeric) AS deliveredquantity,
    COALESCE(min(pcqo.quantity), (0)::numeric) AS producequantity,
    masterorderproduct.price
   FROM (((((((((((((public.masterorders_masterorderproduct masterorderproduct
     LEFT JOIN public.masterorders_masterorder masterorder ON ((masterorderproduct.masterorder_id = masterorder.id)))
     LEFT JOIN public.masterorders_masterorderdefinition masterorderdefinition ON ((masterorderdefinition.id = masterorder.masterorderdefinition_id)))
     LEFT JOIN public.basic_product _product ON ((_product.id = masterorderproduct.product_id)))
     LEFT JOIN public.basic_model model ON ((model.id = _product.model_id)))
     LEFT JOIN public.basic_company company ON ((company.id = masterorder.company_id)))
     LEFT JOIN public.technologies_technology technology ON ((technology.id = masterorderproduct.technology_id)))
     LEFT JOIN public.orders_order orders ON (((orders.masterorder_id = masterorderproduct.masterorder_id) AND (orders.product_id = masterorderproduct.product_id) AND ((orders.vendorinfo)::text = (masterorderproduct.vendorinfo)::text))))
     LEFT JOIN public.basic_company companypayer ON ((companypayer.id = masterorder.companypayer_id)))
     LEFT JOIN public.basic_assortment assortment ON ((assortment.id = _product.assortment_id)))
     LEFT JOIN public.masterorders_salesplan salesplan ON ((salesplan.id = masterorder.salesplan_id)))
     LEFT JOIN warehousestatehelper wsh ON ((wsh.product_id = masterorderproduct.product_id)))
     LEFT JOIN public.masterorders_position_deliveryproductquantityhelper mopdpqh ON ((mopdpqh.product_id = masterorderproduct.product_id)))
     LEFT JOIN productioncountingquantityoutput pcqo ON ((pcqo.productid = masterorderproduct.product_id)))
  WHERE (masterorderproduct.vendorinfo IS NOT NULL)
  GROUP BY masterorderdefinition.number, masterorder.id, masterorderproduct.product_id, masterorderproduct.id, masterorder.name, masterorder.deadline, masterorder.masterorderstate, masterorderproduct.masterorderpositionstatus, masterorderproduct.comments, _product.number, _product.name, _product.unit, technology.number, company.name, masterorder.active, companypayer.name, assortment.name, model.name, company.contractorcategory, salesplan.number, salesplan.name, masterorder.warehouseorder;


--
-- Name: ordersgroups_drafrptquantitydto _RETURN; Type: RULE; Schema: public; Owner: -
--

CREATE OR REPLACE VIEW public.ordersgroups_drafrptquantitydto AS
 SELECT DISTINCT ordersgroup.id,
    ordersgroup.number,
    COALESCE(sum(topoc.usedquantity), (0)::numeric) AS sum
   FROM ((((public.productioncounting_trackingoperationproductoutcomponent topoc
     JOIN public.productioncounting_productiontracking pt ON ((pt.id = topoc.productiontracking_id)))
     JOIN public.orders_order ord ON ((ord.id = pt.order_id)))
     JOIN public.ordersgroups_ordersgroup ordersgroup ON ((ord.ordersgroup_id = ordersgroup.id)))
     JOIN public.basic_product product ON ((topoc.product_id = product.id)))
  WHERE ((pt.state)::text = '01draft'::text)
  GROUP BY ordersgroup.id;


--
-- Name: productioncounting_productionanalysisdto _RETURN; Type: RULE; Schema: public; Owner: -
--

CREATE OR REPLACE VIEW public.productioncounting_productionanalysisdto AS
 SELECT mv_productioncounting_productionanalysisdto.id,
    mv_productioncounting_productionanalysisdto.active,
    mv_productioncounting_productionanalysisdto.productionline_id,
    mv_productioncounting_productionanalysisdto.productionlinenumber,
    mv_productioncounting_productionanalysisdto.company_id,
    mv_productioncounting_productionanalysisdto.companynumber,
    mv_productioncounting_productionanalysisdto.staff_id,
    mv_productioncounting_productionanalysisdto.staffname,
    mv_productioncounting_productionanalysisdto.assortment_id,
    mv_productioncounting_productionanalysisdto.assortmentname,
    mv_productioncounting_productionanalysisdto.product_id,
    mv_productioncounting_productionanalysisdto.productnumber,
    mv_productioncounting_productionanalysisdto.productname,
    mv_productioncounting_productionanalysisdto.productunit,
    mv_productioncounting_productionanalysisdto.sizenumber,
    mv_productioncounting_productionanalysisdto.usedquantity,
    mv_productioncounting_productionanalysisdto.wastesquantity,
    mv_productioncounting_productionanalysisdto.donequantity,
    mv_productioncounting_productionanalysisdto.causeofwastes,
    mv_productioncounting_productionanalysisdto.shift_id,
    mv_productioncounting_productionanalysisdto.shiftname,
    mv_productioncounting_productionanalysisdto.timerangefrom,
    mv_productioncounting_productionanalysisdto.timerangeto,
    mv_productioncounting_productionanalysisdto.generator_id,
    mv_productioncounting_productionanalysisdto.generatorname,
    mv_productioncounting_productionanalysisdto.order_id,
    mv_productioncounting_productionanalysisdto.ordernumber,
    mv_productioncounting_productionanalysisdto.obtainedmasterordernumber,
    mv_productioncounting_productionanalysisdto.technologygroupnumber,
    mv_productioncounting_productionanalysisdto.typeofmaterial
   FROM public.mv_productioncounting_productionanalysisdto;


--
-- Name: productioncounting_trackingoperationproductincomponenthelper _RETURN; Type: RULE; Schema: public; Owner: -
--

CREATE OR REPLACE VIEW public.productioncounting_trackingoperationproductincomponenthelper AS
 SELECT trackingoperationproductincomponent.id,
    (productiontracking.id)::integer AS productiontracking_id,
    (product.id)::integer AS product_id,
    product.number AS productnumber,
    product.name AS productname,
    product.unit AS productunit,
    sum(productioncountingquantity.plannedquantity) AS plannedquantity,
        CASE
            WHEN (usedbatch.id IS NULL) THEN trackingoperationproductincomponent.usedquantity
            ELSE usedbatch.quantity
        END AS usedquantity,
    batch.number AS batchnumber,
    producedbatch.number AS producedbatchnumber
   FROM ((((((public.productioncounting_trackingoperationproductincomponent trackingoperationproductincomponent
     LEFT JOIN public.productioncounting_productiontracking productiontracking ON ((productiontracking.id = trackingoperationproductincomponent.productiontracking_id)))
     LEFT JOIN public.basic_product product ON ((product.id = trackingoperationproductincomponent.product_id)))
     LEFT JOIN public.advancedgenealogy_batch producedbatch ON ((producedbatch.id = productiontracking.batch_id)))
     LEFT JOIN public.productioncounting_usedbatch usedbatch ON ((usedbatch.trackingoperationproductincomponent_id = trackingoperationproductincomponent.id)))
     LEFT JOIN public.advancedgenealogy_batch batch ON ((batch.id = usedbatch.batch_id)))
     LEFT JOIN public.basicproductioncounting_productioncountingquantity productioncountingquantity ON (((productioncountingquantity.order_id = productiontracking.order_id) AND (productioncountingquantity.product_id = trackingoperationproductincomponent.product_id) AND ((productioncountingquantity.role)::text = '01used'::text) AND
        CASE
            WHEN (productiontracking.technologyoperationcomponent_id IS NOT NULL) THEN (productioncountingquantity.technologyoperationcomponent_id = productiontracking.technologyoperationcomponent_id)
            ELSE (1 = 1)
        END)))
  WHERE ((productiontracking.state)::text <> ALL (ARRAY[(('03declined'::text)::character varying)::text, (('04corrected'::text)::character varying)::text]))
  GROUP BY trackingoperationproductincomponent.id, productiontracking.id, product.id, product.number, producedbatch.number, product.unit, trackingoperationproductincomponent.usedquantity, productiontracking.technologyoperationcomponent_id, usedbatch.id, usedbatch.quantity, batch.number;


--
-- Name: productioncounting_trackingoperationproductoutcomponenthelper _RETURN; Type: RULE; Schema: public; Owner: -
--

CREATE OR REPLACE VIEW public.productioncounting_trackingoperationproductoutcomponenthelper AS
 SELECT trackingoperationproductoutcomponent.id,
    (productiontracking.id)::integer AS productiontracking_id,
    (product.id)::integer AS product_id,
    product.number AS productnumber,
    product.name AS productname,
    product.unit AS productunit,
        CASE
            WHEN (productiontracking.technologyoperationcomponent_id IS NULL) THEN ( SELECT sum(productioncountingquantity_1.plannedquantity) AS sum)
            ELSE ( SELECT sum(productioncountingquantity_2.plannedquantity) AS sum)
        END AS plannedquantity,
    trackingoperationproductoutcomponent.usedquantity,
    batch.number AS batchnumber,
    producedbatch.number AS producedbatchnumber
   FROM ((((((public.productioncounting_trackingoperationproductoutcomponent trackingoperationproductoutcomponent
     LEFT JOIN public.productioncounting_productiontracking productiontracking ON ((productiontracking.id = trackingoperationproductoutcomponent.productiontracking_id)))
     LEFT JOIN public.advancedgenealogy_batch producedbatch ON ((producedbatch.id = productiontracking.batch_id)))
     LEFT JOIN public.basic_product product ON ((product.id = trackingoperationproductoutcomponent.product_id)))
     LEFT JOIN public.advancedgenealogy_batch batch ON ((batch.id = trackingoperationproductoutcomponent.batch_id)))
     LEFT JOIN public.basicproductioncounting_productioncountingquantity productioncountingquantity_1 ON (((productioncountingquantity_1.order_id = productiontracking.order_id) AND (productioncountingquantity_1.product_id = trackingoperationproductoutcomponent.product_id) AND ((productioncountingquantity_1.role)::text = '02produced'::text))))
     LEFT JOIN public.basicproductioncounting_productioncountingquantity productioncountingquantity_2 ON (((productioncountingquantity_2.order_id = productiontracking.order_id) AND (productioncountingquantity_2.technologyoperationcomponent_id = productiontracking.technologyoperationcomponent_id) AND (productioncountingquantity_2.product_id = trackingoperationproductoutcomponent.product_id) AND ((productioncountingquantity_2.role)::text = '02produced'::text))))
  WHERE ((productiontracking.state)::text <> ALL (ARRAY[(('03declined'::text)::character varying)::text, (('04corrected'::text)::character varying)::text]))
  GROUP BY trackingoperationproductoutcomponent.id, productiontracking.id, product.id, product.number, product.unit, producedbatch.number, trackingoperationproductoutcomponent.usedquantity, productiontracking.technologyoperationcomponent_id, batch.number;


--
-- Name: productioncounting_trackingoperationproductoutcomponentdto _RETURN; Type: RULE; Schema: public; Owner: -
--

CREATE OR REPLACE VIEW public.productioncounting_trackingoperationproductoutcomponentdto AS
 WITH quantities AS (
         SELECT COALESCE(sum(opoc.usedquantity), (0)::numeric) AS producedsum,
            COALESCE(sum(opoc.wastesquantity), (0)::numeric) AS wastessum,
            pt.order_id,
            pt.technologyoperationcomponent_id,
            opoc.product_id
           FROM (public.productioncounting_trackingoperationproductoutcomponent opoc
             JOIN public.productioncounting_productiontracking pt ON ((pt.id = opoc.productiontracking_id)))
          WHERE ((pt.state)::text = '02accepted'::text)
          GROUP BY pt.order_id, pt.technologyoperationcomponent_id, opoc.product_id
        )
 SELECT trackingoperationproductoutcomponent.id,
    (productiontracking.id)::integer AS productiontrackingid,
    product.number AS productnumber,
    product.name AS productname,
    product.unit AS productunit,
    COALESCE(sum(productioncountingquantity.plannedquantity), (0)::numeric) AS plannedquantity,
    COALESCE(quantities.producedsum, (0)::numeric) AS producedsum,
    COALESCE(quantities.wastessum, (0)::numeric) AS wastessum,
    GREATEST((COALESCE(sum(productioncountingquantity.plannedquantity), (0)::numeric) - COALESCE(quantities.producedsum, (0)::numeric)), (0)::numeric) AS remainingquantity,
    trackingoperationproductoutcomponent.wastesquantity,
    trackingoperationproductoutcomponent.usedquantity,
    trackingoperationproductoutcomponent.wastedquantity,
    b.number AS batchnumber,
    trackingoperationproductoutcomponent.typeofmaterial
   FROM (((((public.productioncounting_trackingoperationproductoutcomponent trackingoperationproductoutcomponent
     LEFT JOIN public.productioncounting_productiontracking productiontracking ON ((productiontracking.id = trackingoperationproductoutcomponent.productiontracking_id)))
     LEFT JOIN public.basic_product product ON ((product.id = trackingoperationproductoutcomponent.product_id)))
     LEFT JOIN public.advancedgenealogy_batch b ON ((b.id = trackingoperationproductoutcomponent.batch_id)))
     LEFT JOIN public.basicproductioncounting_productioncountingquantity productioncountingquantity ON (((productioncountingquantity.order_id = productiontracking.order_id) AND (productioncountingquantity.product_id = trackingoperationproductoutcomponent.product_id) AND ((productioncountingquantity.role)::text = '02produced'::text))))
     LEFT JOIN quantities ON (((quantities.order_id = productiontracking.order_id) AND (quantities.product_id = trackingoperationproductoutcomponent.product_id))))
  WHERE (productiontracking.technologyoperationcomponent_id IS NULL)
  GROUP BY trackingoperationproductoutcomponent.id, productiontracking.id, product.number, product.name, product.unit, trackingoperationproductoutcomponent.wastesquantity, trackingoperationproductoutcomponent.usedquantity, trackingoperationproductoutcomponent.wastedquantity, b.number, quantities.producedsum, quantities.wastessum
UNION
 SELECT trackingoperationproductoutcomponent.id,
    (productiontracking.id)::integer AS productiontrackingid,
    product.number AS productnumber,
    product.name AS productname,
    product.unit AS productunit,
    COALESCE(sum(productioncountingquantity.plannedquantity), (0)::numeric) AS plannedquantity,
    COALESCE(quantities.producedsum, (0)::numeric) AS producedsum,
    COALESCE(quantities.wastessum, (0)::numeric) AS wastessum,
    GREATEST((COALESCE(sum(productioncountingquantity.plannedquantity), (0)::numeric) - COALESCE(quantities.producedsum, (0)::numeric)), (0)::numeric) AS remainingquantity,
    trackingoperationproductoutcomponent.wastesquantity,
    trackingoperationproductoutcomponent.usedquantity,
    trackingoperationproductoutcomponent.wastedquantity,
    b.number AS batchnumber,
    trackingoperationproductoutcomponent.typeofmaterial
   FROM (((((public.productioncounting_trackingoperationproductoutcomponent trackingoperationproductoutcomponent
     LEFT JOIN public.productioncounting_productiontracking productiontracking ON ((productiontracking.id = trackingoperationproductoutcomponent.productiontracking_id)))
     LEFT JOIN public.basic_product product ON ((product.id = trackingoperationproductoutcomponent.product_id)))
     LEFT JOIN public.advancedgenealogy_batch b ON ((b.id = trackingoperationproductoutcomponent.batch_id)))
     LEFT JOIN public.basicproductioncounting_productioncountingquantity productioncountingquantity ON (((productioncountingquantity.order_id = productiontracking.order_id) AND (productioncountingquantity.technologyoperationcomponent_id = productiontracking.technologyoperationcomponent_id) AND (productioncountingquantity.product_id = trackingoperationproductoutcomponent.product_id) AND ((productioncountingquantity.role)::text = '02produced'::text))))
     LEFT JOIN quantities quantities ON (((quantities.order_id = productiontracking.order_id) AND (quantities.technologyoperationcomponent_id = productiontracking.technologyoperationcomponent_id) AND (quantities.product_id = trackingoperationproductoutcomponent.product_id))))
  WHERE (productiontracking.technologyoperationcomponent_id IS NOT NULL)
  GROUP BY trackingoperationproductoutcomponent.id, productiontracking.id, product.number, product.name, product.unit, trackingoperationproductoutcomponent.wastesquantity, trackingoperationproductoutcomponent.usedquantity, trackingoperationproductoutcomponent.wastedquantity, b.number, productiontracking.technologyoperationcomponent_id, quantities.producedsum, quantities.wastessum;


--
-- Name: technologies_operationproductincomponentdto _RETURN; Type: RULE; Schema: public; Owner: -
--

CREATE OR REPLACE VIEW public.technologies_operationproductincomponentdto AS
 SELECT operationproductincomponent.id,
    (technologyoperationcomponent.id)::integer AS operationcomponentid,
    product.id AS product_id,
    (product.id)::integer AS productid,
    product.number AS productnumber,
    product.name AS productname,
        CASE
            WHEN (operationproductincomponent.technologyinputproducttype_id IS NULL) THEN product.unit
            ELSE operationproductincomponent.givenunit
        END AS productunit,
    operationproductincomponent.quantity,
    operationproductincomponent.priority,
    operationproductincomponent.itemnumberintheexplodedview,
    operation.name AS operationname,
    technologyoperationcomponent.nodenumber,
    (technology.id)::integer AS technologyid,
    technology.name AS technologyname,
    technology.state AS technologystate,
    technology.number AS technologynumber,
    technology.master AS mastertechnology,
    technology.active AS activetechnology,
    (count(technologyaccepted.id) > 0) AS hasacceptedtechnology,
    (count(technologychecked.id) > 0) AS hascheckedtechnology,
    technologyinputproducttype.name AS technologyinputproducttypename,
    operationproductincomponent.differentproductsindifferentsizes,
    model.name AS modelname,
    assortment.name AS assortmentname,
    technology_product.number AS technologyproductnumber
   FROM ((((((((((public.technologies_operationproductincomponent operationproductincomponent
     LEFT JOIN public.technologies_technologyoperationcomponent technologyoperationcomponent ON ((technologyoperationcomponent.id = operationproductincomponent.operationcomponent_id)))
     LEFT JOIN public.technologies_operation operation ON ((operation.id = technologyoperationcomponent.operation_id)))
     LEFT JOIN public.basic_product product ON ((product.id = operationproductincomponent.product_id)))
     LEFT JOIN public.technologies_technology technology ON ((technology.id = technologyoperationcomponent.technology_id)))
     LEFT JOIN public.basic_product technology_product ON ((technology_product.id = technology.product_id)))
     LEFT JOIN public.basic_model model ON ((model.id = technology_product.model_id)))
     LEFT JOIN public.basic_assortment assortment ON ((assortment.id = technology_product.assortment_id)))
     LEFT JOIN public.technologies_technology technologyaccepted ON (((technologyaccepted.product_id = operationproductincomponent.product_id) AND (technologyaccepted.active = true) AND ((technologyaccepted.state)::text = '02accepted'::text))))
     LEFT JOIN public.technologies_technology technologychecked ON (((technologychecked.product_id = operationproductincomponent.product_id) AND (technologychecked.active = true) AND ((technologychecked.state)::text = '05checked'::text))))
     LEFT JOIN public.technologies_technologyinputproducttype technologyinputproducttype ON ((technologyinputproducttype.id = operationproductincomponent.technologyinputproducttype_id)))
  GROUP BY operationproductincomponent.id, technologyoperationcomponent.id, product.id, product.number, product.name, product.unit, operationproductincomponent.quantity, operationproductincomponent.priority, operationproductincomponent.itemnumberintheexplodedview, technology.name, technology.number, technology.state, technology.master, operation.name, technology.active, technology.id, technologyinputproducttype.name, technology_product.number, model.name, assortment.name;


--
-- Name: technologies_operationproductinproductdto _RETURN; Type: RULE; Schema: public; Owner: -
--

CREATE OR REPLACE VIEW public.technologies_operationproductinproductdto AS
 SELECT technologies_operationproductincomponentdto.id,
    (technologies_operationproductincomponentdto.id)::integer AS operationproductincomponentid,
    technologies_operationproductincomponentdto.product_id,
    technologies_operationproductincomponentdto.productid,
    technologies_operationproductincomponentdto.nodenumber,
    technologies_operationproductincomponentdto.technologyid,
    technologies_operationproductincomponentdto.technologyname,
    technologies_operationproductincomponentdto.technologystate,
    technologies_operationproductincomponentdto.technologynumber,
    technologies_operationproductincomponentdto.operationname,
    technologies_operationproductincomponentdto.quantity,
    technologies_operationproductincomponentdto.mastertechnology,
    technologies_operationproductincomponentdto.operationcomponentid,
    technologies_operationproductincomponentdto.activetechnology,
    false AS sizeproduct,
    NULL::integer AS productbysizegroupid,
    technologies_operationproductincomponentdto.modelname,
    technologies_operationproductincomponentdto.assortmentname,
    technologies_operationproductincomponentdto.productnumber,
    technologies_operationproductincomponentdto.technologyproductnumber
   FROM public.technologies_operationproductincomponentdto
UNION ALL
 SELECT (10000000 + productbysizegroup.id) AS id,
    (operationproductincomponent.id)::integer AS operationproductincomponentid,
    product.id AS product_id,
    (product.id)::integer AS productid,
    technologyoperationcomponent.nodenumber,
    (technology.id)::integer AS technologyid,
    technology.name AS technologyname,
    technology.state AS technologystate,
    technology.number AS technologynumber,
    operation.name AS operationname,
    operationproductincomponent.quantity,
    technology.master AS mastertechnology,
    (technologyoperationcomponent.id)::integer AS operationcomponentid,
    technology.active AS activetechnology,
    true AS sizeproduct,
    (productbysizegroup.id)::integer AS productbysizegroupid,
    model.name AS modelname,
    assortment.name AS assortmentname,
    product.number AS productnumber,
    technology_product.number AS technologyproductnumber
   FROM (((((((((public.technologies_productbysizegroup productbysizegroup
     LEFT JOIN public.technologies_operationproductincomponent operationproductincomponent ON ((operationproductincomponent.id = productbysizegroup.operationproductincomponent_id)))
     LEFT JOIN public.technologies_technologyoperationcomponent technologyoperationcomponent ON ((technologyoperationcomponent.id = operationproductincomponent.operationcomponent_id)))
     LEFT JOIN public.technologies_operation operation ON ((operation.id = technologyoperationcomponent.operation_id)))
     LEFT JOIN public.basic_product product ON ((product.id = productbysizegroup.product_id)))
     LEFT JOIN public.technologies_technology technology ON ((technology.id = technologyoperationcomponent.technology_id)))
     LEFT JOIN public.basic_product technology_product ON ((technology_product.id = technology.product_id)))
     LEFT JOIN public.basic_model model ON ((model.id = technology_product.model_id)))
     LEFT JOIN public.basic_assortment assortment ON ((assortment.id = technology_product.assortment_id)))
     LEFT JOIN public.technologies_technologyinputproducttype technologyinputproducttype ON ((technologyinputproducttype.id = operationproductincomponent.technologyinputproducttype_id)))
  GROUP BY productbysizegroup.id, operationproductincomponent.id, technologyoperationcomponent.id, product.id, product.number, product.name, product.unit, operationproductincomponent.quantity, operationproductincomponent.priority, operationproductincomponent.itemnumberintheexplodedview, technology.name, technology.number, technology.state, technology.master, operation.name, technology.active, technology.id, technologyinputproducttype.name, technology_product.number, model.name, assortment.name;


--
-- Name: technologies_technologydto _RETURN; Type: RULE; Schema: public; Owner: -
--

CREATE OR REPLACE VIEW public.technologies_technologydto AS
 SELECT technology.id,
    technology.name,
    technology.number,
    technology.description,
    technology.externalsynchronized,
    technology.master,
    technology.state,
    product.number AS productnumber,
    product.globaltypeofmaterial AS productglobaltypeofmaterial,
    technologygroup.number AS technologygroupnumber,
    division.name AS divisionname,
    product.name AS productname,
    technology.active,
    tpl.standardperformance,
    generatorcontext.number AS generatorname,
    (count(technologyattachment.id) <> 0) AS attachmentsexists,
    technologystatechange.dateandtime,
    productionline.number AS productionlinenumber,
    assortment.name AS assortmentname,
    qualitycard.number AS qualitycardnumber,
    technology.istemplateaccepted
   FROM ((((((((((public.technologies_technology technology
     LEFT JOIN public.basic_product product ON ((product.id = technology.product_id)))
     LEFT JOIN public.basic_assortment assortment ON ((assortment.id = product.assortment_id)))
     LEFT JOIN public.basic_division division ON ((division.id = technology.division_id)))
     LEFT JOIN public.technologies_technologygroup technologygroup ON ((technologygroup.id = technology.technologygroup_id)))
     LEFT JOIN public.technologies_technologyattachment technologyattachment ON ((technologyattachment.technology_id = technology.id)))
     LEFT JOIN public.technologiesgenerator_generatorcontext generatorcontext ON ((generatorcontext.id = technology.generatorcontext_id)))
     LEFT JOIN public.technologies_technologystatechange technologystatechange ON (((technologystatechange.technology_id = technology.id) AND ((technologystatechange.status)::text = '03successful'::text) AND (technologystatechange.sourcestate IS NULL) AND ((technologystatechange.targetstate)::text = '01draft'::text))))
     LEFT JOIN public.basic_qualitycard qualitycard ON ((qualitycard.id = technology.qualitycard_id)))
     LEFT JOIN public.technologies_technologyproductionline tpl ON (((tpl.technology_id = technology.id) AND tpl.master)))
     LEFT JOIN public.productionlines_productionline productionline ON ((productionline.id = tpl.productionline_id)))
  GROUP BY technology.id, product.number, product.globaltypeofmaterial, technologygroup.number, division.name, product.name, generatorcontext.number, technologystatechange.dateandtime, tpl.standardperformance, productionline.number, assortment.name, qualitycard.number;


--
-- Name: assignmenttoshift_assignmenttoshift assignmenttoshift_assignmenttoshift_trigger_externalnumber; Type: TRIGGER; Schema: public; Owner: -
--

CREATE TRIGGER assignmenttoshift_assignmenttoshift_trigger_externalnumber BEFORE INSERT ON public.assignmenttoshift_assignmenttoshift FOR EACH ROW EXECUTE FUNCTION public.generate_and_set_assignmenttoshift_externalnumber_trigger();


--
-- Name: cmmsmachineparts_maintenanceevent cmmsmachineparts_maintenanceevent_trigger_number; Type: TRIGGER; Schema: public; Owner: -
--

CREATE TRIGGER cmmsmachineparts_maintenanceevent_trigger_number BEFORE INSERT ON public.cmmsmachineparts_maintenanceevent FOR EACH ROW EXECUTE FUNCTION public.generate_and_set_maintenanceevent_number_trigger();


--
-- Name: goodfood_confectionprotocol goodfood_confectionprotocol_trigger_externalnumber; Type: TRIGGER; Schema: public; Owner: -
--

CREATE TRIGGER goodfood_confectionprotocol_trigger_externalnumber BEFORE INSERT ON public.goodfood_confectionprotocol FOR EACH ROW EXECUTE FUNCTION public.generate_and_set_confectionprotocol_externalnumber_trigger();


--
-- Name: goodfood_extrusionprotocol goodfood_extrusionprotocol_trigger_externalnumber; Type: TRIGGER; Schema: public; Owner: -
--

CREATE TRIGGER goodfood_extrusionprotocol_trigger_externalnumber BEFORE INSERT ON public.goodfood_extrusionprotocol FOR EACH ROW EXECUTE FUNCTION public.generate_and_set_extrusionprotocol_externalnumber_trigger();


--
-- Name: goodfood_pallet goodfood_pallet_trigger_externalnumber; Type: TRIGGER; Schema: public; Owner: -
--

CREATE TRIGGER goodfood_pallet_trigger_externalnumber BEFORE INSERT ON public.goodfood_pallet FOR EACH ROW EXECUTE FUNCTION public.generate_and_set_pallet_externalnumber_trigger();


--
-- Name: materialflowresources_document materialflowresources_document_trigger_number; Type: TRIGGER; Schema: public; Owner: -
--

CREATE TRIGGER materialflowresources_document_trigger_number BEFORE INSERT ON public.materialflowresources_document FOR EACH ROW EXECUTE FUNCTION public.generate_and_set_document_number_trigger();


--
-- Name: orders_operationaltask orders_operationaltask_trigger_number; Type: TRIGGER; Schema: public; Owner: -
--

CREATE TRIGGER orders_operationaltask_trigger_number BEFORE INSERT ON public.orders_operationaltask FOR EACH ROW EXECUTE FUNCTION public.generate_and_set_operational_task_number_trigger();


--
-- Name: repairs_repairorder repairs_repairorder_trigger_number; Type: TRIGGER; Schema: public; Owner: -
--

CREATE TRIGGER repairs_repairorder_trigger_number BEFORE INSERT ON public.repairs_repairorder FOR EACH ROW EXECUTE FUNCTION public.generate_and_set_repairorder_number_trigger();


--
-- Name: jointable_action_subassembly action_subassembly_action_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.jointable_action_subassembly
    ADD CONSTRAINT action_subassembly_action_fkey FOREIGN KEY (action_id) REFERENCES public.cmmsmachineparts_action(id) DEFERRABLE;


--
-- Name: jointable_action_subassembly action_subassembly_subassembly_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.jointable_action_subassembly
    ADD CONSTRAINT action_subassembly_subassembly_fkey FOREIGN KEY (subassembly_id) REFERENCES public.basic_subassembly(id) DEFERRABLE;


--
-- Name: jointable_action_workstation action_workstation_action_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.jointable_action_workstation
    ADD CONSTRAINT action_workstation_action_fkey FOREIGN KEY (action_id) REFERENCES public.cmmsmachineparts_action(id) DEFERRABLE;


--
-- Name: jointable_action_workstation action_workstation_workstation_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.jointable_action_workstation
    ADD CONSTRAINT action_workstation_workstation_fkey FOREIGN KEY (workstation_id) REFERENCES public.basic_workstation(id) DEFERRABLE;


--
-- Name: jointable_action_workstationtype action_workstationtype_action_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.jointable_action_workstationtype
    ADD CONSTRAINT action_workstationtype_action_fkey FOREIGN KEY (action_id) REFERENCES public.cmmsmachineparts_action(id) DEFERRABLE;


--
-- Name: jointable_action_workstationtype action_workstationtype_workstationtype_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.jointable_action_workstationtype
    ADD CONSTRAINT action_workstationtype_workstationtype_fkey FOREIGN KEY (workstationtype_id) REFERENCES public.basic_workstationtype(id) DEFERRABLE;


--
-- Name: cmmsmachineparts_actionforplannedevent actionforplannedevet_action_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.cmmsmachineparts_actionforplannedevent
    ADD CONSTRAINT actionforplannedevet_action_fkey FOREIGN KEY (action_id) REFERENCES public.cmmsmachineparts_action(id) DEFERRABLE;


--
-- Name: cmmsmachineparts_actionforplannedevent actionforplannedevet_plannedevent_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.cmmsmachineparts_actionforplannedevent
    ADD CONSTRAINT actionforplannedevet_plannedevent_fkey FOREIGN KEY (plannedevent_id) REFERENCES public.cmmsmachineparts_plannedevent(id) DEFERRABLE;


--
-- Name: cmmsmachineparts_actionforplannedevent actionforplannedevet_staff_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.cmmsmachineparts_actionforplannedevent
    ADD CONSTRAINT actionforplannedevet_staff_fkey FOREIGN KEY (responsibleworker_id) REFERENCES public.basic_staff(id) DEFERRABLE;


--
-- Name: cmmsscheduler_actionforrecurringevent actionforrecurringevent_action_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.cmmsscheduler_actionforrecurringevent
    ADD CONSTRAINT actionforrecurringevent_action_fkey FOREIGN KEY (action_id) REFERENCES public.cmmsmachineparts_action(id) DEFERRABLE;


--
-- Name: cmmsscheduler_actionforrecurringevent actionforrecurringevent_recurringevent_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.cmmsscheduler_actionforrecurringevent
    ADD CONSTRAINT actionforrecurringevent_recurringevent_fkey FOREIGN KEY (recurringevent_id) REFERENCES public.cmmsscheduler_recurringevent(id) DEFERRABLE;


--
-- Name: jointable_additionaldirectcost_technology additionaldirectcost_technology_additionaldirectcost_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.jointable_additionaldirectcost_technology
    ADD CONSTRAINT additionaldirectcost_technology_additionaldirectcost_fkey FOREIGN KEY (additionaldirectcost_id) REFERENCES public.costcalculation_additionaldirectcost(id) DEFERRABLE;


--
-- Name: jointable_additionaldirectcost_technology additionaldirectcost_technology_technology_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.jointable_additionaldirectcost_technology
    ADD CONSTRAINT additionaldirectcost_technology_technology_fkey FOREIGN KEY (technology_id) REFERENCES public.technologies_technology(id) DEFERRABLE;


--
-- Name: costcalculation_additionaldirectcostitem additionaldirectcostitem_additionaldirectcost_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.costcalculation_additionaldirectcostitem
    ADD CONSTRAINT additionaldirectcostitem_additionaldirectcost_fkey FOREIGN KEY (additionaldirectcost_id) REFERENCES public.costcalculation_additionaldirectcost(id) DEFERRABLE;


--
-- Name: basic_address address_company_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.basic_address
    ADD CONSTRAINT address_company_fkey FOREIGN KEY (company_id) REFERENCES public.basic_company(id) DEFERRABLE;


--
-- Name: basic_address address_country_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.basic_address
    ADD CONSTRAINT address_country_fkey FOREIGN KEY (country_id) REFERENCES public.basic_country(id) DEFERRABLE;


--
-- Name: goodfood_confectioninputproduct advancedgenealogy_batch_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.goodfood_confectioninputproduct
    ADD CONSTRAINT advancedgenealogy_batch_fkey FOREIGN KEY (batch_id) REFERENCES public.advancedgenealogy_batch(id) DEFERRABLE;


--
-- Name: qcadooview_viewedalert alert_user_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.qcadooview_viewedalert
    ADD CONSTRAINT alert_user_fkey FOREIGN KEY (user_id) REFERENCES public.qcadoosecurity_user(id) DEFERRABLE;


--
-- Name: jointable_anomaly_anomalyreason anomaly_anomalyreason_anomaly_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.jointable_anomaly_anomalyreason
    ADD CONSTRAINT anomaly_anomalyreason_anomaly_fkey FOREIGN KEY (anomaly_id) REFERENCES public.productioncounting_anomaly(id) DEFERRABLE;


--
-- Name: jointable_anomaly_anomalyreason anomaly_anomalyreason_anomalyreason_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.jointable_anomaly_anomalyreason
    ADD CONSTRAINT anomaly_anomalyreason_anomalyreason_fkey FOREIGN KEY (anomalyreason_id) REFERENCES public.productioncounting_anomalyreason(id) DEFERRABLE;


--
-- Name: productioncounting_anomaly anomaly_location_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.productioncounting_anomaly
    ADD CONSTRAINT anomaly_location_fkey FOREIGN KEY (location_id) REFERENCES public.materialflow_location(id) DEFERRABLE;


--
-- Name: productioncounting_anomaly anomaly_masterproduct_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.productioncounting_anomaly
    ADD CONSTRAINT anomaly_masterproduct_fkey FOREIGN KEY (masterproduct_id) REFERENCES public.basic_product(id) DEFERRABLE;


--
-- Name: productioncounting_anomaly anomaly_product_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.productioncounting_anomaly
    ADD CONSTRAINT anomaly_product_fkey FOREIGN KEY (product_id) REFERENCES public.basic_product(id) DEFERRABLE;


--
-- Name: productioncounting_anomaly anomaly_productiontracking_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.productioncounting_anomaly
    ADD CONSTRAINT anomaly_productiontracking_fkey FOREIGN KEY (productiontracking_id) REFERENCES public.productioncounting_productiontracking(id) DEFERRABLE;


--
-- Name: productioncounting_anomalyexplanation anomalyexplanation_anomaly_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.productioncounting_anomalyexplanation
    ADD CONSTRAINT anomalyexplanation_anomaly_fkey FOREIGN KEY (anomaly_id) REFERENCES public.productioncounting_anomaly(id) DEFERRABLE;


--
-- Name: productioncounting_anomalyexplanation anomalyexplanation_location_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.productioncounting_anomalyexplanation
    ADD CONSTRAINT anomalyexplanation_location_fkey FOREIGN KEY (location_id) REFERENCES public.materialflow_location(id) DEFERRABLE;


--
-- Name: productioncounting_anomalyexplanation anomalyexplanation_product_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.productioncounting_anomalyexplanation
    ADD CONSTRAINT anomalyexplanation_product_fkey FOREIGN KEY (product_id) REFERENCES public.basic_product(id) DEFERRABLE;


--
-- Name: productioncounting_anomalyproductiontrackingentryhelper anomalyproductiontrackingentryhelper_apt_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.productioncounting_anomalyproductiontrackingentryhelper
    ADD CONSTRAINT anomalyproductiontrackingentryhelper_apt_fkey FOREIGN KEY (anomalyproductiontracking_id) REFERENCES public.productioncounting_anomalyproductiontrackinghelper(id) DEFERRABLE;


--
-- Name: productioncounting_anomalyproductiontrackingentryhelper anomalyproductiontrackingentryhelper_topic_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.productioncounting_anomalyproductiontrackingentryhelper
    ADD CONSTRAINT anomalyproductiontrackingentryhelper_topic_fkey FOREIGN KEY (trackingoperationproductincomponent_id) REFERENCES public.productioncounting_trackingoperationproductincomponent(id) DEFERRABLE;


--
-- Name: productioncounting_anomalyreasoncontainer anomalyreasoncontainer_anomalyreason_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.productioncounting_anomalyreasoncontainer
    ADD CONSTRAINT anomalyreasoncontainer_anomalyreason_fkey FOREIGN KEY (anomalyreason_id) REFERENCES public.productioncounting_anomalyreason(id) DEFERRABLE;


--
-- Name: productioncounting_anomalyreasoncontainer anomalyreasoncontainer_apteh_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.productioncounting_anomalyreasoncontainer
    ADD CONSTRAINT anomalyreasoncontainer_apteh_fkey FOREIGN KEY (anomalyproductiontrackingentryhelper_id) REFERENCES public.productioncounting_anomalyproductiontrackingentryhelper(id) DEFERRABLE;


--
-- Name: assignmenttoshift_assignmenttoshiftstatechange assignmenttoshift_assignmenttoshift_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.assignmenttoshift_assignmenttoshiftstatechange
    ADD CONSTRAINT assignmenttoshift_assignmenttoshift_fkey FOREIGN KEY (assignmenttoshift_id) REFERENCES public.assignmenttoshift_assignmenttoshift(id) DEFERRABLE;


--
-- Name: assignmenttoshift_staffassignmenttoshift assignmenttoshift_assignmenttoshift_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.assignmenttoshift_staffassignmenttoshift
    ADD CONSTRAINT assignmenttoshift_assignmenttoshift_fkey FOREIGN KEY (assignmenttoshift_id) REFERENCES public.assignmenttoshift_assignmenttoshift(id) DEFERRABLE;


--
-- Name: avglaborcostcalcfororder_assignmentworkertoshift assignmenttoshift_assignmenttoshift_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.avglaborcostcalcfororder_assignmentworkertoshift
    ADD CONSTRAINT assignmenttoshift_assignmenttoshift_fkey FOREIGN KEY (assignmenttoshift_id) REFERENCES public.assignmenttoshift_assignmenttoshift(id) DEFERRABLE;


--
-- Name: assignmenttoshift_assignmenttoshift assignmenttoshift_crew_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.assignmenttoshift_assignmenttoshift
    ADD CONSTRAINT assignmenttoshift_crew_fkey FOREIGN KEY (crew_id) REFERENCES public.basic_crew(id) DEFERRABLE;


--
-- Name: assignmenttoshift_assignmenttoshift assignmenttoshift_factory_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.assignmenttoshift_assignmenttoshift
    ADD CONSTRAINT assignmenttoshift_factory_fkey FOREIGN KEY (factory_id) REFERENCES public.basic_factory(id) DEFERRABLE;


--
-- Name: jointable_multiassignmenttoshift_staff assignmenttoshift_multiassignmenttoshift_staff_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.jointable_multiassignmenttoshift_staff
    ADD CONSTRAINT assignmenttoshift_multiassignmenttoshift_staff_fkey FOREIGN KEY (multiassignmenttoshift_id) REFERENCES public.assignmenttoshift_multiassignmenttoshift(id) DEFERRABLE;


--
-- Name: assignmenttoshift_assignmenttoshiftreport assignmenttoshiftreport_factory_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.assignmenttoshift_assignmenttoshiftreport
    ADD CONSTRAINT assignmenttoshiftreport_factory_fkey FOREIGN KEY (factory_id) REFERENCES public.basic_factory(id) DEFERRABLE;


--
-- Name: assignmenttoshift_assignmenttoshiftreport assignmenttoshiftreport_shift_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.assignmenttoshift_assignmenttoshiftreport
    ADD CONSTRAINT assignmenttoshiftreport_shift_fkey FOREIGN KEY (shift_id) REFERENCES public.basic_shift(id) DEFERRABLE;


--
-- Name: basic_assortmentelement assortmentelement_assortment_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.basic_assortmentelement
    ADD CONSTRAINT assortmentelement_assortment_fkey FOREIGN KEY (assortment_id) REFERENCES public.basic_assortment(id) DEFERRABLE;


--
-- Name: advancedgenealogy_trackingrecordstatechange atrackingrecordstatechange_trackingrecord_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.advancedgenealogy_trackingrecordstatechange
    ADD CONSTRAINT atrackingrecordstatechange_trackingrecord_fkey FOREIGN KEY (trackingrecord_id) REFERENCES public.advancedgenealogy_trackingrecord(id) DEFERRABLE;


--
-- Name: cmmsscheduler_recurringeventattachment attachment_event_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.cmmsscheduler_recurringeventattachment
    ADD CONSTRAINT attachment_event_fkey FOREIGN KEY (recurringevent_id) REFERENCES public.cmmsscheduler_recurringevent(id) DEFERRABLE;


--
-- Name: basic_attributevalue attributevalue_attribute_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.basic_attributevalue
    ADD CONSTRAINT attributevalue_attribute_fkey FOREIGN KEY (attribute_id) REFERENCES public.basic_attribute(id) DEFERRABLE;


--
-- Name: avglaborcostcalcfororder_assignmentworkertoshift avglaborcostcalcfororder_avglaborcostcalcfororder_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.avglaborcostcalcfororder_assignmentworkertoshift
    ADD CONSTRAINT avglaborcostcalcfororder_avglaborcostcalcfororder_fkey FOREIGN KEY (avglaborcostcalcfororder_id) REFERENCES public.avglaborcostcalcfororder_avglaborcostcalcfororder(id) DEFERRABLE;


--
-- Name: productionpershift_balance balance_context_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.productionpershift_balance
    ADD CONSTRAINT balance_context_fkey FOREIGN KEY (context_id) REFERENCES public.productionpershift_balancecontext(id) DEFERRABLE;


--
-- Name: technologies_barcodeoperationcomponent barcodeoperationcomponen_operationcomponent_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.technologies_barcodeoperationcomponent
    ADD CONSTRAINT barcodeoperationcomponen_operationcomponent_fkey FOREIGN KEY (operationcomponent_id) REFERENCES public.technologies_technologyoperationcomponent(id) DEFERRABLE;


--
-- Name: technologies_barcodeoperationcomponent barcodeoperationcomponent_orderfkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.technologies_barcodeoperationcomponent
    ADD CONSTRAINT barcodeoperationcomponent_orderfkey FOREIGN KEY (order_id) REFERENCES public.orders_order(id) DEFERRABLE;


--
-- Name: integrationbaselinker_baselinkerparameters baselinkerparameters_locationfrom_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.integrationbaselinker_baselinkerparameters
    ADD CONSTRAINT baselinkerparameters_locationfrom_fkey FOREIGN KEY (locationfrom_id) REFERENCES public.materialflow_location(id) DEFERRABLE;


--
-- Name: integrationbaselinker_baselinkerparameters baselinkerparameters_locationto_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.integrationbaselinker_baselinkerparameters
    ADD CONSTRAINT baselinkerparameters_locationto_fkey FOREIGN KEY (locationto_id) REFERENCES public.materialflow_location(id) DEFERRABLE;


--
-- Name: basic_staff basic_company_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.basic_staff
    ADD CONSTRAINT basic_company_fkey FOREIGN KEY (workfor_id) REFERENCES public.basic_company(id) DEFERRABLE;


--
-- Name: masterorders_masterorder basic_company_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.masterorders_masterorder
    ADD CONSTRAINT basic_company_fkey FOREIGN KEY (companypayer_id) REFERENCES public.basic_company(id) DEFERRABLE;


--
-- Name: basic_parameter basic_parameter_attribute_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.basic_parameter
    ADD CONSTRAINT basic_parameter_attribute_fkey FOREIGN KEY (terminalproductattribute_id) REFERENCES public.basic_attribute(id) DEFERRABLE;


--
-- Name: basic_parameter basic_parameter_defaultproductionline_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.basic_parameter
    ADD CONSTRAINT basic_parameter_defaultproductionline_fkey FOREIGN KEY (defaultproductionline_id) REFERENCES public.productionlines_productionline(id) DEFERRABLE;


--
-- Name: basic_reportcolumnwidth basic_parameter_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.basic_reportcolumnwidth
    ADD CONSTRAINT basic_parameter_fkey FOREIGN KEY (parameter_id) REFERENCES public.basic_parameter(id) DEFERRABLE;


--
-- Name: materialflowresources_costnormslocation basic_parameter_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.materialflowresources_costnormslocation
    ADD CONSTRAINT basic_parameter_fkey FOREIGN KEY (parameter_id) REFERENCES public.basic_parameter(id) DEFERRABLE;


--
-- Name: goodfood_confectionprotocol basic_product_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.goodfood_confectionprotocol
    ADD CONSTRAINT basic_product_fkey FOREIGN KEY (filmproduct_id) REFERENCES public.basic_product(id) DEFERRABLE;


--
-- Name: goodfood_confectioninputproduct basic_product_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.goodfood_confectioninputproduct
    ADD CONSTRAINT basic_product_fkey FOREIGN KEY (product_id) REFERENCES public.basic_product(id) DEFERRABLE;


--
-- Name: goodfood_confectionremainderinputproduct basic_product_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.goodfood_confectionremainderinputproduct
    ADD CONSTRAINT basic_product_fkey FOREIGN KEY (product_id) REFERENCES public.basic_product(id) DEFERRABLE;


--
-- Name: basic_product basic_product_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.basic_product
    ADD CONSTRAINT basic_product_fkey FOREIGN KEY (parent_id) REFERENCES public.basic_product(id) DEFERRABLE;


--
-- Name: basic_product basic_product_technologygroup_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.basic_product
    ADD CONSTRAINT basic_product_technologygroup_fkey FOREIGN KEY (technologygroup_id) REFERENCES public.technologies_technologygroup(id) DEFERRABLE;


--
-- Name: jointable_product_warehouseminimumstatemulti basic_product_warehouseminimumstatemulti_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.jointable_product_warehouseminimumstatemulti
    ADD CONSTRAINT basic_product_warehouseminimumstatemulti_fkey FOREIGN KEY (product_id) REFERENCES public.basic_product(id) DEFERRABLE;


--
-- Name: goodfood_confectioncontext basic_shift_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.goodfood_confectioncontext
    ADD CONSTRAINT basic_shift_fkey FOREIGN KEY (shift_id) REFERENCES public.basic_shift(id) DEFERRABLE;


--
-- Name: goodfood_extrusioncontext basic_shift_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.goodfood_extrusioncontext
    ADD CONSTRAINT basic_shift_fkey FOREIGN KEY (shift_id) REFERENCES public.basic_shift(id) DEFERRABLE;


--
-- Name: advancedgenealogy_batchstatechange basic_shift_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.advancedgenealogy_batchstatechange
    ADD CONSTRAINT basic_shift_fkey FOREIGN KEY (shift_id) REFERENCES public.basic_shift(id) DEFERRABLE;


--
-- Name: advancedgenealogy_trackingrecordstatechange basic_shift_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.advancedgenealogy_trackingrecordstatechange
    ADD CONSTRAINT basic_shift_fkey FOREIGN KEY (shift_id) REFERENCES public.basic_shift(id) DEFERRABLE;


--
-- Name: assignmenttoshift_assignmenttoshift basic_shift_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.assignmenttoshift_assignmenttoshift
    ADD CONSTRAINT basic_shift_fkey FOREIGN KEY (shift_id) REFERENCES public.basic_shift(id) DEFERRABLE;


--
-- Name: assignmenttoshift_assignmenttoshiftstatechange basic_shift_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.assignmenttoshift_assignmenttoshiftstatechange
    ADD CONSTRAINT basic_shift_fkey FOREIGN KEY (shift_id) REFERENCES public.basic_shift(id) DEFERRABLE;


--
-- Name: productioncounting_productiontrackingstatechange basic_shift_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.productioncounting_productiontrackingstatechange
    ADD CONSTRAINT basic_shift_fkey FOREIGN KEY (shift_id) REFERENCES public.basic_shift(id) DEFERRABLE;


--
-- Name: basic_staff basic_staff_division_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.basic_staff
    ADD CONSTRAINT basic_staff_division_fkey FOREIGN KEY (division_id) REFERENCES public.basic_division(id) DEFERRABLE;


--
-- Name: goodfood_confectionstaff basic_staff_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.goodfood_confectionstaff
    ADD CONSTRAINT basic_staff_fkey FOREIGN KEY (worker_id) REFERENCES public.basic_staff(id) DEFERRABLE;


--
-- Name: goodfood_extrusionsouse basic_staff_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.goodfood_extrusionsouse
    ADD CONSTRAINT basic_staff_fkey FOREIGN KEY (worker_id) REFERENCES public.basic_staff(id) DEFERRABLE;


--
-- Name: assignmenttoshift_staffassignmenttoshift basic_staff_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.assignmenttoshift_staffassignmenttoshift
    ADD CONSTRAINT basic_staff_fkey FOREIGN KEY (worker_id) REFERENCES public.basic_staff(id) DEFERRABLE;


--
-- Name: avglaborcostcalcfororder_assignmentworkertoshift basic_staff_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.avglaborcostcalcfororder_assignmentworkertoshift
    ADD CONSTRAINT basic_staff_fkey FOREIGN KEY (worker_id) REFERENCES public.basic_staff(id) DEFERRABLE;


--
-- Name: basic_staff basic_staff_workstation_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.basic_staff
    ADD CONSTRAINT basic_staff_workstation_fkey FOREIGN KEY (workstation_id) REFERENCES public.basic_workstation(id) DEFERRABLE;


--
-- Name: basicproductioncounting_basicproductioncounting basicproductioncounting_order_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.basicproductioncounting_basicproductioncounting
    ADD CONSTRAINT basicproductioncounting_order_fkey FOREIGN KEY (order_id) REFERENCES public.orders_order(id) DEFERRABLE;


--
-- Name: basicproductioncounting_basicproductioncounting basicproductioncounting_product_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.basicproductioncounting_basicproductioncounting
    ADD CONSTRAINT basicproductioncounting_product_fkey FOREIGN KEY (product_id) REFERENCES public.basic_product(id) DEFERRABLE;


--
-- Name: advancedgenealogy_batch batch_product_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.advancedgenealogy_batch
    ADD CONSTRAINT batch_product_fkey FOREIGN KEY (product_id) REFERENCES public.basic_product(id) DEFERRABLE;


--
-- Name: jointable_batch_productioncountingquantity batch_productioncountingquantity_batch; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.jointable_batch_productioncountingquantity
    ADD CONSTRAINT batch_productioncountingquantity_batch FOREIGN KEY (batch_id) REFERENCES public.advancedgenealogy_batch(id) DEFERRABLE;


--
-- Name: jointable_batch_productioncountingquantity batch_productioncountingquantity_productioncountingquantity; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.jointable_batch_productioncountingquantity
    ADD CONSTRAINT batch_productioncountingquantity_productioncountingquantity FOREIGN KEY (productioncountingquantity_id) REFERENCES public.basicproductioncounting_productioncountingquantity(id) DEFERRABLE;


--
-- Name: advancedgenealogy_batch batch_supplier_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.advancedgenealogy_batch
    ADD CONSTRAINT batch_supplier_fkey FOREIGN KEY (supplier_id) REFERENCES public.basic_company(id) DEFERRABLE;


--
-- Name: advancedgenealogy_batchattachment batchattachment_batch_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.advancedgenealogy_batchattachment
    ADD CONSTRAINT batchattachment_batch_fkey FOREIGN KEY (batch_id) REFERENCES public.advancedgenealogy_batch(id) DEFERRABLE;


--
-- Name: advancedgenealogy_batchstatechange batchstatechange_batch_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.advancedgenealogy_batchstatechange
    ADD CONSTRAINT batchstatechange_batch_fkey FOREIGN KEY (batch_id) REFERENCES public.advancedgenealogy_batch(id) DEFERRABLE;


--
-- Name: costnormsforoperation_calculationoperationcomponent calculationoperationcomponent_costcalculation_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.costnormsforoperation_calculationoperationcomponent
    ADD CONSTRAINT calculationoperationcomponent_costcalculation_fkey FOREIGN KEY (costcalculation_id) REFERENCES public.costcalculation_costcalculation(id) DEFERRABLE;


--
-- Name: costnormsforoperation_calculationoperationcomponent calculationoperationcomponent_operation_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.costnormsforoperation_calculationoperationcomponent
    ADD CONSTRAINT calculationoperationcomponent_operation_fkey FOREIGN KEY (operation_id) REFERENCES public.technologies_operation(id) DEFERRABLE;


--
-- Name: costnormsforoperation_calculationoperationcomponent calculationoperationcomponent_parent_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.costnormsforoperation_calculationoperationcomponent
    ADD CONSTRAINT calculationoperationcomponent_parent_fkey FOREIGN KEY (parent_id) REFERENCES public.costnormsforoperation_calculationoperationcomponent(id) DEFERRABLE;


--
-- Name: costnormsforoperation_calculationoperationcomponent calculationoperationcomponent_technologyoperationcomponent_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.costnormsforoperation_calculationoperationcomponent
    ADD CONSTRAINT calculationoperationcomponent_technologyoperationcomponent_fkey FOREIGN KEY (technologyoperationcomponent_id) REFERENCES public.technologies_technologyoperationcomponent(id) DEFERRABLE;


--
-- Name: costcalculation_calculationresult calculationresult_costcalculation_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.costcalculation_calculationresult
    ADD CONSTRAINT calculationresult_costcalculation_fkey FOREIGN KEY (costcalculation_id) REFERENCES public.costcalculation_costcalculation(id) DEFERRABLE;


--
-- Name: costcalculation_calculationresult calculationresult_product_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.costcalculation_calculationresult
    ADD CONSTRAINT calculationresult_product_fkey FOREIGN KEY (product_id) REFERENCES public.basic_product(id) DEFERRABLE;


--
-- Name: costcalculation_calculationresult calculationresult_technology_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.costcalculation_calculationresult
    ADD CONSTRAINT calculationresult_technology_fkey FOREIGN KEY (technology_id) REFERENCES public.technologies_technology(id) DEFERRABLE;


--
-- Name: qualitycontrol_changequalitycards changequalitycards_qualitycard_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.qualitycontrol_changequalitycards
    ADD CONSTRAINT changequalitycards_qualitycard_fkey FOREIGN KEY (qualitycard_id) REFERENCES public.basic_qualitycard(id) DEFERRABLE;


--
-- Name: technologies_changetechnologyparameters changetechnologyparameters_technologygroup_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.technologies_changetechnologyparameters
    ADD CONSTRAINT changetechnologyparameters_technologygroup_fkey FOREIGN KEY (technologygroup_id) REFERENCES public.technologies_technologygroup(id) DEFERRABLE;


--
-- Name: deliveries_columnfordeliveries columnfordeliveries_parameter_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.deliveries_columnfordeliveries
    ADD CONSTRAINT columnfordeliveries_parameter_fkey FOREIGN KEY (parameter_id) REFERENCES public.basic_parameter(id) DEFERRABLE;


--
-- Name: supplynegotiations_columnforoffers columnforoffers_parameter_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.supplynegotiations_columnforoffers
    ADD CONSTRAINT columnforoffers_parameter_fkey FOREIGN KEY (parameter_id) REFERENCES public.basic_parameter(id) DEFERRABLE;


--
-- Name: deliveries_columnfororders columnfororders_parameter_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.deliveries_columnfororders
    ADD CONSTRAINT columnfororders_parameter_fkey FOREIGN KEY (parameter_id) REFERENCES public.basic_parameter(id) DEFERRABLE;


--
-- Name: supplynegotiations_columnforrequests columnforrequests_parameter_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.supplynegotiations_columnforrequests
    ADD CONSTRAINT columnforrequests_parameter_fkey FOREIGN KEY (parameter_id) REFERENCES public.basic_parameter(id) DEFERRABLE;


--
-- Name: orders_order company_company_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.orders_order
    ADD CONSTRAINT company_company_fkey FOREIGN KEY (company_id) REFERENCES public.basic_company(id) DEFERRABLE;


--
-- Name: basic_company company_country_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.basic_company
    ADD CONSTRAINT company_country_fkey FOREIGN KEY (country_id) REFERENCES public.basic_country(id) DEFERRABLE;


--
-- Name: basic_company company_currency_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.basic_company
    ADD CONSTRAINT company_currency_fkey FOREIGN KEY (currency_id) REFERENCES public.basic_currency(id) DEFERRABLE;


--
-- Name: jointable_company_negotiation company_negotiation_company_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.jointable_company_negotiation
    ADD CONSTRAINT company_negotiation_company_fkey FOREIGN KEY (company_id) REFERENCES public.basic_company(id) DEFERRABLE;


--
-- Name: jointable_company_negotiation company_negotiation_negotiation_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.jointable_company_negotiation
    ADD CONSTRAINT company_negotiation_negotiation_fkey FOREIGN KEY (negotiation_id) REFERENCES public.supplynegotiations_negotiation(id) DEFERRABLE;


--
-- Name: basic_company company_taxtcountrycode_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.basic_company
    ADD CONSTRAINT company_taxtcountrycode_fkey FOREIGN KEY (taxcountrycode_id) REFERENCES public.basic_country(id) DEFERRABLE;


--
-- Name: techsubcontracting_companyoperation companyoperation_company_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.techsubcontracting_companyoperation
    ADD CONSTRAINT companyoperation_company_fkey FOREIGN KEY (company_id) REFERENCES public.basic_company(id) DEFERRABLE;


--
-- Name: techsubcontracting_companyoperation companyoperation_operation_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.techsubcontracting_companyoperation
    ADD CONSTRAINT companyoperation_operation_fkey FOREIGN KEY (operation_id) REFERENCES public.technologies_operation(id) DEFERRABLE;


--
-- Name: techsubcontracting_companyoperationgroup companyoperationgroup_company_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.techsubcontracting_companyoperationgroup
    ADD CONSTRAINT companyoperationgroup_company_fkey FOREIGN KEY (company_id) REFERENCES public.basic_company(id) DEFERRABLE;


--
-- Name: techsubcontracting_companyoperationgroup companyoperationgroup_operationgroup_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.techsubcontracting_companyoperationgroup
    ADD CONSTRAINT companyoperationgroup_operationgroup_fkey FOREIGN KEY (operationgroup_id) REFERENCES public.technologies_operationgroup(id) DEFERRABLE;


--
-- Name: deliveries_companyproduct companyproduct_company_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.deliveries_companyproduct
    ADD CONSTRAINT companyproduct_company_fkey FOREIGN KEY (company_id) REFERENCES public.basic_company(id) DEFERRABLE;


--
-- Name: deliveries_companyproduct companyproduct_product_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.deliveries_companyproduct
    ADD CONSTRAINT companyproduct_product_fkey FOREIGN KEY (product_id) REFERENCES public.basic_product(id) DEFERRABLE;


--
-- Name: costcalculation_componentcost componentcost_costcalculation_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.costcalculation_componentcost
    ADD CONSTRAINT componentcost_costcalculation_fkey FOREIGN KEY (costcalculation_id) REFERENCES public.costcalculation_costcalculation(id) DEFERRABLE;


--
-- Name: costcalculation_componentcost componentcost_product_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.costcalculation_componentcost
    ADD CONSTRAINT componentcost_product_fkey FOREIGN KEY (product_id) REFERENCES public.basic_product(id) DEFERRABLE;


--
-- Name: goodfood_confectionadditionalinputproduct confectionadditionalinputproduct_batch_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.goodfood_confectionadditionalinputproduct
    ADD CONSTRAINT confectionadditionalinputproduct_batch_fkey FOREIGN KEY (batch_id) REFERENCES public.advancedgenealogy_batch(id) DEFERRABLE;


--
-- Name: goodfood_confectionadditionalinputproduct confectionadditionalinputproduct_confectionprotocol_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.goodfood_confectionadditionalinputproduct
    ADD CONSTRAINT confectionadditionalinputproduct_confectionprotocol_fkey FOREIGN KEY (confectionprotocol_id) REFERENCES public.goodfood_confectionprotocol(id) DEFERRABLE;


--
-- Name: goodfood_confectionadditionalinputproduct confectionadditionalinputproduct_product_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.goodfood_confectionadditionalinputproduct
    ADD CONSTRAINT confectionadditionalinputproduct_product_fkey FOREIGN KEY (product_id) REFERENCES public.basic_product(id) DEFERRABLE;


--
-- Name: goodfood_confectioncontext confectioncontext_operator_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.goodfood_confectioncontext
    ADD CONSTRAINT confectioncontext_operator_fkey FOREIGN KEY (operator_id) REFERENCES public.basic_staff(id) DEFERRABLE;


--
-- Name: goodfood_confectionfilmproduct confectionfilmproduct_confectionprotocol_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.goodfood_confectionfilmproduct
    ADD CONSTRAINT confectionfilmproduct_confectionprotocol_fkey FOREIGN KEY (confectionprotocol_id) REFERENCES public.goodfood_confectionprotocol(id) DEFERRABLE;


--
-- Name: goodfood_confectionfilmproductentry confectionfilmproductentry_batch_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.goodfood_confectionfilmproductentry
    ADD CONSTRAINT confectionfilmproductentry_batch_fkey FOREIGN KEY (batch_id) REFERENCES public.advancedgenealogy_batch(id) DEFERRABLE;


--
-- Name: goodfood_confectionfilmproductentry confectionfilmproductentry_confectionfilmproduct_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.goodfood_confectionfilmproductentry
    ADD CONSTRAINT confectionfilmproductentry_confectionfilmproduct_fkey FOREIGN KEY (confectionfilmproduct_id) REFERENCES public.goodfood_confectionfilmproduct(id) DEFERRABLE;


--
-- Name: goodfood_confectionprotocol confectionprotocol_additionalfilmproduct_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.goodfood_confectionprotocol
    ADD CONSTRAINT confectionprotocol_additionalfilmproduct_fkey FOREIGN KEY (additionalfilmproduct_id) REFERENCES public.basic_product(id) DEFERRABLE;


--
-- Name: goodfood_confectionfilmproduct confectionprotocol_filmproduct_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.goodfood_confectionfilmproduct
    ADD CONSTRAINT confectionprotocol_filmproduct_fkey FOREIGN KEY (filmproduct_id) REFERENCES public.basic_product(id) DEFERRABLE;


--
-- Name: goodfood_confectionprotocolcorrect confectionprotocolcorrect_confectionprotocol_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.goodfood_confectionprotocolcorrect
    ADD CONSTRAINT confectionprotocolcorrect_confectionprotocol_fkey FOREIGN KEY (confectionprotocol_id) REFERENCES public.goodfood_confectionprotocol(id) DEFERRABLE;


--
-- Name: goodfood_confectionprotocolstatechange confectionprotocolstatechange_confectionprotocol_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.goodfood_confectionprotocolstatechange
    ADD CONSTRAINT confectionprotocolstatechange_confectionprotocol_fkey FOREIGN KEY (confectionprotocol_id) REFERENCES public.goodfood_confectionprotocol(id) DEFERRABLE;


--
-- Name: goodfood_confectionprotocolstatechange confectionprotocolstatechange_shift_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.goodfood_confectionprotocolstatechange
    ADD CONSTRAINT confectionprotocolstatechange_shift_fkey FOREIGN KEY (shift_id) REFERENCES public.basic_shift(id) DEFERRABLE;


--
-- Name: subcontractorportal_subordercost cost_product_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.subcontractorportal_subordercost
    ADD CONSTRAINT cost_product_fkey FOREIGN KEY (product_id) REFERENCES public.basic_product(id) DEFERRABLE;


--
-- Name: subcontractorportal_subordercost cost_suborder_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.subcontractorportal_subordercost
    ADD CONSTRAINT cost_suborder_fkey FOREIGN KEY (suborder_id) REFERENCES public.subcontractorportal_suborder(id) DEFERRABLE;


--
-- Name: costcalculation_costcalculation costcalculation_offer_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.costcalculation_costcalculation
    ADD CONSTRAINT costcalculation_offer_fkey FOREIGN KEY (offer_id) REFERENCES public.supplynegotiations_offer(id) DEFERRABLE;


--
-- Name: costcalculation_costcalculation costcalculation_standardlaborcost_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.costcalculation_costcalculation
    ADD CONSTRAINT costcalculation_standardlaborcost_fkey FOREIGN KEY (standardlaborcost_id) REFERENCES public.costcalculation_standardlaborcost(id) DEFERRABLE;


--
-- Name: jointable_costcalculation_technology costcalculation_technology_costcalculation_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.jointable_costcalculation_technology
    ADD CONSTRAINT costcalculation_technology_costcalculation_fkey FOREIGN KEY (costcalculation_id) REFERENCES public.costcalculation_costcalculation(id) DEFERRABLE;


--
-- Name: jointable_costcalculation_technology costcalculation_technology_technology_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.jointable_costcalculation_technology
    ADD CONSTRAINT costcalculation_technology_technology_fkey FOREIGN KEY (technology_id) REFERENCES public.technologies_technology(id) DEFERRABLE;


--
-- Name: costnormsformaterials_technologyinstoperproductincomp costnormsforproduct_orderoperationproductincomponent_o_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.costnormsformaterials_technologyinstoperproductincomp
    ADD CONSTRAINT costnormsforproduct_orderoperationproductincomponent_o_fkey FOREIGN KEY (order_id) REFERENCES public.orders_order(id) DEFERRABLE;


--
-- Name: costnormsformaterials_technologyinstoperproductincomp costnormsforproduct_orderoperationproductincomponent_p_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.costnormsformaterials_technologyinstoperproductincomp
    ADD CONSTRAINT costnormsforproduct_orderoperationproductincomponent_p_fkey FOREIGN KEY (product_id) REFERENCES public.basic_product(id) DEFERRABLE;


--
-- Name: materialflowresources_costnormslocation costnormslocation_costnormsgenerator_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.materialflowresources_costnormslocation
    ADD CONSTRAINT costnormslocation_costnormsgenerator_fkey FOREIGN KEY (costnormsgenerator_id) REFERENCES public.materialflowresources_costnormsgenerator(id) DEFERRABLE;


--
-- Name: materialflowresources_costnormslocation costnormslocation_location_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.materialflowresources_costnormslocation
    ADD CONSTRAINT costnormslocation_location_fkey FOREIGN KEY (location_id) REFERENCES public.materialflow_location(id) DEFERRABLE;


--
-- Name: ordersupplies_coverageanalysisfororder coverageanalysisfororder_materialrequirementcoverage_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.ordersupplies_coverageanalysisfororder
    ADD CONSTRAINT coverageanalysisfororder_materialrequirementcoverage_fkey FOREIGN KEY (materialrequirementcoverage_id) REFERENCES public.ordersupplies_materialrequirementcoverage(id) DEFERRABLE;


--
-- Name: ordersupplies_coverageanalysisfororder coverageanalysisfororder_order_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.ordersupplies_coverageanalysisfororder
    ADD CONSTRAINT coverageanalysisfororder_order_fkey FOREIGN KEY (order_id) REFERENCES public.orders_order(id) DEFERRABLE;


--
-- Name: ordersupplies_coverageanalysisfororder coverageanalysisfororder_orderedproduct_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.ordersupplies_coverageanalysisfororder
    ADD CONSTRAINT coverageanalysisfororder_orderedproduct_fkey FOREIGN KEY (orderedproduct_id) REFERENCES public.basic_product(id) DEFERRABLE;


--
-- Name: materialrequirementcoveragefororder_coveragelocation coveragelocation_coveragefororder_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.materialrequirementcoveragefororder_coveragelocation
    ADD CONSTRAINT coveragelocation_coveragefororder_fkey FOREIGN KEY (coveragefororder_id) REFERENCES public.materialrequirementcoveragefororder_coveragefororder(id) DEFERRABLE;


--
-- Name: ordersupplies_coveragelocation coveragelocation_location_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.ordersupplies_coveragelocation
    ADD CONSTRAINT coveragelocation_location_fkey FOREIGN KEY (location_id) REFERENCES public.materialflow_location(id) DEFERRABLE;


--
-- Name: materialrequirementcoveragefororder_coveragelocation coveragelocation_location_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.materialrequirementcoveragefororder_coveragelocation
    ADD CONSTRAINT coveragelocation_location_fkey FOREIGN KEY (location_id) REFERENCES public.materialflow_location(id) DEFERRABLE;


--
-- Name: ordersupplies_coveragelocation coveragelocation_materialrequirementcoverage_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.ordersupplies_coveragelocation
    ADD CONSTRAINT coveragelocation_materialrequirementcoverage_fkey FOREIGN KEY (materialrequirementcoverage_id) REFERENCES public.ordersupplies_materialrequirementcoverage(id) DEFERRABLE;


--
-- Name: ordersupplies_coveragelocation coveragelocation_parameter_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.ordersupplies_coveragelocation
    ADD CONSTRAINT coveragelocation_parameter_fkey FOREIGN KEY (parameter_id) REFERENCES public.basic_parameter(id) DEFERRABLE;


--
-- Name: materialrequirementcoveragefororder_coveragelocation coveragelocation_parameter_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.materialrequirementcoveragefororder_coveragelocation
    ADD CONSTRAINT coveragelocation_parameter_fkey FOREIGN KEY (parameter_id) REFERENCES public.basic_parameter(id) DEFERRABLE;


--
-- Name: ordersupplies_coverageorderstate coverageorderstate_materialrequirementcoverage_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.ordersupplies_coverageorderstate
    ADD CONSTRAINT coverageorderstate_materialrequirementcoverage_fkey FOREIGN KEY (materialrequirementcoverage_id) REFERENCES public.ordersupplies_materialrequirementcoverage(id) DEFERRABLE;


--
-- Name: ordersupplies_coverageorderstate coverageorderstate_parameter_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.ordersupplies_coverageorderstate
    ADD CONSTRAINT coverageorderstate_parameter_fkey FOREIGN KEY (parameter_id) REFERENCES public.basic_parameter(id) DEFERRABLE;


--
-- Name: ordersupplies_coverageproduct coverageproduct_company_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.ordersupplies_coverageproduct
    ADD CONSTRAINT coverageproduct_company_fkey FOREIGN KEY (company_id) REFERENCES public.basic_company(id) DEFERRABLE;


--
-- Name: materialrequirementcoveragefororder_coverageproduct coverageproduct_coveragefororder_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.materialrequirementcoveragefororder_coverageproduct
    ADD CONSTRAINT coverageproduct_coveragefororder_fkey FOREIGN KEY (coveragefororder_id) REFERENCES public.materialrequirementcoveragefororder_coveragefororder(id) DEFERRABLE;


--
-- Name: ordersupplies_coverageproduct coverageproduct_materialrequirementcoverage_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.ordersupplies_coverageproduct
    ADD CONSTRAINT coverageproduct_materialrequirementcoverage_fkey FOREIGN KEY (materialrequirementcoverage_id) REFERENCES public.ordersupplies_materialrequirementcoverage(id) DEFERRABLE;


--
-- Name: materialrequirementcoveragefororder_coverageproduct coverageproduct_order_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.materialrequirementcoveragefororder_coverageproduct
    ADD CONSTRAINT coverageproduct_order_fkey FOREIGN KEY (order_id) REFERENCES public.orders_order(id) DEFERRABLE;


--
-- Name: ordersupplies_coverageproduct coverageproduct_product_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.ordersupplies_coverageproduct
    ADD CONSTRAINT coverageproduct_product_fkey FOREIGN KEY (product_id) REFERENCES public.basic_product(id) DEFERRABLE;


--
-- Name: materialrequirementcoveragefororder_coverageproduct coverageproduct_product_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.materialrequirementcoveragefororder_coverageproduct
    ADD CONSTRAINT coverageproduct_product_fkey FOREIGN KEY (product_id) REFERENCES public.basic_product(id) DEFERRABLE;


--
-- Name: materialrequirementcoveragefororder_coverageproductlogging coverageproductlogging_coverageproduct_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.materialrequirementcoveragefororder_coverageproductlogging
    ADD CONSTRAINT coverageproductlogging_coverageproduct_fkey FOREIGN KEY (coverageproduct_id) REFERENCES public.materialrequirementcoveragefororder_coverageproduct(id) DEFERRABLE;


--
-- Name: ordersupplies_coverageproductlogging coverageproductlogging_coverageproduct_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.ordersupplies_coverageproductlogging
    ADD CONSTRAINT coverageproductlogging_coverageproduct_fkey FOREIGN KEY (coverageproduct_id) REFERENCES public.ordersupplies_coverageproduct(id) DEFERRABLE;


--
-- Name: materialrequirementcoveragefororder_coverageproductlogging coverageproductlogging_delivery_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.materialrequirementcoveragefororder_coverageproductlogging
    ADD CONSTRAINT coverageproductlogging_delivery_fkey FOREIGN KEY (delivery_id) REFERENCES public.deliveries_delivery(id) DEFERRABLE;


--
-- Name: ordersupplies_coverageproductlogging coverageproductlogging_delivery_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.ordersupplies_coverageproductlogging
    ADD CONSTRAINT coverageproductlogging_delivery_fkey FOREIGN KEY (delivery_id) REFERENCES public.deliveries_delivery(id) DEFERRABLE;


--
-- Name: ordersupplies_coverageproductlogging coverageproductlogging_operation_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.ordersupplies_coverageproductlogging
    ADD CONSTRAINT coverageproductlogging_operation_fkey FOREIGN KEY (operation_id) REFERENCES public.technologies_operation(id) DEFERRABLE;


--
-- Name: materialrequirementcoveragefororder_coverageproductlogging coverageproductlogging_operation_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.materialrequirementcoveragefororder_coverageproductlogging
    ADD CONSTRAINT coverageproductlogging_operation_fkey FOREIGN KEY (operation_id) REFERENCES public.technologies_operation(id) DEFERRABLE;


--
-- Name: ordersupplies_coverageproductlogging coverageproductlogging_order_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.ordersupplies_coverageproductlogging
    ADD CONSTRAINT coverageproductlogging_order_fkey FOREIGN KEY (order_id) REFERENCES public.orders_order(id) DEFERRABLE;


--
-- Name: materialrequirementcoveragefororder_coverageproductlogging coverageproductlogging_order_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.materialrequirementcoveragefororder_coverageproductlogging
    ADD CONSTRAINT coverageproductlogging_order_fkey FOREIGN KEY (order_id) REFERENCES public.orders_order(id) DEFERRABLE;


--
-- Name: ordersupplies_coverageproductlogging coverageproductlogging_subcontractedoperation_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.ordersupplies_coverageproductlogging
    ADD CONSTRAINT coverageproductlogging_subcontractedoperation_fkey FOREIGN KEY (subcontractedoperation_id) REFERENCES public.technologies_operation(id) DEFERRABLE;


--
-- Name: materialrequirementcoveragefororder_coverageproductlogging coverageproductlogging_subcontractedoperation_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.materialrequirementcoveragefororder_coverageproductlogging
    ADD CONSTRAINT coverageproductlogging_subcontractedoperation_fkey FOREIGN KEY (subcontractedoperation_id) REFERENCES public.technologies_operation(id) DEFERRABLE;


--
-- Name: ordersupplies_coverageproductselected coverageproductselected_coverageproduct_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.ordersupplies_coverageproductselected
    ADD CONSTRAINT coverageproductselected_coverageproduct_fkey FOREIGN KEY (coverageproduct_id) REFERENCES public.ordersupplies_coverageproduct(id) DEFERRABLE;


--
-- Name: basic_crew crew_staff_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.basic_crew
    ADD CONSTRAINT crew_staff_fkey FOREIGN KEY (leader_id) REFERENCES public.basic_staff(id) DEFERRABLE;


--
-- Name: productionpershift_dailyprogress dailyprogress_progressforday_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.productionpershift_dailyprogress
    ADD CONSTRAINT dailyprogress_progressforday_fkey FOREIGN KEY (progressforday_id) REFERENCES public.productionpershift_progressforday(id) DEFERRABLE;


--
-- Name: productionpershift_dailyprogress dailyprogress_shift_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.productionpershift_dailyprogress
    ADD CONSTRAINT dailyprogress_shift_fkey FOREIGN KEY (shift_id) REFERENCES public.basic_shift(id) DEFERRABLE;


--
-- Name: basic_dashboardbutton dashboardbutton_item_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.basic_dashboardbutton
    ADD CONSTRAINT dashboardbutton_item_fkey FOREIGN KEY (item_id) REFERENCES public.qcadooview_item(id) DEFERRABLE;


--
-- Name: basic_dashboardbutton dashboardbutton_parameter_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.basic_dashboardbutton
    ADD CONSTRAINT dashboardbutton_parameter_fkey FOREIGN KEY (parameter_id) REFERENCES public.basic_parameter(id) DEFERRABLE;


--
-- Name: deliveries_deliveredpackage deliveredpackage_delivery_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.deliveries_deliveredpackage
    ADD CONSTRAINT deliveredpackage_delivery_fkey FOREIGN KEY (delivery_id) REFERENCES public.deliveries_delivery(id) DEFERRABLE;


--
-- Name: deliveries_deliveredpackage deliveredpackage_product_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.deliveries_deliveredpackage
    ADD CONSTRAINT deliveredpackage_product_fkey FOREIGN KEY (product_id) REFERENCES public.basic_product(id) DEFERRABLE;


--
-- Name: deliveries_deliveredproduct deliveredproduct_batch_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.deliveries_deliveredproduct
    ADD CONSTRAINT deliveredproduct_batch_fkey FOREIGN KEY (batch_id) REFERENCES public.advancedgenealogy_batch(id) DEFERRABLE;


--
-- Name: deliveries_deliveredproduct deliveredproduct_delivery_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.deliveries_deliveredproduct
    ADD CONSTRAINT deliveredproduct_delivery_fkey FOREIGN KEY (delivery_id) REFERENCES public.deliveries_delivery(id) DEFERRABLE;


--
-- Name: deliveries_orderedproduct deliveredproduct_offer_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.deliveries_orderedproduct
    ADD CONSTRAINT deliveredproduct_offer_fkey FOREIGN KEY (offer_id) REFERENCES public.supplynegotiations_offer(id) DEFERRABLE;


--
-- Name: deliveries_deliveredproduct deliveredproduct_operation_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.deliveries_deliveredproduct
    ADD CONSTRAINT deliveredproduct_operation_fkey FOREIGN KEY (operation_id) REFERENCES public.technologies_operation(id) DEFERRABLE;


--
-- Name: deliveries_deliveredproduct deliveredproduct_orderedproduct_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.deliveries_deliveredproduct
    ADD CONSTRAINT deliveredproduct_orderedproduct_fkey FOREIGN KEY (orderedproduct_id) REFERENCES public.deliveries_orderedproduct(id) DEFERRABLE;


--
-- Name: deliveries_deliveredproduct deliveredproduct_palletnumber_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.deliveries_deliveredproduct
    ADD CONSTRAINT deliveredproduct_palletnumber_fkey FOREIGN KEY (palletnumber_id) REFERENCES public.basic_palletnumber(id) DEFERRABLE;


--
-- Name: deliveries_deliveredproduct deliveredproduct_product_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.deliveries_deliveredproduct
    ADD CONSTRAINT deliveredproduct_product_fkey FOREIGN KEY (product_id) REFERENCES public.basic_product(id) DEFERRABLE;


--
-- Name: deliveries_deliveredproduct deliveredproduct_storagelocation_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.deliveries_deliveredproduct
    ADD CONSTRAINT deliveredproduct_storagelocation_fkey FOREIGN KEY (storagelocation_id) REFERENCES public.materialflowresources_storagelocation(id) DEFERRABLE;


--
-- Name: deliveries_deliveredproductattributeval deliveredproductattributeval_attribute_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.deliveries_deliveredproductattributeval
    ADD CONSTRAINT deliveredproductattributeval_attribute_fkey FOREIGN KEY (attribute_id) REFERENCES public.basic_attribute(id) DEFERRABLE;


--
-- Name: deliveries_deliveredproductattributeval deliveredproductattributeval_attributevalue_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.deliveries_deliveredproductattributeval
    ADD CONSTRAINT deliveredproductattributeval_attributevalue_fkey FOREIGN KEY (attributevalue_id) REFERENCES public.basic_attributevalue(id) DEFERRABLE;


--
-- Name: deliveries_deliveredproductattributeval deliveredproductattributeval_deliveredproduct_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.deliveries_deliveredproductattributeval
    ADD CONSTRAINT deliveredproductattributeval_deliveredproduct_fkey FOREIGN KEY (deliveredproduct_id) REFERENCES public.deliveries_deliveredproduct(id) DEFERRABLE;


--
-- Name: deliveries_deliveredproductmultiposition deliveredproductmp_deliveredproductmulti_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.deliveries_deliveredproductmultiposition
    ADD CONSTRAINT deliveredproductmp_deliveredproductmulti_fkey FOREIGN KEY (deliveredproductmulti_id) REFERENCES public.deliveries_deliveredproductmulti(id) DEFERRABLE;


--
-- Name: deliveries_deliveredproductmultiposition deliveredproductmp_product_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.deliveries_deliveredproductmultiposition
    ADD CONSTRAINT deliveredproductmp_product_fkey FOREIGN KEY (product_id) REFERENCES public.basic_product(id) DEFERRABLE;


--
-- Name: deliveries_deliveredproductmulti deliveredproductmulti_delivery_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.deliveries_deliveredproductmulti
    ADD CONSTRAINT deliveredproductmulti_delivery_fkey FOREIGN KEY (delivery_id) REFERENCES public.deliveries_delivery(id) DEFERRABLE;


--
-- Name: deliveries_deliveredproductmulti deliveredproductmulti_palletnumber_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.deliveries_deliveredproductmulti
    ADD CONSTRAINT deliveredproductmulti_palletnumber_fkey FOREIGN KEY (palletnumber_id) REFERENCES public.basic_palletnumber(id) DEFERRABLE;


--
-- Name: deliveries_deliveredproductmulti deliveredproductmulti_storagelocation_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.deliveries_deliveredproductmulti
    ADD CONSTRAINT deliveredproductmulti_storagelocation_fkey FOREIGN KEY (storagelocation_id) REFERENCES public.materialflowresources_storagelocation(id) DEFERRABLE;


--
-- Name: deliveries_deliveredproductmultiposition deliveredproductmultiposition_batch_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.deliveries_deliveredproductmultiposition
    ADD CONSTRAINT deliveredproductmultiposition_batch_fkey FOREIGN KEY (batch_id) REFERENCES public.advancedgenealogy_batch(id) DEFERRABLE;


--
-- Name: deliveries_deliveredproductmultiposition deliveredproductmultiposition_offer_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.deliveries_deliveredproductmultiposition
    ADD CONSTRAINT deliveredproductmultiposition_offer_fkey FOREIGN KEY (offer_id) REFERENCES public.supplynegotiations_offer(id) DEFERRABLE;


--
-- Name: deliveries_delivery deliveries_delivery_salesplan_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.deliveries_delivery
    ADD CONSTRAINT deliveries_delivery_salesplan_fkey FOREIGN KEY (salesplan_id) REFERENCES public.masterorders_salesplan(id) DEFERRABLE;


--
-- Name: deliveries_delivery delivery_company_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.deliveries_delivery
    ADD CONSTRAINT delivery_company_fkey FOREIGN KEY (supplier_id) REFERENCES public.basic_company(id) DEFERRABLE;


--
-- Name: deliveries_delivery delivery_currency_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.deliveries_delivery
    ADD CONSTRAINT delivery_currency_fkey FOREIGN KEY (currency_id) REFERENCES public.basic_currency(id) DEFERRABLE;


--
-- Name: deliveries_delivery delivery_delivery_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.deliveries_delivery
    ADD CONSTRAINT delivery_delivery_fkey FOREIGN KEY (relateddelivery_id) REFERENCES public.deliveries_delivery(id) DEFERRABLE;


--
-- Name: deliveries_delivery delivery_location_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.deliveries_delivery
    ADD CONSTRAINT delivery_location_fkey FOREIGN KEY (location_id) REFERENCES public.materialflow_location(id) DEFERRABLE;


--
-- Name: deliveries_deliveryattachment deliveryattachment_delivery_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.deliveries_deliveryattachment
    ADD CONSTRAINT deliveryattachment_delivery_fkey FOREIGN KEY (delivery_id) REFERENCES public.deliveries_delivery(id) DEFERRABLE;


--
-- Name: qualitycontrol_deliveryqualitycontrol deliveryqualitycontrol_delivery_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.qualitycontrol_deliveryqualitycontrol
    ADD CONSTRAINT deliveryqualitycontrol_delivery_fkey FOREIGN KEY (delivery_id) REFERENCES public.deliveries_delivery(id) DEFERRABLE;


--
-- Name: deliveries_deliverystatechange deliverystatechange_delivery_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.deliveries_deliverystatechange
    ADD CONSTRAINT deliverystatechange_delivery_fkey FOREIGN KEY (delivery_id) REFERENCES public.deliveries_delivery(id) DEFERRABLE;


--
-- Name: deliveries_deliverystatechange deliverystatechange_shift_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.deliveries_deliverystatechange
    ADD CONSTRAINT deliverystatechange_shift_fkey FOREIGN KEY (shift_id) REFERENCES public.basic_shift(id) DEFERRABLE;


--
-- Name: qcadoomodel_dictionaryitem dictionaryitem_dictionary_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.qcadoomodel_dictionaryitem
    ADD CONSTRAINT dictionaryitem_dictionary_fkey FOREIGN KEY (dictionary_id) REFERENCES public.qcadoomodel_dictionary(id) DEFERRABLE;


--
-- Name: technologies_dimensioncontrolattribute dimensioncontrolattribute_attribute_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.technologies_dimensioncontrolattribute
    ADD CONSTRAINT dimensioncontrolattribute_attribute_fkey FOREIGN KEY (attribute_id) REFERENCES public.basic_attribute(id) DEFERRABLE;


--
-- Name: technologies_dimensioncontrolattribute dimensioncontrolattribute_paramter_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.technologies_dimensioncontrolattribute
    ADD CONSTRAINT dimensioncontrolattribute_paramter_fkey FOREIGN KEY (parameter_id) REFERENCES public.basic_parameter(id) DEFERRABLE;


--
-- Name: basic_division division_componentslocation_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.basic_division
    ADD CONSTRAINT division_componentslocation_fkey FOREIGN KEY (componentslocation_id) REFERENCES public.materialflow_location(id) DEFERRABLE;


--
-- Name: basic_division division_componentsoutputlocation_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.basic_division
    ADD CONSTRAINT division_componentsoutputlocation_fkey FOREIGN KEY (componentsoutputlocation_id) REFERENCES public.materialflow_location(id) DEFERRABLE;


--
-- Name: basic_division division_factory_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.basic_division
    ADD CONSTRAINT division_factory_fkey FOREIGN KEY (factory_id) REFERENCES public.basic_factory(id) DEFERRABLE;


--
-- Name: basic_division division_productionline_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.basic_division
    ADD CONSTRAINT division_productionline_fkey FOREIGN KEY (productionline_id) REFERENCES public.productionlines_productionline(id) DEFERRABLE;


--
-- Name: basic_division division_productsflowlocation_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.basic_division
    ADD CONSTRAINT division_productsflowlocation_fkey FOREIGN KEY (productsflowlocation_id) REFERENCES public.materialflow_location(id) DEFERRABLE;


--
-- Name: basic_division division_productsinputlocation_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.basic_division
    ADD CONSTRAINT division_productsinputlocation_fkey FOREIGN KEY (productsinputlocation_id) REFERENCES public.materialflow_location(id) DEFERRABLE;


--
-- Name: basic_division division_supervisor_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.basic_division
    ADD CONSTRAINT division_supervisor_fkey FOREIGN KEY (supervisor_id) REFERENCES public.basic_staff(id) DEFERRABLE;


--
-- Name: productflowthrudivision_warehouseissue division_warehouseissue_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.productflowthrudivision_warehouseissue
    ADD CONSTRAINT division_warehouseissue_fkey FOREIGN KEY (division_id) REFERENCES public.basic_division(id) DEFERRABLE;


--
-- Name: basic_division division_wastereceptionwarehouse_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.basic_division
    ADD CONSTRAINT division_wastereceptionwarehouse_fkey FOREIGN KEY (wastereceptionwarehouse_id) REFERENCES public.materialflow_location(id) DEFERRABLE;


--
-- Name: materialflowresources_document document_address_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.materialflowresources_document
    ADD CONSTRAINT document_address_fkey FOREIGN KEY (address_id) REFERENCES public.basic_address(id) DEFERRABLE;


--
-- Name: materialflowresources_document document_company_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.materialflowresources_document
    ADD CONSTRAINT document_company_fkey FOREIGN KEY (company_id) REFERENCES public.basic_company(id) DEFERRABLE;


--
-- Name: materialflowresources_document document_delivery_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.materialflowresources_document
    ADD CONSTRAINT document_delivery_fkey FOREIGN KEY (delivery_id) REFERENCES public.deliveries_delivery(id) DEFERRABLE;


--
-- Name: materialflowresources_document document_linkeddocumentlocation_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.materialflowresources_document
    ADD CONSTRAINT document_linkeddocumentlocation_fkey FOREIGN KEY (linkeddocumentlocation_id) REFERENCES public.materialflow_location(id) DEFERRABLE;


--
-- Name: materialflowresources_document document_locationfrom_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.materialflowresources_document
    ADD CONSTRAINT document_locationfrom_fkey FOREIGN KEY (locationfrom_id) REFERENCES public.materialflow_location(id) DEFERRABLE;


--
-- Name: materialflowresources_document document_locationto_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.materialflowresources_document
    ADD CONSTRAINT document_locationto_fkey FOREIGN KEY (locationto_id) REFERENCES public.materialflow_location(id) DEFERRABLE;


--
-- Name: materialflowresources_document document_maintenanceevent_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.materialflowresources_document
    ADD CONSTRAINT document_maintenanceevent_fkey FOREIGN KEY (maintenanceevent_id) REFERENCES public.cmmsmachineparts_maintenanceevent(id) DEFERRABLE;


--
-- Name: materialflowresources_document document_order_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.materialflowresources_document
    ADD CONSTRAINT document_order_fkey FOREIGN KEY (order_id) REFERENCES public.orders_order(id) DEFERRABLE;


--
-- Name: materialflowresources_document document_ordersgroup_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.materialflowresources_document
    ADD CONSTRAINT document_ordersgroup_fkey FOREIGN KEY (ordersgroup_id) REFERENCES public.ordersgroups_ordersgroup(id) DEFERRABLE;


--
-- Name: materialflowresources_document document_staff_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.materialflowresources_document
    ADD CONSTRAINT document_staff_fkey FOREIGN KEY (staff_id) REFERENCES public.basic_staff(id) DEFERRABLE;


--
-- Name: materialflowresources_document document_suborder_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.materialflowresources_document
    ADD CONSTRAINT document_suborder_fkey FOREIGN KEY (suborder_id) REFERENCES public.subcontractorportal_suborder(id) DEFERRABLE;


--
-- Name: materialflowresources_document document_user_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.materialflowresources_document
    ADD CONSTRAINT document_user_fkey FOREIGN KEY (user_id) REFERENCES public.qcadoosecurity_user(id) DEFERRABLE;


--
-- Name: materialflowresources_documentpositionparametersitem documentpositionparametersitem_attribute_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.materialflowresources_documentpositionparametersitem
    ADD CONSTRAINT documentpositionparametersitem_attribute_fkey FOREIGN KEY (attribute_id) REFERENCES public.basic_attribute(id) DEFERRABLE;


--
-- Name: materialflowresources_documentpositionparametersitem documentpositionparametersitem_parameters_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.materialflowresources_documentpositionparametersitem
    ADD CONSTRAINT documentpositionparametersitem_parameters_fkey FOREIGN KEY (parameters_id) REFERENCES public.materialflowresources_documentpositionparameters(id) DEFERRABLE;


--
-- Name: materialflowresources_documentstatechange documentstatechange_document_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.materialflowresources_documentstatechange
    ADD CONSTRAINT documentstatechange_document_fkey FOREIGN KEY (document_id) REFERENCES public.materialflowresources_document(id) DEFERRABLE;


--
-- Name: subcontractorportal_suborderevent event_staff_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.subcontractorportal_suborderevent
    ADD CONSTRAINT event_staff_fkey FOREIGN KEY (staff_id) REFERENCES public.basic_staff(id) DEFERRABLE;


--
-- Name: subcontractorportal_suborderevent event_suborder_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.subcontractorportal_suborderevent
    ADD CONSTRAINT event_suborder_fkey FOREIGN KEY (suborder_id) REFERENCES public.subcontractorportal_suborder(id) DEFERRABLE;


--
-- Name: cmmsmachineparts_eventattachment eventattachment_maintenanceevent_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.cmmsmachineparts_eventattachment
    ADD CONSTRAINT eventattachment_maintenanceevent_fkey FOREIGN KEY (maintenanceevent_id) REFERENCES public.cmmsmachineparts_maintenanceevent(id) DEFERRABLE;


--
-- Name: goodfood_eventlog eventlog_product_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.goodfood_eventlog
    ADD CONSTRAINT eventlog_product_fkey FOREIGN KEY (product_id) REFERENCES public.basic_product(id) DEFERRABLE;


--
-- Name: goodfood_eventlog eventlog_user_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.goodfood_eventlog
    ADD CONSTRAINT eventlog_user_fkey FOREIGN KEY (user_id) REFERENCES public.qcadoosecurity_user(id) DEFERRABLE;


--
-- Name: goodfood_extrusionaddedmixentry extrusionaddedmixentry_extrusionmix_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.goodfood_extrusionaddedmixentry
    ADD CONSTRAINT extrusionaddedmixentry_extrusionmix_fkey FOREIGN KEY (extrusionmix_id) REFERENCES public.goodfood_extrusionmix(id) DEFERRABLE;


--
-- Name: goodfood_extrusionaddedmixentry extrusionaddedmixentry_extrusionprotocol_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.goodfood_extrusionaddedmixentry
    ADD CONSTRAINT extrusionaddedmixentry_extrusionprotocol_fkey FOREIGN KEY (extrusionprotocol_id) REFERENCES public.goodfood_extrusionprotocol(id) DEFERRABLE;


--
-- Name: goodfood_extrusionaddedmixingredient extrusionaddedmixingredient_batch_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.goodfood_extrusionaddedmixingredient
    ADD CONSTRAINT extrusionaddedmixingredient_batch_fkey FOREIGN KEY (batch_id) REFERENCES public.advancedgenealogy_batch(id) DEFERRABLE;


--
-- Name: goodfood_extrusionaddedmixingredient extrusionaddedmixingredient_extrusionaddedmixentry_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.goodfood_extrusionaddedmixingredient
    ADD CONSTRAINT extrusionaddedmixingredient_extrusionaddedmixentry_fkey FOREIGN KEY (extrusionaddedmixentry_id) REFERENCES public.goodfood_extrusionaddedmixentry(id) DEFERRABLE;


--
-- Name: goodfood_extrusionaddedmixingredient extrusionaddedmixingredient_extrusionmixingredient_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.goodfood_extrusionaddedmixingredient
    ADD CONSTRAINT extrusionaddedmixingredient_extrusionmixingredient_fkey FOREIGN KEY (extrusionmixingredient_id) REFERENCES public.goodfood_extrusionmixingredient(id) DEFERRABLE;


--
-- Name: goodfood_extrusionaddedmixingredient extrusionaddedmixingredient_product_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.goodfood_extrusionaddedmixingredient
    ADD CONSTRAINT extrusionaddedmixingredient_product_fkey FOREIGN KEY (product_id) REFERENCES public.basic_product(id) DEFERRABLE;


--
-- Name: goodfood_extrusioncontext extrusioncontext_operator_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.goodfood_extrusioncontext
    ADD CONSTRAINT extrusioncontext_operator_fkey FOREIGN KEY (operator_id) REFERENCES public.basic_staff(id) DEFERRABLE;


--
-- Name: goodfood_extrusionpouring extrusionpouring_extrusionprotocol_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.goodfood_extrusionpouring
    ADD CONSTRAINT extrusionpouring_extrusionprotocol_fkey FOREIGN KEY (extrusionprotocol_id) REFERENCES public.goodfood_extrusionprotocol(id) DEFERRABLE;


--
-- Name: goodfood_extrusionpouringingredient extrusionpouringingredient_batch_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.goodfood_extrusionpouringingredient
    ADD CONSTRAINT extrusionpouringingredient_batch_fkey FOREIGN KEY (batch_id) REFERENCES public.advancedgenealogy_batch(id) DEFERRABLE;


--
-- Name: goodfood_extrusionpouringingredient extrusionpouringingredient_extrusionpouring_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.goodfood_extrusionpouringingredient
    ADD CONSTRAINT extrusionpouringingredient_extrusionpouring_fkey FOREIGN KEY (extrusionpouring_id) REFERENCES public.goodfood_extrusionpouring(id) DEFERRABLE;


--
-- Name: goodfood_extrusionpouringingredient extrusionpouringingredient_extrusionpouringmix_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.goodfood_extrusionpouringingredient
    ADD CONSTRAINT extrusionpouringingredient_extrusionpouringmix_fkey FOREIGN KEY (extrusionpouringmix_id) REFERENCES public.goodfood_extrusionpouringmix(id) DEFERRABLE;


--
-- Name: goodfood_extrusionpouringingredient extrusionpouringingredient_product_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.goodfood_extrusionpouringingredient
    ADD CONSTRAINT extrusionpouringingredient_product_fkey FOREIGN KEY (product_id) REFERENCES public.basic_product(id) DEFERRABLE;


--
-- Name: goodfood_extrusionpouringmix extrusionpouringmix_extrusionpouring_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.goodfood_extrusionpouringmix
    ADD CONSTRAINT extrusionpouringmix_extrusionpouring_fkey FOREIGN KEY (extrusionpouring_id) REFERENCES public.goodfood_extrusionpouring(id) DEFERRABLE;


--
-- Name: goodfood_extrusionprotocolcorrect extrusionprotocolcorrect_extrusionprotocol_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.goodfood_extrusionprotocolcorrect
    ADD CONSTRAINT extrusionprotocolcorrect_extrusionprotocol_fkey FOREIGN KEY (extrusionprotocol_id) REFERENCES public.goodfood_extrusionprotocol(id) DEFERRABLE;


--
-- Name: goodfood_extrusionprotocolstatechange extrusionprotocolstatechange_extrusionprotocol_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.goodfood_extrusionprotocolstatechange
    ADD CONSTRAINT extrusionprotocolstatechange_extrusionprotocol_fkey FOREIGN KEY (extrusionprotocol_id) REFERENCES public.goodfood_extrusionprotocol(id) DEFERRABLE;


--
-- Name: goodfood_extrusionprotocolstatechange extrusionprotocolstatechange_shif_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.goodfood_extrusionprotocolstatechange
    ADD CONSTRAINT extrusionprotocolstatechange_shif_fkey FOREIGN KEY (shift_id) REFERENCES public.basic_shift(id) DEFERRABLE;


--
-- Name: goodfood_extrusiontakenoffmixentry extrusiontakenoffmixentry_extrusionmix_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.goodfood_extrusiontakenoffmixentry
    ADD CONSTRAINT extrusiontakenoffmixentry_extrusionmix_fkey FOREIGN KEY (extrusionmix_id) REFERENCES public.goodfood_extrusionmix(id) DEFERRABLE;


--
-- Name: goodfood_extrusiontakenoffmixentry extrusiontakenoffmixentry_extrusionprotocol_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.goodfood_extrusiontakenoffmixentry
    ADD CONSTRAINT extrusiontakenoffmixentry_extrusionprotocol_fkey FOREIGN KEY (extrusionprotocol_id) REFERENCES public.goodfood_extrusionprotocol(id) DEFERRABLE;


--
-- Name: goodfood_extrusiontakenoffmixingredient extrusiontakenoffmixingredient_batch_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.goodfood_extrusiontakenoffmixingredient
    ADD CONSTRAINT extrusiontakenoffmixingredient_batch_fkey FOREIGN KEY (batch_id) REFERENCES public.advancedgenealogy_batch(id) DEFERRABLE;


--
-- Name: goodfood_extrusiontakenoffmixingredient extrusiontakenoffmixingredient_extrusionmixingredient_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.goodfood_extrusiontakenoffmixingredient
    ADD CONSTRAINT extrusiontakenoffmixingredient_extrusionmixingredient_fkey FOREIGN KEY (extrusionmixingredient_id) REFERENCES public.goodfood_extrusionmixingredient(id) DEFERRABLE;


--
-- Name: goodfood_extrusiontakenoffmixingredient extrusiontakenoffmixingredient_extrusiontakenoffmixentry_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.goodfood_extrusiontakenoffmixingredient
    ADD CONSTRAINT extrusiontakenoffmixingredient_extrusiontakenoffmixentry_fkey FOREIGN KEY (extrusiontakenoffmixentry_id) REFERENCES public.goodfood_extrusiontakenoffmixentry(id) DEFERRABLE;


--
-- Name: goodfood_extrusiontakenoffmixingredient extrusiontakenoffmixingredient_product_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.goodfood_extrusiontakenoffmixingredient
    ADD CONSTRAINT extrusiontakenoffmixingredient_product_fkey FOREIGN KEY (product_id) REFERENCES public.basic_product(id) DEFERRABLE;


--
-- Name: basic_factory factory_warehouse_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.basic_factory
    ADD CONSTRAINT factory_warehouse_fkey FOREIGN KEY (warehouse_id) REFERENCES public.materialflow_location(id) DEFERRABLE;


--
-- Name: productionlines_factorystructureelement factorystructureelement_maintenanceevent_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.productionlines_factorystructureelement
    ADD CONSTRAINT factorystructureelement_maintenanceevent_fkey FOREIGN KEY (maintenanceevent_id) REFERENCES public.cmmsmachineparts_maintenanceevent(id) DEFERRABLE;


--
-- Name: productionlines_factorystructureelement factorystructureelement_parent_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.productionlines_factorystructureelement
    ADD CONSTRAINT factorystructureelement_parent_fkey FOREIGN KEY (parent_id) REFERENCES public.productionlines_factorystructureelement(id) DEFERRABLE;


--
-- Name: productionlines_factorystructureelement factorystructureelement_productionline_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.productionlines_factorystructureelement
    ADD CONSTRAINT factorystructureelement_productionline_fkey FOREIGN KEY (productionline_id) REFERENCES public.productionlines_productionline(id) DEFERRABLE;


--
-- Name: productionlines_factorystructureelement factorystructureelement_subassembly_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.productionlines_factorystructureelement
    ADD CONSTRAINT factorystructureelement_subassembly_fkey FOREIGN KEY (subassembly_id) REFERENCES public.basic_subassembly(id) DEFERRABLE;


--
-- Name: productionlines_factorystructureelement factorystructureelement_workstation_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.productionlines_factorystructureelement
    ADD CONSTRAINT factorystructureelement_workstation_fkey FOREIGN KEY (workstation_id) REFERENCES public.basic_workstation(id) DEFERRABLE;


--
-- Name: basic_forms forms_company_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.basic_forms
    ADD CONSTRAINT forms_company_fkey FOREIGN KEY (company_id) REFERENCES public.basic_company(id) DEFERRABLE;


--
-- Name: advancedgenealogyfororders_genealogyproductinbatch genealogyproductinbatch_batch_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.advancedgenealogyfororders_genealogyproductinbatch
    ADD CONSTRAINT genealogyproductinbatch_batch_fkey FOREIGN KEY (batch_id) REFERENCES public.advancedgenealogy_batch(id) DEFERRABLE;


--
-- Name: advancedgenealogyfororders_genealogyproductinbatch genealogyproductinbatch_genealogyproductincomponent_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.advancedgenealogyfororders_genealogyproductinbatch
    ADD CONSTRAINT genealogyproductinbatch_genealogyproductincomponent_fkey FOREIGN KEY (genealogyproductincomponent_id) REFERENCES public.advancedgenealogyfororders_genealogyproductincomponent(id) DEFERRABLE;


--
-- Name: advancedgenealogyfororders_genealogyproductincomponent genealogyproductincomponent_product_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.advancedgenealogyfororders_genealogyproductincomponent
    ADD CONSTRAINT genealogyproductincomponent_product_fkey FOREIGN KEY (product_id) REFERENCES public.basic_product(id) DEFERRABLE;


--
-- Name: advancedgenealogyfororders_genealogyproductincomponent genealogyproductincomponent_technologyoperationcomponent_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.advancedgenealogyfororders_genealogyproductincomponent
    ADD CONSTRAINT genealogyproductincomponent_technologyoperationcomponent_fkey FOREIGN KEY (technologyoperationcomponent_id) REFERENCES public.technologies_technologyoperationcomponent(id) DEFERRABLE;


--
-- Name: advancedgenealogyfororders_genealogyproductincomponent genealogyproductincomponent_trackingrecord_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.advancedgenealogyfororders_genealogyproductincomponent
    ADD CONSTRAINT genealogyproductincomponent_trackingrecord_fkey FOREIGN KEY (trackingrecord_id) REFERENCES public.advancedgenealogy_trackingrecord(id) DEFERRABLE;


--
-- Name: advancedgenealogy_genealogyreport genealogyreport_batch_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.advancedgenealogy_genealogyreport
    ADD CONSTRAINT genealogyreport_batch_fkey FOREIGN KEY (batch_id) REFERENCES public.advancedgenealogy_batch(id) DEFERRABLE;


--
-- Name: technologiesgenerator_generatorcontext generatorcontext_product_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.technologiesgenerator_generatorcontext
    ADD CONSTRAINT generatorcontext_product_fkey FOREIGN KEY (product_id) REFERENCES public.basic_product(id) DEFERRABLE;


--
-- Name: technologiesgenerator_generatorcontext generatorcontext_technology_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.technologiesgenerator_generatorcontext
    ADD CONSTRAINT generatorcontext_technology_fkey FOREIGN KEY (technology_id) REFERENCES public.technologies_technology(id) DEFERRABLE;


--
-- Name: technologiesgenerator_generatortechnologiesforproduct generatortechnologiesforproduct_generatorcontext_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.technologiesgenerator_generatortechnologiesforproduct
    ADD CONSTRAINT generatortechnologiesforproduct_generatorcontext_fkey FOREIGN KEY (generatorcontext_id) REFERENCES public.technologiesgenerator_generatorcontext(id) DEFERRABLE;


--
-- Name: technologiesgenerator_generatortechnologiesforproduct generatortechnologiesforproduct_product_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.technologiesgenerator_generatortechnologiesforproduct
    ADD CONSTRAINT generatortechnologiesforproduct_product_fkey FOREIGN KEY (product_id) REFERENCES public.basic_product(id) DEFERRABLE;


--
-- Name: technologiesgenerator_generatortechnologiesforproduct generatortechnologiesforproduct_technology_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.technologiesgenerator_generatortechnologiesforproduct
    ADD CONSTRAINT generatortechnologiesforproduct_technology_fkey FOREIGN KEY (technology_id) REFERENCES public.technologies_technology(id) DEFERRABLE;


--
-- Name: technologiesgenerator_generatortreenode generatortreen_originaltechnology_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.technologiesgenerator_generatortreenode
    ADD CONSTRAINT generatortreen_originaltechnology_fkey FOREIGN KEY (originaltechnology_id) REFERENCES public.technologies_technology(id) DEFERRABLE;


--
-- Name: technologiesgenerator_generatortreenode generatortreeno_producttechnology_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.technologiesgenerator_generatortreenode
    ADD CONSTRAINT generatortreeno_producttechnology_fkey FOREIGN KEY (producttechnology_id) REFERENCES public.technologies_technology(id) DEFERRABLE;


--
-- Name: technologiesgenerator_generatortreenode generatortreenod_generatorcontext_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.technologiesgenerator_generatortreenode
    ADD CONSTRAINT generatortreenod_generatorcontext_fkey FOREIGN KEY (generatorcontext_id) REFERENCES public.technologiesgenerator_generatorcontext(id) DEFERRABLE;


--
-- Name: technologiesgenerator_generatortreenode generatortreenode_division_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.technologiesgenerator_generatortreenode
    ADD CONSTRAINT generatortreenode_division_fkey FOREIGN KEY (division_id) REFERENCES public.basic_division(id) DEFERRABLE;


--
-- Name: technologiesgenerator_generatortreenode generatortreenode_operation_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.technologiesgenerator_generatortreenode
    ADD CONSTRAINT generatortreenode_operation_fkey FOREIGN KEY (operation_id) REFERENCES public.technologies_operation(id) DEFERRABLE;


--
-- Name: technologiesgenerator_generatortreenode generatortreenode_parent_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.technologiesgenerator_generatortreenode
    ADD CONSTRAINT generatortreenode_parent_fkey FOREIGN KEY (parent_id) REFERENCES public.technologiesgenerator_generatortreenode(id) DEFERRABLE;


--
-- Name: technologiesgenerator_generatortreenode generatortreenode_product_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.technologiesgenerator_generatortreenode
    ADD CONSTRAINT generatortreenode_product_fkey FOREIGN KEY (product_id) REFERENCES public.basic_product(id) DEFERRABLE;


--
-- Name: technologiesgenerator_generatortreenode generatortreenode_sizegroup_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.technologiesgenerator_generatortreenode
    ADD CONSTRAINT generatortreenode_sizegroup_fkey FOREIGN KEY (sizegroup_id) REFERENCES public.basic_sizegroup(id) DEFERRABLE;


--
-- Name: technologiesgenerator_generatortreenode generatortreenode_technologyinputproducttype_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.technologiesgenerator_generatortreenode
    ADD CONSTRAINT generatortreenode_technologyinputproducttype_fkey FOREIGN KEY (technologyinputproducttype_id) REFERENCES public.technologies_technologyinputproducttype(id) DEFERRABLE;


--
-- Name: masterorders_masterorder goodfood_batch_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.masterorders_masterorder
    ADD CONSTRAINT goodfood_batch_fkey FOREIGN KEY (batch_id) REFERENCES public.advancedgenealogy_batch(id) DEFERRABLE;


--
-- Name: goodfood_confectionprotocol goodfood_confectioncontext_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.goodfood_confectionprotocol
    ADD CONSTRAINT goodfood_confectioncontext_fkey FOREIGN KEY (confectioncontext_id) REFERENCES public.goodfood_confectioncontext(id) DEFERRABLE;


--
-- Name: goodfood_confectioninputproduct goodfood_confectionprotocol_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.goodfood_confectioninputproduct
    ADD CONSTRAINT goodfood_confectionprotocol_fkey FOREIGN KEY (confectionprotocol_id) REFERENCES public.goodfood_confectionprotocol(id) DEFERRABLE;


--
-- Name: goodfood_confectionremainderinputproduct goodfood_confectionprotocol_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.goodfood_confectionremainderinputproduct
    ADD CONSTRAINT goodfood_confectionprotocol_fkey FOREIGN KEY (confectionprotocol_id) REFERENCES public.goodfood_confectionprotocol(id) DEFERRABLE;


--
-- Name: goodfood_confectionstaff goodfood_confectionprotocol_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.goodfood_confectionstaff
    ADD CONSTRAINT goodfood_confectionprotocol_fkey FOREIGN KEY (confectionprotocol_id) REFERENCES public.goodfood_confectionprotocol(id) DEFERRABLE;


--
-- Name: cdnrcgoodfood_cancelprotocol goodfood_confectionprotocol_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.cdnrcgoodfood_cancelprotocol
    ADD CONSTRAINT goodfood_confectionprotocol_fkey FOREIGN KEY (confectionprotocol_id) REFERENCES public.goodfood_confectionprotocol(id) DEFERRABLE;


--
-- Name: goodfood_extrusionprotocol goodfood_extrusioncontext_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.goodfood_extrusionprotocol
    ADD CONSTRAINT goodfood_extrusioncontext_fkey FOREIGN KEY (extrusioncontext_id) REFERENCES public.goodfood_extrusioncontext(id) DEFERRABLE;


--
-- Name: goodfood_extrusionmix goodfood_extrusionmix_operator_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.goodfood_extrusionmix
    ADD CONSTRAINT goodfood_extrusionmix_operator_fkey FOREIGN KEY (operator_id) REFERENCES public.basic_staff(id) DEFERRABLE;


--
-- Name: goodfood_extrusionmix goodfood_extrusionmix_product_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.goodfood_extrusionmix
    ADD CONSTRAINT goodfood_extrusionmix_product_fkey FOREIGN KEY (product_id) REFERENCES public.basic_product(id) DEFERRABLE;


--
-- Name: goodfood_extrusionmix goodfood_extrusionmix_productionline_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.goodfood_extrusionmix
    ADD CONSTRAINT goodfood_extrusionmix_productionline_fkey FOREIGN KEY (productionline_id) REFERENCES public.productionlines_productionline(id) DEFERRABLE;


--
-- Name: goodfood_extrusionmix goodfood_extrusionmix_shift_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.goodfood_extrusionmix
    ADD CONSTRAINT goodfood_extrusionmix_shift_fkey FOREIGN KEY (shift_id) REFERENCES public.basic_shift(id) DEFERRABLE;


--
-- Name: goodfood_extrusionmix goodfood_extrusionmix_technology_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.goodfood_extrusionmix
    ADD CONSTRAINT goodfood_extrusionmix_technology_fkey FOREIGN KEY (technology_id) REFERENCES public.technologies_technology(id) DEFERRABLE;


--
-- Name: goodfood_extrusionmixingredient goodfood_extrusionmixingredient_batch_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.goodfood_extrusionmixingredient
    ADD CONSTRAINT goodfood_extrusionmixingredient_batch_fkey FOREIGN KEY (batch_id) REFERENCES public.advancedgenealogy_batch(id) DEFERRABLE;


--
-- Name: goodfood_extrusionmixingredient goodfood_extrusionmixingredient_extrusionmix_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.goodfood_extrusionmixingredient
    ADD CONSTRAINT goodfood_extrusionmixingredient_extrusionmix_fkey FOREIGN KEY (extrusionmix_id) REFERENCES public.goodfood_extrusionmix(id) DEFERRABLE;


--
-- Name: goodfood_extrusionmixingredient goodfood_extrusionmixingredient_product_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.goodfood_extrusionmixingredient
    ADD CONSTRAINT goodfood_extrusionmixingredient_product_fkey FOREIGN KEY (product_id) REFERENCES public.basic_product(id) DEFERRABLE;


--
-- Name: goodfood_extrusionsouse goodfood_extrusionprotocol_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.goodfood_extrusionsouse
    ADD CONSTRAINT goodfood_extrusionprotocol_fkey FOREIGN KEY (extrusionprotocol_id) REFERENCES public.goodfood_extrusionprotocol(id) DEFERRABLE;


--
-- Name: cdnrcgoodfood_cancelprotocol goodfood_extrusionprotocol_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.cdnrcgoodfood_cancelprotocol
    ADD CONSTRAINT goodfood_extrusionprotocol_fkey FOREIGN KEY (extrusionprotocol_id) REFERENCES public.goodfood_extrusionprotocol(id) DEFERRABLE;


--
-- Name: jointable_group_role group_role_group_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.jointable_group_role
    ADD CONSTRAINT group_role_group_fkey FOREIGN KEY (group_id) REFERENCES public.qcadoosecurity_group(id) DEFERRABLE;


--
-- Name: jointable_group_role group_role_role_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.jointable_group_role
    ADD CONSTRAINT group_role_role_fkey FOREIGN KEY (role_id) REFERENCES public.qcadoosecurity_role(id) DEFERRABLE;


--
-- Name: materialflowresources_importstoragelocation importstoragelocation_location_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.materialflowresources_importstoragelocation
    ADD CONSTRAINT importstoragelocation_location_fkey FOREIGN KEY (location_id) REFERENCES public.materialflow_location(id) DEFERRABLE;


--
-- Name: productflowthrudivision_issue issue_document_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.productflowthrudivision_issue
    ADD CONSTRAINT issue_document_fkey FOREIGN KEY (document_id) REFERENCES public.materialflowresources_document(id) DEFERRABLE;


--
-- Name: jointable_issue_productstoissuehelper issue_productstoissuehelper_issue_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.jointable_issue_productstoissuehelper
    ADD CONSTRAINT issue_productstoissuehelper_issue_fkey FOREIGN KEY (issue_id) REFERENCES public.productflowthrudivision_issue(id) DEFERRABLE;


--
-- Name: jointable_issue_productstoissuehelper issue_productstoissuehelper_productstoissuehelper_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.jointable_issue_productstoissuehelper
    ADD CONSTRAINT issue_productstoissuehelper_productstoissuehelper_fkey FOREIGN KEY (productstoissuehelper_id) REFERENCES public.productflowthrudivision_productstoissuehelper(id) DEFERRABLE;


--
-- Name: qcadooview_item item_category_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.qcadooview_item
    ADD CONSTRAINT item_category_fkey FOREIGN KEY (category_id) REFERENCES public.qcadooview_category(id) DEFERRABLE;


--
-- Name: qcadooview_item item_view_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.qcadooview_item
    ADD CONSTRAINT item_view_fkey FOREIGN KEY (view_id) REFERENCES public.qcadooview_view(id) DEFERRABLE;


--
-- Name: jointable_company_subassembly jointable_company_subassembly_company_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.jointable_company_subassembly
    ADD CONSTRAINT jointable_company_subassembly_company_fkey FOREIGN KEY (company_id) REFERENCES public.basic_company(id) DEFERRABLE;


--
-- Name: jointable_company_subassembly jointable_company_subassembly_subassembly_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.jointable_company_subassembly
    ADD CONSTRAINT jointable_company_subassembly_subassembly_fkey FOREIGN KEY (subassembly_id) REFERENCES public.basic_subassembly(id) DEFERRABLE;


--
-- Name: jointable_company_workstation jointable_company_workstation_company_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.jointable_company_workstation
    ADD CONSTRAINT jointable_company_workstation_company_fkey FOREIGN KEY (company_id) REFERENCES public.basic_company(id) DEFERRABLE;


--
-- Name: jointable_company_workstation jointable_company_workstation_workstation_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.jointable_company_workstation
    ADD CONSTRAINT jointable_company_workstation_workstation_fkey FOREIGN KEY (workstation_id) REFERENCES public.basic_workstation(id) DEFERRABLE;


--
-- Name: jointable_division_productionline jointable_division_productionline_division_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.jointable_division_productionline
    ADD CONSTRAINT jointable_division_productionline_division_fkey FOREIGN KEY (division_id) REFERENCES public.basic_division(id) DEFERRABLE;


--
-- Name: jointable_division_productionline jointable_division_productionline_productionline_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.jointable_division_productionline
    ADD CONSTRAINT jointable_division_productionline_productionline_fkey FOREIGN KEY (productionline_id) REFERENCES public.productionlines_productionline(id) DEFERRABLE;


--
-- Name: jointable_faulttype_subassembly jointable_faulttype_subassembly_faulttype_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.jointable_faulttype_subassembly
    ADD CONSTRAINT jointable_faulttype_subassembly_faulttype_fkey FOREIGN KEY (faulttype_id) REFERENCES public.basic_faulttype(id) DEFERRABLE;


--
-- Name: jointable_faulttype_subassembly jointable_faulttype_subassembly_subassembly_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.jointable_faulttype_subassembly
    ADD CONSTRAINT jointable_faulttype_subassembly_subassembly_fkey FOREIGN KEY (subassembly_id) REFERENCES public.basic_subassembly(id) DEFERRABLE;


--
-- Name: jointable_faulttype_workstation jointable_faulttype_workstation_faulttype_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.jointable_faulttype_workstation
    ADD CONSTRAINT jointable_faulttype_workstation_faulttype_fkey FOREIGN KEY (faulttype_id) REFERENCES public.basic_faulttype(id) DEFERRABLE;


--
-- Name: jointable_faulttype_workstation jointable_faulttype_workstation_workstation_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.jointable_faulttype_workstation
    ADD CONSTRAINT jointable_faulttype_workstation_workstation_fkey FOREIGN KEY (workstation_id) REFERENCES public.basic_workstation(id) DEFERRABLE;


--
-- Name: jointable_faulttype_workstationtype jointable_faulttype_workstationtype_faulttype_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.jointable_faulttype_workstationtype
    ADD CONSTRAINT jointable_faulttype_workstationtype_faulttype_fkey FOREIGN KEY (faulttype_id) REFERENCES public.basic_faulttype(id) DEFERRABLE;


--
-- Name: jointable_faulttype_workstationtype jointable_faulttype_workstationtype_workstationtype_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.jointable_faulttype_workstationtype
    ADD CONSTRAINT jointable_faulttype_workstationtype_workstationtype_fkey FOREIGN KEY (workstationtype_id) REFERENCES public.basic_workstationtype(id) DEFERRABLE;


--
-- Name: jointable_productionline_technology jointable_pl_tech_productionline_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.jointable_productionline_technology
    ADD CONSTRAINT jointable_pl_tech_productionline_fkey FOREIGN KEY (productionline_id) REFERENCES public.productionlines_productionline(id) DEFERRABLE;


--
-- Name: jointable_productionline_technology jointable_pl_tech_technology_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.jointable_productionline_technology
    ADD CONSTRAINT jointable_pl_tech_technology_fkey FOREIGN KEY (technology_id) REFERENCES public.technologies_technology(id) DEFERRABLE;


--
-- Name: jointable_productionline_technologygroup jointable_pl_techgroup_productionline_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.jointable_productionline_technologygroup
    ADD CONSTRAINT jointable_pl_techgroup_productionline_fkey FOREIGN KEY (productionline_id) REFERENCES public.productionlines_productionline(id) DEFERRABLE;


--
-- Name: jointable_productionline_technologygroup jointable_pl_techgroup_technologygroup_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.jointable_productionline_technologygroup
    ADD CONSTRAINT jointable_pl_techgroup_technologygroup_fkey FOREIGN KEY (technologygroup_id) REFERENCES public.technologies_technologygroup(id) DEFERRABLE;


--
-- Name: productioncounting_lack lack_trackingoperationproductoutcomponent_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.productioncounting_lack
    ADD CONSTRAINT lack_trackingoperationproductoutcomponent_fkey FOREIGN KEY (trackingoperationproductoutcomponent_id) REFERENCES public.productioncounting_trackingoperationproductoutcomponent(id) DEFERRABLE;


--
-- Name: productioncounting_lackreason lackreason_lack_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.productioncounting_lackreason
    ADD CONSTRAINT lackreason_lack_fkey FOREIGN KEY (lack_id) REFERENCES public.productioncounting_lack(id) DEFERRABLE;


--
-- Name: basic_licenseusage licenseusage_staff_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.basic_licenseusage
    ADD CONSTRAINT licenseusage_staff_fkey FOREIGN KEY (staff_id) REFERENCES public.basic_staff(id) DEFERRABLE;


--
-- Name: basic_licenseusage licenseusage_user_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.basic_licenseusage
    ADD CONSTRAINT licenseusage_user_fkey FOREIGN KEY (user_id) REFERENCES public.qcadoosecurity_user(id) DEFERRABLE;


--
-- Name: linechangeovernorms_linechangeovernorms linechangeovernorms_fromtechnology_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.linechangeovernorms_linechangeovernorms
    ADD CONSTRAINT linechangeovernorms_fromtechnology_fkey FOREIGN KEY (fromtechnology_id) REFERENCES public.technologies_technology(id) DEFERRABLE;


--
-- Name: linechangeovernorms_linechangeovernorms linechangeovernorms_fromtechnologygroup_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.linechangeovernorms_linechangeovernorms
    ADD CONSTRAINT linechangeovernorms_fromtechnologygroup_fkey FOREIGN KEY (fromtechnologygroup_id) REFERENCES public.technologies_technologygroup(id) DEFERRABLE;


--
-- Name: linechangeovernorms_linechangeovernorms linechangeovernorms_productionline_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.linechangeovernorms_linechangeovernorms
    ADD CONSTRAINT linechangeovernorms_productionline_fkey FOREIGN KEY (productionline_id) REFERENCES public.productionlines_productionline(id) DEFERRABLE;


--
-- Name: linechangeovernorms_linechangeovernorms linechangeovernorms_totechnology_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.linechangeovernorms_linechangeovernorms
    ADD CONSTRAINT linechangeovernorms_totechnology_fkey FOREIGN KEY (totechnology_id) REFERENCES public.technologies_technology(id) DEFERRABLE;


--
-- Name: linechangeovernorms_linechangeovernorms linechangeovernorms_totechnologygroup_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.linechangeovernorms_linechangeovernorms
    ADD CONSTRAINT linechangeovernorms_totechnologygroup_fkey FOREIGN KEY (totechnologygroup_id) REFERENCES public.technologies_technologygroup(id) DEFERRABLE;


--
-- Name: productflowthrudivision_issue location_issue_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.productflowthrudivision_issue
    ADD CONSTRAINT location_issue_fkey FOREIGN KEY (location_id) REFERENCES public.materialflow_location(id) DEFERRABLE;


--
-- Name: productflowthrudivision_productstoissue location_productstoissue_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.productflowthrudivision_productstoissue
    ADD CONSTRAINT location_productstoissue_fkey FOREIGN KEY (location_id) REFERENCES public.materialflow_location(id) DEFERRABLE;


--
-- Name: materialflow_location location_realizationlocation_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.materialflow_location
    ADD CONSTRAINT location_realizationlocation_fkey FOREIGN KEY (realizationlocation_id) REFERENCES public.basic_parameter(id) DEFERRABLE;


--
-- Name: basic_log log_user_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.basic_log
    ADD CONSTRAINT log_user_fkey FOREIGN KEY (user_id) REFERENCES public.qcadoosecurity_user(id) DEFERRABLE;


--
-- Name: cmmsmachineparts_machinepartattachment machinepartattachment_product_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.cmmsmachineparts_machinepartattachment
    ADD CONSTRAINT machinepartattachment_product_fkey FOREIGN KEY (product_id) REFERENCES public.basic_product(id) DEFERRABLE;


--
-- Name: cmmsmachineparts_machinepartforevent machinepartforevent_machinepart_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.cmmsmachineparts_machinepartforevent
    ADD CONSTRAINT machinepartforevent_machinepart_fkey FOREIGN KEY (machinepart_id) REFERENCES public.basic_product(id) DEFERRABLE;


--
-- Name: cmmsmachineparts_machinepartforevent machinepartforevent_maintenanceevent_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.cmmsmachineparts_machinepartforevent
    ADD CONSTRAINT machinepartforevent_maintenanceevent_fkey FOREIGN KEY (maintenanceevent_id) REFERENCES public.cmmsmachineparts_maintenanceevent(id) DEFERRABLE;


--
-- Name: cmmsmachineparts_machinepartforevent machinepartforevent_plannedevent_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.cmmsmachineparts_machinepartforevent
    ADD CONSTRAINT machinepartforevent_plannedevent_fkey FOREIGN KEY (plannedevent_id) REFERENCES public.cmmsmachineparts_plannedevent(id) DEFERRABLE;


--
-- Name: cmmsmachineparts_machinepartforevent machinepartforevent_recurringevent_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.cmmsmachineparts_machinepartforevent
    ADD CONSTRAINT machinepartforevent_recurringevent_fkey FOREIGN KEY (recurringevent_id) REFERENCES public.cmmsscheduler_recurringevent(id) DEFERRABLE;


--
-- Name: cmmsmachineparts_machinepartforevent machinepartforevent_warehouse_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.cmmsmachineparts_machinepartforevent
    ADD CONSTRAINT machinepartforevent_warehouse_fkey FOREIGN KEY (warehouse_id) REFERENCES public.materialflow_location(id) DEFERRABLE;


--
-- Name: basic_machineworkingperiod machineworkingperiod_launchedby_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.basic_machineworkingperiod
    ADD CONSTRAINT machineworkingperiod_launchedby_fkey FOREIGN KEY (launchedby_id) REFERENCES public.basic_staff(id) DEFERRABLE;


--
-- Name: basic_machineworkingperiod machineworkingperiod_stoppedby_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.basic_machineworkingperiod
    ADD CONSTRAINT machineworkingperiod_stoppedby_fkey FOREIGN KEY (stoppedby_id) REFERENCES public.basic_staff(id) DEFERRABLE;


--
-- Name: basic_machineworkingperiod machineworkingperiod_workstation_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.basic_machineworkingperiod
    ADD CONSTRAINT machineworkingperiod_workstation_fkey FOREIGN KEY (workstation_id) REFERENCES public.basic_workstation(id) DEFERRABLE;


--
-- Name: cmmsmachineparts_maintenanceevent maintenanceevent_division_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.cmmsmachineparts_maintenanceevent
    ADD CONSTRAINT maintenanceevent_division_fkey FOREIGN KEY (division_id) REFERENCES public.basic_division(id) DEFERRABLE;


--
-- Name: cmmsmachineparts_maintenanceevent maintenanceevent_factory_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.cmmsmachineparts_maintenanceevent
    ADD CONSTRAINT maintenanceevent_factory_fkey FOREIGN KEY (factory_id) REFERENCES public.basic_factory(id) DEFERRABLE;


--
-- Name: cmmsmachineparts_maintenanceevent maintenanceevent_faulttype_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.cmmsmachineparts_maintenanceevent
    ADD CONSTRAINT maintenanceevent_faulttype_fkey FOREIGN KEY (faulttype_id) REFERENCES public.basic_faulttype(id) DEFERRABLE;


--
-- Name: cmmsmachineparts_maintenanceevent maintenanceevent_maintenanceeventcontext_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.cmmsmachineparts_maintenanceevent
    ADD CONSTRAINT maintenanceevent_maintenanceeventcontext_fkey FOREIGN KEY (maintenanceeventcontext_id) REFERENCES public.cmmsmachineparts_maintenanceeventcontext(id) DEFERRABLE;


--
-- Name: cmmsmachineparts_maintenanceevent maintenanceevent_personreceiving_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.cmmsmachineparts_maintenanceevent
    ADD CONSTRAINT maintenanceevent_personreceiving_fkey FOREIGN KEY (personreceiving_id) REFERENCES public.basic_staff(id) DEFERRABLE;


--
-- Name: cmmsmachineparts_maintenanceevent maintenanceevent_productionline_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.cmmsmachineparts_maintenanceevent
    ADD CONSTRAINT maintenanceevent_productionline_fkey FOREIGN KEY (productionline_id) REFERENCES public.productionlines_productionline(id) DEFERRABLE;


--
-- Name: cmmsmachineparts_maintenanceevent maintenanceevent_reportingemployee_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.cmmsmachineparts_maintenanceevent
    ADD CONSTRAINT maintenanceevent_reportingemployee_fkey FOREIGN KEY (reportingemployee_id) REFERENCES public.basic_staff(id) DEFERRABLE;


--
-- Name: cmmsmachineparts_maintenanceevent maintenanceevent_sourcecost_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.cmmsmachineparts_maintenanceevent
    ADD CONSTRAINT maintenanceevent_sourcecost_fkey FOREIGN KEY (sourcecost_id) REFERENCES public.cmmsmachineparts_sourcecost(id) DEFERRABLE;


--
-- Name: cmmsmachineparts_maintenanceevent maintenanceevent_subassembly_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.cmmsmachineparts_maintenanceevent
    ADD CONSTRAINT maintenanceevent_subassembly_fkey FOREIGN KEY (subassembly_id) REFERENCES public.basic_subassembly(id) DEFERRABLE;


--
-- Name: cmmsmachineparts_maintenanceevent maintenanceevent_workstation_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.cmmsmachineparts_maintenanceevent
    ADD CONSTRAINT maintenanceevent_workstation_fkey FOREIGN KEY (workstation_id) REFERENCES public.basic_workstation(id) DEFERRABLE;


--
-- Name: cmmsmachineparts_maintenanceeventcontext maintenanceeventcontext_division_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.cmmsmachineparts_maintenanceeventcontext
    ADD CONSTRAINT maintenanceeventcontext_division_fkey FOREIGN KEY (division_id) REFERENCES public.basic_division(id) DEFERRABLE;


--
-- Name: cmmsmachineparts_maintenanceeventcontext maintenanceeventcontext_factory_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.cmmsmachineparts_maintenanceeventcontext
    ADD CONSTRAINT maintenanceeventcontext_factory_fkey FOREIGN KEY (factory_id) REFERENCES public.basic_factory(id) DEFERRABLE;


--
-- Name: cmmsmachineparts_maintenanceeventstatechange maintenanceeventstatechange_maintenanceevent_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.cmmsmachineparts_maintenanceeventstatechange
    ADD CONSTRAINT maintenanceeventstatechange_maintenanceevent_fkey FOREIGN KEY (maintenanceevent_id) REFERENCES public.cmmsmachineparts_maintenanceevent(id) DEFERRABLE;


--
-- Name: cmmsmachineparts_maintenanceeventstatechange maintenanceeventstatechange_shift_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.cmmsmachineparts_maintenanceeventstatechange
    ADD CONSTRAINT maintenanceeventstatechange_shift_fkey FOREIGN KEY (shift_id) REFERENCES public.basic_shift(id) DEFERRABLE;


--
-- Name: masterorders_masterorder masterorder_address_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.masterorders_masterorder
    ADD CONSTRAINT masterorder_address_fkey FOREIGN KEY (address_id) REFERENCES public.basic_address(id) DEFERRABLE;


--
-- Name: masterorders_masterorder masterorder_company_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.masterorders_masterorder
    ADD CONSTRAINT masterorder_company_fkey FOREIGN KEY (company_id) REFERENCES public.basic_company(id) DEFERRABLE;


--
-- Name: masterorders_masterorder masterorder_masterorderdefinition_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.masterorders_masterorder
    ADD CONSTRAINT masterorder_masterorderdefinition_fkey FOREIGN KEY (masterorderdefinition_id) REFERENCES public.masterorders_masterorderdefinition(id) DEFERRABLE;


--
-- Name: jointable_masterorder_masterordersmaterialrequirement masterorder_masterordersmaterialrequirement_masterorder_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.jointable_masterorder_masterordersmaterialrequirement
    ADD CONSTRAINT masterorder_masterordersmaterialrequirement_masterorder_fkey FOREIGN KEY (masterorder_id) REFERENCES public.masterorders_masterorder(id) DEFERRABLE;


--
-- Name: jointable_masterorder_masterordersmaterialrequirement masterorder_masterordersmaterialrequirement_masterordersmateria; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.jointable_masterorder_masterordersmaterialrequirement
    ADD CONSTRAINT masterorder_masterordersmaterialrequirement_masterordersmateria FOREIGN KEY (masterordersmaterialrequirement_id) REFERENCES public.masterorders_masterordersmaterialrequirement(id) DEFERRABLE;


--
-- Name: masterorders_masterorder masterorder_salesplan_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.masterorders_masterorder
    ADD CONSTRAINT masterorder_salesplan_fkey FOREIGN KEY (salesplan_id) REFERENCES public.masterorders_salesplan(id) DEFERRABLE;


--
-- Name: masterorders_masterorderdefinition masterorderdefinition_parameter_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.masterorders_masterorderdefinition
    ADD CONSTRAINT masterorderdefinition_parameter_fkey FOREIGN KEY (parameter_id) REFERENCES public.basic_parameter(id) DEFERRABLE;


--
-- Name: masterorders_masterorderproduct masterorderproduct_masterorder_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.masterorders_masterorderproduct
    ADD CONSTRAINT masterorderproduct_masterorder_fkey FOREIGN KEY (masterorder_id) REFERENCES public.masterorders_masterorder(id) DEFERRABLE;


--
-- Name: goodfood_palnumber masterorderproduct_masterorder_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.goodfood_palnumber
    ADD CONSTRAINT masterorderproduct_masterorder_fkey FOREIGN KEY (masterorder_id) REFERENCES public.masterorders_masterorder(id) DEFERRABLE;


--
-- Name: masterorders_masterorderproduct masterorderproduct_product_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.masterorders_masterorderproduct
    ADD CONSTRAINT masterorderproduct_product_fkey FOREIGN KEY (product_id) REFERENCES public.basic_product(id) DEFERRABLE;


--
-- Name: masterorders_masterorderproduct masterorderproduct_technology_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.masterorders_masterorderproduct
    ADD CONSTRAINT masterorderproduct_technology_fkey FOREIGN KEY (technology_id) REFERENCES public.technologies_technology(id) DEFERRABLE;


--
-- Name: masterorders_masterorderproductattrvalue masterorderproductattrvalue_attribute_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.masterorders_masterorderproductattrvalue
    ADD CONSTRAINT masterorderproductattrvalue_attribute_fkey FOREIGN KEY (attribute_id) REFERENCES public.basic_attribute(id) DEFERRABLE;


--
-- Name: masterorders_masterorderproductattrvalue masterorderproductattrvalue_attributevalue_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.masterorders_masterorderproductattrvalue
    ADD CONSTRAINT masterorderproductattrvalue_attributevalue_fkey FOREIGN KEY (attributevalue_id) REFERENCES public.basic_attributevalue(id) DEFERRABLE;


--
-- Name: masterorders_masterorderproductattrvalue masterorderproductattrvalue_masterorderproduct_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.masterorders_masterorderproductattrvalue
    ADD CONSTRAINT masterorderproductattrvalue_masterorderproduct_fkey FOREIGN KEY (masterorderproduct_id) REFERENCES public.masterorders_masterorderproduct(id) DEFERRABLE;


--
-- Name: masterorders_masterordersmaterialrequirementproduct masterordersmaterialrequirementproduct_company_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.masterorders_masterordersmaterialrequirementproduct
    ADD CONSTRAINT masterordersmaterialrequirementproduct_company_fkey FOREIGN KEY (supplier_id) REFERENCES public.basic_company(id) DEFERRABLE;


--
-- Name: masterorders_masterordersmaterialrequirementproduct masterordersmaterialrequirementproduct_masterordersmaterialrequ; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.masterorders_masterordersmaterialrequirementproduct
    ADD CONSTRAINT masterordersmaterialrequirementproduct_masterordersmaterialrequ FOREIGN KEY (masterordersmaterialrequirement_id) REFERENCES public.masterorders_masterordersmaterialrequirement(id) DEFERRABLE;


--
-- Name: masterorders_masterordersmaterialrequirementproduct masterordersmaterialrequirementproduct_product_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.masterorders_masterordersmaterialrequirementproduct
    ADD CONSTRAINT masterordersmaterialrequirementproduct_product_fkey FOREIGN KEY (product_id) REFERENCES public.basic_product(id) DEFERRABLE;


--
-- Name: masterorders_masterordersmaterialrequirementproduct masterordersmaterialrequirementproduct_technologyinputproductty; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.masterorders_masterordersmaterialrequirementproduct
    ADD CONSTRAINT masterordersmaterialrequirementproduct_technologyinputproductty FOREIGN KEY (technologyinputproducttype_id) REFERENCES public.technologies_technologyinputproducttype(id) DEFERRABLE;


--
-- Name: productflowthrudivision_materialavailability materialavailability_location_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.productflowthrudivision_materialavailability
    ADD CONSTRAINT materialavailability_location_fkey FOREIGN KEY (location_id) REFERENCES public.materialflow_location(id) DEFERRABLE;


--
-- Name: productflowthrudivision_materialavailability materialavailability_order_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.productflowthrudivision_materialavailability
    ADD CONSTRAINT materialavailability_order_fkey FOREIGN KEY (order_id) REFERENCES public.orders_order(id) DEFERRABLE;


--
-- Name: productflowthrudivision_materialavailability materialavailability_product_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.productflowthrudivision_materialavailability
    ADD CONSTRAINT materialavailability_product_fkey FOREIGN KEY (product_id) REFERENCES public.basic_product(id) DEFERRABLE;


--
-- Name: materialrequirements_materialrequirement materialrequirement_location_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.materialrequirements_materialrequirement
    ADD CONSTRAINT materialrequirement_location_fkey FOREIGN KEY (location_id) REFERENCES public.materialflow_location(id) DEFERRABLE;


--
-- Name: jointable_materialrequirement_order materialrequirement_order_materialrequirement_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.jointable_materialrequirement_order
    ADD CONSTRAINT materialrequirement_order_materialrequirement_fkey FOREIGN KEY (materialrequirement_id) REFERENCES public.materialrequirements_materialrequirement(id) DEFERRABLE;


--
-- Name: jointable_materialrequirement_order materialrequirement_order_order_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.jointable_materialrequirement_order
    ADD CONSTRAINT materialrequirement_order_order_fkey FOREIGN KEY (order_id) REFERENCES public.orders_order(id) DEFERRABLE;


--
-- Name: ordersupplies_materialrequirementcoverage materialrequirementcoverage_forder_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.ordersupplies_materialrequirementcoverage
    ADD CONSTRAINT materialrequirementcoverage_forder_fkey FOREIGN KEY (order_id) REFERENCES public.orders_order(id) DEFERRABLE;


--
-- Name: materialrequirementcoveragefororder_coveragefororder materialrequirementcoverage_order_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.materialrequirementcoveragefororder_coveragefororder
    ADD CONSTRAINT materialrequirementcoverage_order_fkey FOREIGN KEY (order_id) REFERENCES public.orders_order(id) DEFERRABLE;


--
-- Name: jointable_materialrequirementcoverage_order materialrequirementcoverage_order_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.jointable_materialrequirementcoverage_order
    ADD CONSTRAINT materialrequirementcoverage_order_fkey FOREIGN KEY (materialrequirementcoverage_id) REFERENCES public.ordersupplies_materialrequirementcoverage(id) DEFERRABLE;


--
-- Name: ordersupplies_materialrequirementcoverage materialrequirementcoverage_ordersgroup_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.ordersupplies_materialrequirementcoverage
    ADD CONSTRAINT materialrequirementcoverage_ordersgroup_fkey FOREIGN KEY (forordersgroup_id) REFERENCES public.ordersgroups_ordersgroup(id) DEFERRABLE;


--
-- Name: materialrequirements_materialrequirementproduct materialrequirementproduct_batch_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.materialrequirements_materialrequirementproduct
    ADD CONSTRAINT materialrequirementproduct_batch_fkey FOREIGN KEY (batch_id) REFERENCES public.advancedgenealogy_batch(id) DEFERRABLE;


--
-- Name: materialrequirements_materialrequirementproduct materialrequirementproduct_location_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.materialrequirements_materialrequirementproduct
    ADD CONSTRAINT materialrequirementproduct_location_fkey FOREIGN KEY (location_id) REFERENCES public.materialflow_location(id) DEFERRABLE;


--
-- Name: materialrequirements_materialrequirementproduct materialrequirementproduct_product_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.materialrequirements_materialrequirementproduct
    ADD CONSTRAINT materialrequirementproduct_product_fkey FOREIGN KEY (product_id) REFERENCES public.basic_product(id) DEFERRABLE;


--
-- Name: states_message message_assignmenttoshiftstatechange_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.states_message
    ADD CONSTRAINT message_assignmenttoshiftstatechange_fkey FOREIGN KEY (assignmenttoshiftstatechange_id) REFERENCES public.assignmenttoshift_assignmenttoshiftstatechange(id) DEFERRABLE;


--
-- Name: states_message message_batchstatechange_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.states_message
    ADD CONSTRAINT message_batchstatechange_fkey FOREIGN KEY (batchstatechange_id) REFERENCES public.advancedgenealogy_batchstatechange(id) DEFERRABLE;


--
-- Name: subcontractorportal_subordermessage message_company_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.subcontractorportal_subordermessage
    ADD CONSTRAINT message_company_fkey FOREIGN KEY (company_id) REFERENCES public.basic_company(id) DEFERRABLE;


--
-- Name: states_message message_confectionprotocolstatechange_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.states_message
    ADD CONSTRAINT message_confectionprotocolstatechange_fkey FOREIGN KEY (confectionprotocolstatechange_id) REFERENCES public.goodfood_confectionprotocolstatechange(id) DEFERRABLE;


--
-- Name: states_message message_deliverystatechange_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.states_message
    ADD CONSTRAINT message_deliverystatechange_fkey FOREIGN KEY (deliverystatechange_id) REFERENCES public.deliveries_deliverystatechange(id) DEFERRABLE;


--
-- Name: states_message message_extrusionprotocolstatechange_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.states_message
    ADD CONSTRAINT message_extrusionprotocolstatechange_fkey FOREIGN KEY (extrusionprotocolstatechange_id) REFERENCES public.goodfood_extrusionprotocolstatechange(id) DEFERRABLE;


--
-- Name: states_message message_maintenanceeventstatechange_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.states_message
    ADD CONSTRAINT message_maintenanceeventstatechange_fkey FOREIGN KEY (maintenanceeventstatechange_id) REFERENCES public.cmmsmachineparts_maintenanceeventstatechange(id) DEFERRABLE;


--
-- Name: states_message message_negotiationstatechange_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.states_message
    ADD CONSTRAINT message_negotiationstatechange_fkey FOREIGN KEY (negotiationstatechange_id) REFERENCES public.supplynegotiations_negotiationstatechange(id) DEFERRABLE;


--
-- Name: states_message message_offerstatechange_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.states_message
    ADD CONSTRAINT message_offerstatechange_fkey FOREIGN KEY (offerstatechange_id) REFERENCES public.supplynegotiations_offerstatechange(id) DEFERRABLE;


--
-- Name: states_message message_orderstatechange_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.states_message
    ADD CONSTRAINT message_orderstatechange_fkey FOREIGN KEY (orderstatechange_id) REFERENCES public.orders_orderstatechange(id) DEFERRABLE;


--
-- Name: states_message message_palletlabelstatechange_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.states_message
    ADD CONSTRAINT message_palletlabelstatechange_fkey FOREIGN KEY (palletlabelstatechange_id) REFERENCES public.goodfood_palletlabelstatechange(id) DEFERRABLE;


--
-- Name: states_message message_palletstatechange_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.states_message
    ADD CONSTRAINT message_palletstatechange_fkey FOREIGN KEY (palletstatechange_id) REFERENCES public.goodfood_palletstatechange(id) DEFERRABLE;


--
-- Name: states_message message_plannedeventstatechange_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.states_message
    ADD CONSTRAINT message_plannedeventstatechange_fkey FOREIGN KEY (plannedeventstatechange_id) REFERENCES public.cmmsmachineparts_plannedeventstatechange(id) DEFERRABLE;


--
-- Name: states_message message_prodrecstatechange_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.states_message
    ADD CONSTRAINT message_prodrecstatechange_fkey FOREIGN KEY (productiontrackingstatechange_id) REFERENCES public.productioncounting_productiontrackingstatechange(id) DEFERRABLE;


--
-- Name: states_message message_recurringeventstatechange_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.states_message
    ADD CONSTRAINT message_recurringeventstatechange_fkey FOREIGN KEY (recurringeventstatechange_id) REFERENCES public.cmmsscheduler_recurringeventstatechange(id) DEFERRABLE;


--
-- Name: states_message message_requestforquotationstatechange_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.states_message
    ADD CONSTRAINT message_requestforquotationstatechange_fkey FOREIGN KEY (requestforquotationstatechange_id) REFERENCES public.supplynegotiations_requestforquotationstatechange(id) DEFERRABLE;


--
-- Name: subcontractorportal_subordermessage message_staff_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.subcontractorportal_subordermessage
    ADD CONSTRAINT message_staff_fkey FOREIGN KEY (staff_id) REFERENCES public.basic_staff(id) DEFERRABLE;


--
-- Name: subcontractorportal_subordermessage message_suborder_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.subcontractorportal_subordermessage
    ADD CONSTRAINT message_suborder_fkey FOREIGN KEY (suborder_id) REFERENCES public.subcontractorportal_suborder(id) DEFERRABLE;


--
-- Name: states_message message_technologystatechange_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.states_message
    ADD CONSTRAINT message_technologystatechange_fkey FOREIGN KEY (technologystatechange_id) REFERENCES public.technologies_technologystatechange(id) DEFERRABLE;


--
-- Name: states_message message_trackingrecordstatechange_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.states_message
    ADD CONSTRAINT message_trackingrecordstatechange_fkey FOREIGN KEY (trackingrecordstatechange_id) REFERENCES public.advancedgenealogy_trackingrecordstatechange(id) DEFERRABLE;


--
-- Name: states_message message_warehouseissuestatechange_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.states_message
    ADD CONSTRAINT message_warehouseissuestatechange_fkey FOREIGN KEY (warehouseissuestatechange_id) REFERENCES public.productflowthrudivision_warehouseissuestatechange(id) DEFERRABLE;


--
-- Name: basic_model model_assortment_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.basic_model
    ADD CONSTRAINT model_assortment_fkey FOREIGN KEY (assortment_id) REFERENCES public.basic_assortment(id) DEFERRABLE;


--
-- Name: basic_model model_forms_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.basic_model
    ADD CONSTRAINT model_forms_fkey FOREIGN KEY (forms_id) REFERENCES public.basic_forms(id) DEFERRABLE;


--
-- Name: basic_model model_label_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.basic_model
    ADD CONSTRAINT model_label_fkey FOREIGN KEY (label_id) REFERENCES public.basic_label(id) DEFERRABLE;


--
-- Name: productflowthrudivision_modelcardproduct modelcardproduct_modelcard_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.productflowthrudivision_modelcardproduct
    ADD CONSTRAINT modelcardproduct_modelcard_fkey FOREIGN KEY (modelcard_id) REFERENCES public.productflowthrudivision_modelcard(id) DEFERRABLE;


--
-- Name: productflowthrudivision_modelcardproduct modelcardproduct_product_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.productflowthrudivision_modelcardproduct
    ADD CONSTRAINT modelcardproduct_product_fkey FOREIGN KEY (product_id) REFERENCES public.basic_product(id) DEFERRABLE;


--
-- Name: productflowthrudivision_modelcardproduct modelcardproduct_technology_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.productflowthrudivision_modelcardproduct
    ADD CONSTRAINT modelcardproduct_technology_fkey FOREIGN KEY (technology_id) REFERENCES public.technologies_technology(id) DEFERRABLE;


--
-- Name: technologies_modifytechnologyaddproducthelper modifytechnologyaddproducthelper_modifytechnologyhelper_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.technologies_modifytechnologyaddproducthelper
    ADD CONSTRAINT modifytechnologyaddproducthelper_modifytechnologyhelper_fkey FOREIGN KEY (modifytechnologyhelper_id) REFERENCES public.technologies_modifytechnologyhelper(id) DEFERRABLE;


--
-- Name: technologies_modifytechnologyaddproducthelper modifytechnologyaddproducthelper_product_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.technologies_modifytechnologyaddproducthelper
    ADD CONSTRAINT modifytechnologyaddproducthelper_product_fkey FOREIGN KEY (product_id) REFERENCES public.basic_product(id) DEFERRABLE;


--
-- Name: technologies_modifytechnologyhelper modifytechnologyhelper_product_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.technologies_modifytechnologyhelper
    ADD CONSTRAINT modifytechnologyhelper_product_fkey FOREIGN KEY (product_id) REFERENCES public.basic_product(id) DEFERRABLE;


--
-- Name: technologies_modifytechnologyhelper modifytechnologyhelper_replaceproduct_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.technologies_modifytechnologyhelper
    ADD CONSTRAINT modifytechnologyhelper_replaceproduct_fkey FOREIGN KEY (replaceproduct_id) REFERENCES public.basic_product(id) DEFERRABLE;


--
-- Name: assignmenttoshift_multiassignmenttoshift multiassignmenttoshift_assignmenttoshift_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.assignmenttoshift_multiassignmenttoshift
    ADD CONSTRAINT multiassignmenttoshift_assignmenttoshift_fkey FOREIGN KEY (assignmenttoshift_id) REFERENCES public.assignmenttoshift_assignmenttoshift(id) DEFERRABLE;


--
-- Name: assignmenttoshift_multiassignmenttoshift multiassignmenttoshift_masterorder_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.assignmenttoshift_multiassignmenttoshift
    ADD CONSTRAINT multiassignmenttoshift_masterorder_fkey FOREIGN KEY (masterorder_id) REFERENCES public.masterorders_masterorder(id) DEFERRABLE;


--
-- Name: assignmenttoshift_multiassignmenttoshift multiassignmenttoshift_productionline_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.assignmenttoshift_multiassignmenttoshift
    ADD CONSTRAINT multiassignmenttoshift_productionline_fkey FOREIGN KEY (productionline_id) REFERENCES public.productionlines_productionline(id) DEFERRABLE;


--
-- Name: supplynegotiations_negotiationproduct negotiationproduct_negotiation_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.supplynegotiations_negotiationproduct
    ADD CONSTRAINT negotiationproduct_negotiation_fkey FOREIGN KEY (negotiation_id) REFERENCES public.supplynegotiations_negotiation(id) DEFERRABLE;


--
-- Name: supplynegotiations_negotiationproduct negotiationproduct_operation_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.supplynegotiations_negotiationproduct
    ADD CONSTRAINT negotiationproduct_operation_fkey FOREIGN KEY (operation_id) REFERENCES public.technologies_operation(id) DEFERRABLE;


--
-- Name: supplynegotiations_negotiationproduct negotiationproduct_product_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.supplynegotiations_negotiationproduct
    ADD CONSTRAINT negotiationproduct_product_fkey FOREIGN KEY (product_id) REFERENCES public.basic_product(id) DEFERRABLE;


--
-- Name: supplynegotiations_negotiationstatechange negotiationstatechange_negotiation_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.supplynegotiations_negotiationstatechange
    ADD CONSTRAINT negotiationstatechange_negotiation_fkey FOREIGN KEY (negotiation_id) REFERENCES public.supplynegotiations_negotiation(id) DEFERRABLE;


--
-- Name: supplynegotiations_negotiationstatechange negotiationstatechange_shift_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.supplynegotiations_negotiationstatechange
    ADD CONSTRAINT negotiationstatechange_shift_fkey FOREIGN KEY (shift_id) REFERENCES public.basic_shift(id) DEFERRABLE;


--
-- Name: basic_numberpatternelement numberpatternelement_numberpattern_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.basic_numberpatternelement
    ADD CONSTRAINT numberpatternelement_numberpattern_fkey FOREIGN KEY (numberpattern_id) REFERENCES public.basic_numberpattern(id);


--
-- Name: nutritionfacts_prototypeproductcomponent nutrientcalculation_product_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.nutritionfacts_prototypeproductcomponent
    ADD CONSTRAINT nutrientcalculation_product_fkey FOREIGN KEY (product_id) REFERENCES public.basic_product(id) DEFERRABLE;


--
-- Name: nutritionfacts_nutrientcalculation nutrientcalculation_product_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.nutritionfacts_nutrientcalculation
    ADD CONSTRAINT nutrientcalculation_product_fkey FOREIGN KEY (product_id) REFERENCES public.basic_product(id) DEFERRABLE;


--
-- Name: nutritionfacts_nutrition nutrition_nutritiongroup_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.nutritionfacts_nutrition
    ADD CONSTRAINT nutrition_nutritiongroup_fkey FOREIGN KEY (nutritiongroup_id) REFERENCES public.nutritionfacts_nutritiongroup(id) DEFERRABLE;


--
-- Name: nutritionfacts_nutritionelement nutritionelement_nutrition_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.nutritionfacts_nutritionelement
    ADD CONSTRAINT nutritionelement_nutrition_fkey FOREIGN KEY (nutrition_id) REFERENCES public.nutritionfacts_nutrition(id) DEFERRABLE;


--
-- Name: nutritionfacts_nutritionelement nutritionelement_product_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.nutritionfacts_nutritionelement
    ADD CONSTRAINT nutritionelement_product_fkey FOREIGN KEY (product_id) REFERENCES public.basic_product(id) DEFERRABLE;


--
-- Name: nutritionfacts_nutritionelement nutritionelement_prototypeproduct_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.nutritionfacts_nutritionelement
    ADD CONSTRAINT nutritionelement_prototypeproduct_fkey FOREIGN KEY (prototypeproduct_id) REFERENCES public.nutritionfacts_prototypeproduct(id) DEFERRABLE;


--
-- Name: nutritionfacts_prototypeproductcomponent nutritionfacts_prototypeproduct_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.nutritionfacts_prototypeproductcomponent
    ADD CONSTRAINT nutritionfacts_prototypeproduct_fkey FOREIGN KEY (prototypeproduct_id) REFERENCES public.nutritionfacts_prototypeproduct(id) DEFERRABLE;


--
-- Name: jointable_oee_productionline oee_productionline_oee_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.jointable_oee_productionline
    ADD CONSTRAINT oee_productionline_oee_fkey FOREIGN KEY (oee_id) REFERENCES public.oee_oee(id) DEFERRABLE;


--
-- Name: jointable_oee_productionline oee_productionline_productionline_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.jointable_oee_productionline
    ADD CONSTRAINT oee_productionline_productionline_fkey FOREIGN KEY (productionline_id) REFERENCES public.productionlines_productionline(id) DEFERRABLE;


--
-- Name: jointable_oee_workstation oee_workstation_oee_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.jointable_oee_workstation
    ADD CONSTRAINT oee_workstation_oee_fkey FOREIGN KEY (oee_id) REFERENCES public.oee_oee(id) DEFERRABLE;


--
-- Name: jointable_oee_workstation oee_workstation_workstation_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.jointable_oee_workstation
    ADD CONSTRAINT oee_workstation_workstation_fkey FOREIGN KEY (workstation_id) REFERENCES public.basic_workstation(id) DEFERRABLE;


--
-- Name: oee_oeevalue oeevalue_oee_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.oee_oeevalue
    ADD CONSTRAINT oeevalue_oee_fkey FOREIGN KEY (oee_id) REFERENCES public.oee_oee(id) DEFERRABLE;


--
-- Name: oee_oeevalue oeevalue_productionline_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.oee_oeevalue
    ADD CONSTRAINT oeevalue_productionline_fkey FOREIGN KEY (productionline_id) REFERENCES public.productionlines_productionline(id) DEFERRABLE;


--
-- Name: oee_oeevalue oeevalue_workstation_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.oee_oeevalue
    ADD CONSTRAINT oeevalue_workstation_fkey FOREIGN KEY (workstation_id) REFERENCES public.basic_workstation(id) DEFERRABLE;


--
-- Name: supplynegotiations_offer offer_company_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.supplynegotiations_offer
    ADD CONSTRAINT offer_company_fkey FOREIGN KEY (supplier_id) REFERENCES public.basic_company(id) DEFERRABLE;


--
-- Name: supplynegotiations_offer offer_currency_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.supplynegotiations_offer
    ADD CONSTRAINT offer_currency_fkey FOREIGN KEY (currency_id) REFERENCES public.basic_currency(id) DEFERRABLE;


--
-- Name: supplynegotiations_offer offer_negotiation_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.supplynegotiations_offer
    ADD CONSTRAINT offer_negotiation_fkey FOREIGN KEY (negotiation_id) REFERENCES public.supplynegotiations_negotiation(id) DEFERRABLE;


--
-- Name: supplynegotiations_offer offer_requestforquotation_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.supplynegotiations_offer
    ADD CONSTRAINT offer_requestforquotation_fkey FOREIGN KEY (requestforquotation_id) REFERENCES public.supplynegotiations_requestforquotation(id) DEFERRABLE;


--
-- Name: supplynegotiations_offerproduct offerproduct_offer_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.supplynegotiations_offerproduct
    ADD CONSTRAINT offerproduct_offer_fkey FOREIGN KEY (offer_id) REFERENCES public.supplynegotiations_offer(id) DEFERRABLE;


--
-- Name: supplynegotiations_offerproduct offerproduct_operation_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.supplynegotiations_offerproduct
    ADD CONSTRAINT offerproduct_operation_fkey FOREIGN KEY (operation_id) REFERENCES public.technologies_operation(id) DEFERRABLE;


--
-- Name: supplynegotiations_offerproduct offerproduct_product_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.supplynegotiations_offerproduct
    ADD CONSTRAINT offerproduct_product_fkey FOREIGN KEY (product_id) REFERENCES public.basic_product(id) DEFERRABLE;


--
-- Name: supplynegotiations_offerstatechange offerstatechange_offer_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.supplynegotiations_offerstatechange
    ADD CONSTRAINT offerstatechange_offer_fkey FOREIGN KEY (offer_id) REFERENCES public.supplynegotiations_offer(id) DEFERRABLE;


--
-- Name: supplynegotiations_offerstatechange offerstatechange_shift_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.supplynegotiations_offerstatechange
    ADD CONSTRAINT offerstatechange_shift_fkey FOREIGN KEY (shift_id) REFERENCES public.basic_shift(id) DEFERRABLE;


--
-- Name: ordersgroups_ordersgroupissuedmaterialposition ogissuedmaterialposition_ordersgroupissuedmaterial_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.ordersgroups_ordersgroupissuedmaterialposition
    ADD CONSTRAINT ogissuedmaterialposition_ordersgroupissuedmaterial_fkey FOREIGN KEY (ordersgroupissuedmaterial_id) REFERENCES public.ordersgroups_ordersgroupissuedmaterial(id) DEFERRABLE;


--
-- Name: ordersgroups_ordersgroupproductstoissueentryhelper ogproductstoissueentryhelper_ogproductstoissuehelper_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.ordersgroups_ordersgroupproductstoissueentryhelper
    ADD CONSTRAINT ogproductstoissueentryhelper_ogproductstoissuehelper_fkey FOREIGN KEY (ordersgroupproductstoissuehelper_id) REFERENCES public.ordersgroups_ordersgroupproductstoissuehelper(id);


--
-- Name: ordersgroups_ordersgroupproductstoissuehelper ogproductstoissuehelper_ordersgroupmaterialrequirement_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.ordersgroups_ordersgroupproductstoissuehelper
    ADD CONSTRAINT ogproductstoissuehelper_ordersgroupmaterialrequirement_fkey FOREIGN KEY (ordersgroupmaterialrequirement_id) REFERENCES public.ordersgroups_ordersgroupmaterialrequirement(id);


--
-- Name: ordersgroups_ordersgroupproductstoissueentryhelper ogroductstoissueentryhelper_ogmaterialrequirementproduct_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.ordersgroups_ordersgroupproductstoissueentryhelper
    ADD CONSTRAINT ogroductstoissueentryhelper_ogmaterialrequirementproduct_fkey FOREIGN KEY (ordersgroupmaterialrequirementproduct_id) REFERENCES public.ordersgroups_ordersgroupmaterialrequirementproduct(id);


--
-- Name: orders_ordertechnologicalprocesswaste oordertechnologicalprocesswaste_technologicalprocess_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.orders_ordertechnologicalprocesswaste
    ADD CONSTRAINT oordertechnologicalprocesswaste_technologicalprocess_fkey FOREIGN KEY (technologicalprocess_id) REFERENCES public.technologies_technologicalprocess(id) DEFERRABLE;


--
-- Name: subcontractorportal_operation operation_company_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.subcontractorportal_operation
    ADD CONSTRAINT operation_company_fkey FOREIGN KEY (company_id) REFERENCES public.basic_company(id) DEFERRABLE;


--
-- Name: technologies_operation operation_division_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.technologies_operation
    ADD CONSTRAINT operation_division_fkey FOREIGN KEY (division_id) REFERENCES public.basic_division(id) DEFERRABLE;


--
-- Name: subcontractorportal_operation operation_operationcomponent_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.subcontractorportal_operation
    ADD CONSTRAINT operation_operationcomponent_fkey FOREIGN KEY (operationcomponent_id) REFERENCES public.technologies_technologyoperationcomponent(id) DEFERRABLE;


--
-- Name: technologies_operation operation_operationgroup_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.technologies_operation
    ADD CONSTRAINT operation_operationgroup_fkey FOREIGN KEY (operationgroup_id) REFERENCES public.technologies_operationgroup(id) DEFERRABLE;


--
-- Name: technologies_operation operation_piecerate_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.technologies_operation
    ADD CONSTRAINT operation_piecerate_fkey FOREIGN KEY (piecerate_id) REFERENCES public.basic_piecerate(id) DEFERRABLE;


--
-- Name: technologies_operation operation_product_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.technologies_operation
    ADD CONSTRAINT operation_product_fkey FOREIGN KEY (product_id) REFERENCES public.basic_product(id) DEFERRABLE;


--
-- Name: jointable_operation_workstation operation_workstation_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.jointable_operation_workstation
    ADD CONSTRAINT operation_workstation_fkey FOREIGN KEY (workstation_id) REFERENCES public.basic_workstation(id) DEFERRABLE;


--
-- Name: technologies_operation operation_workstation_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.technologies_operation
    ADD CONSTRAINT operation_workstation_fkey FOREIGN KEY (workstationtype_id) REFERENCES public.basic_workstationtype(id) DEFERRABLE;


--
-- Name: orders_operationaltask operationaltask_division_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.orders_operationaltask
    ADD CONSTRAINT operationaltask_division_fkey FOREIGN KEY (division_id) REFERENCES public.basic_division(id) DEFERRABLE;


--
-- Name: orders_operationaltask operationaltask_product_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.orders_operationaltask
    ADD CONSTRAINT operationaltask_product_fkey FOREIGN KEY (product_id) REFERENCES public.basic_product(id) DEFERRABLE;


--
-- Name: orders_operationaltask operationaltask_scheduleposition_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.orders_operationaltask
    ADD CONSTRAINT operationaltask_scheduleposition_fkey FOREIGN KEY (scheduleposition_id) REFERENCES public.orders_scheduleposition(id) DEFERRABLE;


--
-- Name: orders_operationaltask operationaltask_staff_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.orders_operationaltask
    ADD CONSTRAINT operationaltask_staff_fkey FOREIGN KEY (staff_id) REFERENCES public.basic_staff(id) DEFERRABLE;


--
-- Name: jointable_operationaltask_staff operationaltask_staff_operationaltask; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.jointable_operationaltask_staff
    ADD CONSTRAINT operationaltask_staff_operationaltask FOREIGN KEY (operationaltask_id) REFERENCES public.orders_operationaltask(id) DEFERRABLE;


--
-- Name: jointable_operationaltask_staff operationaltask_staff_staff; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.jointable_operationaltask_staff
    ADD CONSTRAINT operationaltask_staff_staff FOREIGN KEY (staff_id) REFERENCES public.basic_staff(id) DEFERRABLE;


--
-- Name: orders_operationaltask operationaltask_suborder_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.orders_operationaltask
    ADD CONSTRAINT operationaltask_suborder_fkey FOREIGN KEY (suborder_id) REFERENCES public.subcontractorportal_suborder(id) DEFERRABLE;


--
-- Name: orders_operationaltask operationaltask_technologyoperationcomponent_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.orders_operationaltask
    ADD CONSTRAINT operationaltask_technologyoperationcomponent_fkey FOREIGN KEY (technologyoperationcomponent_id) REFERENCES public.technologies_technologyoperationcomponent(id) DEFERRABLE;


--
-- Name: orders_operationaltask operationaltask_workstation_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.orders_operationaltask
    ADD CONSTRAINT operationaltask_workstation_fkey FOREIGN KEY (workstation_id) REFERENCES public.basic_workstation(id) DEFERRABLE;


--
-- Name: orders_operationaltaskstatechange operationaltaskstatechange_operationaltask_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.orders_operationaltaskstatechange
    ADD CONSTRAINT operationaltaskstatechange_operationaltask_fkey FOREIGN KEY (operationaltask_id) REFERENCES public.orders_operationaltask(id) DEFERRABLE;


--
-- Name: orders_operationaltaskstatechange operationaltaskstatechange_shift_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.orders_operationaltaskstatechange
    ADD CONSTRAINT operationaltaskstatechange_shift_fkey FOREIGN KEY (shift_id) REFERENCES public.basic_shift(id) DEFERRABLE;


--
-- Name: technologies_operationproductincomponent operationproductincomponent_attribute_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.technologies_operationproductincomponent
    ADD CONSTRAINT operationproductincomponent_attribute_fkey FOREIGN KEY (attribute_id) REFERENCES public.basic_attribute(id) DEFERRABLE;


--
-- Name: technologies_operationproductincomponent operationproductincomponent_operationcomponent_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.technologies_operationproductincomponent
    ADD CONSTRAINT operationproductincomponent_operationcomponent_fkey FOREIGN KEY (operationcomponent_id) REFERENCES public.technologies_technologyoperationcomponent(id) DEFERRABLE;


--
-- Name: technologies_operationproductincomponent operationproductincomponent_product_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.technologies_operationproductincomponent
    ADD CONSTRAINT operationproductincomponent_product_fkey FOREIGN KEY (product_id) REFERENCES public.basic_product(id) DEFERRABLE;


--
-- Name: technologies_operationproductincomponent operationproductincomponent_productsflowlocation_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.technologies_operationproductincomponent
    ADD CONSTRAINT operationproductincomponent_productsflowlocation_fkey FOREIGN KEY (productsflowlocation_id) REFERENCES public.materialflow_location(id) DEFERRABLE;


--
-- Name: technologies_operationproductoutcomponent operationproductoutcomponent_operationcomponent_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.technologies_operationproductoutcomponent
    ADD CONSTRAINT operationproductoutcomponent_operationcomponent_fkey FOREIGN KEY (operationcomponent_id) REFERENCES public.technologies_technologyoperationcomponent(id) DEFERRABLE;


--
-- Name: technologies_operationproductoutcomponent operationproductoutcomponent_product_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.technologies_operationproductoutcomponent
    ADD CONSTRAINT operationproductoutcomponent_product_fkey FOREIGN KEY (product_id) REFERENCES public.basic_product(id) DEFERRABLE;


--
-- Name: technologies_operationproductoutcomponent operationproductoutcomponent_productsflowlocation_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.technologies_operationproductoutcomponent
    ADD CONSTRAINT operationproductoutcomponent_productsflowlocation_fkey FOREIGN KEY (productsflowlocation_id) REFERENCES public.materialflow_location(id) DEFERRABLE;


--
-- Name: technologies_operationproductoutcomponent operationproductoutcomponent_wastereceptionwarehouse_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.technologies_operationproductoutcomponent
    ADD CONSTRAINT operationproductoutcomponent_wastereceptionwarehouse_fkey FOREIGN KEY (wastereceptionwarehouse_id) REFERENCES public.materialflow_location(id) DEFERRABLE;


--
-- Name: technologies_operationskill operationskill_operation_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.technologies_operationskill
    ADD CONSTRAINT operationskill_operation_fkey FOREIGN KEY (operation_id) REFERENCES public.technologies_operation(id) DEFERRABLE;


--
-- Name: cmmsmachineparts_operationtool operationtool_operation_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.cmmsmachineparts_operationtool
    ADD CONSTRAINT operationtool_operation_fkey FOREIGN KEY (operation_id) REFERENCES public.technologies_operation(id) DEFERRABLE;


--
-- Name: cmmsmachineparts_operationtool operationtool_tool_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.cmmsmachineparts_operationtool
    ADD CONSTRAINT operationtool_tool_fkey FOREIGN KEY (tool_id) REFERENCES public.cmmsmachineparts_tool(id) DEFERRABLE;


--
-- Name: timenormsforoperations_operationworkstationtime operationworkstationtime_operation_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.timenormsforoperations_operationworkstationtime
    ADD CONSTRAINT operationworkstationtime_operation_fkey FOREIGN KEY (operation_id) REFERENCES public.technologies_operation(id) DEFERRABLE;


--
-- Name: timenormsforoperations_operationworkstationtime operationworkstationtime_workstation_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.timenormsforoperations_operationworkstationtime
    ADD CONSTRAINT operationworkstationtime_workstation_fkey FOREIGN KEY (workstation_id) REFERENCES public.basic_workstation(id) DEFERRABLE;


--
-- Name: productionscheduling_opercomptimecalculation opercomptimecalculation_ordertimecalculation_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.productionscheduling_opercomptimecalculation
    ADD CONSTRAINT opercomptimecalculation_ordertimecalculation_fkey FOREIGN KEY (ordertimecalculation_id) REFERENCES public.productionscheduling_ordertimecalculation(id) DEFERRABLE;


--
-- Name: productionscheduling_opercomptimecalculation opercomptimecalculation_technologyoperationcomponent_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.productionscheduling_opercomptimecalculation
    ADD CONSTRAINT opercomptimecalculation_technologyoperationcomponent_fkey FOREIGN KEY (technologyoperationcomponent_id) REFERENCES public.technologies_technologyoperationcomponent(id) DEFERRABLE;


--
-- Name: productflowthrudivision_opertaskmaterialavailability opertaskmaterialavailability_location_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.productflowthrudivision_opertaskmaterialavailability
    ADD CONSTRAINT opertaskmaterialavailability_location_fkey FOREIGN KEY (location_id) REFERENCES public.materialflow_location(id) DEFERRABLE;


--
-- Name: productflowthrudivision_opertaskmaterialavailability opertaskmaterialavailability_operationaltask_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.productflowthrudivision_opertaskmaterialavailability
    ADD CONSTRAINT opertaskmaterialavailability_operationaltask_fkey FOREIGN KEY (operationaltask_id) REFERENCES public.orders_operationaltask(id) DEFERRABLE;


--
-- Name: productflowthrudivision_opertaskmaterialavailability opertaskmaterialavailability_product_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.productflowthrudivision_opertaskmaterialavailability
    ADD CONSTRAINT opertaskmaterialavailability_product_fkey FOREIGN KEY (product_id) REFERENCES public.basic_product(id) DEFERRABLE;


--
-- Name: orders_order order_address_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.orders_order
    ADD CONSTRAINT order_address_fkey FOREIGN KEY (address_id) REFERENCES public.basic_address(id) DEFERRABLE;


--
-- Name: orders_order order_division_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.orders_order
    ADD CONSTRAINT order_division_fkey FOREIGN KEY (division_id) REFERENCES public.basic_division(id) DEFERRABLE;


--
-- Name: orders_order order_masterorder_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.orders_order
    ADD CONSTRAINT order_masterorder_fkey FOREIGN KEY (masterorder_id) REFERENCES public.masterorders_masterorder(id) DEFERRABLE;


--
-- Name: orders_order order_masterorderproduct_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.orders_order
    ADD CONSTRAINT order_masterorderproduct_fkey FOREIGN KEY (masterorderproduct_id) REFERENCES public.basic_product(id) DEFERRABLE;


--
-- Name: orders_order order_masterorderproductcomponent_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.orders_order
    ADD CONSTRAINT order_masterorderproductcomponent_fkey FOREIGN KEY (masterorderproductcomponent_id) REFERENCES public.masterorders_masterorderproduct(id) DEFERRABLE;


--
-- Name: jointable_materialrequirementcoverage_order order_materialrequirementcoverage_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.jointable_materialrequirementcoverage_order
    ADD CONSTRAINT order_materialrequirementcoverage_fkey FOREIGN KEY (order_id) REFERENCES public.orders_order(id) DEFERRABLE;


--
-- Name: orders_order order_ordersgroup_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.orders_order
    ADD CONSTRAINT order_ordersgroup_fkey FOREIGN KEY (ordersgroup_id) REFERENCES public.ordersgroups_ordersgroup(id) DEFERRABLE;


--
-- Name: jointable_order_orderstoolrequirement order_orderstoolrequirement_order_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.jointable_order_orderstoolrequirement
    ADD CONSTRAINT order_orderstoolrequirement_order_fkey FOREIGN KEY (order_id) REFERENCES public.orders_order(id) DEFERRABLE;


--
-- Name: jointable_order_orderstoolrequirement order_orderstoolrequirement_orderstoolrequirement_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.jointable_order_orderstoolrequirement
    ADD CONSTRAINT order_orderstoolrequirement_orderstoolrequirement_fkey FOREIGN KEY (orderstoolrequirement_id) REFERENCES public.cmmsmachineparts_orderstoolrequirement(id) DEFERRABLE;


--
-- Name: orders_order order_parent_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.orders_order
    ADD CONSTRAINT order_parent_fkey FOREIGN KEY (parent_id) REFERENCES public.orders_order(id) DEFERRABLE;


--
-- Name: jointable_order_printlabelshelper order_printlabelshelper_order_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.jointable_order_printlabelshelper
    ADD CONSTRAINT order_printlabelshelper_order_fkey FOREIGN KEY (order_id) REFERENCES public.orders_order(id) DEFERRABLE;


--
-- Name: jointable_order_printlabelshelper order_printlabelshelper_printlabelshelper_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.jointable_order_printlabelshelper
    ADD CONSTRAINT order_printlabelshelper_printlabelshelper_fkey FOREIGN KEY (printlabelshelper_id) REFERENCES public.integrationbartender_printlabelshelper(id) DEFERRABLE;


--
-- Name: orders_order order_product_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.orders_order
    ADD CONSTRAINT order_product_fkey FOREIGN KEY (product_id) REFERENCES public.basic_product(id) DEFERRABLE;


--
-- Name: jointable_order_productionbalance order_productionbalance_order_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.jointable_order_productionbalance
    ADD CONSTRAINT order_productionbalance_order_fkey FOREIGN KEY (order_id) REFERENCES public.orders_order(id) DEFERRABLE;


--
-- Name: jointable_order_productionbalance order_productionbalance_productionbalance_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.jointable_order_productionbalance
    ADD CONSTRAINT order_productionbalance_productionbalance_fkey FOREIGN KEY (productionbalance_id) REFERENCES public.productioncounting_productionbalance(id) DEFERRABLE;


--
-- Name: jointable_order_productionlineschedule order_productionlineschedule_order; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.jointable_order_productionlineschedule
    ADD CONSTRAINT order_productionlineschedule_order FOREIGN KEY (order_id) REFERENCES public.orders_order(id) DEFERRABLE;


--
-- Name: jointable_order_productionlineschedule order_productionlineschedule_productionlineschedule; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.jointable_order_productionlineschedule
    ADD CONSTRAINT order_productionlineschedule_productionlineschedule FOREIGN KEY (productionlineschedule_id) REFERENCES public.orders_productionlineschedule(id) DEFERRABLE;


--
-- Name: orders_order order_salesplan_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.orders_order
    ADD CONSTRAINT order_salesplan_fkey FOREIGN KEY (salesplan_id) REFERENCES public.masterorders_salesplan(id) DEFERRABLE;


--
-- Name: jointable_order_schedule order_schedule_order; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.jointable_order_schedule
    ADD CONSTRAINT order_schedule_order FOREIGN KEY (order_id) REFERENCES public.orders_order(id) DEFERRABLE;


--
-- Name: jointable_order_schedule order_schedule_schedule; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.jointable_order_schedule
    ADD CONSTRAINT order_schedule_schedule FOREIGN KEY (schedule_id) REFERENCES public.orders_schedule(id) DEFERRABLE;


--
-- Name: jointable_order_staff order_staff_order; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.jointable_order_staff
    ADD CONSTRAINT order_staff_order FOREIGN KEY (order_id) REFERENCES public.orders_order(id) DEFERRABLE;


--
-- Name: jointable_order_staff order_staff_staff; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.jointable_order_staff
    ADD CONSTRAINT order_staff_staff FOREIGN KEY (staff_id) REFERENCES public.basic_staff(id) DEFERRABLE;


--
-- Name: orders_order order_technology_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.orders_order
    ADD CONSTRAINT order_technology_fkey FOREIGN KEY (technology_id) REFERENCES public.technologies_technology(id) DEFERRABLE;


--
-- Name: orders_order order_technologyprototype_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.orders_order
    ADD CONSTRAINT order_technologyprototype_fkey FOREIGN KEY (technologyprototype_id) REFERENCES public.technologies_technology(id) DEFERRABLE;


--
-- Name: jointable_order_workplan order_workplan_order_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.jointable_order_workplan
    ADD CONSTRAINT order_workplan_order_fkey FOREIGN KEY (order_id) REFERENCES public.orders_order(id) DEFERRABLE;


--
-- Name: jointable_order_workplan order_workplan_workplan_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.jointable_order_workplan
    ADD CONSTRAINT order_workplan_workplan_fkey FOREIGN KEY (workplan_id) REFERENCES public.workplans_workplan(id) DEFERRABLE;


--
-- Name: costcalculation_orderadditionaldirectcost orderadditionaldirectcost_additionaldirectcost_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.costcalculation_orderadditionaldirectcost
    ADD CONSTRAINT orderadditionaldirectcost_additionaldirectcost_fkey FOREIGN KEY (additionaldirectcost_id) REFERENCES public.costcalculation_additionaldirectcost(id) DEFERRABLE;


--
-- Name: costcalculation_orderadditionaldirectcost orderadditionaldirectcost_order_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.costcalculation_orderadditionaldirectcost
    ADD CONSTRAINT orderadditionaldirectcost_order_fkey FOREIGN KEY (order_id) REFERENCES public.orders_order(id) DEFERRABLE;


--
-- Name: orders_orderattachment orderattachment_order_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.orders_orderattachment
    ADD CONSTRAINT orderattachment_order_fkey FOREIGN KEY (order_id) REFERENCES public.orders_order(id) DEFERRABLE;


--
-- Name: productioncounting_orderbalance orderbalance_productionbalance_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.productioncounting_orderbalance
    ADD CONSTRAINT orderbalance_productionbalance_fkey FOREIGN KEY (productionbalance_id) REFERENCES public.productioncounting_productionbalance(id) DEFERRABLE;


--
-- Name: orders_ordercategorycolor ordercategorycolor_parameter_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.orders_ordercategorycolor
    ADD CONSTRAINT ordercategorycolor_parameter_fkey FOREIGN KEY (parameter_id) REFERENCES public.basic_parameter(id) DEFERRABLE;


--
-- Name: orders_dimensioncontrolattribute orderdimensioncontrolattribute_attribute_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.orders_dimensioncontrolattribute
    ADD CONSTRAINT orderdimensioncontrolattribute_attribute_fkey FOREIGN KEY (attribute_id) REFERENCES public.basic_attribute(id) DEFERRABLE;


--
-- Name: orders_dimensioncontrolattribute orderdimensioncontrolattribute_paramter_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.orders_dimensioncontrolattribute
    ADD CONSTRAINT orderdimensioncontrolattribute_paramter_fkey FOREIGN KEY (parameter_id) REFERENCES public.basic_parameter(id) DEFERRABLE;


--
-- Name: deliveries_orderedproduct orderedproduct_batch_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.deliveries_orderedproduct
    ADD CONSTRAINT orderedproduct_batch_fkey FOREIGN KEY (batch_id) REFERENCES public.advancedgenealogy_batch(id) DEFERRABLE;


--
-- Name: deliveries_orderedproduct orderedproduct_delivery_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.deliveries_orderedproduct
    ADD CONSTRAINT orderedproduct_delivery_fkey FOREIGN KEY (delivery_id) REFERENCES public.deliveries_delivery(id) DEFERRABLE;


--
-- Name: deliveries_deliveredproduct orderedproduct_offer_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.deliveries_deliveredproduct
    ADD CONSTRAINT orderedproduct_offer_fkey FOREIGN KEY (offer_id) REFERENCES public.supplynegotiations_offer(id) DEFERRABLE;


--
-- Name: deliveries_orderedproduct orderedproduct_operation_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.deliveries_orderedproduct
    ADD CONSTRAINT orderedproduct_operation_fkey FOREIGN KEY (operation_id) REFERENCES public.technologies_operation(id) DEFERRABLE;


--
-- Name: deliveries_orderedproduct orderedproduct_product_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.deliveries_orderedproduct
    ADD CONSTRAINT orderedproduct_product_fkey FOREIGN KEY (product_id) REFERENCES public.basic_product(id) DEFERRABLE;


--
-- Name: deliveries_orderedproduct orderedproduct_qualitycard_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.deliveries_orderedproduct
    ADD CONSTRAINT orderedproduct_qualitycard_fkey FOREIGN KEY (qualitycard_id) REFERENCES public.basic_qualitycard(id) DEFERRABLE;


--
-- Name: masterorders_orderedproductconfiguratorattribute orderedproductconfiguratorattribute_attribute_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.masterorders_orderedproductconfiguratorattribute
    ADD CONSTRAINT orderedproductconfiguratorattribute_attribute_fkey FOREIGN KEY (attribute_id) REFERENCES public.basic_attribute(id) DEFERRABLE;


--
-- Name: masterorders_orderedproductconfiguratorattribute orderedproductconfiguratorattribute_orderedproductconfigurator_; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.masterorders_orderedproductconfiguratorattribute
    ADD CONSTRAINT orderedproductconfiguratorattribute_orderedproductconfigurator_ FOREIGN KEY (orderedproductconfigurator_id) REFERENCES public.masterorders_orderedproductconfigurator(id) DEFERRABLE;


--
-- Name: techsubcontracting_orderexternalservicecost orderexternalservicecost_order_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.techsubcontracting_orderexternalservicecost
    ADD CONSTRAINT orderexternalservicecost_order_fkey FOREIGN KEY (order_id) REFERENCES public.orders_order(id) DEFERRABLE;


--
-- Name: techsubcontracting_orderexternalservicecost orderexternalservicecost_product_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.techsubcontracting_orderexternalservicecost
    ADD CONSTRAINT orderexternalservicecost_product_fkey FOREIGN KEY (product_id) REFERENCES public.basic_product(id) DEFERRABLE;


--
-- Name: techsubcontracting_orderexternalservicecost orderexternalservicecost_technologyoperationcomponent_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.techsubcontracting_orderexternalservicecost
    ADD CONSTRAINT orderexternalservicecost_technologyoperationcomponent_fkey FOREIGN KEY (technologyoperationcomponent_id) REFERENCES public.technologies_technologyoperationcomponent(id) DEFERRABLE;


--
-- Name: orders_orderpack orderpack_order_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.orders_orderpack
    ADD CONSTRAINT orderpack_order_fkey FOREIGN KEY (order_id) REFERENCES public.orders_order(id) DEFERRABLE;


--
-- Name: orders_orderpackstatechange orderpackstatechange_orderpack_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.orders_orderpackstatechange
    ADD CONSTRAINT orderpackstatechange_orderpack_fkey FOREIGN KEY (orderpack_id) REFERENCES public.orders_orderpack(id) DEFERRABLE;


--
-- Name: orders_orderpackstatechange orderpackstatechange_shift_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.orders_orderpackstatechange
    ADD CONSTRAINT orderpackstatechange_shift_fkey FOREIGN KEY (shift_id) REFERENCES public.basic_shift(id) DEFERRABLE;


--
-- Name: productflowthrudivision_orderproductresourcereservation orderproductresourcereservation_productioncountingquantity_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.productflowthrudivision_orderproductresourcereservation
    ADD CONSTRAINT orderproductresourcereservation_productioncountingquantity_fkey FOREIGN KEY (productioncountingquantity_id) REFERENCES public.basicproductioncounting_productioncountingquantity(id) DEFERRABLE;


--
-- Name: productflowthrudivision_orderproductresourcereservation orderproductresourcereservation_resource_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.productflowthrudivision_orderproductresourcereservation
    ADD CONSTRAINT orderproductresourcereservation_resource_fkey FOREIGN KEY (resource_id) REFERENCES public.materialflowresources_resource(id) DEFERRABLE;


--
-- Name: goodfood_confectionprotocol orders_order_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.goodfood_confectionprotocol
    ADD CONSTRAINT orders_order_fkey FOREIGN KEY (order_id) REFERENCES public.orders_order(id) DEFERRABLE;


--
-- Name: goodfood_extrusionprotocol orders_order_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.goodfood_extrusionprotocol
    ADD CONSTRAINT orders_order_fkey FOREIGN KEY (order_id) REFERENCES public.orders_order(id) DEFERRABLE;


--
-- Name: avglaborcostcalcfororder_avglaborcostcalcfororder orders_order_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.avglaborcostcalcfororder_avglaborcostcalcfororder
    ADD CONSTRAINT orders_order_fkey FOREIGN KEY (order_id) REFERENCES public.orders_order(id) DEFERRABLE;


--
-- Name: orders_operationaltask orders_order_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.orders_operationaltask
    ADD CONSTRAINT orders_order_fkey FOREIGN KEY (order_id) REFERENCES public.orders_order(id) DEFERRABLE;


--
-- Name: orders_order orders_order_productionline_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.orders_order
    ADD CONSTRAINT orders_order_productionline_fkey FOREIGN KEY (productionline_id) REFERENCES public.productionlines_productionline(id) DEFERRABLE;


--
-- Name: orders_order orders_order_root_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.orders_order
    ADD CONSTRAINT orders_order_root_fkey FOREIGN KEY (root_id) REFERENCES public.orders_order(id) DEFERRABLE;


--
-- Name: ordersgroups_ordersgroup ordersgroup_assortment_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.ordersgroups_ordersgroup
    ADD CONSTRAINT ordersgroup_assortment_fkey FOREIGN KEY (assortment_id) REFERENCES public.basic_assortment(id) DEFERRABLE;


--
-- Name: ordersgroups_ordersgroup ordersgroup_masterorder_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.ordersgroups_ordersgroup
    ADD CONSTRAINT ordersgroup_masterorder_fkey FOREIGN KEY (masterorder_id) REFERENCES public.masterorders_masterorder(id) DEFERRABLE;


--
-- Name: ordersgroups_ordersgroup ordersgroup_parent_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.ordersgroups_ordersgroup
    ADD CONSTRAINT ordersgroup_parent_fkey FOREIGN KEY (parent_id) REFERENCES public.ordersgroups_ordersgroup(id) DEFERRABLE;


--
-- Name: ordersgroups_ordersgroup ordersgroup_productionline_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.ordersgroups_ordersgroup
    ADD CONSTRAINT ordersgroup_productionline_fkey FOREIGN KEY (productionline_id) REFERENCES public.productionlines_productionline(id) DEFERRABLE;


--
-- Name: ordersgroups_ordersgroup ordersgroup_salesplan_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.ordersgroups_ordersgroup
    ADD CONSTRAINT ordersgroup_salesplan_fkey FOREIGN KEY (salesplan_id) REFERENCES public.masterorders_salesplan(id) DEFERRABLE;


--
-- Name: ordersgroups_ordersgroupissuedmaterial ordersgroupissuedmaterial_ordersgroup_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.ordersgroups_ordersgroupissuedmaterial
    ADD CONSTRAINT ordersgroupissuedmaterial_ordersgroup_fkey FOREIGN KEY (ordersgroup_id) REFERENCES public.ordersgroups_ordersgroup(id) DEFERRABLE;


--
-- Name: ordersgroups_ordersgroupissuedmaterial ordersgroupissuedmaterial_product_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.ordersgroups_ordersgroupissuedmaterial
    ADD CONSTRAINT ordersgroupissuedmaterial_product_fkey FOREIGN KEY (product_id) REFERENCES public.basic_product(id) DEFERRABLE;


--
-- Name: ordersgroups_ordersgroupmaterialrequirement ordersgroupmaterialrequirement_ordersgroup_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.ordersgroups_ordersgroupmaterialrequirement
    ADD CONSTRAINT ordersgroupmaterialrequirement_ordersgroup_fkey FOREIGN KEY (ordersgroup_id) REFERENCES public.ordersgroups_ordersgroup(id) DEFERRABLE;


--
-- Name: ordersgroups_ordersgroupmaterialrequirementproduct ordersgroupmaterialrequirementproduct_division_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.ordersgroups_ordersgroupmaterialrequirementproduct
    ADD CONSTRAINT ordersgroupmaterialrequirementproduct_division_fkey FOREIGN KEY (division_id) REFERENCES public.basic_division(id) DEFERRABLE;


--
-- Name: ordersgroups_ordersgroupmaterialrequirementproduct ordersgroupmaterialrequirementproduct_location_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.ordersgroups_ordersgroupmaterialrequirementproduct
    ADD CONSTRAINT ordersgroupmaterialrequirementproduct_location_fkey FOREIGN KEY (location_id) REFERENCES public.materialflow_location(id) DEFERRABLE;


--
-- Name: ordersgroups_ordersgroupmaterialrequirementproduct ordersgroupmaterialrequirementproduct_materialrequirement_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.ordersgroups_ordersgroupmaterialrequirementproduct
    ADD CONSTRAINT ordersgroupmaterialrequirementproduct_materialrequirement_fkey FOREIGN KEY (ordersgroupmaterialrequirement_id) REFERENCES public.ordersgroups_ordersgroupmaterialrequirement(id) DEFERRABLE;


--
-- Name: ordersgroups_ordersgroupmaterialrequirementproduct ordersgroupmaterialrequirementproduct_product_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.ordersgroups_ordersgroupmaterialrequirementproduct
    ADD CONSTRAINT ordersgroupmaterialrequirementproduct_product_fkey FOREIGN KEY (product_id) REFERENCES public.basic_product(id) DEFERRABLE;


--
-- Name: ordersgroups_ordersgroupmaterialrequirementproduct ordersgroupmaterialrequirementproduct_producttype_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.ordersgroups_ordersgroupmaterialrequirementproduct
    ADD CONSTRAINT ordersgroupmaterialrequirementproduct_producttype_fkey FOREIGN KEY (technologyinputproducttype_id) REFERENCES public.technologies_technologyinputproducttype(id) DEFERRABLE;


--
-- Name: ordersgroups_ordersgroupmaterialrequirementproduct ordersgroupmaterialrequirementproduct_supplier_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.ordersgroups_ordersgroupmaterialrequirementproduct
    ADD CONSTRAINT ordersgroupmaterialrequirementproduct_supplier_fkey FOREIGN KEY (supplier_id) REFERENCES public.basic_company(id) DEFERRABLE;


--
-- Name: ordersgroups_ordersgroupproducedproduct ordersgroupproducedproduct_batch_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.ordersgroups_ordersgroupproducedproduct
    ADD CONSTRAINT ordersgroupproducedproduct_batch_fkey FOREIGN KEY (batch_id) REFERENCES public.advancedgenealogy_batch(id) DEFERRABLE;


--
-- Name: ordersgroups_ordersgroupproducedproduct ordersgroupproducedproduct_document_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.ordersgroups_ordersgroupproducedproduct
    ADD CONSTRAINT ordersgroupproducedproduct_document_fkey FOREIGN KEY (document_id) REFERENCES public.materialflowresources_document(id) DEFERRABLE;


--
-- Name: ordersgroups_ordersgroupproducedproduct ordersgroupproducedproduct_location_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.ordersgroups_ordersgroupproducedproduct
    ADD CONSTRAINT ordersgroupproducedproduct_location_fkey FOREIGN KEY (location_id) REFERENCES public.materialflow_location(id) DEFERRABLE;


--
-- Name: ordersgroups_ordersgroupproducedproduct ordersgroupproducedproduct_ordersgroup_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.ordersgroups_ordersgroupproducedproduct
    ADD CONSTRAINT ordersgroupproducedproduct_ordersgroup_fkey FOREIGN KEY (ordersgroup_id) REFERENCES public.ordersgroups_ordersgroup(id) DEFERRABLE;


--
-- Name: ordersgroups_ordersgroupproducedproduct ordersgroupproducedproduct_palletnumber_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.ordersgroups_ordersgroupproducedproduct
    ADD CONSTRAINT ordersgroupproducedproduct_palletnumber_fkey FOREIGN KEY (palletnumber_id) REFERENCES public.basic_palletnumber(id) DEFERRABLE;


--
-- Name: ordersgroups_ordersgroupproducedproduct ordersgroupproducedproduct_product_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.ordersgroups_ordersgroupproducedproduct
    ADD CONSTRAINT ordersgroupproducedproduct_product_fkey FOREIGN KEY (product_id) REFERENCES public.basic_product(id) DEFERRABLE;


--
-- Name: ordersgroups_ordersgroupproducedproduct ordersgroupproducedproduct_storagelocation_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.ordersgroups_ordersgroupproducedproduct
    ADD CONSTRAINT ordersgroupproducedproduct_storagelocation_fkey FOREIGN KEY (storagelocation_id) REFERENCES public.materialflowresources_storagelocation(id) DEFERRABLE;


--
-- Name: orders_orderstatechange orderstatechange_order_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.orders_orderstatechange
    ADD CONSTRAINT orderstatechange_order_fkey FOREIGN KEY (order_id) REFERENCES public.orders_order(id) DEFERRABLE;


--
-- Name: orders_orderstatechange orderstatechange_shift_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.orders_orderstatechange
    ADD CONSTRAINT orderstatechange_shift_fkey FOREIGN KEY (shift_id) REFERENCES public.basic_shift(id) DEFERRABLE;


--
-- Name: cmmsmachineparts_orderstoolrequirementtool orderstoolrequirementtool_masterordersmaterialrequirement_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.cmmsmachineparts_orderstoolrequirementtool
    ADD CONSTRAINT orderstoolrequirementtool_masterordersmaterialrequirement_fkey FOREIGN KEY (orderstoolrequirement_id) REFERENCES public.cmmsmachineparts_orderstoolrequirement(id) DEFERRABLE;


--
-- Name: cmmsmachineparts_orderstoolrequirementtool orderstoolrequirementtool_operation_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.cmmsmachineparts_orderstoolrequirementtool
    ADD CONSTRAINT orderstoolrequirementtool_operation_fkey FOREIGN KEY (operation_id) REFERENCES public.technologies_operation(id) DEFERRABLE;


--
-- Name: cmmsmachineparts_orderstoolrequirementtool orderstoolrequirementtool_order_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.cmmsmachineparts_orderstoolrequirementtool
    ADD CONSTRAINT orderstoolrequirementtool_order_fkey FOREIGN KEY (order_id) REFERENCES public.orders_order(id) DEFERRABLE;


--
-- Name: cmmsmachineparts_orderstoolrequirementtool orderstoolrequirementtool_technologyoperationtool_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.cmmsmachineparts_orderstoolrequirementtool
    ADD CONSTRAINT orderstoolrequirementtool_technologyoperationtool_fkey FOREIGN KEY (technologyoperationtool_id) REFERENCES public.cmmsmachineparts_technologyoperationtool(id) DEFERRABLE;


--
-- Name: orders_ordertechnologicalprocess ordertechnologicalprocess_operation_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.orders_ordertechnologicalprocess
    ADD CONSTRAINT ordertechnologicalprocess_operation_fkey FOREIGN KEY (operation_id) REFERENCES public.technologies_operation(id) DEFERRABLE;


--
-- Name: orders_ordertechnologicalprocess ordertechnologicalprocess_order_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.orders_ordertechnologicalprocess
    ADD CONSTRAINT ordertechnologicalprocess_order_fkey FOREIGN KEY (order_id) REFERENCES public.orders_order(id) DEFERRABLE;


--
-- Name: orders_ordertechnologicalprocess ordertechnologicalprocess_orderpack_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.orders_ordertechnologicalprocess
    ADD CONSTRAINT ordertechnologicalprocess_orderpack_fkey FOREIGN KEY (orderpack_id) REFERENCES public.orders_orderpack(id) DEFERRABLE;


--
-- Name: orders_ordertechnologicalprocess ordertechnologicalprocess_product_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.orders_ordertechnologicalprocess
    ADD CONSTRAINT ordertechnologicalprocess_product_fkey FOREIGN KEY (product_id) REFERENCES public.basic_product(id) DEFERRABLE;


--
-- Name: orders_ordertechnologicalprocess ordertechnologicalprocess_staff_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.orders_ordertechnologicalprocess
    ADD CONSTRAINT ordertechnologicalprocess_staff_fkey FOREIGN KEY (worker_id) REFERENCES public.basic_staff(id) DEFERRABLE;


--
-- Name: orders_ordertechnologicalprocess ordertechnologicalprocess_technologicalprocess_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.orders_ordertechnologicalprocess
    ADD CONSTRAINT ordertechnologicalprocess_technologicalprocess_fkey FOREIGN KEY (technologicalprocess_id) REFERENCES public.technologies_technologicalprocess(id) DEFERRABLE;


--
-- Name: orders_ordertechnologicalprocess ordertechnologicalprocess_technologyoperationcomponent_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.orders_ordertechnologicalprocess
    ADD CONSTRAINT ordertechnologicalprocess_technologyoperationcomponent_fkey FOREIGN KEY (technologyoperationcomponent_id) REFERENCES public.technologies_technologyoperationcomponent(id) DEFERRABLE;


--
-- Name: orders_ordertechnologicalprocesspart ordertechnologicalprocesspart_ordertechnologicalprocess_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.orders_ordertechnologicalprocesspart
    ADD CONSTRAINT ordertechnologicalprocesspart_ordertechnologicalprocess_fkey FOREIGN KEY (ordertechnologicalprocess_id) REFERENCES public.orders_ordertechnologicalprocess(id) DEFERRABLE;


--
-- Name: orders_ordertechnologicalprocesswaste ordertechnologicalprocesswaste_order_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.orders_ordertechnologicalprocesswaste
    ADD CONSTRAINT ordertechnologicalprocesswaste_order_fkey FOREIGN KEY (order_id) REFERENCES public.orders_order(id) DEFERRABLE;


--
-- Name: orders_ordertechnologicalprocesswaste ordertechnologicalprocesswaste_orderpack_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.orders_ordertechnologicalprocesswaste
    ADD CONSTRAINT ordertechnologicalprocesswaste_orderpack_fkey FOREIGN KEY (orderpack_id) REFERENCES public.orders_orderpack(id) DEFERRABLE;


--
-- Name: orders_ordertechnologicalprocesswaste ordertechnologicalprocesswaste_ordertechnologicalprocess_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.orders_ordertechnologicalprocesswaste
    ADD CONSTRAINT ordertechnologicalprocesswaste_ordertechnologicalprocess_fkey FOREIGN KEY (ordertechnologicalprocess_id) REFERENCES public.orders_ordertechnologicalprocess(id) DEFERRABLE;


--
-- Name: orders_ordertechnologicalprocesswaste ordertechnologicalprocesswaste_product_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.orders_ordertechnologicalprocesswaste
    ADD CONSTRAINT ordertechnologicalprocesswaste_product_fkey FOREIGN KEY (product_id) REFERENCES public.basic_product(id) DEFERRABLE;


--
-- Name: orders_ordertechnologicalprocesswaste ordertechnologicalprocesswaste_staff_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.orders_ordertechnologicalprocesswaste
    ADD CONSTRAINT ordertechnologicalprocesswaste_staff_fkey FOREIGN KEY (worker_id) REFERENCES public.basic_staff(id) DEFERRABLE;


--
-- Name: productionscheduling_ordertimecalculation ordertimecalculation_order_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.productionscheduling_ordertimecalculation
    ADD CONSTRAINT ordertimecalculation_order_fkey FOREIGN KEY (order_id) REFERENCES public.orders_order(id) DEFERRABLE;


--
-- Name: goodfood_pallet pallet_pallet_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.goodfood_pallet
    ADD CONSTRAINT pallet_pallet_fkey FOREIGN KEY (secondpallet_id) REFERENCES public.goodfood_pallet(id) DEFERRABLE;


--
-- Name: goodfood_pallet pallet_palletcontext_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.goodfood_pallet
    ADD CONSTRAINT pallet_palletcontext_fkey FOREIGN KEY (palletcontext_id) REFERENCES public.goodfood_palletcontext(id) DEFERRABLE;


--
-- Name: goodfood_pallet pallet_palletlabel_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.goodfood_pallet
    ADD CONSTRAINT pallet_palletlabel_fkey FOREIGN KEY (palletlabel_id) REFERENCES public.goodfood_palletlabel(id) DEFERRABLE;


--
-- Name: goodfood_pallet pallet_product_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.goodfood_pallet
    ADD CONSTRAINT pallet_product_fkey FOREIGN KEY (product_id) REFERENCES public.basic_product(id) DEFERRABLE;


--
-- Name: goodfood_palletcontext palletcontext_operator_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.goodfood_palletcontext
    ADD CONSTRAINT palletcontext_operator_fkey FOREIGN KEY (operator_id) REFERENCES public.basic_staff(id) DEFERRABLE;


--
-- Name: goodfood_palletcontext palletcontext_shift_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.goodfood_palletcontext
    ADD CONSTRAINT palletcontext_shift_fkey FOREIGN KEY (shift_id) REFERENCES public.basic_shift(id) DEFERRABLE;


--
-- Name: goodfood_palletlabel palletlabel_batch_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.goodfood_palletlabel
    ADD CONSTRAINT palletlabel_batch_fkey FOREIGN KEY (batch_id) REFERENCES public.advancedgenealogy_batch(id) DEFERRABLE;


--
-- Name: goodfood_palletlabel palletlabel_masterorder_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.goodfood_palletlabel
    ADD CONSTRAINT palletlabel_masterorder_fkey FOREIGN KEY (masterorder_id) REFERENCES public.masterorders_masterorder(id) DEFERRABLE;


--
-- Name: goodfood_palletlabel palletlabel_palletcontext_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.goodfood_palletlabel
    ADD CONSTRAINT palletlabel_palletcontext_fkey FOREIGN KEY (palletcontext_id) REFERENCES public.goodfood_palletcontext(id) DEFERRABLE;


--
-- Name: jointable_palletlabel_printlabelshelper palletlabel_printlabelshelper_label_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.jointable_palletlabel_printlabelshelper
    ADD CONSTRAINT palletlabel_printlabelshelper_label_fkey FOREIGN KEY (palletlabel_id) REFERENCES public.goodfood_palletlabel(id) DEFERRABLE;


--
-- Name: jointable_palletlabel_printlabelshelper palletlabel_printlabelshelper_printlabelshelper_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.jointable_palletlabel_printlabelshelper
    ADD CONSTRAINT palletlabel_printlabelshelper_printlabelshelper_fkey FOREIGN KEY (printlabelshelper_id) REFERENCES public.integrationbartender_printlabelshelper(id) DEFERRABLE;


--
-- Name: goodfood_palletlabel palletlabel_productionline_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.goodfood_palletlabel
    ADD CONSTRAINT palletlabel_productionline_fkey FOREIGN KEY (productionline_id) REFERENCES public.productionlines_productionline(id) DEFERRABLE;


--
-- Name: goodfood_palletlabelstatechange palletlabelstatechange_palletlabel_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.goodfood_palletlabelstatechange
    ADD CONSTRAINT palletlabelstatechange_palletlabel_fkey FOREIGN KEY (palletlabel_id) REFERENCES public.goodfood_palletlabel(id) DEFERRABLE;


--
-- Name: goodfood_palletlabelstatechange palletlabelstatechange_shift_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.goodfood_palletlabelstatechange
    ADD CONSTRAINT palletlabelstatechange_shift_fkey FOREIGN KEY (shift_id) REFERENCES public.basic_shift(id) DEFERRABLE;


--
-- Name: jointable_palletnumber_palletnumberhelper palletnumber_palletnumberhelper_palletnumber_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.jointable_palletnumber_palletnumberhelper
    ADD CONSTRAINT palletnumber_palletnumberhelper_palletnumber_fkey FOREIGN KEY (palletnumber_id) REFERENCES public.basic_palletnumber(id) DEFERRABLE;


--
-- Name: jointable_palletnumber_palletnumberhelper palletnumber_palletnumberhelper_palletnumberhelper_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.jointable_palletnumber_palletnumberhelper
    ADD CONSTRAINT palletnumber_palletnumberhelper_palletnumberhelper_fkey FOREIGN KEY (palletnumberhelper_id) REFERENCES public.basic_palletnumberhelper(id) DEFERRABLE;


--
-- Name: goodfood_palletstatechange palletstatechange_pallet_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.goodfood_palletstatechange
    ADD CONSTRAINT palletstatechange_pallet_fkey FOREIGN KEY (pallet_id) REFERENCES public.goodfood_pallet(id) DEFERRABLE;


--
-- Name: goodfood_palletstatechange palletstatechange_shift_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.goodfood_palletstatechange
    ADD CONSTRAINT palletstatechange_shift_fkey FOREIGN KEY (shift_id) REFERENCES public.basic_shift(id) DEFERRABLE;


--
-- Name: basic_parameter parameter_attributeonordersgrouppdf_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.basic_parameter
    ADD CONSTRAINT parameter_attributeonordersgrouppdf_fkey FOREIGN KEY (attributeonordersgrouppdf_id) REFERENCES public.basic_attribute(id) DEFERRABLE;


--
-- Name: basic_parameter parameter_attributeonordersgrouprequirementpdf_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.basic_parameter
    ADD CONSTRAINT parameter_attributeonordersgrouprequirementpdf_fkey FOREIGN KEY (attributeonordersgrouprequirementpdf_id) REFERENCES public.basic_attribute(id) DEFERRABLE;


--
-- Name: basic_parameter parameter_attributeonthelabel_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.basic_parameter
    ADD CONSTRAINT parameter_attributeonthelabel_fkey FOREIGN KEY (attributeonthelabel_id) REFERENCES public.basic_attribute(id) DEFERRABLE;


--
-- Name: basic_parameter parameter_attributeoptimizecutting_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.basic_parameter
    ADD CONSTRAINT parameter_attributeoptimizecutting_fkey FOREIGN KEY (optimizecuttinglengthattribute_id) REFERENCES public.basic_attribute(id) DEFERRABLE;


--
-- Name: basic_parameter parameter_baselinkerparameters_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.basic_parameter
    ADD CONSTRAINT parameter_baselinkerparameters_fkey FOREIGN KEY (baselinkerparameters_id) REFERENCES public.integrationbaselinker_baselinkerparameters(id) DEFERRABLE;


--
-- Name: basic_parameter parameter_company_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.basic_parameter
    ADD CONSTRAINT parameter_company_fkey FOREIGN KEY (company_id) REFERENCES public.basic_company(id) DEFERRABLE;


--
-- Name: basic_parameter parameter_companyname_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.basic_parameter
    ADD CONSTRAINT parameter_companyname_fkey FOREIGN KEY (companyname_id) REFERENCES public.basic_company(id) DEFERRABLE;


--
-- Name: basic_parameter parameter_country_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.basic_parameter
    ADD CONSTRAINT parameter_country_fkey FOREIGN KEY (country_id) REFERENCES public.basic_country(id) DEFERRABLE;


--
-- Name: basic_parameter parameter_currency_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.basic_parameter
    ADD CONSTRAINT parameter_currency_fkey FOREIGN KEY (currency_id) REFERENCES public.basic_currency(id) DEFERRABLE;


--
-- Name: basic_parameter parameter_dashboardcomponentslocation_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.basic_parameter
    ADD CONSTRAINT parameter_dashboardcomponentslocation_fkey FOREIGN KEY (dashboardcomponentslocation_id) REFERENCES public.materialflow_location(id) DEFERRABLE;


--
-- Name: basic_parameter parameter_dashboardoperation_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.basic_parameter
    ADD CONSTRAINT parameter_dashboardoperation_fkey FOREIGN KEY (dashboardoperation_id) REFERENCES public.technologies_operation(id) DEFERRABLE;


--
-- Name: basic_parameter parameter_dashboardproductsinputlocation_feky; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.basic_parameter
    ADD CONSTRAINT parameter_dashboardproductsinputlocation_feky FOREIGN KEY (dashboardproductsinputlocation_id) REFERENCES public.materialflow_location(id) DEFERRABLE;


--
-- Name: basic_parameter parameter_division_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.basic_parameter
    ADD CONSTRAINT parameter_division_fkey FOREIGN KEY (division_id) REFERENCES public.basic_division(id) DEFERRABLE;


--
-- Name: basic_parameter parameter_issuelocation_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.basic_parameter
    ADD CONSTRAINT parameter_issuelocation_fkey FOREIGN KEY (issuelocation_id) REFERENCES public.materialflow_location(id) DEFERRABLE;


--
-- Name: basic_parameter parameter_location_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.basic_parameter
    ADD CONSTRAINT parameter_location_fkey FOREIGN KEY (location_id) REFERENCES public.materialflow_location(id) DEFERRABLE;


--
-- Name: basic_parameter parameter_masterorderreleaselocation_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.basic_parameter
    ADD CONSTRAINT parameter_masterorderreleaselocation_fkey FOREIGN KEY (masterorderreleaselocation_id) REFERENCES public.materialflow_location(id) DEFERRABLE;


--
-- Name: basic_parameter parameter_materialattribute_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.basic_parameter
    ADD CONSTRAINT parameter_materialattribute_fkey FOREIGN KEY (materialattribute_id) REFERENCES public.basic_attribute(id) DEFERRABLE;


--
-- Name: basic_parameter parameter_moldrewclient_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.basic_parameter
    ADD CONSTRAINT parameter_moldrewclient_fkey FOREIGN KEY (moldrewclient_id) REFERENCES public.basic_company(id) DEFERRABLE;


--
-- Name: basic_parameter parameter_numberpattern_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.basic_parameter
    ADD CONSTRAINT parameter_numberpattern_fkey FOREIGN KEY (numberpattern_id) REFERENCES public.basic_numberpattern(id) DEFERRABLE;


--
-- Name: basic_parameter parameter_numberpatternordergroup_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.basic_parameter
    ADD CONSTRAINT parameter_numberpatternordergroup_fkey FOREIGN KEY (numberpatternordergroup_id) REFERENCES public.basic_numberpattern(id) DEFERRABLE;


--
-- Name: basic_parameter parameter_ordersganttparameters_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.basic_parameter
    ADD CONSTRAINT parameter_ordersganttparameters_fkey FOREIGN KEY (ordersganttparameters_id) REFERENCES public.ordersgantt_ordersganttparameters(id) DEFERRABLE;


--
-- Name: basic_parameter parameter_packaginglocation_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.basic_parameter
    ADD CONSTRAINT parameter_packaginglocation_fkey FOREIGN KEY (packaginglocation_id) REFERENCES public.materialflow_location(id) DEFERRABLE;


--
-- Name: basic_parameter parameter_pdbatchnumberpattern_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.basic_parameter
    ADD CONSTRAINT parameter_pdbatchnumberpattern_id_fkey FOREIGN KEY (productdeliverybatchnumberpattern_id) REFERENCES public.basic_numberpattern(id) DEFERRABLE;


--
-- Name: basic_parameter parameter_pricelistattribute1_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.basic_parameter
    ADD CONSTRAINT parameter_pricelistattribute1_fkey FOREIGN KEY (pricelistattribute1_id) REFERENCES public.basic_attribute(id) DEFERRABLE;


--
-- Name: basic_parameter parameter_pricelistattribute2_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.basic_parameter
    ADD CONSTRAINT parameter_pricelistattribute2_fkey FOREIGN KEY (pricelistattribute2_id) REFERENCES public.basic_attribute(id) DEFERRABLE;


--
-- Name: basic_parameter parameter_productattribute_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.basic_parameter
    ADD CONSTRAINT parameter_productattribute_fkey FOREIGN KEY (productattribute_id) REFERENCES public.basic_attribute(id) DEFERRABLE;


--
-- Name: jointable_parameter_productionline parameter_productionline_parameter_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.jointable_parameter_productionline
    ADD CONSTRAINT parameter_productionline_parameter_fkey FOREIGN KEY (parameter_id) REFERENCES public.basic_parameter(id) DEFERRABLE;


--
-- Name: jointable_parameter_productionline parameter_productionline_productionline_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.jointable_parameter_productionline
    ADD CONSTRAINT parameter_productionline_productionline_fkey FOREIGN KEY (productionline_id) REFERENCES public.productionlines_productionline(id) DEFERRABLE;


--
-- Name: basic_parameter parameter_standardlaborcost_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.basic_parameter
    ADD CONSTRAINT parameter_standardlaborcost_fkey FOREIGN KEY (standardlaborcost_id) REFERENCES public.costcalculation_standardlaborcost(id) DEFERRABLE;


--
-- Name: basic_parameter parameter_warehouse_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.basic_parameter
    ADD CONSTRAINT parameter_warehouse_fkey FOREIGN KEY (warehouse_id) REFERENCES public.materialflow_location(id) DEFERRABLE;


--
-- Name: supplynegotiations_parametercolumnforoffers parametercolumnforoffers_columnforoffers_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.supplynegotiations_parametercolumnforoffers
    ADD CONSTRAINT parametercolumnforoffers_columnforoffers_fkey FOREIGN KEY (columnforoffers_id) REFERENCES public.supplynegotiations_columnforoffers(id) DEFERRABLE;


--
-- Name: supplynegotiations_parametercolumnforoffers parametercolumnforoffers_parameter_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.supplynegotiations_parametercolumnforoffers
    ADD CONSTRAINT parametercolumnforoffers_parameter_fkey FOREIGN KEY (parameter_id) REFERENCES public.basic_parameter(id) DEFERRABLE;


--
-- Name: supplynegotiations_parametercolumnforrequests parametercolumnforrequests_columnforrequests_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.supplynegotiations_parametercolumnforrequests
    ADD CONSTRAINT parametercolumnforrequests_columnforrequests_fkey FOREIGN KEY (columnforrequests_id) REFERENCES public.supplynegotiations_columnforrequests(id) DEFERRABLE;


--
-- Name: supplynegotiations_parametercolumnforrequests parametercolumnforrequests_parameter_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.supplynegotiations_parametercolumnforrequests
    ADD CONSTRAINT parametercolumnforrequests_parameter_fkey FOREIGN KEY (parameter_id) REFERENCES public.basic_parameter(id) DEFERRABLE;


--
-- Name: deliveries_parameterdeliveryordercolumn parameterdeliveryordercolumn_columnfororders_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.deliveries_parameterdeliveryordercolumn
    ADD CONSTRAINT parameterdeliveryordercolumn_columnfororders_fkey FOREIGN KEY (columnfororders_id) REFERENCES public.deliveries_columnfororders(id) DEFERRABLE;


--
-- Name: deliveries_parameterdeliveryordercolumn parameterdeliveryordercolumn_parameter_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.deliveries_parameterdeliveryordercolumn
    ADD CONSTRAINT parameterdeliveryordercolumn_parameter_fkey FOREIGN KEY (parameter_id) REFERENCES public.basic_parameter(id) DEFERRABLE;


--
-- Name: basic_parameter parammeter_documentpositionparameters_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.basic_parameter
    ADD CONSTRAINT parammeter_documentpositionparameters_fkey FOREIGN KEY (documentpositionparameters_id) REFERENCES public.materialflowresources_documentpositionparameters(id) DEFERRABLE;


--
-- Name: qcadoosecurity_passwordresettoken passwordresettoken_user_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.qcadoosecurity_passwordresettoken
    ADD CONSTRAINT passwordresettoken_user_fkey FOREIGN KEY (user_id) REFERENCES public.qcadoosecurity_user(id) DEFERRABLE;


--
-- Name: productioncounting_staffworktime pc_swt_basic_staff_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.productioncounting_staffworktime
    ADD CONSTRAINT pc_swt_basic_staff_fkey FOREIGN KEY (worker_id) REFERENCES public.basic_staff(id) DEFERRABLE;


--
-- Name: productioncounting_staffworktime pc_swt_pc_productionrecord_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.productioncounting_staffworktime
    ADD CONSTRAINT pc_swt_pc_productionrecord_fkey FOREIGN KEY (productionrecord_id) REFERENCES public.productioncounting_productiontracking(id) DEFERRABLE;


--
-- Name: basic_piecerateitem piecerateitem_piecerate_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.basic_piecerateitem
    ADD CONSTRAINT piecerateitem_piecerate_fkey FOREIGN KEY (piecerate_id) REFERENCES public.basic_piecerate(id) DEFERRABLE;


--
-- Name: productflowthrudivision_warehouseissue placeofissue_warehouseissue_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.productflowthrudivision_warehouseissue
    ADD CONSTRAINT placeofissue_warehouseissue_fkey FOREIGN KEY (placeofissue_id) REFERENCES public.materialflow_location(id) DEFERRABLE;


--
-- Name: productionpershift_plandailyprogress plandailyprogress_progressforday_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.productionpershift_plandailyprogress
    ADD CONSTRAINT plandailyprogress_progressforday_fkey FOREIGN KEY (progressforday_id) REFERENCES public.productionpershift_planprogressforday(id) DEFERRABLE;


--
-- Name: productionpershift_plandailyprogress plandailyprogress_shift_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.productionpershift_plandailyprogress
    ADD CONSTRAINT plandailyprogress_shift_fkey FOREIGN KEY (shift_id) REFERENCES public.basic_shift(id) DEFERRABLE;


--
-- Name: productionplans_dimensioncontrolattribute plandimensioncontrolattribute_attribute_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.productionplans_dimensioncontrolattribute
    ADD CONSTRAINT plandimensioncontrolattribute_attribute_fkey FOREIGN KEY (attribute_id) REFERENCES public.basic_attribute(id) DEFERRABLE;


--
-- Name: productionplans_dimensioncontrolattribute plandimensioncontrolattribute_paramter_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.productionplans_dimensioncontrolattribute
    ADD CONSTRAINT plandimensioncontrolattribute_paramter_fkey FOREIGN KEY (parameter_id) REFERENCES public.basic_parameter(id) DEFERRABLE;


--
-- Name: cmmsmachineparts_plannedevent plannedevent_company_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.cmmsmachineparts_plannedevent
    ADD CONSTRAINT plannedevent_company_fkey FOREIGN KEY (company_id) REFERENCES public.basic_company(id) DEFERRABLE;


--
-- Name: cmmsmachineparts_plannedevent plannedevent_division_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.cmmsmachineparts_plannedevent
    ADD CONSTRAINT plannedevent_division_fkey FOREIGN KEY (division_id) REFERENCES public.basic_division(id) DEFERRABLE;


--
-- Name: cmmsmachineparts_plannedevent plannedevent_factory_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.cmmsmachineparts_plannedevent
    ADD CONSTRAINT plannedevent_factory_fkey FOREIGN KEY (factory_id) REFERENCES public.basic_factory(id) DEFERRABLE;


--
-- Name: materialflowresources_document plannedevent_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.materialflowresources_document
    ADD CONSTRAINT plannedevent_fkey FOREIGN KEY (plannedevent_id) REFERENCES public.cmmsmachineparts_plannedevent(id) DEFERRABLE;


--
-- Name: cmmsmachineparts_plannedevent plannedevent_maintenanceevent_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.cmmsmachineparts_plannedevent
    ADD CONSTRAINT plannedevent_maintenanceevent_fkey FOREIGN KEY (maintenanceevent_id) REFERENCES public.cmmsmachineparts_maintenanceevent(id) DEFERRABLE;


--
-- Name: jointable_plannedevent_plannedevent plannedevent_plannedevent_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.jointable_plannedevent_plannedevent
    ADD CONSTRAINT plannedevent_plannedevent_fkey FOREIGN KEY (plannedevent_id) REFERENCES public.cmmsmachineparts_plannedevent(id) DEFERRABLE;


--
-- Name: jointable_plannedevent_staff plannedevent_plannedevent_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.jointable_plannedevent_staff
    ADD CONSTRAINT plannedevent_plannedevent_fkey FOREIGN KEY (plannedevent_id) REFERENCES public.cmmsmachineparts_plannedevent(id) DEFERRABLE;


--
-- Name: cmmsmachineparts_plannedevent plannedevent_plannedeventcontext_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.cmmsmachineparts_plannedevent
    ADD CONSTRAINT plannedevent_plannedeventcontext_fkey FOREIGN KEY (plannedeventcontext_id) REFERENCES public.cmmsmachineparts_plannedeventcontext(id) DEFERRABLE;


--
-- Name: cmmsmachineparts_plannedevent plannedevent_productionline_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.cmmsmachineparts_plannedevent
    ADD CONSTRAINT plannedevent_productionline_fkey FOREIGN KEY (productionline_id) REFERENCES public.productionlines_productionline(id) DEFERRABLE;


--
-- Name: cmmsmachineparts_plannedevent plannedevent_recurringevent_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.cmmsmachineparts_plannedevent
    ADD CONSTRAINT plannedevent_recurringevent_fkey FOREIGN KEY (recurringevent_id) REFERENCES public.cmmsscheduler_recurringevent(id) DEFERRABLE;


--
-- Name: jointable_plannedevent_plannedevent plannedevent_relatedevent_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.jointable_plannedevent_plannedevent
    ADD CONSTRAINT plannedevent_relatedevent_fkey FOREIGN KEY (relatedevent_id) REFERENCES public.cmmsmachineparts_plannedevent(id) DEFERRABLE;


--
-- Name: cmmsmachineparts_plannedevent plannedevent_sourcecost_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.cmmsmachineparts_plannedevent
    ADD CONSTRAINT plannedevent_sourcecost_fkey FOREIGN KEY (sourcecost_id) REFERENCES public.cmmsmachineparts_sourcecost(id) DEFERRABLE;


--
-- Name: cmmsmachineparts_plannedevent plannedevent_staff_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.cmmsmachineparts_plannedevent
    ADD CONSTRAINT plannedevent_staff_fkey FOREIGN KEY (owner_id) REFERENCES public.basic_staff(id) DEFERRABLE;


--
-- Name: jointable_plannedevent_staff plannedevent_staff_staff_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.jointable_plannedevent_staff
    ADD CONSTRAINT plannedevent_staff_staff_fkey FOREIGN KEY (staff_id) REFERENCES public.basic_staff(id) DEFERRABLE;


--
-- Name: cmmsmachineparts_plannedevent plannedevent_subassembly_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.cmmsmachineparts_plannedevent
    ADD CONSTRAINT plannedevent_subassembly_fkey FOREIGN KEY (subassembly_id) REFERENCES public.basic_subassembly(id) DEFERRABLE;


--
-- Name: cmmsmachineparts_plannedevent plannedevent_workstation_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.cmmsmachineparts_plannedevent
    ADD CONSTRAINT plannedevent_workstation_fkey FOREIGN KEY (workstation_id) REFERENCES public.basic_workstation(id) DEFERRABLE;


--
-- Name: cmmsmachineparts_plannedeventattachment plannedeventattachment_plannedevent_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.cmmsmachineparts_plannedeventattachment
    ADD CONSTRAINT plannedeventattachment_plannedevent_fkey FOREIGN KEY (plannedevent_id) REFERENCES public.cmmsmachineparts_plannedevent(id) DEFERRABLE;


--
-- Name: cmmsmachineparts_plannedeventcontext plannedeventcontext_division_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.cmmsmachineparts_plannedeventcontext
    ADD CONSTRAINT plannedeventcontext_division_fkey FOREIGN KEY (division_id) REFERENCES public.basic_division(id) DEFERRABLE;


--
-- Name: cmmsmachineparts_plannedeventcontext plannedeventcontext_factory_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.cmmsmachineparts_plannedeventcontext
    ADD CONSTRAINT plannedeventcontext_factory_fkey FOREIGN KEY (factory_id) REFERENCES public.basic_factory(id) DEFERRABLE;


--
-- Name: cmmsmachineparts_plannedeventrealization plannedeventrealization_action_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.cmmsmachineparts_plannedeventrealization
    ADD CONSTRAINT plannedeventrealization_action_fkey FOREIGN KEY (action_id) REFERENCES public.cmmsmachineparts_actionforplannedevent(id) DEFERRABLE;


--
-- Name: cmmsmachineparts_plannedeventrealization plannedeventrealization_plannedevent_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.cmmsmachineparts_plannedeventrealization
    ADD CONSTRAINT plannedeventrealization_plannedevent_fkey FOREIGN KEY (plannedevent_id) REFERENCES public.cmmsmachineparts_plannedevent(id) DEFERRABLE;


--
-- Name: cmmsmachineparts_plannedeventrealization plannedeventrealization_worker_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.cmmsmachineparts_plannedeventrealization
    ADD CONSTRAINT plannedeventrealization_worker_fkey FOREIGN KEY (worker_id) REFERENCES public.basic_staff(id) DEFERRABLE;


--
-- Name: cmmsmachineparts_plannedeventstatechange plannedeventstatechange_plannedevent_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.cmmsmachineparts_plannedeventstatechange
    ADD CONSTRAINT plannedeventstatechange_plannedevent_fkey FOREIGN KEY (plannedevent_id) REFERENCES public.cmmsmachineparts_plannedevent(id) DEFERRABLE;


--
-- Name: cmmsmachineparts_plannedeventstatechange plannedeventstatechange_shift_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.cmmsmachineparts_plannedeventstatechange
    ADD CONSTRAINT plannedeventstatechange_shift_fkey FOREIGN KEY (shift_id) REFERENCES public.basic_shift(id) DEFERRABLE;


--
-- Name: productionscheduling_planopercomptimecalculation planopercomptimecalculation_ordertimecalculation_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.productionscheduling_planopercomptimecalculation
    ADD CONSTRAINT planopercomptimecalculation_ordertimecalculation_fkey FOREIGN KEY (ordertimecalculation_id) REFERENCES public.productionscheduling_planordertimecalculation(id) DEFERRABLE;


--
-- Name: productionscheduling_planopercomptimecalculation planopercomptimecalculation_technologyoperationcomponent_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.productionscheduling_planopercomptimecalculation
    ADD CONSTRAINT planopercomptimecalculation_technologyoperationcomponent_fkey FOREIGN KEY (technologyoperationcomponent_id) REFERENCES public.technologies_technologyoperationcomponent(id) DEFERRABLE;


--
-- Name: productionscheduling_planordertimecalculation planordertimecalculation_order_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.productionscheduling_planordertimecalculation
    ADD CONSTRAINT planordertimecalculation_order_fkey FOREIGN KEY (order_id) REFERENCES public.orders_order(id) DEFERRABLE;


--
-- Name: productionscheduling_planordertimecalculation planordertimecalculation_productionline_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.productionscheduling_planordertimecalculation
    ADD CONSTRAINT planordertimecalculation_productionline_fkey FOREIGN KEY (productionline_id) REFERENCES public.productionlines_productionline(id) DEFERRABLE;


--
-- Name: productionscheduling_planordertimecalculation planordertimecalculation_productionlineschedule_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.productionscheduling_planordertimecalculation
    ADD CONSTRAINT planordertimecalculation_productionlineschedule_fkey FOREIGN KEY (productionlineschedule_id) REFERENCES public.orders_productionlineschedule(id) DEFERRABLE;


--
-- Name: productionpershift_planproductionpershift planproductionpershift_order_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.productionpershift_planproductionpershift
    ADD CONSTRAINT planproductionpershift_order_fkey FOREIGN KEY (order_id) REFERENCES public.orders_order(id) DEFERRABLE;


--
-- Name: productionpershift_planproductionpershift planproductionpershift_productionline_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.productionpershift_planproductionpershift
    ADD CONSTRAINT planproductionpershift_productionline_fkey FOREIGN KEY (productionline_id) REFERENCES public.productionlines_productionline(id) DEFERRABLE;


--
-- Name: productionpershift_planproductionpershift planproductionpershift_productionlineschedule_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.productionpershift_planproductionpershift
    ADD CONSTRAINT planproductionpershift_productionlineschedule_fkey FOREIGN KEY (productionlineschedule_id) REFERENCES public.orders_productionlineschedule(id) DEFERRABLE;


--
-- Name: productionpershift_planprogressforday planprogressforday_productionpershift_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.productionpershift_planprogressforday
    ADD CONSTRAINT planprogressforday_productionpershift_fkey FOREIGN KEY (productionpershift_id) REFERENCES public.productionpershift_planproductionpershift(id) DEFERRABLE;


--
-- Name: materialflowresources_position position_batch_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.materialflowresources_position
    ADD CONSTRAINT position_batch_fkey FOREIGN KEY (batch_id) REFERENCES public.advancedgenealogy_batch(id) DEFERRABLE;


--
-- Name: masterorders_position_deliveryproductquantityhelper position_deliveryproductquantityhelper_product_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.masterorders_position_deliveryproductquantityhelper
    ADD CONSTRAINT position_deliveryproductquantityhelper_product_fkey FOREIGN KEY (product_id) REFERENCES public.basic_product(id) DEFERRABLE;


--
-- Name: materialflowresources_position position_document_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.materialflowresources_position
    ADD CONSTRAINT position_document_fkey FOREIGN KEY (document_id) REFERENCES public.materialflowresources_document(id) DEFERRABLE;


--
-- Name: materialflowresources_position position_documentpart_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.materialflowresources_position
    ADD CONSTRAINT position_documentpart_fkey FOREIGN KEY (documentpart_id) REFERENCES public.mobilewms_wmsdocumentpart(id) DEFERRABLE;


--
-- Name: materialflowresources_position position_palletnumber_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.materialflowresources_position
    ADD CONSTRAINT position_palletnumber_fkey FOREIGN KEY (palletnumber_id) REFERENCES public.basic_palletnumber(id) DEFERRABLE;


--
-- Name: materialflowresources_position position_pickingworker_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.materialflowresources_position
    ADD CONSTRAINT position_pickingworker_fkey FOREIGN KEY (pickingworker_id) REFERENCES public.qcadoosecurity_user(id) DEFERRABLE;


--
-- Name: materialflowresources_position position_product_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.materialflowresources_position
    ADD CONSTRAINT position_product_fkey FOREIGN KEY (product_id) REFERENCES public.basic_product(id) DEFERRABLE;


--
-- Name: materialflowresources_position position_resource_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.materialflowresources_position
    ADD CONSTRAINT position_resource_fkey FOREIGN KEY (resource_id) REFERENCES public.materialflowresources_resource(id) DEFERRABLE;


--
-- Name: materialflowresources_position position_storagelocation_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.materialflowresources_position
    ADD CONSTRAINT position_storagelocation_fkey FOREIGN KEY (storagelocation_id) REFERENCES public.materialflowresources_storagelocation(id) DEFERRABLE;


--
-- Name: masterorders_position_warehousestatehelper position_warehousestatehelper_location_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.masterorders_position_warehousestatehelper
    ADD CONSTRAINT position_warehousestatehelper_location_fkey FOREIGN KEY (location_id) REFERENCES public.materialflow_location(id) DEFERRABLE;


--
-- Name: masterorders_position_warehousestatehelper position_warehousestatehelper_product_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.masterorders_position_warehousestatehelper
    ADD CONSTRAINT position_warehousestatehelper_product_fkey FOREIGN KEY (product_id) REFERENCES public.basic_product(id) DEFERRABLE;


--
-- Name: materialflowresources_positionattributevalue positionattributevalue_attribute_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.materialflowresources_positionattributevalue
    ADD CONSTRAINT positionattributevalue_attribute_fkey FOREIGN KEY (attribute_id) REFERENCES public.basic_attribute(id) DEFERRABLE;


--
-- Name: materialflowresources_positionattributevalue positionattributevalue_attributevalue_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.materialflowresources_positionattributevalue
    ADD CONSTRAINT positionattributevalue_attributevalue_fkey FOREIGN KEY (attributevalue_id) REFERENCES public.basic_attributevalue(id) DEFERRABLE;


--
-- Name: materialflowresources_positionattributevalue positionattributevalue_position_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.materialflowresources_positionattributevalue
    ADD CONSTRAINT positionattributevalue_position_fkey FOREIGN KEY (position_id) REFERENCES public.materialflowresources_position(id) DEFERRABLE;


--
-- Name: masterorders_priceslist priceslist_attribute1value_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.masterorders_priceslist
    ADD CONSTRAINT priceslist_attribute1value_fkey FOREIGN KEY (attribute1value_id) REFERENCES public.basic_attributevalue(id) DEFERRABLE;


--
-- Name: masterorders_priceslist priceslist_attribute2value_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.masterorders_priceslist
    ADD CONSTRAINT priceslist_attribute2value_fkey FOREIGN KEY (attribute2value_id) REFERENCES public.basic_attributevalue(id) DEFERRABLE;


--
-- Name: masterorders_priceslist priceslist_product_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.masterorders_priceslist
    ADD CONSTRAINT priceslist_product_fkey FOREIGN KEY (product_id) REFERENCES public.basic_product(id) DEFERRABLE;


--
-- Name: goodfood_printedlabel printedlabel_masterorder_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.goodfood_printedlabel
    ADD CONSTRAINT printedlabel_masterorder_fkey FOREIGN KEY (masterorder_id) REFERENCES public.masterorders_masterorder(id) DEFERRABLE;


--
-- Name: goodfood_printedlabel printedlabel_palletcontext_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.goodfood_printedlabel
    ADD CONSTRAINT printedlabel_palletcontext_fkey FOREIGN KEY (palletcontext_id) REFERENCES public.goodfood_palletcontext(id) DEFERRABLE;


--
-- Name: goodfood_printedlabel printedlabel_productionline_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.goodfood_printedlabel
    ADD CONSTRAINT printedlabel_productionline_fkey FOREIGN KEY (productionline_id) REFERENCES public.productionlines_productionline(id) DEFERRABLE;


--
-- Name: integrationbartender_printlabelshelper printlabelshelper_masterorder_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.integrationbartender_printlabelshelper
    ADD CONSTRAINT printlabelshelper_masterorder_fkey FOREIGN KEY (masterorder_id) REFERENCES public.masterorders_masterorder(id) DEFERRABLE;


--
-- Name: integrationbartender_printlabelshelper printlabelshelper_order_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.integrationbartender_printlabelshelper
    ADD CONSTRAINT printlabelshelper_order_fkey FOREIGN KEY (order_id) REFERENCES public.orders_order(id) DEFERRABLE;


--
-- Name: jointable_printlabelshelper_printedlabel printlabelshelper_printedlabel_printedlabel_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.jointable_printlabelshelper_printedlabel
    ADD CONSTRAINT printlabelshelper_printedlabel_printedlabel_fkey FOREIGN KEY (printedlabel_id) REFERENCES public.goodfood_printedlabel(id) DEFERRABLE;


--
-- Name: jointable_printlabelshelper_printedlabel printlabelshelper_printedlabel_printedlabelshelper_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.jointable_printlabelshelper_printedlabel
    ADD CONSTRAINT printlabelshelper_printedlabel_printedlabelshelper_fkey FOREIGN KEY (printlabelshelper_id) REFERENCES public.integrationbartender_printlabelshelper(id) DEFERRABLE;


--
-- Name: integrationbartender_printlabelshelper printlabelshelper_printer_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.integrationbartender_printlabelshelper
    ADD CONSTRAINT printlabelshelper_printer_fkey FOREIGN KEY (printer_id) REFERENCES public.integrationbartender_printer(id) DEFERRABLE;


--
-- Name: productioncounting_prodoutresourceattrval prodoutresourceattrval_attribute_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.productioncounting_prodoutresourceattrval
    ADD CONSTRAINT prodoutresourceattrval_attribute_fkey FOREIGN KEY (attribute_id) REFERENCES public.basic_attribute(id) DEFERRABLE;


--
-- Name: productioncounting_prodoutresourceattrval prodoutresourceattrval_attributevalue_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.productioncounting_prodoutresourceattrval
    ADD CONSTRAINT prodoutresourceattrval_attributevalue_fkey FOREIGN KEY (attributevalue_id) REFERENCES public.basic_attributevalue(id) DEFERRABLE;


--
-- Name: productioncounting_prodoutresourceattrval prodoutresourceattrval_trackingoperationproductoutcomponent_fke; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.productioncounting_prodoutresourceattrval
    ADD CONSTRAINT prodoutresourceattrval_trackingoperationproductoutcomponent_fke FOREIGN KEY (trackingoperationproductoutcomponent_id) REFERENCES public.productioncounting_trackingoperationproductoutcomponent(id) DEFERRABLE;


--
-- Name: basic_product product_assortment_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.basic_product
    ADD CONSTRAINT product_assortment_fkey FOREIGN KEY (assortment_id) REFERENCES public.basic_assortment(id) DEFERRABLE;


--
-- Name: basic_product product_averagecostcurrency_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.basic_product
    ADD CONSTRAINT product_averagecostcurrency_fkey FOREIGN KEY (averagecostcurrency_id) REFERENCES public.basic_currency(id) DEFERRABLE;


--
-- Name: basic_product product_batchnumberpattern_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.basic_product
    ADD CONSTRAINT product_batchnumberpattern_fkey FOREIGN KEY (batchnumberpattern_id) REFERENCES public.basic_numberpattern(id) DEFERRABLE;


--
-- Name: basic_product product_company_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.basic_product
    ADD CONSTRAINT product_company_fkey FOREIGN KEY (producer_id) REFERENCES public.basic_company(id) DEFERRABLE;


--
-- Name: basic_product product_costnormsgenerator_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.basic_product
    ADD CONSTRAINT product_costnormsgenerator_fkey FOREIGN KEY (costnormsgenerator_id) REFERENCES public.materialflowresources_costnormsgenerator(id) DEFERRABLE;


--
-- Name: basic_product product_generatorcontext_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.basic_product
    ADD CONSTRAINT product_generatorcontext_fkey FOREIGN KEY (generatorcontext_id) REFERENCES public.technologiesgenerator_generatorcontext(id) DEFERRABLE;


--
-- Name: productflowthrudivision_issue product_issue_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.productflowthrudivision_issue
    ADD CONSTRAINT product_issue_fkey FOREIGN KEY (product_id) REFERENCES public.basic_product(id) DEFERRABLE;


--
-- Name: basic_product product_lastpurchasecostcurrency_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.basic_product
    ADD CONSTRAINT product_lastpurchasecostcurrency_fkey FOREIGN KEY (lastpurchasecostcurrency_id) REFERENCES public.basic_currency(id) DEFERRABLE;


--
-- Name: basic_product product_model_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.basic_product
    ADD CONSTRAINT product_model_fkey FOREIGN KEY (model_id) REFERENCES public.basic_model(id) DEFERRABLE;


--
-- Name: basic_product product_nominalcostcurrency_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.basic_product
    ADD CONSTRAINT product_nominalcostcurrency_fkey FOREIGN KEY (nominalcostcurrency_id) REFERENCES public.basic_currency(id) DEFERRABLE;


--
-- Name: basic_product product_orderedproductconfigurator_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.basic_product
    ADD CONSTRAINT product_orderedproductconfigurator_fkey FOREIGN KEY (orderedproductconfigurator_id) REFERENCES public.masterorders_orderedproductconfigurator(id) DEFERRABLE;


--
-- Name: basic_product product_productform_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.basic_product
    ADD CONSTRAINT product_productform_fkey FOREIGN KEY (productform_id) REFERENCES public.basic_forms(id) DEFERRABLE;


--
-- Name: productflowthrudivision_productstoissue product_productstoissue_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.productflowthrudivision_productstoissue
    ADD CONSTRAINT product_productstoissue_fkey FOREIGN KEY (product_id) REFERENCES public.basic_product(id) DEFERRABLE;


--
-- Name: jointable_product_qualitycard product_qualitycard_product_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.jointable_product_qualitycard
    ADD CONSTRAINT product_qualitycard_product_fkey FOREIGN KEY (product_id) REFERENCES public.basic_product(id) DEFERRABLE;


--
-- Name: jointable_product_qualitycard product_qualitycard_qualitycard_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.jointable_product_qualitycard
    ADD CONSTRAINT product_qualitycard_qualitycard_fkey FOREIGN KEY (qualitycard_id) REFERENCES public.basic_qualitycard(id) DEFERRABLE;


--
-- Name: jointable_product_salesvolumemulti product_salesvolumemulti_product_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.jointable_product_salesvolumemulti
    ADD CONSTRAINT product_salesvolumemulti_product_fkey FOREIGN KEY (product_id) REFERENCES public.basic_product(id) DEFERRABLE;


--
-- Name: jointable_product_salesvolumemulti product_salesvolumemulti_salesvolumemulti_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.jointable_product_salesvolumemulti
    ADD CONSTRAINT product_salesvolumemulti_salesvolumemulti_fkey FOREIGN KEY (salesvolumemulti_id) REFERENCES public.masterorders_salesvolumemulti(id) DEFERRABLE;


--
-- Name: jointable_product_scale product_scale_product_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.jointable_product_scale
    ADD CONSTRAINT product_scale_product_fkey FOREIGN KEY (product_id) REFERENCES public.basic_product(id) DEFERRABLE;


--
-- Name: jointable_product_scale product_scale_scale_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.jointable_product_scale
    ADD CONSTRAINT product_scale_scale_fkey FOREIGN KEY (scale_id) REFERENCES public.integrationscales_scale(id) DEFERRABLE;


--
-- Name: basic_product product_size_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.basic_product
    ADD CONSTRAINT product_size_fkey FOREIGN KEY (size_id) REFERENCES public.basic_size(id) DEFERRABLE;


--
-- Name: jointable_product_storagelocation product_storagelocation_product_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.jointable_product_storagelocation
    ADD CONSTRAINT product_storagelocation_product_fkey FOREIGN KEY (product_id) REFERENCES public.basic_product(id) DEFERRABLE;


--
-- Name: jointable_product_storagelocation product_storagelocation_storagelocation_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.jointable_product_storagelocation
    ADD CONSTRAINT product_storagelocation_storagelocation_fkey FOREIGN KEY (storagelocation_id) REFERENCES public.materialflowresources_storagelocation(id) DEFERRABLE;


--
-- Name: basic_product product_supplier_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.basic_product
    ADD CONSTRAINT product_supplier_fkey FOREIGN KEY (supplier_id) REFERENCES public.basic_company(id) DEFERRABLE;


--
-- Name: productflowthrudivision_productandquantityhelper productandquantityhelper_location_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.productflowthrudivision_productandquantityhelper
    ADD CONSTRAINT productandquantityhelper_location_fkey FOREIGN KEY (location_id) REFERENCES public.materialflow_location(id) DEFERRABLE;


--
-- Name: productflowthrudivision_productandquantityhelper productandquantityhelper_product_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.productflowthrudivision_productandquantityhelper
    ADD CONSTRAINT productandquantityhelper_product_fkey FOREIGN KEY (product_id) REFERENCES public.basic_product(id) DEFERRABLE;


--
-- Name: basic_productattachment productattachment_product_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.basic_productattachment
    ADD CONSTRAINT productattachment_product_fkey FOREIGN KEY (product_id) REFERENCES public.basic_product(id) DEFERRABLE;


--
-- Name: basic_productattributevalue productattributevalue_attribute_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.basic_productattributevalue
    ADD CONSTRAINT productattributevalue_attribute_fkey FOREIGN KEY (attribute_id) REFERENCES public.basic_attribute(id) DEFERRABLE;


--
-- Name: basic_productattributevalue productattributevalue_attributevalue_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.basic_productattributevalue
    ADD CONSTRAINT productattributevalue_attributevalue_fkey FOREIGN KEY (attributevalue_id) REFERENCES public.basic_attributevalue(id) DEFERRABLE;


--
-- Name: basic_productattributevalue productattributevalue_product_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.basic_productattributevalue
    ADD CONSTRAINT productattributevalue_product_fkey FOREIGN KEY (product_id) REFERENCES public.basic_product(id) DEFERRABLE;


--
-- Name: technologies_productbysizegroup productbysizegroup_product_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.technologies_productbysizegroup
    ADD CONSTRAINT productbysizegroup_product_fkey FOREIGN KEY (product_id) REFERENCES public.basic_product(id) DEFERRABLE;


--
-- Name: technologies_productbysizegroup productbysizegroup_sizegroup_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.technologies_productbysizegroup
    ADD CONSTRAINT productbysizegroup_sizegroup_fkey FOREIGN KEY (sizegroup_id) REFERENCES public.basic_sizegroup(id) DEFERRABLE;


--
-- Name: productcatalognumbers_productcatalognumbers productcatalognumbers_company_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.productcatalognumbers_productcatalognumbers
    ADD CONSTRAINT productcatalognumbers_company_fkey FOREIGN KEY (company_id) REFERENCES public.basic_company(id) DEFERRABLE;


--
-- Name: productcatalognumbers_productcatalognumbers productcatalognumbers_product_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.productcatalognumbers_productcatalognumbers
    ADD CONSTRAINT productcatalognumbers_product_fkey FOREIGN KEY (product_id) REFERENCES public.basic_product(id) DEFERRABLE;


--
-- Name: technologies_productcomponent productcomponent_operationin_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.technologies_productcomponent
    ADD CONSTRAINT productcomponent_operationin_fkey FOREIGN KEY (operationin_id) REFERENCES public.technologies_operation(id) DEFERRABLE;


--
-- Name: technologies_productcomponent productcomponent_operationout_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.technologies_productcomponent
    ADD CONSTRAINT productcomponent_operationout_fkey FOREIGN KEY (operationout_id) REFERENCES public.technologies_operation(id) DEFERRABLE;


--
-- Name: technologies_productcomponent productcomponent_product_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.technologies_productcomponent
    ADD CONSTRAINT productcomponent_product_fkey FOREIGN KEY (product_id) REFERENCES public.basic_product(id) DEFERRABLE;


--
-- Name: technologies_productdata productdata_product_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.technologies_productdata
    ADD CONSTRAINT productdata_product_fkey FOREIGN KEY (product_id) REFERENCES public.basic_product(id) DEFERRABLE;


--
-- Name: technologies_productdata productdata_staff_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.technologies_productdata
    ADD CONSTRAINT productdata_staff_fkey FOREIGN KEY (staff_id) REFERENCES public.basic_staff(id) DEFERRABLE;


--
-- Name: technologies_productdata productdata_technology_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.technologies_productdata
    ADD CONSTRAINT productdata_technology_fkey FOREIGN KEY (technology_id) REFERENCES public.technologies_technology(id) DEFERRABLE;


--
-- Name: technologies_productdataattachment productdataattachment_productdata_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.technologies_productdataattachment
    ADD CONSTRAINT productdataattachment_productdata_fkey FOREIGN KEY (productdata_id) REFERENCES public.technologies_productdata(id) DEFERRABLE;


--
-- Name: technologies_productdatainput productdatainput_productdata_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.technologies_productdatainput
    ADD CONSTRAINT productdatainput_productdata_fkey FOREIGN KEY (productdata_id) REFERENCES public.technologies_productdata(id) DEFERRABLE;


--
-- Name: technologies_productdataoperation productdataoperation_operationcomponent_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.technologies_productdataoperation
    ADD CONSTRAINT productdataoperation_operationcomponent_fkey FOREIGN KEY (technologyoperationcomponent_id) REFERENCES public.technologies_technologyoperationcomponent(id) DEFERRABLE;


--
-- Name: technologies_productdatainput productdataoperation_operationproductincomponent_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.technologies_productdatainput
    ADD CONSTRAINT productdataoperation_operationproductincomponent_fkey FOREIGN KEY (operationproductincomponent_id) REFERENCES public.technologies_operationproductincomponent(id) DEFERRABLE;


--
-- Name: technologies_productdataoperation productdataoperation_productdata_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.technologies_productdataoperation
    ADD CONSTRAINT productdataoperation_productdata_fkey FOREIGN KEY (productdata_id) REFERENCES public.technologies_productdata(id) DEFERRABLE;


--
-- Name: productflowthrudivision_issue productincomponent_issue_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.productflowthrudivision_issue
    ADD CONSTRAINT productincomponent_issue_fkey FOREIGN KEY (productincomponent_id) REFERENCES public.technologies_operationproductincomponent(id) DEFERRABLE;


--
-- Name: productflowthrudivision_productstoissue productincomponent_productstoissue_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.productflowthrudivision_productstoissue
    ADD CONSTRAINT productincomponent_productstoissue_fkey FOREIGN KEY (productincomponent_id) REFERENCES public.technologies_operationproductincomponent(id) DEFERRABLE;


--
-- Name: ordersgroups_productionbalance productionbalance_ordersgroup_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.ordersgroups_productionbalance
    ADD CONSTRAINT productionbalance_ordersgroup_fkey FOREIGN KEY (ordersgroup_id) REFERENCES public.ordersgroups_ordersgroup(id) DEFERRABLE;


--
-- Name: productioncounting_productiontracking productioncounting_productionrecord_d_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.productioncounting_productiontracking
    ADD CONSTRAINT productioncounting_productionrecord_d_fkey FOREIGN KEY (division_id) REFERENCES public.basic_division(id) DEFERRABLE;


--
-- Name: productioncounting_productiontracking productioncounting_productionrecord_s_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.productioncounting_productiontracking
    ADD CONSTRAINT productioncounting_productionrecord_s_fkey FOREIGN KEY (staff_id) REFERENCES public.basic_staff(id) DEFERRABLE;


--
-- Name: productioncounting_productiontracking productioncounting_productionrecord_wt_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.productioncounting_productiontracking
    ADD CONSTRAINT productioncounting_productionrecord_wt_fkey FOREIGN KEY (workstationtype_id) REFERENCES public.basic_workstationtype(id) DEFERRABLE;


--
-- Name: productioncounting_productiontrackingstatechange productioncounting_productionrecordlogging_pr_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.productioncounting_productiontrackingstatechange
    ADD CONSTRAINT productioncounting_productionrecordlogging_pr_fkey FOREIGN KEY (productiontracking_id) REFERENCES public.productioncounting_productiontracking(id) DEFERRABLE;


--
-- Name: basicproductioncounting_productioncountingattributevalue productioncountingattributevalue_attribute_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.basicproductioncounting_productioncountingattributevalue
    ADD CONSTRAINT productioncountingattributevalue_attribute_fkey FOREIGN KEY (attribute_id) REFERENCES public.basic_attribute(id) DEFERRABLE;


--
-- Name: basicproductioncounting_productioncountingattributevalue productioncountingattributevalue_attributevalue_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.basicproductioncounting_productioncountingattributevalue
    ADD CONSTRAINT productioncountingattributevalue_attributevalue_fkey FOREIGN KEY (attributevalue_id) REFERENCES public.basic_attributevalue(id) DEFERRABLE;


--
-- Name: basicproductioncounting_productioncountingattributevalue productioncountingattributevalue_pcquantity_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.basicproductioncounting_productioncountingattributevalue
    ADD CONSTRAINT productioncountingattributevalue_pcquantity_fkey FOREIGN KEY (productioncountingquantity_id) REFERENCES public.basicproductioncounting_productioncountingquantity(id) DEFERRABLE;


--
-- Name: basicproductioncounting_productioncountingoperationrun productioncountingoperationrun_order_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.basicproductioncounting_productioncountingoperationrun
    ADD CONSTRAINT productioncountingoperationrun_order_fkey FOREIGN KEY (order_id) REFERENCES public.orders_order(id) DEFERRABLE;


--
-- Name: basicproductioncounting_productioncountingoperationrun productioncountingoperationrun_toc_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.basicproductioncounting_productioncountingoperationrun
    ADD CONSTRAINT productioncountingoperationrun_toc_fkey FOREIGN KEY (technologyoperationcomponent_id) REFERENCES public.technologies_technologyoperationcomponent(id) DEFERRABLE;


--
-- Name: basicproductioncounting_productioncountingquantity productioncountingquantity_attribute_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.basicproductioncounting_productioncountingquantity
    ADD CONSTRAINT productioncountingquantity_attribute_fkey FOREIGN KEY (attribute_id) REFERENCES public.basic_attribute(id) DEFERRABLE;


--
-- Name: basicproductioncounting_productioncountingquantity productioncountingquantity_basicproductioncounting_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.basicproductioncounting_productioncountingquantity
    ADD CONSTRAINT productioncountingquantity_basicproductioncounting_fkey FOREIGN KEY (basicproductioncounting_id) REFERENCES public.basicproductioncounting_basicproductioncounting(id) DEFERRABLE;


--
-- Name: basicproductioncounting_productioncountingquantity productioncountingquantity_componentslocation_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.basicproductioncounting_productioncountingquantity
    ADD CONSTRAINT productioncountingquantity_componentslocation_fkey FOREIGN KEY (componentslocation_id) REFERENCES public.materialflow_location(id) DEFERRABLE;


--
-- Name: basicproductioncounting_productioncountingquantity productioncountingquantity_componentsoutputlocation_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.basicproductioncounting_productioncountingquantity
    ADD CONSTRAINT productioncountingquantity_componentsoutputlocation_fkey FOREIGN KEY (componentsoutputlocation_id) REFERENCES public.materialflow_location(id) DEFERRABLE;


--
-- Name: basicproductioncounting_productioncountingquantity productioncountingquantity_order_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.basicproductioncounting_productioncountingquantity
    ADD CONSTRAINT productioncountingquantity_order_fkey FOREIGN KEY (order_id) REFERENCES public.orders_order(id) DEFERRABLE;


--
-- Name: basicproductioncounting_productioncountingquantity productioncountingquantity_product_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.basicproductioncounting_productioncountingquantity
    ADD CONSTRAINT productioncountingquantity_product_fkey FOREIGN KEY (product_id) REFERENCES public.basic_product(id) DEFERRABLE;


--
-- Name: basicproductioncounting_productioncountingquantity productioncountingquantity_productsflowlocation_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.basicproductioncounting_productioncountingquantity
    ADD CONSTRAINT productioncountingquantity_productsflowlocation_fkey FOREIGN KEY (productsflowlocation_id) REFERENCES public.materialflow_location(id) DEFERRABLE;


--
-- Name: basicproductioncounting_productioncountingquantity productioncountingquantity_productsinputlocation_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.basicproductioncounting_productioncountingquantity
    ADD CONSTRAINT productioncountingquantity_productsinputlocation_fkey FOREIGN KEY (productsinputlocation_id) REFERENCES public.materialflow_location(id) DEFERRABLE;


--
-- Name: basicproductioncounting_productioncountingquantity productioncountingquantity_replacementto_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.basicproductioncounting_productioncountingquantity
    ADD CONSTRAINT productioncountingquantity_replacementto_fkey FOREIGN KEY (replacementto_id) REFERENCES public.basic_product(id) DEFERRABLE;


--
-- Name: basicproductioncounting_productioncountingquantity productioncountingquantity_technologyinputproducttype_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.basicproductioncounting_productioncountingquantity
    ADD CONSTRAINT productioncountingquantity_technologyinputproducttype_fkey FOREIGN KEY (technologyinputproducttype_id) REFERENCES public.technologies_technologyinputproducttype(id) DEFERRABLE;


--
-- Name: basicproductioncounting_productioncountingquantity productioncountingquantity_technologyoperationcomponent_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.basicproductioncounting_productioncountingquantity
    ADD CONSTRAINT productioncountingquantity_technologyoperationcomponent_fkey FOREIGN KEY (technologyoperationcomponent_id) REFERENCES public.technologies_technologyoperationcomponent(id) DEFERRABLE;


--
-- Name: basicproductioncounting_productioncountingquantity productioncountingquantity_wastereceptionwarehouse_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.basicproductioncounting_productioncountingquantity
    ADD CONSTRAINT productioncountingquantity_wastereceptionwarehouse_fkey FOREIGN KEY (wastereceptionwarehouse_id) REFERENCES public.materialflow_location(id) DEFERRABLE;


--
-- Name: basicproductioncounting_productioncountingquantitychange productioncountingquantitychange_order_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.basicproductioncounting_productioncountingquantitychange
    ADD CONSTRAINT productioncountingquantitychange_order_fkey FOREIGN KEY (order_id) REFERENCES public.orders_order(id) DEFERRABLE;


--
-- Name: basicproductioncounting_productioncountingquantitychange productioncountingquantitychange_product_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.basicproductioncounting_productioncountingquantitychange
    ADD CONSTRAINT productioncountingquantitychange_product_fkey FOREIGN KEY (product_id) REFERENCES public.basic_product(id) DEFERRABLE;


--
-- Name: productionlines_productionline productionline_printer_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.productionlines_productionline
    ADD CONSTRAINT productionline_printer_fkey FOREIGN KEY (printer_id) REFERENCES public.integrationbartender_printer(id) DEFERRABLE;


--
-- Name: jointable_productionline_scale productionline_scale_productionline_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.jointable_productionline_scale
    ADD CONSTRAINT productionline_scale_productionline_fkey FOREIGN KEY (productionline_id) REFERENCES public.productionlines_productionline(id) DEFERRABLE;


--
-- Name: jointable_productionline_scale productionline_scale_scale_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.jointable_productionline_scale
    ADD CONSTRAINT productionline_scale_scale_fkey FOREIGN KEY (scale_id) REFERENCES public.integrationscales_scale(id) DEFERRABLE;


--
-- Name: jointable_productionline_shift productionline_shift_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.jointable_productionline_shift
    ADD CONSTRAINT productionline_shift_fkey FOREIGN KEY (shift_id) REFERENCES public.basic_shift(id) DEFERRABLE;


--
-- Name: jointable_productionline_shifttimetableexception productionline_shifttimetableexception_productionline_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.jointable_productionline_shifttimetableexception
    ADD CONSTRAINT productionline_shifttimetableexception_productionline_fkey FOREIGN KEY (productionline_id) REFERENCES public.productionlines_productionline(id) DEFERRABLE;


--
-- Name: jointable_productionline_shifttimetableexception productionline_shifttimetableexception_ste_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.jointable_productionline_shifttimetableexception
    ADD CONSTRAINT productionline_shifttimetableexception_ste_fkey FOREIGN KEY (shifttimetableexception_id) REFERENCES public.basic_shifttimetableexception(id) DEFERRABLE;


--
-- Name: integrationscales_productionlineforscale productionlineforscale_productionline_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.integrationscales_productionlineforscale
    ADD CONSTRAINT productionlineforscale_productionline_fkey FOREIGN KEY (productionline_id) REFERENCES public.productionlines_productionline(id) DEFERRABLE;


--
-- Name: integrationscales_productionlineforscale productionlineforscale_scale_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.integrationscales_productionlineforscale
    ADD CONSTRAINT productionlineforscale_scale_fkey FOREIGN KEY (scale_id) REFERENCES public.integrationscales_scale(id) DEFERRABLE;


--
-- Name: productionlines_productionline productionlines_division_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.productionlines_productionline
    ADD CONSTRAINT productionlines_division_fkey FOREIGN KEY (division_id) REFERENCES public.basic_division(id) DEFERRABLE;


--
-- Name: goodfood_confectioncontext productionlines_productionline_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.goodfood_confectioncontext
    ADD CONSTRAINT productionlines_productionline_fkey FOREIGN KEY (productionline_id) REFERENCES public.productionlines_productionline(id) DEFERRABLE;


--
-- Name: goodfood_confectionprotocol productionlines_productionline_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.goodfood_confectionprotocol
    ADD CONSTRAINT productionlines_productionline_fkey FOREIGN KEY (productionline_id) REFERENCES public.productionlines_productionline(id) DEFERRABLE;


--
-- Name: goodfood_extrusioncontext productionlines_productionline_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.goodfood_extrusioncontext
    ADD CONSTRAINT productionlines_productionline_fkey FOREIGN KEY (productionline_id) REFERENCES public.productionlines_productionline(id) DEFERRABLE;


--
-- Name: goodfood_extrusionprotocol productionlines_productionline_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.goodfood_extrusionprotocol
    ADD CONSTRAINT productionlines_productionline_fkey FOREIGN KEY (productionline_id) REFERENCES public.productionlines_productionline(id) DEFERRABLE;


--
-- Name: assignmenttoshift_staffassignmenttoshift productionlines_productionline_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.assignmenttoshift_staffassignmenttoshift
    ADD CONSTRAINT productionlines_productionline_fkey FOREIGN KEY (productionline_id) REFERENCES public.productionlines_productionline(id) DEFERRABLE;


--
-- Name: avglaborcostcalcfororder_avglaborcostcalcfororder productionlines_productionline_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.avglaborcostcalcfororder_avglaborcostcalcfororder
    ADD CONSTRAINT productionlines_productionline_fkey FOREIGN KEY (productionline_id) REFERENCES public.productionlines_productionline(id) DEFERRABLE;


--
-- Name: productionlines_workstationtypecomponent productionlines_workstationtypecomponent_pl_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.productionlines_workstationtypecomponent
    ADD CONSTRAINT productionlines_workstationtypecomponent_pl_fkey FOREIGN KEY (productionline_id) REFERENCES public.productionlines_productionline(id) DEFERRABLE;


--
-- Name: productionlines_workstationtypecomponent productionlines_workstationtypecomponent_wt_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.productionlines_workstationtypecomponent
    ADD CONSTRAINT productionlines_workstationtypecomponent_wt_fkey FOREIGN KEY (workstationtype_id) REFERENCES public.basic_workstationtype(id) DEFERRABLE;


--
-- Name: orders_productionlinescheduleposition productionlinescheduleposition_linechangeovernorm_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.orders_productionlinescheduleposition
    ADD CONSTRAINT productionlinescheduleposition_linechangeovernorm_fkey FOREIGN KEY (linechangeovernorm_id) REFERENCES public.linechangeovernorms_linechangeovernorms(id);


--
-- Name: orders_productionlinescheduleposition productionlinescheduleposition_order_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.orders_productionlinescheduleposition
    ADD CONSTRAINT productionlinescheduleposition_order_fkey FOREIGN KEY (order_id) REFERENCES public.orders_order(id);


--
-- Name: orders_productionlinescheduleposition productionlinescheduleposition_productionline_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.orders_productionlinescheduleposition
    ADD CONSTRAINT productionlinescheduleposition_productionline_fkey FOREIGN KEY (productionline_id) REFERENCES public.productionlines_productionline(id);


--
-- Name: orders_productionlinescheduleposition productionlinescheduleposition_productionlineschedule_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.orders_productionlinescheduleposition
    ADD CONSTRAINT productionlinescheduleposition_productionlineschedule_fkey FOREIGN KEY (productionlineschedule_id) REFERENCES public.orders_productionlineschedule(id);


--
-- Name: technologies_productionlinetechnologygroup productionlinetechnologygroup_productionline_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.technologies_productionlinetechnologygroup
    ADD CONSTRAINT productionlinetechnologygroup_productionline_fkey FOREIGN KEY (productionline_id) REFERENCES public.productionlines_productionline(id) DEFERRABLE;


--
-- Name: technologies_productionlinetechnologygroup productionlinetechnologygroup_technologygroup_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.technologies_productionlinetechnologygroup
    ADD CONSTRAINT productionlinetechnologygroup_technologygroup_fkey FOREIGN KEY (technologygroup_id) REFERENCES public.technologies_technologygroup(id) DEFERRABLE;


--
-- Name: productionpershift_productionpershift productionpershift_order_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.productionpershift_productionpershift
    ADD CONSTRAINT productionpershift_order_fkey FOREIGN KEY (order_id) REFERENCES public.orders_order(id) DEFERRABLE;


--
-- Name: productioncounting_productiontracking productionrecord_subcontractor_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.productioncounting_productiontracking
    ADD CONSTRAINT productionrecord_subcontractor_fkey FOREIGN KEY (subcontractor_id) REFERENCES public.basic_company(id) DEFERRABLE;


--
-- Name: productioncounting_productiontracking productiontracking_batch_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.productioncounting_productiontracking
    ADD CONSTRAINT productiontracking_batch_fkey FOREIGN KEY (batch_id) REFERENCES public.advancedgenealogy_batch(id) DEFERRABLE;


--
-- Name: productioncounting_productiontracking productiontracking_correction_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.productioncounting_productiontracking
    ADD CONSTRAINT productiontracking_correction_fkey FOREIGN KEY (correction_id) REFERENCES public.productioncounting_productiontracking(id) DEFERRABLE;


--
-- Name: productioncounting_productiontracking productiontracking_order_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.productioncounting_productiontracking
    ADD CONSTRAINT productiontracking_order_fkey FOREIGN KEY (order_id) REFERENCES public.orders_order(id) DEFERRABLE;


--
-- Name: productioncounting_productiontracking productiontracking_repairorder_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.productioncounting_productiontracking
    ADD CONSTRAINT productiontracking_repairorder_fkey FOREIGN KEY (repairorder_id) REFERENCES public.repairs_repairorder(id) DEFERRABLE;


--
-- Name: productioncounting_productiontracking productiontracking_shift_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.productioncounting_productiontracking
    ADD CONSTRAINT productiontracking_shift_fkey FOREIGN KEY (shift_id) REFERENCES public.basic_shift(id) DEFERRABLE;


--
-- Name: productioncounting_productiontracking productiontracking_technologyoperationcomponent_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.productioncounting_productiontracking
    ADD CONSTRAINT productiontracking_technologyoperationcomponent_fkey FOREIGN KEY (technologyoperationcomponent_id) REFERENCES public.technologies_technologyoperationcomponent(id) DEFERRABLE;


--
-- Name: productioncounting_productiontracking productiontracking_workstation_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.productioncounting_productiontracking
    ADD CONSTRAINT productiontracking_workstation_fkey FOREIGN KEY (workstation_id) REFERENCES public.basic_workstation(id) DEFERRABLE;


--
-- Name: productioncounting_productiontrackingattachment productiontrackingattachment_productiontracking_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.productioncounting_productiontrackingattachment
    ADD CONSTRAINT productiontrackingattachment_productiontracking_fkey FOREIGN KEY (productiontracking_id) REFERENCES public.productioncounting_productiontracking(id) DEFERRABLE;


--
-- Name: masterorders_productsbyattributeentryhelper productsbyattributeentryhelper_attribute_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.masterorders_productsbyattributeentryhelper
    ADD CONSTRAINT productsbyattributeentryhelper_attribute_fkey FOREIGN KEY (attribute_id) REFERENCES public.basic_attribute(id) DEFERRABLE;


--
-- Name: masterorders_productsbyattributeentryhelper productsbyattributeentryhelper_attributevalue_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.masterorders_productsbyattributeentryhelper
    ADD CONSTRAINT productsbyattributeentryhelper_attributevalue_fkey FOREIGN KEY (attributevalue_id) REFERENCES public.basic_attributevalue(id) DEFERRABLE;


--
-- Name: masterorders_productsbyattributeentryhelper productsbyattributeentryhelper_product_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.masterorders_productsbyattributeentryhelper
    ADD CONSTRAINT productsbyattributeentryhelper_product_fkey FOREIGN KEY (product_id) REFERENCES public.basic_product(id) DEFERRABLE;


--
-- Name: masterorders_productsbyattributeentryhelper productsbyattributeentryhelper_productsbyattributehelper_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.masterorders_productsbyattributeentryhelper
    ADD CONSTRAINT productsbyattributeentryhelper_productsbyattributehelper_fkey FOREIGN KEY (productsbyattributehelper_id) REFERENCES public.masterorders_productsbyattributehelper(id) DEFERRABLE;


--
-- Name: masterorders_productsbyattributehelper productsbyattributehelper_masterorder_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.masterorders_productsbyattributehelper
    ADD CONSTRAINT productsbyattributehelper_masterorder_fkey FOREIGN KEY (masterorder_id) REFERENCES public.masterorders_masterorder(id) DEFERRABLE;


--
-- Name: masterorders_productsbyattributehelper productsbyattributehelper_product_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.masterorders_productsbyattributehelper
    ADD CONSTRAINT productsbyattributehelper_product_fkey FOREIGN KEY (product_id) REFERENCES public.basic_product(id) DEFERRABLE;


--
-- Name: masterorders_productsbysizeentryhelper productsbysizeentryhelper_product_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.masterorders_productsbysizeentryhelper
    ADD CONSTRAINT productsbysizeentryhelper_product_fkey FOREIGN KEY (product_id) REFERENCES public.basic_product(id) DEFERRABLE;


--
-- Name: masterorders_productsbysizeentryhelper productsbysizeentryhelper_productsbysizehelper_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.masterorders_productsbysizeentryhelper
    ADD CONSTRAINT productsbysizeentryhelper_productsbysizehelper_fkey FOREIGN KEY (productsbysizehelper_id) REFERENCES public.masterorders_productsbysizehelper(id) DEFERRABLE;


--
-- Name: masterorders_productsbysizeentryhelper productsbysizeentryhelper_size_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.masterorders_productsbysizeentryhelper
    ADD CONSTRAINT productsbysizeentryhelper_size_fkey FOREIGN KEY (size_id) REFERENCES public.basic_size(id) DEFERRABLE;


--
-- Name: masterorders_productsbysizehelper productsbysizehelper_masterorder_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.masterorders_productsbysizehelper
    ADD CONSTRAINT productsbysizehelper_masterorder_fkey FOREIGN KEY (masterorder_id) REFERENCES public.masterorders_masterorder(id) DEFERRABLE;


--
-- Name: masterorders_productsbysizehelper productsbysizehelper_ordersgroup_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.masterorders_productsbysizehelper
    ADD CONSTRAINT productsbysizehelper_ordersgroup_fkey FOREIGN KEY (ordersgroup_id) REFERENCES public.ordersgroups_ordersgroup(id) DEFERRABLE;


--
-- Name: masterorders_productsbysizehelper productsbysizehelper_product_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.masterorders_productsbysizehelper
    ADD CONSTRAINT productsbysizehelper_product_fkey FOREIGN KEY (product_id) REFERENCES public.basic_product(id) DEFERRABLE;


--
-- Name: masterorders_productsbysizehelper productsbysizehelper_salesplan_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.masterorders_productsbysizehelper
    ADD CONSTRAINT productsbysizehelper_salesplan_fkey FOREIGN KEY (salesplan_id) REFERENCES public.masterorders_salesplan(id) DEFERRABLE;


--
-- Name: productflowthrudivision_productstoissuehelper productstoissuehelper_location_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.productflowthrudivision_productstoissuehelper
    ADD CONSTRAINT productstoissuehelper_location_fkey FOREIGN KEY (locationfrom_id) REFERENCES public.materialflow_location(id) DEFERRABLE;


--
-- Name: technologies_productstructuretreenode productstructuretreenode_division_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.technologies_productstructuretreenode
    ADD CONSTRAINT productstructuretreenode_division_fkey FOREIGN KEY (division_id) REFERENCES public.basic_division(id) DEFERRABLE;


--
-- Name: technologies_productstructuretreenode productstructuretreenode_maintechnology_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.technologies_productstructuretreenode
    ADD CONSTRAINT productstructuretreenode_maintechnology_fkey FOREIGN KEY (maintechnology_id) REFERENCES public.technologies_technology(id) DEFERRABLE;


--
-- Name: technologies_productstructuretreenode productstructuretreenode_operation_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.technologies_productstructuretreenode
    ADD CONSTRAINT productstructuretreenode_operation_fkey FOREIGN KEY (operation_id) REFERENCES public.technologies_technologyoperationcomponent(id) DEFERRABLE;


--
-- Name: technologies_productstructuretreenode productstructuretreenode_parent_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.technologies_productstructuretreenode
    ADD CONSTRAINT productstructuretreenode_parent_fkey FOREIGN KEY (parent_id) REFERENCES public.technologies_productstructuretreenode(id) DEFERRABLE;


--
-- Name: technologies_productstructuretreenode productstructuretreenode_product_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.technologies_productstructuretreenode
    ADD CONSTRAINT productstructuretreenode_product_fkey FOREIGN KEY (product_id) REFERENCES public.basic_product(id) DEFERRABLE;


--
-- Name: technologies_productstructuretreenode productstructuretreenode_sizegroup_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.technologies_productstructuretreenode
    ADD CONSTRAINT productstructuretreenode_sizegroup_fkey FOREIGN KEY (sizegroup_id) REFERENCES public.basic_sizegroup(id) DEFERRABLE;


--
-- Name: technologies_productstructuretreenode productstructuretreenode_technology_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.technologies_productstructuretreenode
    ADD CONSTRAINT productstructuretreenode_technology_fkey FOREIGN KEY (technology_id) REFERENCES public.technologies_technology(id) DEFERRABLE;


--
-- Name: technologies_productstructuretreenode productstructuretreenode_technologyinputproducttype_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.technologies_productstructuretreenode
    ADD CONSTRAINT productstructuretreenode_technologyinputproducttype_fkey FOREIGN KEY (technologyinputproducttype_id) REFERENCES public.technologies_technologyinputproducttype(id) DEFERRABLE;


--
-- Name: productflowthrudivision_producttoissuecorrection producttoissuecorrection_location_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.productflowthrudivision_producttoissuecorrection
    ADD CONSTRAINT producttoissuecorrection_location_fkey FOREIGN KEY (location_id) REFERENCES public.materialflow_location(id) DEFERRABLE;


--
-- Name: productflowthrudivision_producttoissuecorrection producttoissuecorrection_product_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.productflowthrudivision_producttoissuecorrection
    ADD CONSTRAINT producttoissuecorrection_product_fkey FOREIGN KEY (product_id) REFERENCES public.basic_product(id) DEFERRABLE;


--
-- Name: productflowthrudivision_producttoissuecorrection producttoissuecorrection_productstoissue_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.productflowthrudivision_producttoissuecorrection
    ADD CONSTRAINT producttoissuecorrection_productstoissue_fkey FOREIGN KEY (productstoissue_id) REFERENCES public.productflowthrudivision_productstoissue(id) DEFERRABLE;


--
-- Name: productflowthrudivision_producttoissuecorrection producttoissuecorrection_producttoissuecorrectionhelper_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.productflowthrudivision_producttoissuecorrection
    ADD CONSTRAINT producttoissuecorrection_producttoissuecorrectionhelper_fkey FOREIGN KEY (producttoissuecorrectionhelper_id) REFERENCES public.productflowthrudivision_producttoissuecorrectionhelper(id) DEFERRABLE;


--
-- Name: productflowthrudivision_producttoissuecorrection producttoissuecorrection_warehouseissue_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.productflowthrudivision_producttoissuecorrection
    ADD CONSTRAINT producttoissuecorrection_warehouseissue_fkey FOREIGN KEY (warehouseissue_id) REFERENCES public.productflowthrudivision_warehouseissue(id) DEFERRABLE;


--
-- Name: productflowthrudivision_producttoissuecorrectionhelper producttoissuecorrectionhelper_locationfrom_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.productflowthrudivision_producttoissuecorrectionhelper
    ADD CONSTRAINT producttoissuecorrectionhelper_locationfrom_fkey FOREIGN KEY (locationfrom_id) REFERENCES public.materialflow_location(id) DEFERRABLE;


--
-- Name: productflowthrudivision_producttoissuecorrectionhelper producttoissuecorrectionhelper_locationto_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.productflowthrudivision_producttoissuecorrectionhelper
    ADD CONSTRAINT producttoissuecorrectionhelper_locationto_fkey FOREIGN KEY (locationto_id) REFERENCES public.materialflow_location(id) DEFERRABLE;


--
-- Name: technologies_producttoproductgrouptechnology producttoproductgrouptechnology_finalproduct_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.technologies_producttoproductgrouptechnology
    ADD CONSTRAINT producttoproductgrouptechnology_finalproduct_fkey FOREIGN KEY (finalproduct_id) REFERENCES public.basic_product(id);


--
-- Name: technologies_producttoproductgrouptechnology producttoproductgrouptechnology_orderproduct_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.technologies_producttoproductgrouptechnology
    ADD CONSTRAINT producttoproductgrouptechnology_orderproduct_fkey FOREIGN KEY (orderproduct_id) REFERENCES public.basic_product(id);


--
-- Name: technologies_producttoproductgrouptechnology producttoproductgrouptechnology_productfamily_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.technologies_producttoproductgrouptechnology
    ADD CONSTRAINT producttoproductgrouptechnology_productfamily_fkey FOREIGN KEY (productfamily_id) REFERENCES public.basic_product(id);


--
-- Name: productionpershift_progressforday progressforday_productionpershift_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.productionpershift_progressforday
    ADD CONSTRAINT progressforday_productionpershift_fkey FOREIGN KEY (productionpershift_id) REFERENCES public.productionpershift_productionpershift(id) DEFERRABLE;


--
-- Name: qcadoomodel_unitconversionitem qcadoomodel_unitconv_aggregate_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.qcadoomodel_unitconversionitem
    ADD CONSTRAINT qcadoomodel_unitconv_aggregate_fkey FOREIGN KEY (globalunitconversionsaggregate_id) REFERENCES public.qcadoomodel_globalunitconversionsaggregate(id) DEFERRABLE;


--
-- Name: qcadoomodel_unitconversionitem qcadoomodel_unitconv_product_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.qcadoomodel_unitconversionitem
    ADD CONSTRAINT qcadoomodel_unitconv_product_fkey FOREIGN KEY (product_id) REFERENCES public.basic_product(id) DEFERRABLE;


--
-- Name: qualitycontrol_qualitycardattachment qualitycardattachment_qualitycard_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.qualitycontrol_qualitycardattachment
    ADD CONSTRAINT qualitycardattachment_qualitycard_fkey FOREIGN KEY (qualitycard_id) REFERENCES public.basic_qualitycard(id) DEFERRABLE;


--
-- Name: basic_qualitycardstatechange qualitycardstatechange_qualitycard_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.basic_qualitycardstatechange
    ADD CONSTRAINT qualitycardstatechange_qualitycard_fkey FOREIGN KEY (qualitycard_id) REFERENCES public.basic_qualitycard(id) DEFERRABLE;


--
-- Name: basic_qualitycardstatechange qualitycardstatechange_shift_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.basic_qualitycardstatechange
    ADD CONSTRAINT qualitycardstatechange_shift_fkey FOREIGN KEY (shift_id) REFERENCES public.basic_shift(id) DEFERRABLE;


--
-- Name: qualitycontrol_qualitycontrol qualitycontrol_batch_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.qualitycontrol_qualitycontrol
    ADD CONSTRAINT qualitycontrol_batch_fkey FOREIGN KEY (batch_id) REFERENCES public.advancedgenealogy_batch(id);


--
-- Name: qualitycontrol_qualitycontrol qualitycontrol_delivery_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.qualitycontrol_qualitycontrol
    ADD CONSTRAINT qualitycontrol_delivery_fkey FOREIGN KEY (delivery_id) REFERENCES public.deliveries_delivery(id) DEFERRABLE;


--
-- Name: qualitycontrol_qualitycontrol qualitycontrol_order_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.qualitycontrol_qualitycontrol
    ADD CONSTRAINT qualitycontrol_order_fkey FOREIGN KEY (order_id) REFERENCES public.orders_order(id);


--
-- Name: qualitycontrol_qualitycontrol qualitycontrol_product_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.qualitycontrol_qualitycontrol
    ADD CONSTRAINT qualitycontrol_product_fkey FOREIGN KEY (product_id) REFERENCES public.basic_product(id);


--
-- Name: qualitycontrol_qualitycontrol qualitycontrol_qualitycard_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.qualitycontrol_qualitycontrol
    ADD CONSTRAINT qualitycontrol_qualitycard_fkey FOREIGN KEY (qualitycard_id) REFERENCES public.basic_qualitycard(id);


--
-- Name: qualitycontrol_qualitycontrolstatechange qualitycontrol_qualitycontrol_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.qualitycontrol_qualitycontrolstatechange
    ADD CONSTRAINT qualitycontrol_qualitycontrol_fkey FOREIGN KEY (qualitycontrol_id) REFERENCES public.qualitycontrol_qualitycontrol(id) DEFERRABLE;


--
-- Name: qualitycontrol_qualitycontrolstatechange qualitycontrol_shift_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.qualitycontrol_qualitycontrolstatechange
    ADD CONSTRAINT qualitycontrol_shift_fkey FOREIGN KEY (shift_id) REFERENCES public.basic_shift(id) DEFERRABLE;


--
-- Name: qualitycontrol_qualitycontrol qualitycontrol_staff_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.qualitycontrol_qualitycontrol
    ADD CONSTRAINT qualitycontrol_staff_fkey FOREIGN KEY (staff_id) REFERENCES public.basic_staff(id);


--
-- Name: qualitycontrol_qualitycontrolattachment qualitycontrolattachment_qualitycontrol_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.qualitycontrol_qualitycontrolattachment
    ADD CONSTRAINT qualitycontrolattachment_qualitycontrol_fkey FOREIGN KEY (qualitycontrol_id) REFERENCES public.qualitycontrol_qualitycontrol(id) DEFERRABLE;


--
-- Name: qualitycontrol_qualitycontrolattribute qualitycontrolattribute_attribute_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.qualitycontrol_qualitycontrolattribute
    ADD CONSTRAINT qualitycontrolattribute_attribute_fkey FOREIGN KEY (attribute_id) REFERENCES public.basic_attribute(id) DEFERRABLE;


--
-- Name: qualitycontrol_qualitycontrolattribute qualitycontrolattribute_qualitycard_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.qualitycontrol_qualitycontrolattribute
    ADD CONSTRAINT qualitycontrolattribute_qualitycard_fkey FOREIGN KEY (qualitycard_id) REFERENCES public.basic_qualitycard(id) DEFERRABLE;


--
-- Name: qualitycontrol_qualitycontrolattributedeliveredprod qualitycontrolattributedeliveredprod_attribute_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.qualitycontrol_qualitycontrolattributedeliveredprod
    ADD CONSTRAINT qualitycontrolattributedeliveredprod_attribute_fkey FOREIGN KEY (attribute_id) REFERENCES public.basic_attribute(id) DEFERRABLE;


--
-- Name: qualitycontrol_qualitycontrolattributedeliveredprod qualitycontrolattributedeliveredprod_attributevalue_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.qualitycontrol_qualitycontrolattributedeliveredprod
    ADD CONSTRAINT qualitycontrolattributedeliveredprod_attributevalue_fkey FOREIGN KEY (attributevalue_id) REFERENCES public.basic_attributevalue(id) DEFERRABLE;


--
-- Name: qualitycontrol_qualitycontrolattributedeliveredprod qualitycontrolattributedeliveredprod_qualitydeliveredproduct_fk; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.qualitycontrol_qualitycontrolattributedeliveredprod
    ADD CONSTRAINT qualitycontrolattributedeliveredprod_qualitydeliveredproduct_fk FOREIGN KEY (qualitydeliveredproduct_id) REFERENCES public.qualitycontrol_qualitydeliveredproduct(id) DEFERRABLE;


--
-- Name: qualitycontrol_qualitycontrolattributeprodtracking qualitycontrolattributeprodtracking_attribute_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.qualitycontrol_qualitycontrolattributeprodtracking
    ADD CONSTRAINT qualitycontrolattributeprodtracking_attribute_fkey FOREIGN KEY (attribute_id) REFERENCES public.basic_attribute(id) DEFERRABLE;


--
-- Name: qualitycontrol_qualitycontrolattributeprodtracking qualitycontrolattributeprodtracking_attributevalue_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.qualitycontrol_qualitycontrolattributeprodtracking
    ADD CONSTRAINT qualitycontrolattributeprodtracking_attributevalue_fkey FOREIGN KEY (attributevalue_id) REFERENCES public.basic_attributevalue(id) DEFERRABLE;


--
-- Name: qualitycontrol_qualitycontrolattributeprodtracking qualitycontrolattributeprodtracking_productiontracking_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.qualitycontrol_qualitycontrolattributeprodtracking
    ADD CONSTRAINT qualitycontrolattributeprodtracking_productiontracking_fkey FOREIGN KEY (productiontracking_id) REFERENCES public.productioncounting_productiontracking(id) DEFERRABLE;


--
-- Name: qualitycontrol_qualitycontrolattributetoc qualitycontrolattributetoc_qualitycontrolattribute_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.qualitycontrol_qualitycontrolattributetoc
    ADD CONSTRAINT qualitycontrolattributetoc_qualitycontrolattribute_fkey FOREIGN KEY (qualitycontrolattribute_id) REFERENCES public.qualitycontrol_qualitycontrolattribute(id) DEFERRABLE;


--
-- Name: qualitycontrol_qualitycontrolattributetoc qualitycontrolattributetoc_technologyoperationcomponent_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.qualitycontrol_qualitycontrolattributetoc
    ADD CONSTRAINT qualitycontrolattributetoc_technologyoperationcomponent_fkey FOREIGN KEY (technologyoperationcomponent_id) REFERENCES public.technologies_technologyoperationcomponent(id) DEFERRABLE;


--
-- Name: qualitycontrol_qualitycontrolattributevalue qualitycontrolattributevalue_attribute_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.qualitycontrol_qualitycontrolattributevalue
    ADD CONSTRAINT qualitycontrolattributevalue_attribute_fkey FOREIGN KEY (attribute_id) REFERENCES public.basic_attribute(id) DEFERRABLE;


--
-- Name: qualitycontrol_qualitycontrolattributevalue qualitycontrolattributevalue_attributevalue_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.qualitycontrol_qualitycontrolattributevalue
    ADD CONSTRAINT qualitycontrolattributevalue_attributevalue_fkey FOREIGN KEY (attributevalue_id) REFERENCES public.basic_attributevalue(id) DEFERRABLE;


--
-- Name: qualitycontrol_qualitycontrolattributevalue qualitycontrolattributevalue_productiontracking_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.qualitycontrol_qualitycontrolattributevalue
    ADD CONSTRAINT qualitycontrolattributevalue_productiontracking_fkey FOREIGN KEY (productiontracking_id) REFERENCES public.productioncounting_productiontracking(id) DEFERRABLE;


--
-- Name: qualitycontrol_qualitycontrolattributevalue qualitycontrolattributevalue_qualitycontrol_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.qualitycontrol_qualitycontrolattributevalue
    ADD CONSTRAINT qualitycontrolattributevalue_qualitycontrol_fkey FOREIGN KEY (qualitycontrol_id) REFERENCES public.qualitycontrol_qualitycontrol(id) DEFERRABLE;


--
-- Name: qualitycontrol_qualitycontrolresource qualitycontrolresource_qualitycontrol_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.qualitycontrol_qualitycontrolresource
    ADD CONSTRAINT qualitycontrolresource_qualitycontrol_fkey FOREIGN KEY (qualitycontrol_id) REFERENCES public.qualitycontrol_qualitycontrol(id) DEFERRABLE;


--
-- Name: qualitycontrol_qualitycontrolresource qualitycontrolresource_resource_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.qualitycontrol_qualitycontrolresource
    ADD CONSTRAINT qualitycontrolresource_resource_fkey FOREIGN KEY (resource_id) REFERENCES public.materialflowresources_resource(id) DEFERRABLE;


--
-- Name: qualitycontrol_qualitydeliveredproduct qualitydeliveredproduct_batch_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.qualitycontrol_qualitydeliveredproduct
    ADD CONSTRAINT qualitydeliveredproduct_batch_fkey FOREIGN KEY (batch_id) REFERENCES public.advancedgenealogy_batch(id) DEFERRABLE;


--
-- Name: qualitycontrol_qualitydeliveredproduct qualitydeliveredproduct_deliveryqualitycontrol_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.qualitycontrol_qualitydeliveredproduct
    ADD CONSTRAINT qualitydeliveredproduct_deliveryqualitycontrol_fkey FOREIGN KEY (deliveryqualitycontrol_id) REFERENCES public.qualitycontrol_deliveryqualitycontrol(id) DEFERRABLE;


--
-- Name: qualitycontrol_qualitydeliveredproduct qualitydeliveredproduct_orderedproduct_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.qualitycontrol_qualitydeliveredproduct
    ADD CONSTRAINT qualitydeliveredproduct_orderedproduct_fkey FOREIGN KEY (orderedproduct_id) REFERENCES public.deliveries_orderedproduct(id) DEFERRABLE;


--
-- Name: qualitycontrol_qualitydeliveredproduct qualitydeliveredproduct_product_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.qualitycontrol_qualitydeliveredproduct
    ADD CONSTRAINT qualitydeliveredproduct_product_fkey FOREIGN KEY (product_id) REFERENCES public.basic_product(id) DEFERRABLE;


--
-- Name: qualitycontrol_qualitydeliveredproduct qualitydeliveredproduct_qualitycard_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.qualitycontrol_qualitydeliveredproduct
    ADD CONSTRAINT qualitydeliveredproduct_qualitycard_fkey FOREIGN KEY (qualitycard_id) REFERENCES public.basic_qualitycard(id) DEFERRABLE;


--
-- Name: qualitycontrol_qualitydeliveredproduct qualitydeliveredproduct_storagelocation_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.qualitycontrol_qualitydeliveredproduct
    ADD CONSTRAINT qualitydeliveredproduct_storagelocation_fkey FOREIGN KEY (storagelocation_id) REFERENCES public.materialflowresources_storagelocation(id) DEFERRABLE;


--
-- Name: subcontractorportal_suborderrealisation realisation_product_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.subcontractorportal_suborderrealisation
    ADD CONSTRAINT realisation_product_fkey FOREIGN KEY (product_id) REFERENCES public.basic_product(id) DEFERRABLE;


--
-- Name: subcontractorportal_suborderrealisation realisation_suborder_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.subcontractorportal_suborderrealisation
    ADD CONSTRAINT realisation_suborder_fkey FOREIGN KEY (suborder_id) REFERENCES public.subcontractorportal_suborder(id) DEFERRABLE;


--
-- Name: orders_reasontypecorrectiondatefrom reasontypecorrectiondatefrom_changedateshelper_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.orders_reasontypecorrectiondatefrom
    ADD CONSTRAINT reasontypecorrectiondatefrom_changedateshelper_fkey FOREIGN KEY (changedateshelper_id) REFERENCES public.orders_changedateshelper(id) DEFERRABLE;


--
-- Name: orders_reasontypecorrectiondatefrom reasontypecorrectiondatefrom_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.orders_reasontypecorrectiondatefrom
    ADD CONSTRAINT reasontypecorrectiondatefrom_fkey FOREIGN KEY (order_id) REFERENCES public.orders_order(id) DEFERRABLE;


--
-- Name: orders_reasontypecorrectiondateto reasontypecorrectiondateto_changedateshelper_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.orders_reasontypecorrectiondateto
    ADD CONSTRAINT reasontypecorrectiondateto_changedateshelper_fkey FOREIGN KEY (changedateshelper_id) REFERENCES public.orders_changedateshelper(id) DEFERRABLE;


--
-- Name: orders_reasontypecorrectiondateto reasontypecorrectiondateto_order_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.orders_reasontypecorrectiondateto
    ADD CONSTRAINT reasontypecorrectiondateto_order_fkey FOREIGN KEY (order_id) REFERENCES public.orders_order(id) DEFERRABLE;


--
-- Name: orders_reasontypedeviationeffectiveend reasontypedeviationeffectiveend_order_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.orders_reasontypedeviationeffectiveend
    ADD CONSTRAINT reasontypedeviationeffectiveend_order_fkey FOREIGN KEY (order_id) REFERENCES public.orders_order(id) DEFERRABLE;


--
-- Name: orders_reasontypedeviationeffectivestart reasontypedeviationeffectivestart_order_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.orders_reasontypedeviationeffectivestart
    ADD CONSTRAINT reasontypedeviationeffectivestart_order_fkey FOREIGN KEY (order_id) REFERENCES public.orders_order(id) DEFERRABLE;


--
-- Name: orders_reasontypeofchangingorderstate reasontypeofchangingorderstate_orderstatechange_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.orders_reasontypeofchangingorderstate
    ADD CONSTRAINT reasontypeofchangingorderstate_orderstatechange_fkey FOREIGN KEY (orderstatechange_id) REFERENCES public.orders_orderstatechange(id) DEFERRABLE;


--
-- Name: productionpershift_reasontypeofcorrectionplan reasontypeofcorrectionplan_productionpershift_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.productionpershift_reasontypeofcorrectionplan
    ADD CONSTRAINT reasontypeofcorrectionplan_productionpershift_fkey FOREIGN KEY (productionpershift_id) REFERENCES public.productionpershift_productionpershift(id) DEFERRABLE;


--
-- Name: cmmsscheduler_recurringevent recurringevent_company_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.cmmsscheduler_recurringevent
    ADD CONSTRAINT recurringevent_company_fkey FOREIGN KEY (company_id) REFERENCES public.basic_company(id) DEFERRABLE;


--
-- Name: cmmsscheduler_recurringevent recurringevent_division_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.cmmsscheduler_recurringevent
    ADD CONSTRAINT recurringevent_division_fkey FOREIGN KEY (division_id) REFERENCES public.basic_division(id) DEFERRABLE;


--
-- Name: cmmsscheduler_recurringevent recurringevent_factory_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.cmmsscheduler_recurringevent
    ADD CONSTRAINT recurringevent_factory_fkey FOREIGN KEY (factory_id) REFERENCES public.basic_factory(id) DEFERRABLE;


--
-- Name: cmmsscheduler_recurringevent recurringevent_productionline_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.cmmsscheduler_recurringevent
    ADD CONSTRAINT recurringevent_productionline_fkey FOREIGN KEY (productionline_id) REFERENCES public.productionlines_productionline(id) DEFERRABLE;


--
-- Name: cmmsscheduler_recurringevent recurringevent_recurringeventcontext_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.cmmsscheduler_recurringevent
    ADD CONSTRAINT recurringevent_recurringeventcontext_fkey FOREIGN KEY (recurringeventcontext_id) REFERENCES public.cmmsscheduler_recurringeventcontext(id) DEFERRABLE;


--
-- Name: cmmsscheduler_recurringevent recurringevent_sourcecost_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.cmmsscheduler_recurringevent
    ADD CONSTRAINT recurringevent_sourcecost_fkey FOREIGN KEY (sourcecost_id) REFERENCES public.cmmsmachineparts_sourcecost(id) DEFERRABLE;


--
-- Name: cmmsscheduler_recurringevent recurringevent_staff_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.cmmsscheduler_recurringevent
    ADD CONSTRAINT recurringevent_staff_fkey FOREIGN KEY (owner_id) REFERENCES public.basic_staff(id) DEFERRABLE;


--
-- Name: cmmsscheduler_recurringevent recurringevent_subassembly_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.cmmsscheduler_recurringevent
    ADD CONSTRAINT recurringevent_subassembly_fkey FOREIGN KEY (subassembly_id) REFERENCES public.basic_subassembly(id) DEFERRABLE;


--
-- Name: cmmsscheduler_recurringevent recurringevent_workstation_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.cmmsscheduler_recurringevent
    ADD CONSTRAINT recurringevent_workstation_fkey FOREIGN KEY (workstation_id) REFERENCES public.basic_workstation(id) DEFERRABLE;


--
-- Name: cmmsscheduler_recurringeventcontext recurringeventcontext_division_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.cmmsscheduler_recurringeventcontext
    ADD CONSTRAINT recurringeventcontext_division_fkey FOREIGN KEY (division_id) REFERENCES public.basic_division(id) DEFERRABLE;


--
-- Name: cmmsscheduler_recurringeventcontext recurringeventcontext_factory_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.cmmsscheduler_recurringeventcontext
    ADD CONSTRAINT recurringeventcontext_factory_fkey FOREIGN KEY (factory_id) REFERENCES public.basic_factory(id) DEFERRABLE;


--
-- Name: cmmsscheduler_recurringeventstatechange recurringeventstatechange_recurringevent_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.cmmsscheduler_recurringeventstatechange
    ADD CONSTRAINT recurringeventstatechange_recurringevent_fkey FOREIGN KEY (recurringevent_id) REFERENCES public.cmmsscheduler_recurringevent(id) DEFERRABLE;


--
-- Name: cmmsscheduler_recurringeventstatechange recurringeventstatechange_shift_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.cmmsscheduler_recurringeventstatechange
    ADD CONSTRAINT recurringeventstatechange_shift_fkey FOREIGN KEY (shift_id) REFERENCES public.basic_shift(id) DEFERRABLE;


--
-- Name: repairs_repairorder repairorder_division_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.repairs_repairorder
    ADD CONSTRAINT repairorder_division_fkey FOREIGN KEY (division_id) REFERENCES public.basic_division(id) DEFERRABLE;


--
-- Name: repairs_repairorder repairorder_faulttype_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.repairs_repairorder
    ADD CONSTRAINT repairorder_faulttype_fkey FOREIGN KEY (faulttype_id) REFERENCES public.basic_faulttype(id) DEFERRABLE;


--
-- Name: repairs_repairorder repairorder_product_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.repairs_repairorder
    ADD CONSTRAINT repairorder_product_fkey FOREIGN KEY (product_id) REFERENCES public.basic_product(id) DEFERRABLE;


--
-- Name: repairs_repairorder repairorder_productiontracking_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.repairs_repairorder
    ADD CONSTRAINT repairorder_productiontracking_fkey FOREIGN KEY (productiontracking_id) REFERENCES public.productioncounting_productiontracking(id) DEFERRABLE;


--
-- Name: repairs_repairorder repairorder_repairorderproduct_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.repairs_repairorder
    ADD CONSTRAINT repairorder_repairorderproduct_fkey FOREIGN KEY (repairorderproduct_id) REFERENCES public.repairs_repairorderproduct(id) DEFERRABLE;


--
-- Name: repairs_repairorder repairorder_shift_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.repairs_repairorder
    ADD CONSTRAINT repairorder_shift_fkey FOREIGN KEY (shift_id) REFERENCES public.basic_shift(id) DEFERRABLE;


--
-- Name: repairs_repairorder repairorder_staff_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.repairs_repairorder
    ADD CONSTRAINT repairorder_staff_fkey FOREIGN KEY (staff_id) REFERENCES public.basic_staff(id) DEFERRABLE;


--
-- Name: repairs_repairorderproduct repairorderproduct_division_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.repairs_repairorderproduct
    ADD CONSTRAINT repairorderproduct_division_fkey FOREIGN KEY (division_id) REFERENCES public.basic_division(id) DEFERRABLE;


--
-- Name: repairs_repairorderproduct repairorderproduct_faulttype_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.repairs_repairorderproduct
    ADD CONSTRAINT repairorderproduct_faulttype_fkey FOREIGN KEY (faulttype_id) REFERENCES public.basic_faulttype(id) DEFERRABLE;


--
-- Name: repairs_repairorderproduct repairorderproduct_location_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.repairs_repairorderproduct
    ADD CONSTRAINT repairorderproduct_location_fkey FOREIGN KEY (location_id) REFERENCES public.materialflow_location(id) DEFERRABLE;


--
-- Name: repairs_repairorderproduct repairorderproduct_product_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.repairs_repairorderproduct
    ADD CONSTRAINT repairorderproduct_product_fkey FOREIGN KEY (product_id) REFERENCES public.basic_product(id) DEFERRABLE;


--
-- Name: repairs_repairorderproduct repairorderproduct_trackingoperationproductincomponent_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.repairs_repairorderproduct
    ADD CONSTRAINT repairorderproduct_trackingoperationproductincomponent_fkey FOREIGN KEY (trackingoperationproductincomponent_id) REFERENCES public.productioncounting_trackingoperationproductincomponent(id) DEFERRABLE;


--
-- Name: repairs_repairorderstatechange repairorderstatechange_repairorder_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.repairs_repairorderstatechange
    ADD CONSTRAINT repairorderstatechange_repairorder_fkey FOREIGN KEY (repairorder_id) REFERENCES public.repairs_repairorder(id) DEFERRABLE;


--
-- Name: repairs_repairorderstatechange repairorderstatechange_shift_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.repairs_repairorderstatechange
    ADD CONSTRAINT repairorderstatechange_shift_fkey FOREIGN KEY (shift_id) REFERENCES public.basic_shift(id) DEFERRABLE;


--
-- Name: repairs_repairorderworktime repairorderworktime_repairorder_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.repairs_repairorderworktime
    ADD CONSTRAINT repairorderworktime_repairorder_fkey FOREIGN KEY (repairorder_id) REFERENCES public.repairs_repairorder(id) DEFERRABLE;


--
-- Name: repairs_repairorderworktime repairorderworktime_staff_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.repairs_repairorderworktime
    ADD CONSTRAINT repairorderworktime_staff_fkey FOREIGN KEY (staff_id) REFERENCES public.basic_staff(id) DEFERRABLE;


--
-- Name: basicproductioncounting_productioncountingreplacementhelper replacementhelper_productioncountingquantity_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.basicproductioncounting_productioncountingreplacementhelper
    ADD CONSTRAINT replacementhelper_productioncountingquantity_fkey FOREIGN KEY (productioncountingquantity_id) REFERENCES public.basicproductioncounting_productioncountingquantity(id) DEFERRABLE;


--
-- Name: supplynegotiations_requestforquotation requestforquotation_company_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.supplynegotiations_requestforquotation
    ADD CONSTRAINT requestforquotation_company_fkey FOREIGN KEY (supplier_id) REFERENCES public.basic_company(id) DEFERRABLE;


--
-- Name: supplynegotiations_requestforquotation requestforquotation_negotiation_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.supplynegotiations_requestforquotation
    ADD CONSTRAINT requestforquotation_negotiation_fkey FOREIGN KEY (negotiation_id) REFERENCES public.supplynegotiations_negotiation(id) DEFERRABLE;


--
-- Name: supplynegotiations_requestforquotationproduct requestforquotationproduct_operation_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.supplynegotiations_requestforquotationproduct
    ADD CONSTRAINT requestforquotationproduct_operation_fkey FOREIGN KEY (operation_id) REFERENCES public.technologies_operation(id) DEFERRABLE;


--
-- Name: supplynegotiations_requestforquotationproduct requestforquotationproduct_product_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.supplynegotiations_requestforquotationproduct
    ADD CONSTRAINT requestforquotationproduct_product_fkey FOREIGN KEY (product_id) REFERENCES public.basic_product(id) DEFERRABLE;


--
-- Name: supplynegotiations_requestforquotationproduct requestforquotationproduct_requestforquotation_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.supplynegotiations_requestforquotationproduct
    ADD CONSTRAINT requestforquotationproduct_requestforquotation_fkey FOREIGN KEY (requestforquotation_id) REFERENCES public.supplynegotiations_requestforquotation(id) DEFERRABLE;


--
-- Name: supplynegotiations_requestforquotationstatechange requestforquotationstatechange_requestforquotation_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.supplynegotiations_requestforquotationstatechange
    ADD CONSTRAINT requestforquotationstatechange_requestforquotation_fkey FOREIGN KEY (requestforquotation_id) REFERENCES public.supplynegotiations_requestforquotation(id) DEFERRABLE;


--
-- Name: supplynegotiations_requestforquotationstatechange requestforquotationstatechange_shift_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.supplynegotiations_requestforquotationstatechange
    ADD CONSTRAINT requestforquotationstatechange_shift_fkey FOREIGN KEY (shift_id) REFERENCES public.basic_shift(id) DEFERRABLE;


--
-- Name: urcproductioncounting_requestrepair requestrepair_division_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.urcproductioncounting_requestrepair
    ADD CONSTRAINT requestrepair_division_fkey FOREIGN KEY (division_id) REFERENCES public.basic_division(id) DEFERRABLE;


--
-- Name: urcproductioncounting_requestrepair requestrepair_faulttype_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.urcproductioncounting_requestrepair
    ADD CONSTRAINT requestrepair_faulttype_fkey FOREIGN KEY (faulttype_id) REFERENCES public.basic_faulttype(id) DEFERRABLE;


--
-- Name: urcproductioncounting_requestrepair requestrepair_location_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.urcproductioncounting_requestrepair
    ADD CONSTRAINT requestrepair_location_fkey FOREIGN KEY (location_id) REFERENCES public.materialflow_location(id) DEFERRABLE;


--
-- Name: urcmaterialavailability_requiredcomponent requiredcomponent_order_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.urcmaterialavailability_requiredcomponent
    ADD CONSTRAINT requiredcomponent_order_fkey FOREIGN KEY (order_id) REFERENCES public.orders_order(id) DEFERRABLE;


--
-- Name: urcmaterialavailability_requiredcomponent requiredcomponent_product_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.urcmaterialavailability_requiredcomponent
    ADD CONSTRAINT requiredcomponent_product_fkey FOREIGN KEY (product_id) REFERENCES public.basic_product(id) DEFERRABLE;


--
-- Name: urcmaterialavailability_requiredcomponent requiredcomponent_technology_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.urcmaterialavailability_requiredcomponent
    ADD CONSTRAINT requiredcomponent_technology_fkey FOREIGN KEY (technology_id) REFERENCES public.technologies_technology(id) DEFERRABLE;


--
-- Name: materialflowresources_reservation reservation_location_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.materialflowresources_reservation
    ADD CONSTRAINT reservation_location_fkey FOREIGN KEY (location_id) REFERENCES public.materialflow_location(id) DEFERRABLE;


--
-- Name: materialflowresources_reservation reservation_order_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.materialflowresources_reservation
    ADD CONSTRAINT reservation_order_fkey FOREIGN KEY (order_id) REFERENCES public.orders_order(id) DEFERRABLE;


--
-- Name: materialflowresources_reservation reservation_orderproductresourcereservation_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.materialflowresources_reservation
    ADD CONSTRAINT reservation_orderproductresourcereservation_fkey FOREIGN KEY (orderproductresourcereservation_id) REFERENCES public.productflowthrudivision_orderproductresourcereservation(id) DEFERRABLE;


--
-- Name: materialflowresources_reservation reservation_position_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.materialflowresources_reservation
    ADD CONSTRAINT reservation_position_fkey FOREIGN KEY (position_id) REFERENCES public.materialflowresources_position(id) DEFERRABLE;


--
-- Name: materialflowresources_reservation reservation_product_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.materialflowresources_reservation
    ADD CONSTRAINT reservation_product_fkey FOREIGN KEY (product_id) REFERENCES public.basic_product(id) DEFERRABLE;


--
-- Name: materialflowresources_reservation reservation_producttoissue_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.materialflowresources_reservation
    ADD CONSTRAINT reservation_producttoissue_fkey FOREIGN KEY (productstoissue_id) REFERENCES public.productflowthrudivision_productstoissue(id) DEFERRABLE;


--
-- Name: materialflowresources_reservation reservation_resource_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.materialflowresources_reservation
    ADD CONSTRAINT reservation_resource_fkey FOREIGN KEY (resource_id) REFERENCES public.materialflowresources_resource(id) DEFERRABLE;


--
-- Name: materialflowresources_resource resource_batch_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.materialflowresources_resource
    ADD CONSTRAINT resource_batch_fkey FOREIGN KEY (batch_id) REFERENCES public.advancedgenealogy_batch(id) DEFERRABLE;


--
-- Name: materialflowresources_resource resource_location_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.materialflowresources_resource
    ADD CONSTRAINT resource_location_fkey FOREIGN KEY (location_id) REFERENCES public.materialflow_location(id) DEFERRABLE;


--
-- Name: materialflowresources_resource resource_palletnumber_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.materialflowresources_resource
    ADD CONSTRAINT resource_palletnumber_fkey FOREIGN KEY (palletnumber_id) REFERENCES public.basic_palletnumber(id) DEFERRABLE;


--
-- Name: materialflowresources_resource resource_product_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.materialflowresources_resource
    ADD CONSTRAINT resource_product_fkey FOREIGN KEY (product_id) REFERENCES public.basic_product(id) DEFERRABLE;


--
-- Name: materialflowresources_resource resource_storagelocation_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.materialflowresources_resource
    ADD CONSTRAINT resource_storagelocation_fkey FOREIGN KEY (storagelocation_id) REFERENCES public.materialflowresources_storagelocation(id) DEFERRABLE;


--
-- Name: materialflowresources_resourceattributevalue resourceattributevalue_attribute_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.materialflowresources_resourceattributevalue
    ADD CONSTRAINT resourceattributevalue_attribute_fkey FOREIGN KEY (attribute_id) REFERENCES public.basic_attribute(id) DEFERRABLE;


--
-- Name: materialflowresources_resourceattributevalue resourceattributevalue_attributevalue_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.materialflowresources_resourceattributevalue
    ADD CONSTRAINT resourceattributevalue_attributevalue_fkey FOREIGN KEY (attributevalue_id) REFERENCES public.basic_attributevalue(id) DEFERRABLE;


--
-- Name: materialflowresources_resourceattributevalue resourceattributevalue_resource_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.materialflowresources_resourceattributevalue
    ADD CONSTRAINT resourceattributevalue_resource_fkey FOREIGN KEY (resource_id) REFERENCES public.materialflowresources_resource(id) DEFERRABLE;


--
-- Name: materialflowresources_resourceattributevalueaftercorrection resourceattributevalueaftercorrection_attribute_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.materialflowresources_resourceattributevalueaftercorrection
    ADD CONSTRAINT resourceattributevalueaftercorrection_attribute_fkey FOREIGN KEY (attribute_id) REFERENCES public.basic_attribute(id) DEFERRABLE;


--
-- Name: materialflowresources_resourceattributevalueaftercorrection resourceattributevalueaftercorrection_resourcecorrection_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.materialflowresources_resourceattributevalueaftercorrection
    ADD CONSTRAINT resourceattributevalueaftercorrection_resourcecorrection_fkey FOREIGN KEY (resourcecorrection_id) REFERENCES public.materialflowresources_resourcecorrection(id) DEFERRABLE;


--
-- Name: materialflowresources_resourceattributevaluebeforecorrection resourceattributevaluebeforecorrection_attribute_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.materialflowresources_resourceattributevaluebeforecorrection
    ADD CONSTRAINT resourceattributevaluebeforecorrection_attribute_fkey FOREIGN KEY (attribute_id) REFERENCES public.basic_attribute(id) DEFERRABLE;


--
-- Name: materialflowresources_resourceattributevaluebeforecorrection resourceattributevaluebeforecorrection_resourcecorrection_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.materialflowresources_resourceattributevaluebeforecorrection
    ADD CONSTRAINT resourceattributevaluebeforecorrection_resourcecorrection_fkey FOREIGN KEY (resourcecorrection_id) REFERENCES public.materialflowresources_resourcecorrection(id) DEFERRABLE;


--
-- Name: materialflowresources_resourcecorrection resourcecorrection_location_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.materialflowresources_resourcecorrection
    ADD CONSTRAINT resourcecorrection_location_fkey FOREIGN KEY (location_id) REFERENCES public.materialflow_location(id) DEFERRABLE;


--
-- Name: materialflowresources_resourcecorrection resourcecorrection_newbatch_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.materialflowresources_resourcecorrection
    ADD CONSTRAINT resourcecorrection_newbatch_fkey FOREIGN KEY (newbatch_id) REFERENCES public.advancedgenealogy_batch(id) DEFERRABLE;


--
-- Name: materialflowresources_resourcecorrection resourcecorrection_newpalletnumber_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.materialflowresources_resourcecorrection
    ADD CONSTRAINT resourcecorrection_newpalletnumber_fkey FOREIGN KEY (newpalletnumber_id) REFERENCES public.basic_palletnumber(id) DEFERRABLE;


--
-- Name: materialflowresources_resourcecorrection resourcecorrection_newstoragelocation_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.materialflowresources_resourcecorrection
    ADD CONSTRAINT resourcecorrection_newstoragelocation_fkey FOREIGN KEY (newstoragelocation_id) REFERENCES public.materialflowresources_storagelocation(id) DEFERRABLE;


--
-- Name: materialflowresources_resourcecorrection resourcecorrection_oldbatch_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.materialflowresources_resourcecorrection
    ADD CONSTRAINT resourcecorrection_oldbatch_fkey FOREIGN KEY (oldbatch_id) REFERENCES public.advancedgenealogy_batch(id) DEFERRABLE;


--
-- Name: materialflowresources_resourcecorrection resourcecorrection_oldpalletnumber_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.materialflowresources_resourcecorrection
    ADD CONSTRAINT resourcecorrection_oldpalletnumber_fkey FOREIGN KEY (oldpalletnumber_id) REFERENCES public.basic_palletnumber(id) DEFERRABLE;


--
-- Name: materialflowresources_resourcecorrection resourcecorrection_oldstoragelocation_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.materialflowresources_resourcecorrection
    ADD CONSTRAINT resourcecorrection_oldstoragelocation_fkey FOREIGN KEY (oldstoragelocation_id) REFERENCES public.materialflowresources_storagelocation(id) DEFERRABLE;


--
-- Name: materialflowresources_resourcecorrection resourcecorrection_product_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.materialflowresources_resourcecorrection
    ADD CONSTRAINT resourcecorrection_product_fkey FOREIGN KEY (product_id) REFERENCES public.basic_product(id) DEFERRABLE;


--
-- Name: materialflowresources_resourcecorrection resourcecorrection_resource_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.materialflowresources_resourcecorrection
    ADD CONSTRAINT resourcecorrection_resource_fkey FOREIGN KEY (resource_id) REFERENCES public.materialflowresources_resource(id) DEFERRABLE;


--
-- Name: materialflowresources_resourcestock resourcestock_location_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.materialflowresources_resourcestock
    ADD CONSTRAINT resourcestock_location_fkey FOREIGN KEY (location_id) REFERENCES public.materialflow_location(id) DEFERRABLE;


--
-- Name: materialflowresources_resourcestock resourcestock_product_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.materialflowresources_resourcestock
    ADD CONSTRAINT resourcestock_product_fkey FOREIGN KEY (product_id) REFERENCES public.basic_product(id) DEFERRABLE;


--
-- Name: masterorders_salesplanmaterialrequirement salesplanmaterialrequirement_salesplan_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.masterorders_salesplanmaterialrequirement
    ADD CONSTRAINT salesplanmaterialrequirement_salesplan_fkey FOREIGN KEY (salesplan_id) REFERENCES public.masterorders_salesplan(id) DEFERRABLE;


--
-- Name: masterorders_salesplanmaterialrequirementproduct salesplanmaterialrequirementproduct_company_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.masterorders_salesplanmaterialrequirementproduct
    ADD CONSTRAINT salesplanmaterialrequirementproduct_company_fkey FOREIGN KEY (supplier_id) REFERENCES public.basic_company(id) DEFERRABLE;


--
-- Name: masterorders_salesplanmaterialrequirementproduct salesplanmaterialrequirementproduct_product_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.masterorders_salesplanmaterialrequirementproduct
    ADD CONSTRAINT salesplanmaterialrequirementproduct_product_fkey FOREIGN KEY (product_id) REFERENCES public.basic_product(id) DEFERRABLE;


--
-- Name: masterorders_salesplanmaterialrequirementproduct salesplanmaterialrequirementproduct_salesplanmaterialrequiremen; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.masterorders_salesplanmaterialrequirementproduct
    ADD CONSTRAINT salesplanmaterialrequirementproduct_salesplanmaterialrequiremen FOREIGN KEY (salesplanmaterialrequirement_id) REFERENCES public.masterorders_salesplanmaterialrequirement(id) DEFERRABLE;


--
-- Name: masterorders_salesplanmaterialrequirementproduct salesplanmaterialrequirementproduct_sizegroup_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.masterorders_salesplanmaterialrequirementproduct
    ADD CONSTRAINT salesplanmaterialrequirementproduct_sizegroup_fkey FOREIGN KEY (sizegroup_id) REFERENCES public.basic_sizegroup(id) DEFERRABLE;


--
-- Name: masterorders_salesplanordersgroupentryhelper salesplanordersgroupentryhelper_product_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.masterorders_salesplanordersgroupentryhelper
    ADD CONSTRAINT salesplanordersgroupentryhelper_product_fkey FOREIGN KEY (product_id) REFERENCES public.basic_product(id) DEFERRABLE;


--
-- Name: masterorders_salesplanordersgroupentryhelper salesplanordersgroupentryhelper_productfamily_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.masterorders_salesplanordersgroupentryhelper
    ADD CONSTRAINT salesplanordersgroupentryhelper_productfamily_fkey FOREIGN KEY (productfamily_id) REFERENCES public.basic_product(id) DEFERRABLE;


--
-- Name: masterorders_salesplanordersgroupentryhelper salesplanordersgroupentryhelper_technology_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.masterorders_salesplanordersgroupentryhelper
    ADD CONSTRAINT salesplanordersgroupentryhelper_technology_fkey FOREIGN KEY (technology_id) REFERENCES public.technologies_technology(id) DEFERRABLE;


--
-- Name: masterorders_salesplanordersgroupentryhelper salesplanordersgroupentryhelpersale_splanordersgrouphelper_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.masterorders_salesplanordersgroupentryhelper
    ADD CONSTRAINT salesplanordersgroupentryhelpersale_splanordersgrouphelper_fkey FOREIGN KEY (salesplanordersgrouphelper_id) REFERENCES public.masterorders_salesplanordersgrouphelper(id) DEFERRABLE;


--
-- Name: masterorders_salesplanordersgrouphelper salesplanordersgrouphelper_salesplan_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.masterorders_salesplanordersgrouphelper
    ADD CONSTRAINT salesplanordersgrouphelper_salesplan_fkey FOREIGN KEY (salesplan_id) REFERENCES public.masterorders_salesplan(id) DEFERRABLE;


--
-- Name: masterorders_salesplanproduct salesplanproduct_product_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.masterorders_salesplanproduct
    ADD CONSTRAINT salesplanproduct_product_fkey FOREIGN KEY (product_id) REFERENCES public.basic_product(id) DEFERRABLE;


--
-- Name: masterorders_salesplanproduct salesplanproduct_salesplan_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.masterorders_salesplanproduct
    ADD CONSTRAINT salesplanproduct_salesplan_fkey FOREIGN KEY (salesplan_id) REFERENCES public.masterorders_salesplan(id) DEFERRABLE;


--
-- Name: masterorders_salesplanproduct salesplanproduct_technology_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.masterorders_salesplanproduct
    ADD CONSTRAINT salesplanproduct_technology_fkey FOREIGN KEY (technology_id) REFERENCES public.technologies_technology(id) DEFERRABLE;


--
-- Name: masterorders_salesplanstatechange salesplanstatechange_salesplan_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.masterorders_salesplanstatechange
    ADD CONSTRAINT salesplanstatechange_salesplan_fkey FOREIGN KEY (salesplan_id) REFERENCES public.masterorders_salesplan(id) DEFERRABLE;


--
-- Name: masterorders_salesplanstatechange salesplanstatechange_shift_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.masterorders_salesplanstatechange
    ADD CONSTRAINT salesplanstatechange_shift_fkey FOREIGN KEY (shift_id) REFERENCES public.basic_shift(id) DEFERRABLE;


--
-- Name: masterorders_salesvolume salesvolume_product_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.masterorders_salesvolume
    ADD CONSTRAINT salesvolume_product_fkey FOREIGN KEY (product_id) REFERENCES public.basic_product(id) DEFERRABLE;


--
-- Name: orders_scheduleposition scheduleposition_order_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.orders_scheduleposition
    ADD CONSTRAINT scheduleposition_order_fkey FOREIGN KEY (order_id) REFERENCES public.orders_order(id);


--
-- Name: orders_scheduleposition scheduleposition_product_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.orders_scheduleposition
    ADD CONSTRAINT scheduleposition_product_fkey FOREIGN KEY (product_id) REFERENCES public.basic_product(id);


--
-- Name: orders_scheduleposition scheduleposition_schedule_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.orders_scheduleposition
    ADD CONSTRAINT scheduleposition_schedule_fkey FOREIGN KEY (schedule_id) REFERENCES public.orders_schedule(id);


--
-- Name: orders_scheduleposition scheduleposition_staff_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.orders_scheduleposition
    ADD CONSTRAINT scheduleposition_staff_fkey FOREIGN KEY (staff_id) REFERENCES public.basic_staff(id) DEFERRABLE;


--
-- Name: orders_scheduleposition scheduleposition_technologyoperationcomponent_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.orders_scheduleposition
    ADD CONSTRAINT scheduleposition_technologyoperationcomponent_fkey FOREIGN KEY (technologyoperationcomponent_id) REFERENCES public.technologies_technologyoperationcomponent(id);


--
-- Name: orders_scheduleposition scheduleposition_workstation_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.orders_scheduleposition
    ADD CONSTRAINT scheduleposition_workstation_fkey FOREIGN KEY (workstation_id) REFERENCES public.basic_workstation(id);


--
-- Name: orders_productionlineschedulestatechange schedulestatechange_productionlineschedule_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.orders_productionlineschedulestatechange
    ADD CONSTRAINT schedulestatechange_productionlineschedule_fkey FOREIGN KEY (productionlineschedule_id) REFERENCES public.orders_productionlineschedule(id) DEFERRABLE;


--
-- Name: orders_schedulestatechange schedulestatechange_schedule_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.orders_schedulestatechange
    ADD CONSTRAINT schedulestatechange_schedule_fkey FOREIGN KEY (schedule_id) REFERENCES public.orders_schedule(id) DEFERRABLE;


--
-- Name: orders_schedulestatechange schedulestatechange_shift_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.orders_schedulestatechange
    ADD CONSTRAINT schedulestatechange_shift_fkey FOREIGN KEY (shift_id) REFERENCES public.basic_shift(id) DEFERRABLE;


--
-- Name: orders_productionlineschedulestatechange schedulestatechange_shift_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.orders_productionlineschedulestatechange
    ADD CONSTRAINT schedulestatechange_shift_fkey FOREIGN KEY (shift_id) REFERENCES public.basic_shift(id) DEFERRABLE;


--
-- Name: technologies_section section_operationproductincomponent_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.technologies_section
    ADD CONSTRAINT section_operationproductincomponent_fkey FOREIGN KEY (operationproductincomponent_id) REFERENCES public.technologies_operationproductincomponent(id) DEFERRABLE;


--
-- Name: basicproductioncounting_section section_productioncountingquantity_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.basicproductioncounting_section
    ADD CONSTRAINT section_productioncountingquantity_fkey FOREIGN KEY (productioncountingquantity_id) REFERENCES public.basicproductioncounting_productioncountingquantity(id) DEFERRABLE;


--
-- Name: integrationbartender_sendtoprint sendtoprint_printlabelshelper_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.integrationbartender_sendtoprint
    ADD CONSTRAINT sendtoprint_printlabelshelper_fkey FOREIGN KEY (printlabelshelper_id) REFERENCES public.integrationbartender_printlabelshelper(id) DEFERRABLE;


--
-- Name: jointable_productionline_shift shift_productionline_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.jointable_productionline_shift
    ADD CONSTRAINT shift_productionline_fkey FOREIGN KEY (productionline_id) REFERENCES public.productionlines_productionline(id) DEFERRABLE;


--
-- Name: jointable_shift_shifttimetableexception shift_shifttimetableexception_shift_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.jointable_shift_shifttimetableexception
    ADD CONSTRAINT shift_shifttimetableexception_shift_fkey FOREIGN KEY (shift_id) REFERENCES public.basic_shift(id) DEFERRABLE;


--
-- Name: jointable_shift_shifttimetableexception shift_shifttimetableexception_shifttimetableexception_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.jointable_shift_shifttimetableexception
    ADD CONSTRAINT shift_shifttimetableexception_shifttimetableexception_fkey FOREIGN KEY (shifttimetableexception_id) REFERENCES public.basic_shifttimetableexception(id) DEFERRABLE;


--
-- Name: productflowthrudivision_warehouseissuestatechange shift_warehouseissuestatechange_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.productflowthrudivision_warehouseissuestatechange
    ADD CONSTRAINT shift_warehouseissuestatechange_fkey FOREIGN KEY (shift_id) REFERENCES public.basic_shift(id) DEFERRABLE;


--
-- Name: jointable_size_sizegroup size_sizegroup_size_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.jointable_size_sizegroup
    ADD CONSTRAINT size_sizegroup_size_fkey FOREIGN KEY (size_id) REFERENCES public.basic_size(id) DEFERRABLE;


--
-- Name: jointable_size_sizegroup size_sizegroup_sizegroup_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.jointable_size_sizegroup
    ADD CONSTRAINT size_sizegroup_sizegroup_fkey FOREIGN KEY (sizegroup_id) REFERENCES public.basic_sizegroup(id) DEFERRABLE;


--
-- Name: ordersgroups_sizegroupcolor sizegroupcolor_parameter_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.ordersgroups_sizegroupcolor
    ADD CONSTRAINT sizegroupcolor_parameter_fkey FOREIGN KEY (parameter_id) REFERENCES public.basic_parameter(id) DEFERRABLE;


--
-- Name: ordersgroups_sizegroupcolor sizegroupcolor_sizegroup_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.ordersgroups_sizegroupcolor
    ADD CONSTRAINT sizegroupcolor_sizegroup_fkey FOREIGN KEY (sizegroup_id) REFERENCES public.basic_sizegroup(id) DEFERRABLE;


--
-- Name: jointable_storagelocation_storagelocationnumberhelper sl_storagelocationnumberhelper_storagelocation_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.jointable_storagelocation_storagelocationnumberhelper
    ADD CONSTRAINT sl_storagelocationnumberhelper_storagelocation_fkey FOREIGN KEY (storagelocation_id) REFERENCES public.materialflowresources_storagelocation(id) DEFERRABLE;


--
-- Name: jointable_storagelocation_storagelocationnumberhelper sl_storagelocationnumberhelper_storagelocationnumberhelper_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.jointable_storagelocation_storagelocationnumberhelper
    ADD CONSTRAINT sl_storagelocationnumberhelper_storagelocationnumberhelper_fkey FOREIGN KEY (storagelocationnumberhelper_id) REFERENCES public.materialflowresources_storagelocationnumberhelper(id) DEFERRABLE;


--
-- Name: cmmsmachineparts_sourcecost sourcecost_factory_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.cmmsmachineparts_sourcecost
    ADD CONSTRAINT sourcecost_factory_fkey FOREIGN KEY (factory_id) REFERENCES public.basic_factory(id) DEFERRABLE;


--
-- Name: cmmsmachineparts_sourcecostreportfilter sourcecostreportfilter_sourcecost_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.cmmsmachineparts_sourcecostreportfilter
    ADD CONSTRAINT sourcecostreportfilter_sourcecost_fkey FOREIGN KEY (sourcecost_id) REFERENCES public.cmmsmachineparts_sourcecost(id) DEFERRABLE;


--
-- Name: orders_splitorderchild splitorderchild_splitorderparent_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.orders_splitorderchild
    ADD CONSTRAINT splitorderchild_splitorderparent_fkey FOREIGN KEY (splitorderparent_id) REFERENCES public.orders_splitorderparent(id) DEFERRABLE;


--
-- Name: orders_splitorderparent splitorderparent_order_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.orders_splitorderparent
    ADD CONSTRAINT splitorderparent_order_fkey FOREIGN KEY (order_id) REFERENCES public.orders_order(id) DEFERRABLE;


--
-- Name: orders_splitorderparent splitorderparent_splitorderhelper_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.orders_splitorderparent
    ADD CONSTRAINT splitorderparent_splitorderhelper_fkey FOREIGN KEY (splitorderhelper_id) REFERENCES public.orders_splitorderhelper(id) DEFERRABLE;


--
-- Name: basic_staff staff_crew_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.basic_staff
    ADD CONSTRAINT staff_crew_fkey FOREIGN KEY (crew_id) REFERENCES public.basic_crew(id) DEFERRABLE;


--
-- Name: jointable_multiassignmenttoshift_staff staff_multiassignmenttoshift_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.jointable_multiassignmenttoshift_staff
    ADD CONSTRAINT staff_multiassignmenttoshift_fkey FOREIGN KEY (staff_id) REFERENCES public.basic_staff(id) DEFERRABLE;


--
-- Name: basic_staff staff_parameter_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.basic_staff
    ADD CONSTRAINT staff_parameter_fkey FOREIGN KEY (parameter_id) REFERENCES public.basic_parameter(id) DEFERRABLE;


--
-- Name: basic_staff staff_productionline_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.basic_staff
    ADD CONSTRAINT staff_productionline_fkey FOREIGN KEY (productionline_id) REFERENCES public.productionlines_productionline(id) DEFERRABLE;


--
-- Name: jointable_staff_timeusagereportfilter staff_timeusagereportfilter_filter_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.jointable_staff_timeusagereportfilter
    ADD CONSTRAINT staff_timeusagereportfilter_filter_fkey FOREIGN KEY (timeusagereportfilter_id) REFERENCES public.cmmsmachineparts_timeusagereportfilter(id) DEFERRABLE;


--
-- Name: jointable_staff_timeusagereportfilter staff_timeusagereportfilter_staff_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.jointable_staff_timeusagereportfilter
    ADD CONSTRAINT staff_timeusagereportfilter_staff_fkey FOREIGN KEY (staff_id) REFERENCES public.basic_staff(id) DEFERRABLE;


--
-- Name: assignmenttoshift_staffassignmenttoshift staffassignmenttoshift_masterorder_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.assignmenttoshift_staffassignmenttoshift
    ADD CONSTRAINT staffassignmenttoshift_masterorder_fkey FOREIGN KEY (masterorder_id) REFERENCES public.masterorders_masterorder(id) DEFERRABLE;


--
-- Name: emailnotifications_staffnotification staffnotification_parameter_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.emailnotifications_staffnotification
    ADD CONSTRAINT staffnotification_parameter_fkey FOREIGN KEY (parameter_id) REFERENCES public.basic_parameter(id) DEFERRABLE;


--
-- Name: emailnotifications_staffnotification staffnotification_staff_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.emailnotifications_staffnotification
    ADD CONSTRAINT staffnotification_staff_fkey FOREIGN KEY (staff_id) REFERENCES public.basic_staff(id) DEFERRABLE;


--
-- Name: basic_staffskill staffskill_skill_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.basic_staffskill
    ADD CONSTRAINT staffskill_skill_fkey FOREIGN KEY (skill_id) REFERENCES public.basic_skill(id) DEFERRABLE;


--
-- Name: technologies_operationskill staffskill_skill_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.technologies_operationskill
    ADD CONSTRAINT staffskill_skill_fkey FOREIGN KEY (skill_id) REFERENCES public.basic_skill(id) DEFERRABLE;


--
-- Name: basic_staffskill staffskill_staff_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.basic_staffskill
    ADD CONSTRAINT staffskill_staff_fkey FOREIGN KEY (staff_id) REFERENCES public.basic_staff(id) DEFERRABLE;


--
-- Name: cmmsmachineparts_staffworktime staffworktime_worker_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.cmmsmachineparts_staffworktime
    ADD CONSTRAINT staffworktime_worker_fkey FOREIGN KEY (worker_id) REFERENCES public.basic_staff(id) DEFERRABLE;


--
-- Name: integrationbaselinker_statusesfordocument statusesfordocument_baselinkerparameters_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.integrationbaselinker_statusesfordocument
    ADD CONSTRAINT statusesfordocument_baselinkerparameters_fkey FOREIGN KEY (baselinkerparameters_id) REFERENCES public.integrationbaselinker_baselinkerparameters(id) DEFERRABLE;


--
-- Name: integrationbaselinker_statusesformasterorder statusesformasterorder_baselinkerparameters_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.integrationbaselinker_statusesformasterorder
    ADD CONSTRAINT statusesformasterorder_baselinkerparameters_fkey FOREIGN KEY (baselinkerparameters_id) REFERENCES public.integrationbaselinker_baselinkerparameters(id) DEFERRABLE;


--
-- Name: materialflowresources_stocktaking stocktaking_location_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.materialflowresources_stocktaking
    ADD CONSTRAINT stocktaking_location_fkey FOREIGN KEY (location_id) REFERENCES public.materialflow_location(id) DEFERRABLE;


--
-- Name: jointable_stocktaking_storagelocation stocktaking_storagelocation_stocktaking_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.jointable_stocktaking_storagelocation
    ADD CONSTRAINT stocktaking_storagelocation_stocktaking_fkey FOREIGN KEY (stocktaking_id) REFERENCES public.materialflowresources_stocktaking(id) DEFERRABLE;


--
-- Name: jointable_stocktaking_storagelocation stocktaking_storagelocation_storagelocation_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.jointable_stocktaking_storagelocation
    ADD CONSTRAINT stocktaking_storagelocation_storagelocation_fkey FOREIGN KEY (storagelocation_id) REFERENCES public.materialflowresources_storagelocation(id) DEFERRABLE;


--
-- Name: stoppage_stoppage stoppage_order_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.stoppage_stoppage
    ADD CONSTRAINT stoppage_order_fkey FOREIGN KEY (order_id) REFERENCES public.orders_order(id) DEFERRABLE;


--
-- Name: stoppage_stoppage stoppage_productiontracking_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.stoppage_stoppage
    ADD CONSTRAINT stoppage_productiontracking_fkey FOREIGN KEY (productiontracking_id) REFERENCES public.productioncounting_productiontracking(id) DEFERRABLE;


--
-- Name: stoppage_stoppage stoppage_reason_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.stoppage_stoppage
    ADD CONSTRAINT stoppage_reason_fkey FOREIGN KEY (reason_id) REFERENCES public.stoppage_stoppagereason(id) DEFERRABLE;


--
-- Name: materialflowresources_storagelocation storagelocation_location_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.materialflowresources_storagelocation
    ADD CONSTRAINT storagelocation_location_fkey FOREIGN KEY (location_id) REFERENCES public.materialflow_location(id) DEFERRABLE;


--
-- Name: jointable_storagelocation_warehousestockreport storagelocation_warehousestockreport_storagelocation_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.jointable_storagelocation_warehousestockreport
    ADD CONSTRAINT storagelocation_warehousestockreport_storagelocation_fkey FOREIGN KEY (storagelocation_id) REFERENCES public.materialflowresources_storagelocation(id) DEFERRABLE;


--
-- Name: jointable_storagelocation_warehousestockreport storagelocation_warehousestockreport_warehousestockreport_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.jointable_storagelocation_warehousestockreport
    ADD CONSTRAINT storagelocation_warehousestockreport_warehousestockreport_fkey FOREIGN KEY (warehousestockreport_id) REFERENCES public.materialflowresources_warehousestockreport(id) DEFERRABLE;


--
-- Name: materialflowresources_storagelocationhelper storagelocationhelper_location_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.materialflowresources_storagelocationhelper
    ADD CONSTRAINT storagelocationhelper_location_fkey FOREIGN KEY (location_id) REFERENCES public.materialflow_location(id) DEFERRABLE;


--
-- Name: basic_subassembly subassembly_workstation_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.basic_subassembly
    ADD CONSTRAINT subassembly_workstation_fkey FOREIGN KEY (workstation_id) REFERENCES public.basic_workstation(id) DEFERRABLE;


--
-- Name: basic_subassembly subassembly_workstationtype_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.basic_subassembly
    ADD CONSTRAINT subassembly_workstationtype_fkey FOREIGN KEY (workstationtype_id) REFERENCES public.basic_workstationtype(id) DEFERRABLE;


--
-- Name: basic_subassemblyattachment subassemblyattachment_subassembly_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.basic_subassemblyattachment
    ADD CONSTRAINT subassemblyattachment_subassembly_fkey FOREIGN KEY (subassembly_id) REFERENCES public.basic_subassembly(id) DEFERRABLE;


--
-- Name: basic_subassemblytoworkstationhelper subassemblytoworkstationhelper_subassembly_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.basic_subassemblytoworkstationhelper
    ADD CONSTRAINT subassemblytoworkstationhelper_subassembly_fkey FOREIGN KEY (subassembly_id) REFERENCES public.basic_subassembly(id) DEFERRABLE;


--
-- Name: basic_subassemblytoworkstationhelper subassemblytoworkstationhelper_workstation_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.basic_subassemblytoworkstationhelper
    ADD CONSTRAINT subassemblytoworkstationhelper_workstation_fkey FOREIGN KEY (workstation_id) REFERENCES public.basic_workstation(id) DEFERRABLE;


--
-- Name: subcontractorportal_suborder suborder_changedby_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.subcontractorportal_suborder
    ADD CONSTRAINT suborder_changedby_fkey FOREIGN KEY (changedby_id) REFERENCES public.basic_staff(id) DEFERRABLE;


--
-- Name: subcontractorportal_suborder suborder_company_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.subcontractorportal_suborder
    ADD CONSTRAINT suborder_company_fkey FOREIGN KEY (company_id) REFERENCES public.basic_company(id) DEFERRABLE;


--
-- Name: subcontractorportal_suborderattachment suborderattachment_suborder_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.subcontractorportal_suborderattachment
    ADD CONSTRAINT suborderattachment_suborder_fkey FOREIGN KEY (suborder_id) REFERENCES public.subcontractorportal_suborder(id) DEFERRABLE;


--
-- Name: subcontractorportal_subordercost subordercost_operationaltask_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.subcontractorportal_subordercost
    ADD CONSTRAINT subordercost_operationaltask_fkey FOREIGN KEY (operationaltask_id) REFERENCES public.orders_operationaltask(id) DEFERRABLE;


--
-- Name: subcontractorportal_subordercost subordercost_order_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.subcontractorportal_subordercost
    ADD CONSTRAINT subordercost_order_fkey FOREIGN KEY (order_id) REFERENCES public.orders_order(id) DEFERRABLE;


--
-- Name: subcontractorportal_suborderinput suborderinput_product_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.subcontractorportal_suborderinput
    ADD CONSTRAINT suborderinput_product_fkey FOREIGN KEY (product_id) REFERENCES public.basic_product(id) DEFERRABLE;


--
-- Name: subcontractorportal_suborderinput suborderinput_storage_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.subcontractorportal_suborderinput
    ADD CONSTRAINT suborderinput_storage_fkey FOREIGN KEY (location_id) REFERENCES public.materialflow_location(id) DEFERRABLE;


--
-- Name: subcontractorportal_suborderinput suborderinput_suborder_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.subcontractorportal_suborderinput
    ADD CONSTRAINT suborderinput_suborder_fkey FOREIGN KEY (suborder_id) REFERENCES public.subcontractorportal_suborder(id) DEFERRABLE;


--
-- Name: subcontractorportal_suborderissuedproductsreport suborderissuedproductsreport_company_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.subcontractorportal_suborderissuedproductsreport
    ADD CONSTRAINT suborderissuedproductsreport_company_fkey FOREIGN KEY (company_id) REFERENCES public.basic_company(id) DEFERRABLE;


--
-- Name: subcontractorportal_suborderoperation suborderoperation_company_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.subcontractorportal_suborderoperation
    ADD CONSTRAINT suborderoperation_company_fkey FOREIGN KEY (company_id) REFERENCES public.basic_company(id) DEFERRABLE;


--
-- Name: subcontractorportal_suborderoperation suborderoperation_operationcomponent_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.subcontractorportal_suborderoperation
    ADD CONSTRAINT suborderoperation_operationcomponent_fkey FOREIGN KEY (operationcomponent_id) REFERENCES public.technologies_technologyoperationcomponent(id) DEFERRABLE;


--
-- Name: subcontractorportal_suborderoperation suborderoperation_suborder_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.subcontractorportal_suborderoperation
    ADD CONSTRAINT suborderoperation_suborder_fkey FOREIGN KEY (suborder_id) REFERENCES public.subcontractorportal_suborder(id) DEFERRABLE;


--
-- Name: subcontractorportal_suborderoutput suborderoutput_product_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.subcontractorportal_suborderoutput
    ADD CONSTRAINT suborderoutput_product_fkey FOREIGN KEY (product_id) REFERENCES public.basic_product(id) DEFERRABLE;


--
-- Name: subcontractorportal_suborderoutput suborderoutput_storage_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.subcontractorportal_suborderoutput
    ADD CONSTRAINT suborderoutput_storage_fkey FOREIGN KEY (location_id) REFERENCES public.materialflow_location(id) DEFERRABLE;


--
-- Name: subcontractorportal_suborderoutput suborderoutput_suborder_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.subcontractorportal_suborderoutput
    ADD CONSTRAINT suborderoutput_suborder_fkey FOREIGN KEY (suborder_id) REFERENCES public.subcontractorportal_suborder(id) DEFERRABLE;


--
-- Name: ordersforsubproductsgeneration_suborders suborders_order_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.ordersforsubproductsgeneration_suborders
    ADD CONSTRAINT suborders_order_fkey FOREIGN KEY (order_id) REFERENCES public.orders_order(id) DEFERRABLE;


--
-- Name: ordersforsubproductsgeneration_suborders suborders_ordersgroup_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.ordersforsubproductsgeneration_suborders
    ADD CONSTRAINT suborders_ordersgroup_fkey FOREIGN KEY (ordersgroup_id) REFERENCES public.ordersgroups_ordersgroup(id) DEFERRABLE;


--
-- Name: subcontractorportal_suborderstatechange suborderstatechange_shift_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.subcontractorportal_suborderstatechange
    ADD CONSTRAINT suborderstatechange_shift_fkey FOREIGN KEY (shift_id) REFERENCES public.basic_shift(id) DEFERRABLE;


--
-- Name: subcontractorportal_suborderstatechange suborderstatechange_suborder_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.subcontractorportal_suborderstatechange
    ADD CONSTRAINT suborderstatechange_suborder_fkey FOREIGN KEY (suborder_id) REFERENCES public.subcontractorportal_suborder(id) DEFERRABLE;


--
-- Name: subcontractorportal_subordertmp subordertmp_company_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.subcontractorportal_subordertmp
    ADD CONSTRAINT subordertmp_company_fkey FOREIGN KEY (company_id) REFERENCES public.basic_company(id) DEFERRABLE;


--
-- Name: basic_substitutecomponent substitutecomponent_baseproduct_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.basic_substitutecomponent
    ADD CONSTRAINT substitutecomponent_baseproduct_fkey FOREIGN KEY (baseproduct_id) REFERENCES public.basic_product(id) DEFERRABLE;


--
-- Name: basic_substitutecomponent substitutecomponent_product_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.basic_substitutecomponent
    ADD CONSTRAINT substitutecomponent_product_fkey FOREIGN KEY (product_id) REFERENCES public.basic_product(id) DEFERRABLE;


--
-- Name: technologies_technologicalprocess technologicalprocess_sizegroup_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.technologies_technologicalprocess
    ADD CONSTRAINT technologicalprocess_sizegroup_fkey FOREIGN KEY (sizegroup_id) REFERENCES public.basic_sizegroup(id);


--
-- Name: technologies_technologicalprocess technologicalprocess_technologicalprocessrate_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.technologies_technologicalprocess
    ADD CONSTRAINT technologicalprocess_technologicalprocessrate_fkey FOREIGN KEY (technologicalprocessrate_id) REFERENCES public.basic_technologicalprocessrate(id);


--
-- Name: technologies_technologicalprocess technologicalprocess_workstation_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.technologies_technologicalprocess
    ADD CONSTRAINT technologicalprocess_workstation_fkey FOREIGN KEY (workstation_id) REFERENCES public.basic_workstation(id);


--
-- Name: technologies_technologicalprocess technologicalprocess_workstationtype_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.technologies_technologicalprocess
    ADD CONSTRAINT technologicalprocess_workstationtype_fkey FOREIGN KEY (workstationtype_id) REFERENCES public.basic_workstationtype(id);


--
-- Name: technologies_technologicalprocesscomponent technologicalprocesscomponent_sizegroup_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.technologies_technologicalprocesscomponent
    ADD CONSTRAINT technologicalprocesscomponent_sizegroup_fkey FOREIGN KEY (sizegroup_id) REFERENCES public.basic_sizegroup(id);


--
-- Name: technologies_technologicalprocesscomponent technologicalprocesscomponent_technologicalprocess_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.technologies_technologicalprocesscomponent
    ADD CONSTRAINT technologicalprocesscomponent_technologicalprocess_fkey FOREIGN KEY (technologicalprocess_id) REFERENCES public.technologies_technologicalprocess(id);


--
-- Name: technologies_technologicalprocesscomponent technologicalprocesscomponent_technologicalprocesslist_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.technologies_technologicalprocesscomponent
    ADD CONSTRAINT technologicalprocesscomponent_technologicalprocesslist_fkey FOREIGN KEY (technologicalprocesslist_id) REFERENCES public.technologies_technologicalprocesslist(id);


--
-- Name: technologies_technologicalprocesslist technologicalprocesslist_operation_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.technologies_technologicalprocesslist
    ADD CONSTRAINT technologicalprocesslist_operation_fkey FOREIGN KEY (operation_id) REFERENCES public.technologies_operation(id);


--
-- Name: basic_technologicalprocessrateitem technologicalprocessrateitem_technologicalprocessrate_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.basic_technologicalprocessrateitem
    ADD CONSTRAINT technologicalprocessrateitem_technologicalprocessrate_fkey FOREIGN KEY (technologicalprocessrate_id) REFERENCES public.basic_technologicalprocessrate(id) DEFERRABLE;


--
-- Name: technologies_technology technologies_technology_technologygroup_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.technologies_technology
    ADD CONSTRAINT technologies_technology_technologygroup_fkey FOREIGN KEY (technologygroup_id) REFERENCES public.technologies_technologygroup(id) DEFERRABLE;


--
-- Name: technologies_technologyattachment technologies_technologyattachment_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.technologies_technologyattachment
    ADD CONSTRAINT technologies_technologyattachment_fkey FOREIGN KEY (technology_id) REFERENCES public.technologies_technology(id) DEFERRABLE;


--
-- Name: technologiesgenerator_generatortreenode technologies_technologygroup_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.technologiesgenerator_generatortreenode
    ADD CONSTRAINT technologies_technologygroup_fkey FOREIGN KEY (technologygroup_id) REFERENCES public.technologies_technologygroup(id) DEFERRABLE;


--
-- Name: technologies_productstructuretreenode technologies_technologygroup_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.technologies_productstructuretreenode
    ADD CONSTRAINT technologies_technologygroup_fkey FOREIGN KEY (technologygroup_id) REFERENCES public.technologies_technologygroup(id) DEFERRABLE;


--
-- Name: technologies_technology technology_componentslocation_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.technologies_technology
    ADD CONSTRAINT technology_componentslocation_fkey FOREIGN KEY (componentslocation_id) REFERENCES public.materialflow_location(id) DEFERRABLE;


--
-- Name: technologies_operationproductincomponent technology_componentslocation_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.technologies_operationproductincomponent
    ADD CONSTRAINT technology_componentslocation_fkey FOREIGN KEY (componentslocation_id) REFERENCES public.materialflow_location(id) DEFERRABLE;


--
-- Name: technologies_technology technology_componentsoutputlocation_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.technologies_technology
    ADD CONSTRAINT technology_componentsoutputlocation_fkey FOREIGN KEY (componentsoutputlocation_id) REFERENCES public.materialflow_location(id) DEFERRABLE;


--
-- Name: technologies_operationproductincomponent technology_componentsoutputlocation_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.technologies_operationproductincomponent
    ADD CONSTRAINT technology_componentsoutputlocation_fkey FOREIGN KEY (componentsoutputlocation_id) REFERENCES public.materialflow_location(id) DEFERRABLE;


--
-- Name: technologies_technology technology_division_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.technologies_technology
    ADD CONSTRAINT technology_division_fkey FOREIGN KEY (division_id) REFERENCES public.basic_division(id) DEFERRABLE;


--
-- Name: technologies_technology technology_generatorcontext_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.technologies_technology
    ADD CONSTRAINT technology_generatorcontext_fkey FOREIGN KEY (generatorcontext_id) REFERENCES public.technologiesgenerator_generatorcontext(id) DEFERRABLE;


--
-- Name: technologies_technology technology_piecerate_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.technologies_technology
    ADD CONSTRAINT technology_piecerate_fkey FOREIGN KEY (piecerate_id) REFERENCES public.basic_piecerate(id) DEFERRABLE;


--
-- Name: technologies_technology technology_product_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.technologies_technology
    ADD CONSTRAINT technology_product_fkey FOREIGN KEY (product_id) REFERENCES public.basic_product(id) DEFERRABLE;


--
-- Name: technologies_technology technology_productsflowlocation_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.technologies_technology
    ADD CONSTRAINT technology_productsflowlocation_fkey FOREIGN KEY (productsflowlocation_id) REFERENCES public.materialflow_location(id) DEFERRABLE;


--
-- Name: technologies_technology technology_productsinputlocation_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.technologies_technology
    ADD CONSTRAINT technology_productsinputlocation_fkey FOREIGN KEY (productsinputlocation_id) REFERENCES public.materialflow_location(id) DEFERRABLE;


--
-- Name: technologies_operationproductoutcomponent technology_productsinputlocation_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.technologies_operationproductoutcomponent
    ADD CONSTRAINT technology_productsinputlocation_fkey FOREIGN KEY (productsinputlocation_id) REFERENCES public.materialflow_location(id) DEFERRABLE;


--
-- Name: technologies_technology technology_qualitycard_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.technologies_technology
    ADD CONSTRAINT technology_qualitycard_fkey FOREIGN KEY (qualitycard_id) REFERENCES public.basic_qualitycard(id) DEFERRABLE;


--
-- Name: technologies_technology technology_technology_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.technologies_technology
    ADD CONSTRAINT technology_technology_fkey FOREIGN KEY (technologyprototype_id) REFERENCES public.technologies_technology(id) DEFERRABLE;


--
-- Name: technologies_technology technology_wastereceptionwarehouse_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.technologies_technology
    ADD CONSTRAINT technology_wastereceptionwarehouse_fkey FOREIGN KEY (wastereceptionwarehouse_id) REFERENCES public.materialflow_location(id) DEFERRABLE;


--
-- Name: technologies_technologyoperationcomponent technologyoperationcomponent_division_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.technologies_technologyoperationcomponent
    ADD CONSTRAINT technologyoperationcomponent_division_fkey FOREIGN KEY (division_id) REFERENCES public.basic_division(id) DEFERRABLE;


--
-- Name: technologies_technologyoperationcomponent technologyoperationcomponent_operation_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.technologies_technologyoperationcomponent
    ADD CONSTRAINT technologyoperationcomponent_operation_fkey FOREIGN KEY (operation_id) REFERENCES public.technologies_operation(id) DEFERRABLE;


--
-- Name: technologies_technologyoperationcomponent technologyoperationcomponent_parent_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.technologies_technologyoperationcomponent
    ADD CONSTRAINT technologyoperationcomponent_parent_fkey FOREIGN KEY (parent_id) REFERENCES public.technologies_technologyoperationcomponent(id) DEFERRABLE;


--
-- Name: technologies_technologyoperationcomponent technologyoperationcomponent_piecerate_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.technologies_technologyoperationcomponent
    ADD CONSTRAINT technologyoperationcomponent_piecerate_fkey FOREIGN KEY (piecerate_id) REFERENCES public.basic_piecerate(id) DEFERRABLE;


--
-- Name: technologies_technologyoperationcomponent technologyoperationcomponent_technologicalprocesslist_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.technologies_technologyoperationcomponent
    ADD CONSTRAINT technologyoperationcomponent_technologicalprocesslist_fkey FOREIGN KEY (technologicalprocesslist_id) REFERENCES public.technologies_technologicalprocesslist(id) DEFERRABLE;


--
-- Name: technologies_technologyoperationcomponent technologyoperationcomponent_technology_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.technologies_technologyoperationcomponent
    ADD CONSTRAINT technologyoperationcomponent_technology_fkey FOREIGN KEY (technology_id) REFERENCES public.technologies_technology(id) DEFERRABLE;


--
-- Name: technologies_technologyoperationcomponent technologyoperationcomponent_techopercomptimecalculation_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.technologies_technologyoperationcomponent
    ADD CONSTRAINT technologyoperationcomponent_techopercomptimecalculation_fkey FOREIGN KEY (techopercomptimecalculation_id) REFERENCES public.timenormsforoperations_techopercomptimecalculation(id) DEFERRABLE;


--
-- Name: productflowthrudivision_warehouseissue technologyoperationcomponent_warehouseissue_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.productflowthrudivision_warehouseissue
    ADD CONSTRAINT technologyoperationcomponent_warehouseissue_fkey FOREIGN KEY (technologyoperationcomponent_id) REFERENCES public.technologies_technologyoperationcomponent(id) DEFERRABLE;


--
-- Name: jointable_technologyoperationcomponent_workstation technologyoperationcomponent_workstation_workstation_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.jointable_technologyoperationcomponent_workstation
    ADD CONSTRAINT technologyoperationcomponent_workstation_workstation_fkey FOREIGN KEY (workstation_id) REFERENCES public.basic_workstation(id) DEFERRABLE;


--
-- Name: technologies_technologyoperationcomponent technologyoperationcomponent_workstationtype_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.technologies_technologyoperationcomponent
    ADD CONSTRAINT technologyoperationcomponent_workstationtype_fkey FOREIGN KEY (workstationtype_id) REFERENCES public.basic_workstationtype(id) DEFERRABLE;


--
-- Name: cmmsmachineparts_technologyoperationtool technologyoperationtool_technologyoperationcomponent_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.cmmsmachineparts_technologyoperationtool
    ADD CONSTRAINT technologyoperationtool_technologyoperationcomponent_fkey FOREIGN KEY (technologyoperationcomponent_id) REFERENCES public.technologies_technologyoperationcomponent(id) DEFERRABLE;


--
-- Name: cmmsmachineparts_technologyoperationtool technologyoperationtool_tool_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.cmmsmachineparts_technologyoperationtool
    ADD CONSTRAINT technologyoperationtool_tool_fkey FOREIGN KEY (tool_id) REFERENCES public.cmmsmachineparts_tool(id) DEFERRABLE;


--
-- Name: technologies_technologyproductionline technologyproductionline_productionline_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.technologies_technologyproductionline
    ADD CONSTRAINT technologyproductionline_productionline_fkey FOREIGN KEY (productionline_id) REFERENCES public.productionlines_productionline(id) DEFERRABLE;


--
-- Name: technologies_technologyproductionline technologyproductionline_technology_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.technologies_technologyproductionline
    ADD CONSTRAINT technologyproductionline_technology_fkey FOREIGN KEY (technology_id) REFERENCES public.technologies_technology(id) DEFERRABLE;


--
-- Name: technologies_technologystatechange technologystatechange_shift_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.technologies_technologystatechange
    ADD CONSTRAINT technologystatechange_shift_fkey FOREIGN KEY (shift_id) REFERENCES public.basic_shift(id) DEFERRABLE;


--
-- Name: technologies_technologystatechange technologystatechange_technology_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.technologies_technologystatechange
    ADD CONSTRAINT technologystatechange_technology_fkey FOREIGN KEY (technology_id) REFERENCES public.technologies_technology(id) DEFERRABLE;


--
-- Name: timenormsforoperations_techopercompworkstationtime techopercompworkstationtime_technologyoperationcomponent_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.timenormsforoperations_techopercompworkstationtime
    ADD CONSTRAINT techopercompworkstationtime_technologyoperationcomponent_fkey FOREIGN KEY (technologyoperationcomponent_id) REFERENCES public.technologies_technologyoperationcomponent(id) DEFERRABLE;


--
-- Name: timenormsforoperations_techopercompworkstationtime techopercompworkstationtime_workstation_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.timenormsforoperations_techopercompworkstationtime
    ADD CONSTRAINT techopercompworkstationtime_workstation_fkey FOREIGN KEY (workstation_id) REFERENCES public.basic_workstation(id) DEFERRABLE;


--
-- Name: timegapspreview_timegap timegap_context_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.timegapspreview_timegap
    ADD CONSTRAINT timegap_context_fkey FOREIGN KEY (context_id) REFERENCES public.timegapspreview_timegapscontext(id) DEFERRABLE;


--
-- Name: timegapspreview_timegap timegap_productionline_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.timegapspreview_timegap
    ADD CONSTRAINT timegap_productionline_fkey FOREIGN KEY (productionline_id) REFERENCES public.productionlines_productionline(id) DEFERRABLE;


--
-- Name: timegapspreview_timegapscontext timegapscontext_longestdurationline_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.timegapspreview_timegapscontext
    ADD CONSTRAINT timegapscontext_longestdurationline_fkey FOREIGN KEY (longestdurationline_id) REFERENCES public.productionlines_productionline(id) DEFERRABLE;


--
-- Name: timegapspreview_timegapscontext timegapscontext_supportedtechnology_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.timegapspreview_timegapscontext
    ADD CONSTRAINT timegapscontext_supportedtechnology_fkey FOREIGN KEY (supportedtechnology_id) REFERENCES public.technologies_technology(id) DEFERRABLE;


--
-- Name: timegapspreview_timegapscontext timegapscontext_supportedtechnologygroup_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.timegapspreview_timegapscontext
    ADD CONSTRAINT timegapscontext_supportedtechnologygroup_fkey FOREIGN KEY (supportedtechnologygroup_id) REFERENCES public.technologies_technologygroup(id) DEFERRABLE;


--
-- Name: cmmsmachineparts_toolattachment toolattachment_tool_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.cmmsmachineparts_toolattachment
    ADD CONSTRAINT toolattachment_tool_fkey FOREIGN KEY (tool_id) REFERENCES public.cmmsmachineparts_tool(id) DEFERRABLE;


--
-- Name: productioncounting_trackinginproductreplacementhelper trackinginproductreplacementhelper_basicproduct_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.productioncounting_trackinginproductreplacementhelper
    ADD CONSTRAINT trackinginproductreplacementhelper_basicproduct_fkey FOREIGN KEY (basicproduct_id) REFERENCES public.basic_product(id) DEFERRABLE;


--
-- Name: productioncounting_trackinginproductreplacementhelper trackinginproductreplacementhelper_product_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.productioncounting_trackinginproductreplacementhelper
    ADD CONSTRAINT trackinginproductreplacementhelper_product_fkey FOREIGN KEY (product_id) REFERENCES public.basic_product(id) DEFERRABLE;


--
-- Name: productioncounting_trackinginproductreplacementhelper trackinginproductreplacementhelper_productiontracking_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.productioncounting_trackinginproductreplacementhelper
    ADD CONSTRAINT trackinginproductreplacementhelper_productiontracking_fkey FOREIGN KEY (productiontracking_id) REFERENCES public.productioncounting_productiontracking(id) DEFERRABLE;


--
-- Name: productioncounting_trackingoperationproductincomponent trackingoperationproductincomponent_product_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.productioncounting_trackingoperationproductincomponent
    ADD CONSTRAINT trackingoperationproductincomponent_product_fkey FOREIGN KEY (product_id) REFERENCES public.basic_product(id) DEFERRABLE;


--
-- Name: productioncounting_trackingoperationproductincomponent trackingoperationproductincomponent_productiontracking_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.productioncounting_trackingoperationproductincomponent
    ADD CONSTRAINT trackingoperationproductincomponent_productiontracking_fkey FOREIGN KEY (productiontracking_id) REFERENCES public.productioncounting_productiontracking(id) DEFERRABLE;


--
-- Name: productioncounting_trackingoperationproductincomponent trackingoperationproductincomponent_replacementto_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.productioncounting_trackingoperationproductincomponent
    ADD CONSTRAINT trackingoperationproductincomponent_replacementto_fkey FOREIGN KEY (replacementto_id) REFERENCES public.basic_product(id) DEFERRABLE;


--
-- Name: productioncounting_trackingoperationproductoutcomponent trackingoperationproductoutcomponent_batch_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.productioncounting_trackingoperationproductoutcomponent
    ADD CONSTRAINT trackingoperationproductoutcomponent_batch_fkey FOREIGN KEY (batch_id) REFERENCES public.advancedgenealogy_batch(id) DEFERRABLE;


--
-- Name: productioncounting_trackingoperationproductoutcomponent trackingoperationproductoutcomponent_palletnumber_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.productioncounting_trackingoperationproductoutcomponent
    ADD CONSTRAINT trackingoperationproductoutcomponent_palletnumber_fkey FOREIGN KEY (palletnumber_id) REFERENCES public.basic_palletnumber(id) DEFERRABLE;


--
-- Name: productioncounting_trackingoperationproductoutcomponent trackingoperationproductoutcomponent_product_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.productioncounting_trackingoperationproductoutcomponent
    ADD CONSTRAINT trackingoperationproductoutcomponent_product_fkey FOREIGN KEY (product_id) REFERENCES public.basic_product(id) DEFERRABLE;


--
-- Name: productioncounting_trackingoperationproductoutcomponent trackingoperationproductoutcomponent_productiontracking_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.productioncounting_trackingoperationproductoutcomponent
    ADD CONSTRAINT trackingoperationproductoutcomponent_productiontracking_fkey FOREIGN KEY (productiontracking_id) REFERENCES public.productioncounting_productiontracking(id) DEFERRABLE;


--
-- Name: productioncounting_trackingoperationproductoutcomponent trackingoperationproductoutcomponent_storagelocation_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.productioncounting_trackingoperationproductoutcomponent
    ADD CONSTRAINT trackingoperationproductoutcomponent_storagelocation_fkey FOREIGN KEY (storagelocation_id) REFERENCES public.materialflowresources_storagelocation(id) DEFERRABLE;


--
-- Name: productflowthrudivision_trackingproductresourcereservation trackingproductresourcereservation_orderproductresourcereservat; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.productflowthrudivision_trackingproductresourcereservation
    ADD CONSTRAINT trackingproductresourcereservation_orderproductresourcereservat FOREIGN KEY (orderproductresourcereservation_id) REFERENCES public.productflowthrudivision_orderproductresourcereservation(id) DEFERRABLE;


--
-- Name: productflowthrudivision_trackingproductresourcereservation trackingproductresourcereservation_trackingoperationproductinco; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.productflowthrudivision_trackingproductresourcereservation
    ADD CONSTRAINT trackingproductresourcereservation_trackingoperationproductinco FOREIGN KEY (trackingoperationproductincomponent_id) REFERENCES public.productioncounting_trackingoperationproductincomponent(id) DEFERRABLE;


--
-- Name: advancedgenealogy_trackingrecord trackingrecord_order_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.advancedgenealogy_trackingrecord
    ADD CONSTRAINT trackingrecord_order_fkey FOREIGN KEY (order_id) REFERENCES public.orders_order(id) DEFERRABLE;


--
-- Name: advancedgenealogy_trackingrecord trackingrecord_producedbatch_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.advancedgenealogy_trackingrecord
    ADD CONSTRAINT trackingrecord_producedbatch_fkey FOREIGN KEY (producedbatch_id) REFERENCES public.advancedgenealogy_batch(id) DEFERRABLE;


--
-- Name: orders_typeofcorrectioncauses typeofcorrectioncauses_order_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.orders_typeofcorrectioncauses
    ADD CONSTRAINT typeofcorrectioncauses_order_fkey FOREIGN KEY (order_id) REFERENCES public.orders_order(id) DEFERRABLE;


--
-- Name: productioncounting_usedbatch usedbatch_batch_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.productioncounting_usedbatch
    ADD CONSTRAINT usedbatch_batch_fkey FOREIGN KEY (batch_id) REFERENCES public.advancedgenealogy_batch(id) DEFERRABLE;


--
-- Name: productioncounting_usedbatch usedbatch_trackingoperationproductincomponent_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.productioncounting_usedbatch
    ADD CONSTRAINT usedbatch_trackingoperationproductincomponent_fkey FOREIGN KEY (trackingoperationproductincomponent_id) REFERENCES public.productioncounting_trackingoperationproductincomponent(id) DEFERRABLE;


--
-- Name: advancedgenealogy_usedbatchsimple usedbatchsimple_batch_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.advancedgenealogy_usedbatchsimple
    ADD CONSTRAINT usedbatchsimple_batch_fkey FOREIGN KEY (batch_id) REFERENCES public.advancedgenealogy_batch(id) DEFERRABLE;


--
-- Name: advancedgenealogy_usedbatchsimple usedbatchsimple_trackingrecord_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.advancedgenealogy_usedbatchsimple
    ADD CONSTRAINT usedbatchsimple_trackingrecord_fkey FOREIGN KEY (trackingrecord_id) REFERENCES public.advancedgenealogy_trackingrecord(id) DEFERRABLE;


--
-- Name: qcadoosecurity_user user_factory_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.qcadoosecurity_user
    ADD CONSTRAINT user_factory_fkey FOREIGN KEY (factory_id) REFERENCES public.basic_factory(id) DEFERRABLE;


--
-- Name: qcadoosecurity_user user_group_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.qcadoosecurity_user
    ADD CONSTRAINT user_group_fkey FOREIGN KEY (group_id) REFERENCES public.qcadoosecurity_group(id) DEFERRABLE;


--
-- Name: qcadoosecurity_user user_productionline_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.qcadoosecurity_user
    ADD CONSTRAINT user_productionline_fkey FOREIGN KEY (productionline_id) REFERENCES public.productionlines_productionline(id) DEFERRABLE;


--
-- Name: qcadoosecurity_user user_staff_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.qcadoosecurity_user
    ADD CONSTRAINT user_staff_fkey FOREIGN KEY (staff_id) REFERENCES public.basic_staff(id) DEFERRABLE;


--
-- Name: materialflow_userlocation userlocation_location_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.materialflow_userlocation
    ADD CONSTRAINT userlocation_location_fkey FOREIGN KEY (location_id) REFERENCES public.materialflow_location(id) DEFERRABLE;


--
-- Name: materialflow_userlocation userlocation_user_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.materialflow_userlocation
    ADD CONSTRAINT userlocation_user_fkey FOREIGN KEY (user_id) REFERENCES public.qcadoosecurity_user(id) DEFERRABLE;


--
-- Name: basic_viewedactivity viewedactivity_log_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.basic_viewedactivity
    ADD CONSTRAINT viewedactivity_log_fkey FOREIGN KEY (log_id) REFERENCES public.basic_log(id) DEFERRABLE;


--
-- Name: basic_viewedactivity viewedactivity_user_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.basic_viewedactivity
    ADD CONSTRAINT viewedactivity_user_fkey FOREIGN KEY (user_id) REFERENCES public.qcadoosecurity_user(id) DEFERRABLE;


--
-- Name: qcadooview_viewedalert viewedalert_alert_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.qcadooview_viewedalert
    ADD CONSTRAINT viewedalert_alert_fkey FOREIGN KEY (alert_id) REFERENCES public.qcadooview_alert(id) DEFERRABLE;


--
-- Name: basic_staff wagegroups_wagegroup_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.basic_staff
    ADD CONSTRAINT wagegroups_wagegroup_fkey FOREIGN KEY (wagegroup_id) REFERENCES public.wagegroups_wagegroup(id) DEFERRABLE;


--
-- Name: productflowthrudivision_issue warehouseissue_issue_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.productflowthrudivision_issue
    ADD CONSTRAINT warehouseissue_issue_fkey FOREIGN KEY (warehouseissue_id) REFERENCES public.productflowthrudivision_warehouseissue(id) DEFERRABLE;


--
-- Name: productflowthrudivision_warehouseissue warehouseissue_order_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.productflowthrudivision_warehouseissue
    ADD CONSTRAINT warehouseissue_order_fkey FOREIGN KEY (order_id) REFERENCES public.orders_order(id) DEFERRABLE;


--
-- Name: productflowthrudivision_productstoissue warehouseissue_productstoissue_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.productflowthrudivision_productstoissue
    ADD CONSTRAINT warehouseissue_productstoissue_fkey FOREIGN KEY (warehouseissue_id) REFERENCES public.productflowthrudivision_warehouseissue(id) DEFERRABLE;


--
-- Name: productflowthrudivision_warehouseissuestatechange warehouseissue_warehouseissuestatechange_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.productflowthrudivision_warehouseissuestatechange
    ADD CONSTRAINT warehouseissue_warehouseissuestatechange_fkey FOREIGN KEY (warehouseissue_id) REFERENCES public.productflowthrudivision_warehouseissue(id) DEFERRABLE;


--
-- Name: jointable_product_warehouseminimumstatemulti warehouseminimalstate_warehouseminimumstatemulti_product_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.jointable_product_warehouseminimumstatemulti
    ADD CONSTRAINT warehouseminimalstate_warehouseminimumstatemulti_product_fkey FOREIGN KEY (warehouseminimumstatemulti_id) REFERENCES public.warehouseminimalstate_warehouseminimumstatemulti(id) DEFERRABLE;


--
-- Name: warehouseminimalstate_warehouseminimumstate warehouseminimumstate_location_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.warehouseminimalstate_warehouseminimumstate
    ADD CONSTRAINT warehouseminimumstate_location_fkey FOREIGN KEY (location_id) REFERENCES public.materialflow_location(id) DEFERRABLE;


--
-- Name: warehouseminimalstate_warehouseminimumstate warehouseminimumstate_product_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.warehouseminimalstate_warehouseminimumstate
    ADD CONSTRAINT warehouseminimumstate_product_fkey FOREIGN KEY (product_id) REFERENCES public.basic_product(id) DEFERRABLE;


--
-- Name: warehouseminimalstate_warehouseminimumstatemulti warehouseminimumstatemulti_location_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.warehouseminimalstate_warehouseminimumstatemulti
    ADD CONSTRAINT warehouseminimumstatemulti_location_fkey FOREIGN KEY (location_id) REFERENCES public.materialflow_location(id) DEFERRABLE;


--
-- Name: materialflowresources_warehousestockreport warehousestockreport_location_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.materialflowresources_warehousestockreport
    ADD CONSTRAINT warehousestockreport_location_fkey FOREIGN KEY (location_id) REFERENCES public.materialflow_location(id) DEFERRABLE;


--
-- Name: mobilewms_wmsdocumentpart wmsdocumentpart_document_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.mobilewms_wmsdocumentpart
    ADD CONSTRAINT wmsdocumentpart_document_fkey FOREIGN KEY (document_id) REFERENCES public.materialflowresources_document(id) DEFERRABLE;


--
-- Name: cmmsmachineparts_staffworktime worker_maintenanceevent_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.cmmsmachineparts_staffworktime
    ADD CONSTRAINT worker_maintenanceevent_fkey FOREIGN KEY (maintenanceevent_id) REFERENCES public.cmmsmachineparts_maintenanceevent(id) DEFERRABLE;


--
-- Name: productflowthrudivision_warehouseissue workerwhocollected_warehouseissue_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.productflowthrudivision_warehouseissue
    ADD CONSTRAINT workerwhocollected_warehouseissue_fkey FOREIGN KEY (workerwhocollected_id) REFERENCES public.basic_staff(id) DEFERRABLE;


--
-- Name: productflowthrudivision_warehouseissue workerwhoissued__warehouseissue_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.productflowthrudivision_warehouseissue
    ADD CONSTRAINT workerwhoissued__warehouseissue_fkey FOREIGN KEY (workerwhoissued_id) REFERENCES public.basic_staff(id) DEFERRABLE;


--
-- Name: workplans_parameterinputcolumn workplans_parameterinputcolumn_cfip_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.workplans_parameterinputcolumn
    ADD CONSTRAINT workplans_parameterinputcolumn_cfip_fkey FOREIGN KEY (columnforinputproducts_id) REFERENCES public.workplans_columnforinputproducts(id) DEFERRABLE;


--
-- Name: workplans_parameterordercolumn workplans_parameterordercolumn_columnfororders_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.workplans_parameterordercolumn
    ADD CONSTRAINT workplans_parameterordercolumn_columnfororders_fkey FOREIGN KEY (columnfororders_id) REFERENCES public.workplans_columnfororders(id) DEFERRABLE;


--
-- Name: workplans_parameterordercolumn workplans_parameterordercolumn_parameter_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.workplans_parameterordercolumn
    ADD CONSTRAINT workplans_parameterordercolumn_parameter_fkey FOREIGN KEY (parameter_id) REFERENCES public.basic_parameter(id) DEFERRABLE;


--
-- Name: workplans_parameteroutputcolumn workplans_parameteroutputcolumn_cfop_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.workplans_parameteroutputcolumn
    ADD CONSTRAINT workplans_parameteroutputcolumn_cfop_fkey FOREIGN KEY (columnforoutputproducts_id) REFERENCES public.workplans_columnforoutputproducts(id) DEFERRABLE;


--
-- Name: workplans_parameterinputcolumn workplans_parameteroutputcolumn_parameter_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.workplans_parameterinputcolumn
    ADD CONSTRAINT workplans_parameteroutputcolumn_parameter_fkey FOREIGN KEY (parameter_id) REFERENCES public.basic_parameter(id) DEFERRABLE;


--
-- Name: workplans_parameteroutputcolumn workplans_parameteroutputcolumn_parameter_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.workplans_parameteroutputcolumn
    ADD CONSTRAINT workplans_parameteroutputcolumn_parameter_fkey FOREIGN KEY (parameter_id) REFERENCES public.basic_parameter(id) DEFERRABLE;


--
-- Name: workplans_workplan workplans_workplan_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.workplans_workplan
    ADD CONSTRAINT workplans_workplan_fkey FOREIGN KEY (inputproductcolumntosortby_id) REFERENCES public.workplans_columnforinputproducts(id) DEFERRABLE;


--
-- Name: workplans_workplanordercolumn workplans_workplanordercolumn_columnfororders_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.workplans_workplanordercolumn
    ADD CONSTRAINT workplans_workplanordercolumn_columnfororders_fkey FOREIGN KEY (columnfororders_id) REFERENCES public.workplans_columnfororders(id) DEFERRABLE;


--
-- Name: workplans_workplanordercolumn workplans_workplanordercolumn_workplan_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.workplans_workplanordercolumn
    ADD CONSTRAINT workplans_workplanordercolumn_workplan_fkey FOREIGN KEY (workplan_id) REFERENCES public.workplans_workplan(id) DEFERRABLE;


--
-- Name: basic_workstation workstation_division_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.basic_workstation
    ADD CONSTRAINT workstation_division_fkey FOREIGN KEY (division_id) REFERENCES public.basic_division(id) DEFERRABLE;


--
-- Name: basic_workstation workstation_operation_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.basic_workstation
    ADD CONSTRAINT workstation_operation_fkey FOREIGN KEY (operation_id) REFERENCES public.technologies_operation(id) DEFERRABLE;


--
-- Name: jointable_operation_workstation workstation_operation_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.jointable_operation_workstation
    ADD CONSTRAINT workstation_operation_fkey FOREIGN KEY (operation_id) REFERENCES public.technologies_operation(id) DEFERRABLE;


--
-- Name: basic_workstation workstation_productionline_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.basic_workstation
    ADD CONSTRAINT workstation_productionline_fkey FOREIGN KEY (productionline_id) REFERENCES public.productionlines_productionline(id) DEFERRABLE;


--
-- Name: basic_workstation workstation_staff_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.basic_workstation
    ADD CONSTRAINT workstation_staff_fkey FOREIGN KEY (staff_id) REFERENCES public.basic_staff(id) DEFERRABLE;


--
-- Name: jointable_technologyoperationcomponent_workstation workstation_technologyoperationcomponent_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.jointable_technologyoperationcomponent_workstation
    ADD CONSTRAINT workstation_technologyoperationcomponent_fkey FOREIGN KEY (technologyoperationcomponent_id) REFERENCES public.technologies_technologyoperationcomponent(id) DEFERRABLE;


--
-- Name: basic_workstation workstation_workstationtype_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.basic_workstation
    ADD CONSTRAINT workstation_workstationtype_fkey FOREIGN KEY (workstationtype_id) REFERENCES public.basic_workstationtype(id) DEFERRABLE;


--
-- Name: basic_workstationattachment workstationattachment_workstation_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.basic_workstationattachment
    ADD CONSTRAINT workstationattachment_workstation_fkey FOREIGN KEY (workstation_id) REFERENCES public.basic_workstation(id) DEFERRABLE;


--
-- Name: orders_workstationchangeoverforoperationaltask workstationchangeoverforoperationaltask_attribute_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.orders_workstationchangeoverforoperationaltask
    ADD CONSTRAINT workstationchangeoverforoperationaltask_attribute_fkey FOREIGN KEY (attribute_id) REFERENCES public.basic_attribute(id) DEFERRABLE;


--
-- Name: orders_workstationchangeoverforoperationaltask workstationchangeoverforoperationaltask_currentoperationaltask_; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.orders_workstationchangeoverforoperationaltask
    ADD CONSTRAINT workstationchangeoverforoperationaltask_currentoperationaltask_ FOREIGN KEY (currentoperationaltask_id) REFERENCES public.orders_operationaltask(id) DEFERRABLE;


--
-- Name: orders_workstationchangeoverforoperationaltask workstationchangeoverforoperationaltask_fromdattributevalue_fke; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.orders_workstationchangeoverforoperationaltask
    ADD CONSTRAINT workstationchangeoverforoperationaltask_fromdattributevalue_fke FOREIGN KEY (fromattributevalue_id) REFERENCES public.basic_attributevalue(id) DEFERRABLE;


--
-- Name: orders_workstationchangeoverforoperationaltask workstationchangeoverforoperationaltask_previousoperationaltask; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.orders_workstationchangeoverforoperationaltask
    ADD CONSTRAINT workstationchangeoverforoperationaltask_previousoperationaltask FOREIGN KEY (previousoperationaltask_id) REFERENCES public.orders_operationaltask(id) DEFERRABLE;


--
-- Name: orders_workstationchangeoverforoperationaltask workstationchangeoverforoperationaltask_toattributevalue_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.orders_workstationchangeoverforoperationaltask
    ADD CONSTRAINT workstationchangeoverforoperationaltask_toattributevalue_fkey FOREIGN KEY (toattributevalue_id) REFERENCES public.basic_attributevalue(id) DEFERRABLE;


--
-- Name: orders_workstationchangeoverforoperationaltask workstationchangeoverforoperationaltask_workstation_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.orders_workstationchangeoverforoperationaltask
    ADD CONSTRAINT workstationchangeoverforoperationaltask_workstation_fkey FOREIGN KEY (workstation_id) REFERENCES public.basic_workstation(id) DEFERRABLE;


--
-- Name: orders_workstationchangeoverforoperationaltask workstationchangeoverforoperationaltask_workstationchangeoverno; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.orders_workstationchangeoverforoperationaltask
    ADD CONSTRAINT workstationchangeoverforoperationaltask_workstationchangeoverno FOREIGN KEY (workstationchangeovernorm_id) REFERENCES public.technologies_workstationchangeovernorm(id) DEFERRABLE;


--
-- Name: technologies_workstationchangeovernorm workstationchangeovernorm_attribute_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.technologies_workstationchangeovernorm
    ADD CONSTRAINT workstationchangeovernorm_attribute_fkey FOREIGN KEY (attribute_id) REFERENCES public.basic_attribute(id) DEFERRABLE;


--
-- Name: technologies_workstationchangeovernorm workstationchangeovernorm_fromdattributevalue_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.technologies_workstationchangeovernorm
    ADD CONSTRAINT workstationchangeovernorm_fromdattributevalue_fkey FOREIGN KEY (fromattributevalue_id) REFERENCES public.basic_attributevalue(id) DEFERRABLE;


--
-- Name: technologies_workstationchangeovernorm workstationchangeovernorm_toattributevalue_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.technologies_workstationchangeovernorm
    ADD CONSTRAINT workstationchangeovernorm_toattributevalue_fkey FOREIGN KEY (toattributevalue_id) REFERENCES public.basic_attributevalue(id) DEFERRABLE;


--
-- Name: technologies_workstationchangeovernorm workstationchangeovernorm_workstation_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.technologies_workstationchangeovernorm
    ADD CONSTRAINT workstationchangeovernorm_workstation_fkey FOREIGN KEY (workstation_id) REFERENCES public.basic_workstation(id) DEFERRABLE;


--
-- Name: technologies_workstationchangeovernorm workstationchangeovernorm_workstationtype_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.technologies_workstationchangeovernorm
    ADD CONSTRAINT workstationchangeovernorm_workstationtype_fkey FOREIGN KEY (workstationtype_id) REFERENCES public.basic_workstationtype(id) DEFERRABLE;


--
-- Name: orders_workstationchangeoverforscheduleposition workstationchangeoverschedulepos_currentscheduleposition_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.orders_workstationchangeoverforscheduleposition
    ADD CONSTRAINT workstationchangeoverschedulepos_currentscheduleposition_fkey FOREIGN KEY (currentscheduleposition_id) REFERENCES public.orders_scheduleposition(id) DEFERRABLE;


--
-- Name: orders_workstationchangeoverforscheduleposition workstationchangeoverschedulepos_previousoperationaltask_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.orders_workstationchangeoverforscheduleposition
    ADD CONSTRAINT workstationchangeoverschedulepos_previousoperationaltask_fkey FOREIGN KEY (previousoperationaltask_id) REFERENCES public.orders_operationaltask(id) DEFERRABLE;


--
-- Name: orders_workstationchangeoverforscheduleposition workstationchangeoverschedulepos_previousscheduleposition_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.orders_workstationchangeoverforscheduleposition
    ADD CONSTRAINT workstationchangeoverschedulepos_previousscheduleposition_fkey FOREIGN KEY (previousscheduleposition_id) REFERENCES public.orders_scheduleposition(id) DEFERRABLE;


--
-- Name: orders_workstationchangeoverforscheduleposition workstationchangeoverschedulepos_workstationchangeovernorm_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.orders_workstationchangeoverforscheduleposition
    ADD CONSTRAINT workstationchangeoverschedulepos_workstationchangeovernorm_fkey FOREIGN KEY (workstationchangeovernorm_id) REFERENCES public.technologies_workstationchangeovernorm(id) DEFERRABLE;


--
-- Name: technologies_workstationstatechange workstationstatechange_shift_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.technologies_workstationstatechange
    ADD CONSTRAINT workstationstatechange_shift_fkey FOREIGN KEY (shift_id) REFERENCES public.basic_shift(id) DEFERRABLE;


--
-- Name: technologies_workstationstatechange workstationstatechange_workstation_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.technologies_workstationstatechange
    ADD CONSTRAINT workstationstatechange_workstation_fkey FOREIGN KEY (workstation_id) REFERENCES public.basic_workstation(id) DEFERRABLE;


--
-- Name: arch_mv_masterorders_masterorderpositiondto; Type: MATERIALIZED VIEW DATA; Schema: public; Owner: -
--

REFRESH MATERIALIZED VIEW public.arch_mv_masterorders_masterorderpositiondto;


--
-- Name: arch_mv_masterorders_masterorderdto; Type: MATERIALIZED VIEW DATA; Schema: public; Owner: -
--

REFRESH MATERIALIZED VIEW public.arch_mv_masterorders_masterorderdto;


--
-- Name: arch_mv_orders_orderlistdto; Type: MATERIALIZED VIEW DATA; Schema: public; Owner: -
--

REFRESH MATERIALIZED VIEW public.arch_mv_orders_orderlistdto;


--
-- Name: arch_mv_ordersgroups_ordersgroupdto; Type: MATERIALIZED VIEW DATA; Schema: public; Owner: -
--

REFRESH MATERIALIZED VIEW public.arch_mv_ordersgroups_ordersgroupdto;


--
-- Name: arch_mv_productioncounting_productiontrackingdto; Type: MATERIALIZED VIEW DATA; Schema: public; Owner: -
--

REFRESH MATERIALIZED VIEW public.arch_mv_productioncounting_productiontrackingdto;


--
-- Name: mv_productioncounting_performanceanalysisdto; Type: MATERIALIZED VIEW DATA; Schema: public; Owner: -
--

REFRESH MATERIALIZED VIEW public.mv_productioncounting_performanceanalysisdto;


--
-- Name: mv_productioncounting_productionanalysisdto; Type: MATERIALIZED VIEW DATA; Schema: public; Owner: -
--

REFRESH MATERIALIZED VIEW public.mv_productioncounting_productionanalysisdto;


--
-- PostgreSQL database dump complete
--

