Skip to Content

DB

This is the database package, it is intended to have the schema definitions and handle the database migrations, we are using Drizzle ORM to handle all of these, please take a look at the documentations and current project files to check what we are doing currenttly.

Note: Please make sure that all schemas have thei respective relationship definitions

Lookup Table: UserTypes

FieldTypeDescriptionSQL Indicators
idserialAuto-incrementing primary keyPrimary Key, Not Null
namevarchar(256)Name of the user typeNot Null
descriptiontextDescription of the user typeNot Null
isActivebooleanIf the user type is activeNot Null, Default True

Lookup Table: PaymentMethods

FieldTypeDescriptionSQL Indicators
idserialAuto-incrementing primary keyPrimary Key, Not Null
namevarchar(256)Name of the payment methodNot Null
descriptiontextDescription of the payment methodNot Null
isActivebooleanIf the payment method is activeNot Null, Default True

Table: Users

FieldTypeDescriptionSQL Indicators
idvarchar(256)Auto-incrementing primary keyPrimary Key, Not Null
usernamevarchar(256)User’s unique usernameNot Null
emailvarchar(256)User’s email address
passwordvarchar(256)User’s passwordNot Null
namevarchar(256)User’s nameNot Null
paternalLastNamevarchar(256)User’s paternal last nameNot Null
maternalLastNamevarchar(256)User’s maternal last nameNot Null
profilePhotovarchar(256)URL to user’s profile photoNot Null
phonevarchar(256)User’s phone numberNot Null
mobilePhonevarchar(256)User’s mobile phone numberNot Null
phoneExtensionvarchar(256)Extension for the user’s phone numberNot Null
birthDatetimestampUser’s date of birthNot Null
addressvarchar(256)User’s addressNot Null
cityvarchar(256)City where the user livesNot Null
statevarchar(256)State where the user livesNot Null
countryvarchar(256)Country where the user livesNot Null
postalCodevarchar(256)User’s postal codeNot Null
startDatedateUser’s start dateNot Null
userTypeintegerUser’s typeNot Null, Foreign Key
imssNumbervarchar(256)User’s IMSS numberNot Null
imssDatedateUser’s IMSS dateNot Null
rfcvarchar(256)User’s RFCNot Null
emergencyContactNamevarchar(256)User’s emergency contact nameNot Null
emergencyContactPhonevarchar(256)User’s emergency contact phone numberNot Null
emergencyContactRelationshipvarchar(256)User’s relationship with emergency contactNot Null
createdAttimestampRecord creation dateNot Null, Default Now
updatedAttimestampRecord last update dateNot Null
createdBytextRecord creatorNot Null
updatedBytextRecord last updater
isActivebooleanIf the user is activeNot Null, Default True

Table: PaymentInfo

FieldTypeDescriptionSQL Indicators
idserialAuto-incrementing primary keyPrimary Key, Not Null
userIdintegerID of the userNot Null, Foreign Key
weeklyWagedouble precisionUser’s weekly wageNot Null
paymentMethodintegerID of the payment methodNot Null, Foreign Key
startDatedateStart date of the paymentNot Null
nomipaqIdvarchar(256)Nomipaq IDNot Null
deducibleAmountdouble precisionDeducible amountNot Null
ficticialbooleanIf the payment is ficticialNot Null, Default False

Lookup Table: DiscountTypes

FieldTypeDescriptionSQL Indicators
idserialAuto-incrementing primary keyPrimary Key, Not Null
namevarchar(256)Name of the discount typeNot Null
descriptiontextDescription of the discount typeNot Null
isActivebooleanIf the discount type is activeNot Null, Default True

Table: Discounts

FieldTypeDescriptionSQL Indicators
idserialAuto-incrementing primary keyPrimary Key, Not Null
paymentInfoIdintegerID of the payment infoNot Null, Foreign Key
discountTypeintegerID of the discount typeNot Null, Foreign Key
amountdouble precisionDiscount amountNot Null
descriptiontextDescription of the discountNot Null
createdAttimestampRecord creation dateNot Null, Default Now
updatedAttimestampRecord last update dateNot Null
createdBytextRecord creatorNot Null
updatedBytextRecord last updater
isActivebooleanIf the discount is activeNot Null, Default True

Table: BankAccounts

FieldTypeDescriptionSQL Indicators
idserialAuto-incrementing primary keyPrimary Key, Not Null
userIdintegerID of the userNot Null, Foreign Key
bankNamevarchar(256)Name of the bankNot Null
accountNumbervarchar(256)Bank account numberNot Null
clabevarchar(256)CLABE of the bank accountNot Null
createdAttimestampRecord creation dateNot Null, Default Now
updatedAttimestampRecord last update dateNot Null
createdBytextRecord creatorNot Null
updatedBytextRecord last updater
isActivebooleanIf the bank account is activeNot Null, Default True

Table: BonusCategories

FieldTypeDescriptionSQL Indicators
idvarchar(256)Unique identifier of the bonus categoryPK, Not Null
nametextName of the bonus categoryNot Null
descriptiontextDescription of the bonus categoryNot Null
createdAttimestampRecord creation dateDefault: Now, Not Null
updatedAttimestampRecord last update dateNot Null
isActivebooleanIndicates if the bonus category is activeDefault: true, Not Null
createdBytextUser who created the recordNot Null
updatedBytextUser who last updated the record

Table: Bonus

ColumnData TypeDescriptionSQL Indicators
idvarchar(256)Unique identifier for the bonus.PK, Not Null, Unique
nametextName of the bonus.Not Null
descriptiontextDescription of the bonus.Not Null
amountdouble precisionAmount of the bonus.Not Null
categoryIdtextIdentifier of the category that the bonus belongs to. It’s a foreign key referencing bonusCategories.id.FK bonusCategories.id, Not Null, On Delete Restrict, On Update Cascade
createdAttimestampDate and time when the bonus was created. It’s automatically set when creating the bonus.Not Null, Default Now
updatedAttimestampDate and time when the bonus was last updated.Not Null
isActivebooleanIndicates whether the bonus is active. Defaults to true.Not Null, Default True
createdBytextUser who created the bonus.Not Null
updatedBytextUser who last updated the bonus.

Lookup Table: LicenseTypes

FieldTypeDescriptionSQL Indicators
idserialAuto-incrementing primary keyPrimary Key, Not Null
nametextName of the license typeNot Null
descriptiontextDescription of the license typeNot Null
createdAttimestampRecord creation dateNot Null, Default Now
updatedAttimestampRecord last update dateNot Null
isActivebooleanIf the license type is activeNot Null, Default True
createdByintegerRecord creatorNot Null
updatedByintegerRecord last updater

Table: Licenses

FieldTypeDescriptionSQL Indicators
idserialAuto-incrementing primary keyPrimary Key, Not Null
userIdintegerID of the userNot Null, Foreign Key
descriptiontextDescription of the licenseNot Null
expedituretimestampExpediture date of the licenseNot Null
expirationtimestampExpiration date of the licenseNot Null
licenseNumbertextLicense numberNot Null
typeIdintegerID of the license typeNot Null, Foreign Key
createdAttimestampRecord creation dateNot Null, Default Now
updatedAttimestampRecord last update dateNot Null
isActivebooleanIf the license is activeNot Null, Default True
createdByintegerRecord creatorNot Null
updatedByintegerRecord last updater

Table: AllowedConnexionTimes

FieldTypeDescriptionSQL Indicators
idserialAuto-incrementing primary keyPrimary Key, Not Null
userIdintegerID of the userNot Null, Foreign Key
weekDayintegerWeek dayNot Null
startHourintegerStart hour of the allowed connectionNot Null
endHourintegerEnd hour of the allowed connectionNot Null
createdAttimestampRecord creation dateNot Null, Default Now
updatedAttimestampRecord last update dateNot Null
isActivebooleanIf the allowed connection time is activeNot Null, Default True
createdByintegerRecord creatorNot Null
updatedByintegerRecord last updater

Table: UserLogBook

FieldTypeDescriptionSQL Indicators
idserialAuto-incrementing primary keyPrimary Key, Not Null
userIdintegerID of the userNot Null, Foreign Key
actionvarchar(256)Action performed by the userNot Null
createdAttimestampRecord creation dateNot Null, Default Now

Relationship ClassDiagram

Last updated on