Skip to content

chore(model): align Customer column types and nullability with the DB#285

Merged
CryptoJones merged 1 commit into
masterfrom
chore/customer-model-align-with-db-types
May 19, 2026
Merged

chore(model): align Customer column types and nullability with the DB#285
CryptoJones merged 1 commit into
masterfrom
chore/customer-model-align-with-db-types

Conversation

@CryptoJones
Copy link
Copy Markdown
Owner

Summary

The Customer model was the outlier in app/models/: every string field was 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)) per field. Every other model (Worker, BillingType, InventoryItem, Job, Invoice, …) already uses TEXT / STRING(N) accurately with explicit allowNull declarations.

What changed

Aligned each Customer 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

Impact

Test plan

  • npm run lint && npm test — 760 passing, including the tests/unit/associations.test.js block that exercises the model definitions.

Proudly Made in Nebraska. Go Big Red! 🌽 https://xkcd.com/2347/

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>
@CryptoJones CryptoJones merged commit bdf0551 into master May 19, 2026
3 checks passed
@CryptoJones CryptoJones deleted the chore/customer-model-align-with-db-types branch May 19, 2026 15:42
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant