Skip to content

feat: add created_at column to rollovers table#838

Open
joejohnson123[bot] wants to merge 3 commits intodevfrom
jj/rollover-created-at
Open

feat: add created_at column to rollovers table#838
joejohnson123[bot] wants to merge 3 commits intodevfrom
jj/rollover-created-at

Conversation

@joejohnson123
Copy link
Contributor

@joejohnson123 joejohnson123 bot commented Feb 26, 2026

What

Adds a created_at timestamp column to the rollovers table.

Changes

  • rolloverTable.ts: Added created_at column as nullable timestamp with time zone with defaultNow() — existing rows will have NULL, new rows get auto-timestamped by Postgres
  • rolloverUtils.ts: Set created_at: new Date() when constructing new rollovers in getRolloverUpdates
  • Test fixtures: Updated rollover fixture factory to include created_at

Notes

  • The column is nullable so existing data is unaffected
  • SQL DEFAULT NOW() means even if application code doesn't pass created_at, the DB will set it
  • Rollovers created via spread (...curRollover) in applyExistingRollovers.ts and getNewProductRollovers.ts will carry over the original created_at (or undefined → DB default)
  • You'll need to run drizzle-kit generate + drizzle-kit migrate to apply the migration

Summary by cubic

Add a created_at timestamp to rollovers to track when each rollover was created. Existing rows stay unchanged; new rows are auto-stamped by Postgres.

  • New Features

    • Schema: created_at timestamp with timezone, nullable, default NOW(); Zod field is nullable/optional; format matches our standard.
    • App: set created_at when building new rollovers.
    • Tests: fixture factory includes createdAt.
  • Migration

    • Run: drizzle-kit generate && drizzle-kit migrate.

Written for commit 26d426d. Summary will update on new commits.

Greptile Summary

Added a created_at timestamp column to the rollovers table for tracking when rollovers are created. The column is nullable to maintain backward compatibility with existing data and has a database default of NOW() to ensure new rows are automatically timestamped.

Key Changes:

  • [Improvements] Added created_at column to Drizzle table schema with defaultNow() and timezone support
  • [Improvements] Added created_at field to Zod schema as nullable and optional to match database behavior
  • [Improvements] Set created_at: new Date() when creating new rollovers in application code
  • [Improvements] Updated test fixtures to include createdAt parameter for consistency

The implementation correctly handles edge cases: existing rollovers retain NULL, newly created rollovers get timestamped by application code, and rollovers migrated via spread operations preserve their original timestamps or fall back to the database default.

Confidence Score: 5/5

  • This PR is safe to merge with no identified issues
  • The implementation is clean, well-thought-out, and backward compatible. The nullable column with database default ensures existing data is unaffected, while new rollovers are properly timestamped. All code paths that create rollovers are correctly handled.
  • No files require special attention

Important Files Changed

Filename Overview
shared/models/cusProductModels/cusEntModels/rolloverModels/rolloverTable.ts Added created_at timestamp column to Drizzle schema and Zod schema - nullable with DB default, properly typed
server/src/internal/customers/cusProducts/cusEnts/cusRollovers/rolloverUtils.ts Set created_at: new Date() when constructing new rollovers in getRolloverUpdates function
server/tests/utils/fixtures/db/rollovers.ts Updated test fixture factory to include createdAt parameter with default value of new Date()

Last reviewed commit: 76d7a28

(3/5) Reply to the agent's comments like "Can you suggest a fix for this @greptileai?" or ask follow-up questions!

- Add nullable created_at timestamp with SQL default NOW() to rollovers table
- Set created_at on new rollover construction in rolloverUtils
- Update test fixtures to include created_at
- Existing rollovers will have NULL created_at, new ones get auto-timestamped

Co-authored-by: Joe Johnson (JJ) <joejohnson123[bot]@users.noreply.github.com>
@vercel
Copy link

vercel bot commented Feb 26, 2026

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
autumn-vite Ready Ready Preview, Comment Feb 26, 2026 1:53pm

Request Review

Copy link
Contributor

@cubic-dev-ai cubic-dev-ai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No issues found across 3 files

Confidence score: 5/5

  • Automated review surfaced no issues in the provided summaries.
  • No files require special attention.

SirTenzin and others added 2 commits February 26, 2026 13:52
Co-authored-by: Joe Johnson (JJ) <joejohnson123[bot]@users.noreply.github.com>
Co-authored-by: Joe Johnson (JJ) <joejohnson123[bot]@users.noreply.github.com>
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