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); + }); +});