Skip to content

Commit

Permalink
Add constraints to UnsavedRow types (#36)
Browse files Browse the repository at this point in the history
  • Loading branch information
oyvindberg committed Sep 15, 2023
1 parent 2f824db commit dab5bbd
Show file tree
Hide file tree
Showing 61 changed files with 412 additions and 203 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -34,22 +34,28 @@ case class EmployeeRowUnsaved(
loginid: /* max 256 chars */ String,
/** Work title such as Buyer or Sales Representative. */
jobtitle: /* max 50 chars */ String,
/** Date of birth. */
/** Date of birth.
Constraint CK_Employee_BirthDate affecting columns "birthdate": (((birthdate >= '1930-01-01'::date) AND (birthdate <= (now() - '18 years'::interval)))) */
birthdate: TypoLocalDate,
/** M = Married, S = Single */
/** M = Married, S = Single
Constraint CK_Employee_MaritalStatus affecting columns "maritalstatus": ((upper((maritalstatus)::text) = ANY (ARRAY['M'::text, 'S'::text]))) */
maritalstatus: /* bpchar, max 1 chars */ String,
/** M = Male, F = Female */
/** M = Male, F = Female
Constraint CK_Employee_Gender affecting columns "gender": ((upper((gender)::text) = ANY (ARRAY['M'::text, 'F'::text]))) */
gender: /* bpchar, max 1 chars */ String,
/** Employee hired on this date. */
/** Employee hired on this date.
Constraint CK_Employee_HireDate affecting columns "hiredate": (((hiredate >= '1996-07-01'::date) AND (hiredate <= (now() + '1 day'::interval)))) */
hiredate: TypoLocalDate,
/** Default: true
Job classification. 0 = Hourly, not exempt from collective bargaining. 1 = Salaried, exempt from collective bargaining. */
salariedflag: Defaulted[Flag] = Defaulted.UseDefault,
/** Default: 0
Number of available vacation hours. */
Number of available vacation hours.
Constraint CK_Employee_VacationHours affecting columns "vacationhours": (((vacationhours >= '-40'::integer) AND (vacationhours <= 240))) */
vacationhours: Defaulted[TypoShort] = Defaulted.UseDefault,
/** Default: 0
Number of available sick leave hours. */
Number of available sick leave hours.
Constraint CK_Employee_SickLeaveHours affecting columns "sickleavehours": (((sickleavehours >= 0) AND (sickleavehours <= 120))) */
sickleavehours: Defaulted[TypoShort] = Defaulted.UseDefault,
/** Default: true
0 = Inactive, 1 = Active */
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,9 +33,11 @@ case class EmployeedepartmenthistoryRowUnsaved(
/** Identifies which 8-hour shift the employee works. Foreign key to Shift.Shift.ID.
Points to [[shift.ShiftRow.shiftid]] */
shiftid: ShiftId,
/** Date the employee started work in the department. */
/** Date the employee started work in the department.
Constraint CK_EmployeeDepartmentHistory_EndDate affecting columns "enddate", "startdate": (((enddate >= startdate) OR (enddate IS NULL))) */
startdate: TypoLocalDate,
/** Date the employee left the department. NULL = Current department. */
/** Date the employee left the department. NULL = Current department.
Constraint CK_EmployeeDepartmentHistory_EndDate affecting columns "enddate", "startdate": (((enddate >= startdate) OR (enddate IS NULL))) */
enddate: Option[TypoLocalDate],
/** Default: now() */
modifieddate: Defaulted[TypoLocalDateTime] = Defaulted.UseDefault
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,11 @@ case class EmployeepayhistoryRowUnsaved(
businessentityid: BusinessentityId,
/** Date the change in pay is effective */
ratechangedate: TypoLocalDateTime,
/** Salary hourly rate. */
/** Salary hourly rate.
Constraint CK_EmployeePayHistory_Rate affecting columns "rate": (((rate >= 6.50) AND (rate <= 200.00))) */
rate: BigDecimal,
/** 1 = Salary received monthly, 2 = Salary received biweekly */
/** 1 = Salary received monthly, 2 = Salary received biweekly
Constraint CK_EmployeePayHistory_PayFrequency affecting columns "payfrequency": ((payfrequency = ANY (ARRAY[1, 2]))) */
payfrequency: TypoShort,
/** Default: now() */
modifieddate: Defaulted[TypoLocalDateTime] = Defaulted.UseDefault
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,8 @@ case class PersonRowUnsaved(
/** Primary key for Person records.
Points to [[businessentity.BusinessentityRow.businessentityid]] */
businessentityid: BusinessentityId,
/** Primary type of person: SC = Store Contact, IN = Individual (retail) customer, SP = Sales person, EM = Employee (non-sales), VC = Vendor contact, GC = General contact */
/** Primary type of person: SC = Store Contact, IN = Individual (retail) customer, SP = Sales person, EM = Employee (non-sales), VC = Vendor contact, GC = General contact
Constraint CK_Person_PersonType affecting columns "persontype": (((persontype IS NULL) OR (upper((persontype)::text) = ANY (ARRAY['SC'::text, 'VC'::text, 'IN'::text, 'EM'::text, 'SP'::text, 'GC'::text])))) */
persontype: /* bpchar, max 2 chars */ String,
/** A courtesy title. For example, Mr. or Ms. */
title: Option[/* max 8 chars */ String],
Expand All @@ -49,7 +50,8 @@ case class PersonRowUnsaved(
0 = The data in FirstName and LastName are stored in western style (first name, last name) order. 1 = Eastern style (last name, first name) order. */
namestyle: Defaulted[NameStyle] = Defaulted.UseDefault,
/** Default: 0
0 = Contact does not wish to receive e-mail promotions, 1 = Contact does wish to receive e-mail promotions from AdventureWorks, 2 = Contact does wish to receive e-mail promotions from AdventureWorks and selected partners. */
0 = Contact does not wish to receive e-mail promotions, 1 = Contact does wish to receive e-mail promotions from AdventureWorks, 2 = Contact does wish to receive e-mail promotions from AdventureWorks and selected partners.
Constraint CK_Person_EmailPromotion affecting columns "emailpromotion": (((emailpromotion >= 0) AND (emailpromotion <= 2))) */
emailpromotion: Defaulted[Int] = Defaulted.UseDefault,
/** Default: uuid_generate_v1() */
rowguid: Defaulted[TypoUUID] = Defaulted.UseDefault,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,26 +24,34 @@ import scala.util.Try
/** This class corresponds to a row in table `production.billofmaterials` which has not been persisted yet */
case class BillofmaterialsRowUnsaved(
/** Parent product identification number. Foreign key to Product.ProductID.
Points to [[product.ProductRow.productid]] */
Points to [[product.ProductRow.productid]]
Constraint CK_BillOfMaterials_BOMLevel affecting columns "bomlevel", "productassemblyid", "perassemblyqty": ((((productassemblyid IS NULL) AND (bomlevel = 0) AND (perassemblyqty = 1.00)) OR ((productassemblyid IS NOT NULL) AND (bomlevel >= 1))))
Constraint CK_BillOfMaterials_ProductAssemblyID affecting columns "productassemblyid", "componentid": ((productassemblyid <> componentid)) */
productassemblyid: Option[ProductId],
/** Component identification number. Foreign key to Product.ProductID.
Points to [[product.ProductRow.productid]] */
Points to [[product.ProductRow.productid]]
Constraint CK_BillOfMaterials_ProductAssemblyID affecting columns "productassemblyid", "componentid": ((productassemblyid <> componentid)) */
componentid: ProductId,
/** Date the component stopped being used in the assembly item. */
/** Date the component stopped being used in the assembly item.
Constraint CK_BillOfMaterials_EndDate affecting columns "enddate", "startdate": (((enddate > startdate) OR (enddate IS NULL))) */
enddate: Option[TypoLocalDateTime],
/** Standard code identifying the unit of measure for the quantity.
Points to [[unitmeasure.UnitmeasureRow.unitmeasurecode]] */
unitmeasurecode: UnitmeasureId,
/** Indicates the depth the component is from its parent (AssemblyID). */
/** Indicates the depth the component is from its parent (AssemblyID).
Constraint CK_BillOfMaterials_BOMLevel affecting columns "bomlevel", "productassemblyid", "perassemblyqty": ((((productassemblyid IS NULL) AND (bomlevel = 0) AND (perassemblyqty = 1.00)) OR ((productassemblyid IS NOT NULL) AND (bomlevel >= 1)))) */
bomlevel: TypoShort,
/** Default: nextval('production.billofmaterials_billofmaterialsid_seq'::regclass)
Primary key for BillOfMaterials records. */
billofmaterialsid: Defaulted[BillofmaterialsId] = Defaulted.UseDefault,
/** Default: now()
Date the component started being used in the assembly item. */
Date the component started being used in the assembly item.
Constraint CK_BillOfMaterials_EndDate affecting columns "enddate", "startdate": (((enddate > startdate) OR (enddate IS NULL))) */
startdate: Defaulted[TypoLocalDateTime] = Defaulted.UseDefault,
/** Default: 1.00
Quantity of the component needed to create the assembly. */
Quantity of the component needed to create the assembly.
Constraint CK_BillOfMaterials_BOMLevel affecting columns "bomlevel", "productassemblyid", "perassemblyqty": ((((productassemblyid IS NULL) AND (bomlevel = 0) AND (perassemblyqty = 1.00)) OR ((productassemblyid IS NOT NULL) AND (bomlevel >= 1))))
Constraint CK_BillOfMaterials_PerAssemblyQty affecting columns "perassemblyqty": ((perassemblyqty >= 1.00)) */
perassemblyqty: Defaulted[BigDecimal] = Defaulted.UseDefault,
/** Default: now() */
modifieddate: Defaulted[TypoLocalDateTime] = Defaulted.UseDefault
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,8 @@ case class DocumentRowUnsaved(
fileextension: Option[/* max 8 chars */ String],
/** Revision number of the document. */
revision: /* bpchar, max 5 chars */ String,
/** 1 = Pending approval, 2 = Approved, 3 = Obsolete */
/** 1 = Pending approval, 2 = Approved, 3 = Obsolete
Constraint CK_Document_Status affecting columns "status": (((status >= 1) AND (status <= 3))) */
status: TypoShort,
/** Document abstract. */
documentsummary: Option[String],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,10 +27,12 @@ case class LocationRowUnsaved(
Primary key for Location records. */
locationid: Defaulted[LocationId] = Defaulted.UseDefault,
/** Default: 0.00
Standard hourly cost of the manufacturing location. */
Standard hourly cost of the manufacturing location.
Constraint CK_Location_CostRate affecting columns "costrate": ((costrate >= 0.00)) */
costrate: Defaulted[BigDecimal] = Defaulted.UseDefault,
/** Default: 0.00
Work capacity (in hours) of the manufacturing location. */
Work capacity (in hours) of the manufacturing location.
Constraint CK_Location_Availability affecting columns "availability": ((availability >= 0.00)) */
availability: Defaulted[BigDecimal] = Defaulted.UseDefault,
/** Default: now() */
modifieddate: Defaulted[TypoLocalDateTime] = Defaulted.UseDefault
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,13 +33,17 @@ case class ProductRowUnsaved(
productnumber: /* max 25 chars */ String,
/** Product color. */
color: Option[/* max 15 chars */ String],
/** Minimum inventory quantity. */
/** Minimum inventory quantity.
Constraint CK_Product_SafetyStockLevel affecting columns "safetystocklevel": ((safetystocklevel > 0)) */
safetystocklevel: TypoShort,
/** Inventory level that triggers a purchase order or work order. */
/** Inventory level that triggers a purchase order or work order.
Constraint CK_Product_ReorderPoint affecting columns "reorderpoint": ((reorderpoint > 0)) */
reorderpoint: TypoShort,
/** Standard cost of the product. */
/** Standard cost of the product.
Constraint CK_Product_StandardCost affecting columns "standardcost": ((standardcost >= 0.00)) */
standardcost: BigDecimal,
/** Selling price. */
/** Selling price.
Constraint CK_Product_ListPrice affecting columns "listprice": ((listprice >= 0.00)) */
listprice: BigDecimal,
/** Product size. */
size: Option[/* max 5 chars */ String],
Expand All @@ -49,25 +53,32 @@ case class ProductRowUnsaved(
/** Unit of measure for Weight column.
Points to [[unitmeasure.UnitmeasureRow.unitmeasurecode]] */
weightunitmeasurecode: Option[UnitmeasureId],
/** Product weight. */
/** Product weight.
Constraint CK_Product_Weight affecting columns "weight": ((weight > 0.00)) */
weight: Option[BigDecimal],
/** Number of days required to manufacture the product. */
/** Number of days required to manufacture the product.
Constraint CK_Product_DaysToManufacture affecting columns "daystomanufacture": ((daystomanufacture >= 0)) */
daystomanufacture: Int,
/** R = Road, M = Mountain, T = Touring, S = Standard */
/** R = Road, M = Mountain, T = Touring, S = Standard
Constraint CK_Product_ProductLine affecting columns "productline": (((upper((productline)::text) = ANY (ARRAY['S'::text, 'T'::text, 'M'::text, 'R'::text])) OR (productline IS NULL))) */
productline: Option[/* bpchar, max 2 chars */ String],
/** H = High, M = Medium, L = Low */
/** H = High, M = Medium, L = Low
Constraint CK_Product_Class affecting columns "class": (((upper((class)::text) = ANY (ARRAY['L'::text, 'M'::text, 'H'::text])) OR (class IS NULL))) */
`class`: Option[/* bpchar, max 2 chars */ String],
/** W = Womens, M = Mens, U = Universal */
/** W = Womens, M = Mens, U = Universal
Constraint CK_Product_Style affecting columns "style": (((upper((style)::text) = ANY (ARRAY['W'::text, 'M'::text, 'U'::text])) OR (style IS NULL))) */
style: Option[/* bpchar, max 2 chars */ String],
/** Product is a member of this product subcategory. Foreign key to ProductSubCategory.ProductSubCategoryID.
Points to [[productsubcategory.ProductsubcategoryRow.productsubcategoryid]] */
productsubcategoryid: Option[ProductsubcategoryId],
/** Product is a member of this product model. Foreign key to ProductModel.ProductModelID.
Points to [[productmodel.ProductmodelRow.productmodelid]] */
productmodelid: Option[ProductmodelId],
/** Date the product was available for sale. */
/** Date the product was available for sale.
Constraint CK_Product_SellEndDate affecting columns "sellenddate", "sellstartdate": (((sellenddate >= sellstartdate) OR (sellenddate IS NULL))) */
sellstartdate: TypoLocalDateTime,
/** Date the product was no longer available for sale. */
/** Date the product was no longer available for sale.
Constraint CK_Product_SellEndDate affecting columns "sellenddate", "sellstartdate": (((sellenddate >= sellstartdate) OR (sellenddate IS NULL))) */
sellenddate: Option[TypoLocalDateTime],
/** Date the product was discontinued. */
discontinueddate: Option[TypoLocalDateTime],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,11 +24,14 @@ case class ProductcosthistoryRowUnsaved(
/** Product identification number. Foreign key to Product.ProductID
Points to [[product.ProductRow.productid]] */
productid: ProductId,
/** Product cost start date. */
/** Product cost start date.
Constraint CK_ProductCostHistory_EndDate affecting columns "startdate", "enddate": (((enddate >= startdate) OR (enddate IS NULL))) */
startdate: TypoLocalDateTime,
/** Product cost end date. */
/** Product cost end date.
Constraint CK_ProductCostHistory_EndDate affecting columns "startdate", "enddate": (((enddate >= startdate) OR (enddate IS NULL))) */
enddate: Option[TypoLocalDateTime],
/** Standard cost of the product. */
/** Standard cost of the product.
Constraint CK_ProductCostHistory_StandardCost affecting columns "standardcost": ((standardcost >= 0.00)) */
standardcost: BigDecimal,
/** Default: now() */
modifieddate: Defaulted[TypoLocalDateTime] = Defaulted.UseDefault
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,8 @@ case class ProductinventoryRowUnsaved(
locationid: LocationId,
/** Storage compartment within an inventory location. */
shelf: /* max 10 chars */ String,
/** Storage container on a shelf in an inventory location. */
/** Storage container on a shelf in an inventory location.
Constraint CK_ProductInventory_Bin affecting columns "bin": (((bin >= 0) AND (bin <= 100))) */
bin: TypoShort,
/** Default: 0
Quantity of products in the inventory location. */
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,11 +24,14 @@ case class ProductlistpricehistoryRowUnsaved(
/** Product identification number. Foreign key to Product.ProductID
Points to [[product.ProductRow.productid]] */
productid: ProductId,
/** List price start date. */
/** List price start date.
Constraint CK_ProductListPriceHistory_EndDate affecting columns "enddate", "startdate": (((enddate >= startdate) OR (enddate IS NULL))) */
startdate: TypoLocalDateTime,
/** List price end date */
/** List price end date
Constraint CK_ProductListPriceHistory_EndDate affecting columns "enddate", "startdate": (((enddate >= startdate) OR (enddate IS NULL))) */
enddate: Option[TypoLocalDateTime],
/** Product list price. */
/** Product list price.
Constraint CK_ProductListPriceHistory_ListPrice affecting columns "listprice": ((listprice > 0.00)) */
listprice: BigDecimal,
/** Default: now() */
modifieddate: Defaulted[TypoLocalDateTime] = Defaulted.UseDefault
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,8 @@ case class ProductreviewRowUnsaved(
reviewername: Name,
/** Reviewer's e-mail address. */
emailaddress: /* max 50 chars */ String,
/** Product rating given by the reviewer. Scale is 1 to 5 with 5 as the highest rating. */
/** Product rating given by the reviewer. Scale is 1 to 5 with 5 as the highest rating.
Constraint CK_ProductReview_Rating affecting columns "rating": (((rating >= 1) AND (rating <= 5))) */
rating: Int,
/** Reviewer's comments */
comments: Option[/* max 3850 chars */ String],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,8 @@ case class TransactionhistoryRowUnsaved(
productid: ProductId,
/** Purchase order, sales order, or work order identification number. */
referenceorderid: Int,
/** W = WorkOrder, S = SalesOrder, P = PurchaseOrder */
/** W = WorkOrder, S = SalesOrder, P = PurchaseOrder
Constraint CK_TransactionHistory_TransactionType affecting columns "transactiontype": ((upper((transactiontype)::text) = ANY (ARRAY['W'::text, 'S'::text, 'P'::text]))) */
transactiontype: /* bpchar, max 1 chars */ String,
/** Product quantity. */
quantity: Int,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,8 @@ case class TransactionhistoryarchiveRowUnsaved(
productid: Int,
/** Purchase order, sales order, or work order identification number. */
referenceorderid: Int,
/** W = Work Order, S = Sales Order, P = Purchase Order */
/** W = Work Order, S = Sales Order, P = Purchase Order
Constraint CK_TransactionHistoryArchive_TransactionType affecting columns "transactiontype": ((upper((transactiontype)::text) = ANY (ARRAY['W'::text, 'S'::text, 'P'::text]))) */
transactiontype: /* bpchar, max 1 chars */ String,
/** Product quantity. */
quantity: Int,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,13 +26,17 @@ case class WorkorderRowUnsaved(
/** Product identification number. Foreign key to Product.ProductID.
Points to [[product.ProductRow.productid]] */
productid: ProductId,
/** Product quantity to build. */
/** Product quantity to build.
Constraint CK_WorkOrder_OrderQty affecting columns "orderqty": ((orderqty > 0)) */
orderqty: Int,
/** Quantity that failed inspection. */
/** Quantity that failed inspection.
Constraint CK_WorkOrder_ScrappedQty affecting columns "scrappedqty": ((scrappedqty >= 0)) */
scrappedqty: TypoShort,
/** Work order start date. */
/** Work order start date.
Constraint CK_WorkOrder_EndDate affecting columns "startdate", "enddate": (((enddate >= startdate) OR (enddate IS NULL))) */
startdate: TypoLocalDateTime,
/** Work order end date. */
/** Work order end date.
Constraint CK_WorkOrder_EndDate affecting columns "startdate", "enddate": (((enddate >= startdate) OR (enddate IS NULL))) */
enddate: Option[TypoLocalDateTime],
/** Work order due date. */
duedate: TypoLocalDateTime,
Expand Down
Loading

0 comments on commit dab5bbd

Please sign in to comment.