CREATE SCHEMA "S-ERP";
--> statement-breakpoint
CREATE TABLE "S-ERP"."TB_SAP_EquipInfo" (
	"id" serial PRIMARY KEY NOT NULL,
	"Equipment" varchar(20),
	"Description" varchar(100),
	"EquipCategory" varchar(2),
	"SystemStatus" varchar(10),
	"UserStatus" varchar(10),
	"ObjectType" varchar(10),
	"ABCIndicator" varchar(2),
	"PlanningPlant" varchar(10),
	"PlannerGroup" varchar(10),
	"MainWorkCenter" varchar(10),
	"CostCenter" varchar(10),
	"CatalogProfile" varchar(10),
	"FunctionLocation" varchar(20),
	"FunctionLocationDesc" varchar(100),
	"SuperordEquip" varchar(10),
	"COL1" varchar(10),
	"ConstType" varchar(10),
	"AssetNo" varchar(10),
	"TechnivalIdenNo" varchar(10),
	"Class" varchar(10),
	"MaintenancePlant" varchar(10),
	"PlantSection" varchar(10),
	"PlantSectionDescription" varchar(10),
	"ObjectTypeDesc" varchar(100),
	"MainWorkCenterDesc" varchar(100),
	"CostCenterDesc" varchar(100),
	"ObjectNumber" varchar(30),
	"SubAssetNo" varchar(10),
	"AuthorizGroup" varchar(10),
	"Weight" numeric(16, 3),
	"WeightUnit" varchar(10),
	"SizeDimension" varchar(20),
	"InventoryNumber" varchar(50),
	"StartUpDate" varchar(10),
	"AcquistnValue" numeric(19, 4),
	"AcquistnValueCurr" varchar(10),
	"AcquistionDate" varchar(10),
	"Manufacturer" varchar(50),
	"ModelNumber" varchar(10),
	"ManufPartNo" varchar(10),
	"ManufCountry" varchar(4),
	"ManufSerialNo" varchar(50),
	"ConstrYr" varchar(4),
	"ConstrMth" varchar(2),
	"Location" varchar(10),
	"Room" varchar(10),
	"WorkCenter" varchar(10),
	"PPWorkCenter" varchar(10),
	"PPWorkCenterDesc" varchar(100),
	"SortField" varchar(10),
	"CompanyCode" varchar(10),
	"BusinessArea" varchar(10),
	"WBSElement" varchar(10),
	"MainWorkCtrPlant" varchar(10),
	"Position" varchar(10),
	"FinancialManagementArea" varchar(10),
	"CommitmentItem" varchar(20),
	"SysStatus" varchar(1)
);
--> statement-breakpoint
CREATE TABLE "S-ERP"."TB_SAP_MainternanceBOM" (
	"id" serial PRIMARY KEY NOT NULL,
	"Date" varchar(50),
	"Order" integer,
	"Description" varchar(50),
	"FuncLocation" varchar(50),
	"Description_1" varchar(50),
	"WorkCenter" varchar(50),
	"ObjectType" varchar(50),
	"Equipment" integer,
	"Discription" varchar(50),
	"TagNumber" varchar(50),
	"ICT" varchar(50),
	"Component" varchar(50),
	"Quantity" integer,
	"Unit" varchar(50),
	"Description_2" varchar(50),
	"Specification" varchar(50),
	"GEWRK" integer,
	"STLNR" varchar(50),
	"STLAL" varchar(50),
	"WERKS" varchar(50),
	"TPLNR_T" varchar(50),
	"EQUNR_T" integer
);
--> statement-breakpoint
CREATE TABLE "S-ERP"."TB_SAP_MaterialInfo" (
	"id" serial PRIMARY KEY NOT NULL,
	"Plnt" varchar(50),
	"Material" varchar(50),
	"Sloc" varchar(50),
	"Bin" varchar(50),
	"MatlGroup" varchar(50),
	"MaterialDescription" varchar(500),
	"MaterialName" varchar(500),
	"Specification" varchar(500),
	"Unrestr" integer,
	"QualInsp" integer,
	"Blocked" integer,
	"Bun" varchar(50),
	"Warehouse" varchar(50),
	"Message" varchar(500)
);
--> statement-breakpoint
CREATE TABLE "S-ERP"."TB_SAP_MaterialPurchase" (
	"id" serial PRIMARY KEY NOT NULL,
	"Status" varchar(50),
	"Notification" integer,
	"Type" varchar(50),
	"Description" varchar(64),
	"PlanningPlant" varchar(50),
	"PlannerGroup" varchar(50),
	"NameOfPlannerGroup" varchar(50),
	"WorkCenter" varchar(50),
	"NameOfWorkCenter" varchar(50),
	"FunctionalLocation" varchar(50),
	"Equipment" integer,
	"TagNumber" varchar(50),
	"EquipmentDesc" varchar(50),
	"PlantSection" varchar(50),
	"CostCenter" varchar(50),
	"CostCenterDesc" varchar(50),
	"ABCIndicator" varchar(50),
	"NotificationDate" varchar(50),
	"CreatedBy" varchar(50),
	"SystemStatus" varchar(50),
	"UserStatus" varchar(50),
	"Order" integer,
	"Requester" varchar(50),
	"RequesterName" varchar(50),
	"CodeGroup" varchar(50),
	"Code" integer,
	"CodeDescription" varchar(50),
	"BreakdownIndicator" varchar(50),
	"Priority" varchar(50),
	"PriorityDesc" varchar(50),
	"NotifcatnType" varchar(50),
	"Name1" varchar(50),
	"WorkCenterInt" integer,
	"ObjectNumber" varchar(50),
	"CHAR05" varchar(50),
	"Link" varchar(50),
	"Link1" varchar(50),
	"Tooltip" varchar(50),
	"PlantSectionDesc" varchar(50),
	"Catalog" varchar(50),
	"Partner" varchar(50),
	"NotificationTime" varchar(50),
	"CompletionDate" varchar(50),
	"CompletionTime" varchar(50),
	"ExtRequester" varchar(50),
	"COL1" varchar(50),
	"OrderBasicStart" varchar(50),
	"EWRNo" varchar(50),
	"MalfunctionStart" varchar(50),
	"StartTime" varchar(50),
	"MalfunctionEnd" varchar(50),
	"EndTime" varchar(50),
	"BreakdownDuration" real
);
--> statement-breakpoint
CREATE TABLE "S-ERP"."TB_SAP_MaterialReceiving" (
	"id" serial PRIMARY KEY NOT NULL,
	"PostingGRDate" varchar(50),
	"Plant" varchar(50),
	"StorageLoc" varchar(50),
	"StockWBS" varchar(50),
	"InputWBS" varchar(50),
	"Material" varchar(50),
	"OldMaterialNumber" varchar(50),
	"MaterialDesc" varchar(50),
	"Spec" varchar(50),
	"Batch" varchar(50),
	"MovementType" varchar(50),
	"Quantity" integer,
	"BUn" varchar(50),
	"GoodsRecipinet" varchar(50),
	"PO" varchar(50),
	"POItem" integer,
	"Vendor" varchar(50),
	"VendorName" varchar(50),
	"NetWeight" real,
	"GrossWeight" real,
	"Unit" varchar(50),
	"Amount" varchar(50),
	"Currency" varchar(50),
	"MvtTypeTxt" varchar(50),
	"MatDoc" integer,
	"Year" integer,
	"S" varchar(50),
	"MatName" varchar(50),
	"MatGroupDesc" varchar(50),
	"InputProject" varchar(50),
	"HeaderText" varchar(50)
);
--> statement-breakpoint
CREATE TABLE "S-ERP"."TB_SAP_MaterialRelease" (
	"id" serial PRIMARY KEY NOT NULL,
	"PostingGIdate" varchar(50),
	"Plant" varchar(50),
	"StorageLoc" varchar(50),
	"StockWBS" varchar(50),
	"InputWBS" varchar(50),
	"Material" varchar(50),
	"OldMaterialNumber" varchar(50),
	"MaterialDesc" varchar(50),
	"Spec" varchar(64),
	"Batch" varchar(50),
	"MovementType" varchar(50),
	"Quantity" integer,
	"BUn" varchar(50),
	"GoodsRecipinet" varchar(50),
	"NetWeight" real,
	"GrossWeight" real,
	"Unit" varchar(50),
	"Amount" varchar(50),
	"Currency" varchar(50),
	"MvtTypeTxt" varchar(50),
	"MaterialDocument" integer,
	"DocumentYear" integer,
	"S" varchar(50),
	"MatName" varchar(50),
	"MatGroupDesc" varchar(50),
	"InputProject" varchar(50),
	"HeaderText" varchar(50)
);
--> statement-breakpoint
CREATE TABLE "S-ERP"."TB_SAP_MaterialRepair" (
	"id" serial PRIMARY KEY NOT NULL,
	"BreakdownIndicator" varchar(50),
	"Order" integer,
	"OrderType" varchar(50),
	"OrderDescription" varchar(50),
	"MainWorkCenterDescription" varchar(50),
	"FunctionalLocation" varchar(50),
	"Equipment" integer,
	"EquipmentDescription" varchar(50),
	"EquipmentSortField" varchar(50),
	"TagNumber" varchar(50),
	"Notification" integer,
	"Priority" varchar(50),
	"PriorityDesc" varchar(50),
	"PlantSection" varchar(50),
	"PMActivityType" varchar(50),
	"MaintenancePlan" varchar(50),
	"StartDate" varchar(50),
	"FinishDate" varchar(50),
	"SystemStatus" varchar(50),
	"UserStatus" varchar(50),
	"CreatedBy" varchar(50),
	"Name" varchar(50),
	"PlanningPlant" varchar(50),
	"PlannerGroup" varchar(50),
	"PlannerGroupName" varchar(50),
	"MainWorkCenter" varchar(50),
	"Maintenanceplant" varchar(50),
	"PlantSectionDescription" varchar(50),
	"Priority_1" varchar(50),
	"Priority_2" varchar(50),
	"BasicStartTime" varchar(50),
	"BasicFinishTime" varchar(50),
	"ActualStartDate" varchar(50),
	"ActualStartTime" varchar(50),
	"ActualFinishDate" varchar(50),
	"ActualFinishTIme" varchar(50),
	"PlanCost" varchar(50),
	"ActualCost" varchar(50),
	"SettlementCost" varchar(50),
	"Balance" varchar(50),
	"Currency" varchar(50),
	"EquiCategory" integer,
	"ObjectType" varchar(50),
	"ABCIndicatior" varchar(50),
	"EWRNo" varchar(50)
);
--> statement-breakpoint
CREATE TABLE "S-ERP"."TB_SAP_MaterialStock" (
	"id" serial PRIMARY KEY NOT NULL,
	"WBS" varchar(50),
	"OldProjec" varchar(50),
	"Material" varchar(50),
	"MaterialD" varchar(50),
	"Specificat" varchar(50),
	"MRPType" varchar(50),
	"Batch" varchar(50),
	"Amount" varchar(50),
	"StorageLo" varchar(50),
	"StorageLo_1" varchar(50),
	"StorageBin" varchar(50),
	"Warehouse" varchar(50),
	"Warehouse_1" varchar(50),
	"MMTNo" varchar(50),
	"TNo" varchar(50),
	"BOXNo" varchar(50),
	"MaterialT" varchar(50),
	"Unrestrict" integer,
	"QIStock" integer,
	"BlockedSt" integer,
	"REMARK" varchar(50),
	"TotalStoc" integer,
	"Unit" varchar(50),
	"MAP" varchar(50),
	"NetWeight" real,
	"TotalWeig" real,
	"WeightUni" varchar(50),
	"Individual" varchar(50),
	"SpecialSt" varchar(50),
	"Vendor" varchar(50),
	"VendorDes" varchar(50),
	"MaterialG" varchar(50),
	"Procuremen" varchar(50),
	"PLMID" varchar(50),
	"ValveFitt" varchar(50),
	"BLNo" varchar(50),
	"TAGNO" varchar(50)
);
--> statement-breakpoint
CREATE TABLE "S-ERP"."TB_SAP_Order" (
	"id" serial PRIMARY KEY NOT NULL,
	"BreakdownIndicator" varchar(50),
	"Order" varchar(50),
	"OrderType" varchar(50),
	"OrderDescription" varchar(150),
	"MainWorkCenterDesc" varchar(100),
	"FunctionalLocation" varchar(50),
	"Equipment" varchar(50),
	"EquipmentDescriprion" varchar(100),
	"EquipmentSortField" varchar(50),
	"TagNumber" varchar(50),
	"Notification" varchar(50),
	"Priority" varchar(50),
	"PriorityDesc" varchar(50),
	"PlantSection" varchar(50),
	"PMActivityType" varchar(10),
	"MaintenancePlan" varchar(50),
	"StartDate" varchar(10),
	"FinishDate" varchar(10),
	"SystemStatus" varchar(50),
	"UserStatus" varchar(50),
	"CreatedBy" varchar(50),
	"Name" varchar(50),
	"PlanningPlant" varchar(50),
	"PlannerGroupName" varchar(50),
	"MainWorkCenter" varchar(50),
	"MaintenancePlant" varchar(50),
	"PlantSectionDescription" varchar(50),
	"COL1" varchar(50),
	"COL2" varchar(50),
	"BasicStartTime" varchar(50),
	"ActualStartDate" varchar(50),
	"ActualFinishTime" varchar(50),
	"PlanCost" integer,
	"ActualCost" integer,
	"SettlementCost" integer,
	"Balance" integer,
	"Currency" varchar(50),
	"EquiCategory" varchar(50),
	"ObjectType" varchar(50),
	"ABCOmdocatior" varchar(50),
	"EWRNo" varchar(50)
);
--> statement-breakpoint
CREATE TABLE "S-ERP"."TB_SAP_OrderBreakdown" (
	"id" serial PRIMARY KEY NOT NULL,
	"Order" integer,
	"OrderType" varchar(50),
	"FunctionalLocation" varchar(50),
	"FLDesc" varchar(50),
	"Equipment" integer,
	"EquipmentDesc" varchar(50),
	"ABCIndicator" varchar(50),
	"MainWorkCenter" varchar(50),
	"WorkCenterDesc" varchar(50),
	"PlannerGroup" varchar(50),
	"PlannerGroupDesc" varchar(50),
	"ActStartDate" varchar(50),
	"ActEndDate" varchar(50),
	"WorkTimeHR" real,
	"ObjectPart" varchar(50),
	"Damage" varchar(50),
	"Cause" varchar(50),
	"Activity" varchar(50),
	"MaterialCost" varchar(50),
	"LaborCost" varchar(50),
	"TotalCost" varchar(50),
	"Currency" varchar(50),
	"Breakdown" varchar(50),
	"MalfunctionStart" varchar(50),
	"StartTime" varchar(50),
	"MalfunctionEnd" varchar(50),
	"EndTime" varchar(50),
	"BreakdownDuration" real,
	"Plant" varchar(50),
	"Notification" integer,
	"ObjectNumber" varchar(50),
	"OrderDesc" varchar(64),
	"PlantSectionDesc" varchar(50),
	"TagNumber" varchar(50)
);
--> statement-breakpoint
CREATE TABLE "S-ERP"."TB_SAP_OrderConfirm" (
	"id" serial PRIMARY KEY NOT NULL,
	"Confirmation" varchar(50),
	"Count" varchar(50),
	"Order" varchar(50),
	"OpAc" varchar(50),
	"OperationText" varchar(200),
	"ActualWork" numeric(10, 1),
	"Unit" varchar(50),
	"CreateOn" varchar(10),
	"CreateBy" varchar(50),
	"ActualWorker" varchar(50),
	"Name" varchar(50),
	"Reversed" varchar(50),
	"CanceledConfirmation" varchar(50),
	"OrderDescription" varchar(200),
	"BUDAT" varchar(10),
	"STATUS" varchar(10),
	"IWERK" varchar(50),
	"INGRP" varchar(50),
	"GRWRK" varchar(50),
	"AUART" varchar(50)
);
--> statement-breakpoint
CREATE TABLE "S-ERP"."TB_SAP_OrderNotice" (
	"id" serial PRIMARY KEY NOT NULL,
	"Status" varchar(50),
	"Notification" integer,
	"Type" varchar(50),
	"Description" varchar(64),
	"PlanningPlant" varchar(50),
	"PlannerGroup" varchar(50),
	"NameOfPlannerGroup" varchar(50),
	"WorkCenter" varchar(50),
	"NameOfWorkCenter" varchar(50),
	"FunctionalLocation" varchar(50),
	"Equipment" integer,
	"TagNumber" varchar(50),
	"EquipmentDesc" varchar(50),
	"PlantSection" varchar(50),
	"CostCenter" varchar(50),
	"CostCenterDesc" varchar(50),
	"ABCIndicator" varchar(50),
	"NotificationDate" varchar(50),
	"Createdby" varchar(50),
	"SystemStatus" varchar(50),
	"UserStatus" varchar(50),
	"Order" integer,
	"Requester" varchar(50),
	"RequesterName" varchar(50),
	"CodeGroup" varchar(50),
	"Code" integer,
	"CodeDescription" varchar(50),
	"BreakdownIndicator" varchar(50),
	"Priority" varchar(50),
	"PriorityDesc" varchar(50),
	"NotifcatnType" varchar(50),
	"Name1" varchar(50),
	"WorkCenterInt" integer,
	"ObjectNumber" varchar(50),
	"CHAR05" varchar(50),
	"Link" varchar(50),
	"Link1" varchar(50),
	"Tooltip" varchar(50),
	"PlantSectionDesc" varchar(50),
	"Catalog" varchar(50),
	"Partner" varchar(50),
	"NotificationTime" varchar(50),
	"CompletionDate" varchar(50),
	"CompletionTime" varchar(50),
	"ExtRequester" varchar(50),
	"COL1" varchar(50),
	"OrderBasicStart" varchar(50),
	"EWRNo" varchar(50),
	"MalfunctionStart" varchar(50),
	"StartTime" varchar(50),
	"MalfunctionEnd" varchar(50),
	"EndTime" varchar(50),
	"BreakdownDuration" real
);
--> statement-breakpoint
ALTER TABLE "contracts" ALTER COLUMN "project_id" DROP NOT NULL;