chore(model): align Customer column types and nullability with the DB#285
Merged
Merged
Conversation
The Customer model was the outlier in the models/ directory: every string field declared as Sequelize.STRING (varchar 255 default) with no allowNull, even though setup/TimeTracker.sql has the corresponding columns as text NOT NULL (or text NULL, varchar(2), varchar(32)) for specific fields. Every other model (Worker, BillingType, InventoryItem, Job, Invoice, ...) already used TEXT / STRING(N) accurately with explicit allowNull declarations. Aligned each field with the DDL: - custCompanyName / custFName / custLName: TEXT, allowNull: false - custAddress1 / 2 / custCity / custZip / custEmail: TEXT - custState: STRING(2) - custPhone: STRING(32) - custArch: BOOLEAN, allowNull: false, defaultValue: false - custCompId: INTEGER, allowNull: false No behavior change for typical callers: - Zod validation (#265, #277) already enforces the NOT NULL fields + custState length at the request boundary, so this is purely defense in depth. - Removing the STRING-255 implicit cap relaxes the model to match the actual DB TEXT (unbounded), but zod's max(255) still caps inputs at the API layer. 760 tests still pass. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
The
Customermodel was the outlier inapp/models/: every string field was declared asSequelize.STRING(varchar 255 default) with noallowNull, even thoughsetup/TimeTracker.sqlhas the corresponding columns astext NOT NULL(ortext NULL,varchar(2),varchar(32)) per field. Every other model (Worker, BillingType, InventoryItem, Job, Invoice, …) already usesTEXT/STRING(N)accurately with explicitallowNulldeclarations.What changed
Aligned each Customer field with the DDL:
custCompanyName/custFName/custLName:TEXT,allowNull: falsecustAddress1/2/custCity/custZip/custEmail:TEXTcustState:STRING(2)custPhone:STRING(32)custArch:BOOLEAN,allowNull: false,defaultValue: falsecustCompId:INTEGER,allowNull: falseImpact
custStatelength at the request boundary; this is defense in depth at the sequelize layer.textDB column; relaxing toTEXTremoves that artificial ceiling. Zod'smax(255)continues to cap inputs at the API.Test plan
npm run lint && npm test— 760 passing, including thetests/unit/associations.test.jsblock that exercises the model definitions.Proudly Made in Nebraska. Go Big Red! 🌽 https://xkcd.com/2347/