From 3a4f410db171b9b4f0a1166db494e8a958fd4a6b Mon Sep 17 00:00:00 2001 From: "Aaron K. Clark" Date: Tue, 19 May 2026 03:54:17 -0500 Subject: [PATCH] =?UTF-8?q?chore(sequelize-cli):=20sync=20define.timestamp?= =?UTF-8?q?s=20with=20db.config.js=20=E2=80=94=20true,=20not=20false?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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: Claude Opus 4.7 (1M context) --- app/config/sequelize-cli.config.js | 13 ++++++++- tests/unit/sequelize-cli-config.test.js | 39 +++++++++++++++++++++++++ 2 files changed, 51 insertions(+), 1 deletion(-) create mode 100644 tests/unit/sequelize-cli-config.test.js diff --git a/app/config/sequelize-cli.config.js b/app/config/sequelize-cli.config.js index b7535a0..dfc6f5d 100644 --- a/app/config/sequelize-cli.config.js +++ b/app/config/sequelize-cli.config.js @@ -20,7 +20,18 @@ const common = { dialect: 'postgres', define: { schema: 'dbo', - timestamps: false, + // Keep in sync with db.config.js's `define.timestamps`. + // The runtime flipped this to `true` in PR #148 so every + // domain model inherits auto-populated createdAt/updatedAt + // instead of carrying an explicit per-model override. + // sequelize-cli's migration runner doesn't currently exercise + // this default (migrations use queryInterface directly, not + // models), but a future contributor adding model-based code + // paths to a migration would otherwise get silently + // inconsistent behavior between `npm start` and + // `npm run migrate`. tests/unit/sequelize-cli-config.test.js + // pins the two configs in agreement. + timestamps: true, }, // Migrations land in the dbo schema's SequelizeMeta table so we // don't pollute the public schema with framework bookkeeping. diff --git a/tests/unit/sequelize-cli-config.test.js b/tests/unit/sequelize-cli-config.test.js new file mode 100644 index 0000000..3286c30 --- /dev/null +++ b/tests/unit/sequelize-cli-config.test.js @@ -0,0 +1,39 @@ +// SPDX-License-Identifier: Apache-2.0 +// Copyright 2026 Aaron K. Clark +// +// Pin that `app/config/sequelize-cli.config.js` and +// `app/config/db.config.js` agree on the global Sequelize `define` +// defaults that affect schema-shape decisions (schema, timestamps). +// Drift between them is a silent bug source — npm start vs. +// npm run migrate could otherwise inherit different defaults. +// PR #148 flipped db.config.js's `timestamps` from false to true and +// missed sequelize-cli.config.js; this guards against a recurrence. + +import { describe, test, expect } from 'vitest'; + +const dbConfig = require('../../app/config/db.config.js'); +const cliConfig = require('../../app/config/sequelize-cli.config.js'); + +describe('sequelize-cli.config.js stays in sync with db.config.js', () => { + const runtimeDefine = dbConfig.sequelize.options.define; + + test('cli `development` env mirrors runtime `define.timestamps`', () => { + expect(cliConfig.development.define.timestamps).toBe(runtimeDefine.timestamps); + }); + test('cli `test` env mirrors runtime `define.timestamps`', () => { + expect(cliConfig.test.define.timestamps).toBe(runtimeDefine.timestamps); + }); + test('cli `production` env mirrors runtime `define.timestamps`', () => { + expect(cliConfig.production.define.timestamps).toBe(runtimeDefine.timestamps); + }); + + test('cli `development` env mirrors runtime `define.schema`', () => { + expect(cliConfig.development.define.schema).toBe(runtimeDefine.schema); + }); + test('cli `test` env mirrors runtime `define.schema`', () => { + expect(cliConfig.test.define.schema).toBe(runtimeDefine.schema); + }); + test('cli `production` env mirrors runtime `define.schema`', () => { + expect(cliConfig.production.define.schema).toBe(runtimeDefine.schema); + }); +});