Skip to content

chore(db): flip global timestamps default from false to true to match every model's explicit override#148

Merged
CryptoJones merged 1 commit into
masterfrom
chore/db-config-timestamps-default
May 19, 2026
Merged

chore(db): flip global timestamps default from false to true to match every model's explicit override#148
CryptoJones merged 1 commit into
masterfrom
chore/db-config-timestamps-default

Conversation

@CryptoJones
Copy link
Copy Markdown
Owner

Closes #147.

Summary

app/config/db.config.js set define.timestamps: false as a global default for every Sequelize model. But every one of the 18 model files in app/models/ overrides it with timestamps: true (introduced alongside the 20260520-timestamps migration). The global default never matched reality and sat as dead, misleading code.

The trap is for future models. A new model file that forgets the explicit timestamps: true override would silently inherit the global false and skip the timestamps every other table has — subtle bug, easy to miss in review.

Flip the global to true so new models inherit the right behaviour without ceremony. Existing per-model overrides stay (visible documentation; a follow-up could strip them for consistency). No behaviour change for any existing model.

Test plan

  • npm run lint — clean
  • npm test — 520 passed, 15 skipped (unchanged from master; no model's behaviour shifts)

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

… every model's explicit override

`app/config/db.config.js` set `define.timestamps: false` as a global
default for every Sequelize model. But every one of the 18 model
files in `app/models/` overrides it with `timestamps: true`
(introduced alongside the 20260520-timestamps migration that added
`createdAt` / `updatedAt` columns to every domain table + the
ApiKey / ApiMaster auth tables). The global default never matched
reality, so it sat as dead, misleading code: any reader inspecting
db.config.js to learn the project's stance on timestamps got the
wrong answer.

The trap is for future models. A new model file that forgets the
explicit `timestamps: true` override would silently inherit the
global `false` and skip the timestamps that every other table has.
Subtle bug, hard to spot in code review.

Flip the global to `true` so new models inherit the right behaviour
without ceremony. Existing models keep their explicit overrides for
now — they're redundant but they also serve as visible
documentation of the project's stance, and removing them is a
separate consistency-cleanup PR if anyone wants it.

No behavior change for existing models; `npm test` unchanged at
520 passed.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@CryptoJones CryptoJones merged commit e27ddac into master May 19, 2026
3 checks passed
@CryptoJones CryptoJones deleted the chore/db-config-timestamps-default branch May 19, 2026 06:59
CryptoJones added a commit that referenced this pull request May 19, 2026
…, not false (#178)

PR #148 flipped `db.config.js`'s global `define.timestamps` default
from `false` to `true` so every domain model inherits Sequelize's
auto-populated `createdAt` / `updatedAt` without an explicit override.

`sequelize-cli.config.js` — the config file the migrate CLI reads —
was missed and still declared `timestamps: false`. In practice this
doesn't break anything today: migrations use `queryInterface`
directly, not the model layer, so the `define` default never gets
consulted from the CLI path. But two adjacent files declaring
opposite defaults is a smell that would burn a future contributor
who tried to add model-based logic to a migration.

Flip the cli config's value to `true` to match the runtime, and pin
both `define.timestamps` and `define.schema` agreement in a new
`tests/unit/sequelize-cli-config.test.js` so a future drift fails
loudly instead of silently.

Co-authored-by: Aaron K. Clark <akclark@thenetwerk.net>
Co-authored-by: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
CryptoJones added a commit that referenced this pull request May 19, 2026
…#261)

`app/config/env.js` exported two fields neither consumer reads:

  - `dialect: 'postgres'` — `db.config.js` (line 28) and
    `sequelize-cli.config.js` (line 20) both hardcode `'postgres'`
    inline; neither references `env.dialect`.

  - `define: { timestamps: false }` — both consumers override with
    `define: { schema: 'dbo', timestamps: true }`, so the `false`
    in env.js was both dead AND misleading (a reader scanning env.js
    could conclude the runtime has timestamps disabled when in fact
    PR #148 flipped both consumers to `true`).

Verified via grep — nothing in app/, server.js, or tests/ touches
`env.dialect` or `env.define`. Drop both. No behavior change;
just stops env.js from misrepresenting the runtime.

688 tests still pass.

Co-authored-by: Aaron K. Clark <akclark@thenetwerk.net>
Co-authored-by: Claude Opus 4.7 (1M context) <noreply@anthropic.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.

db.config: misleading global timestamps=false default that every model overrides

1 participant