Skip to content

Commit 9aa5863

Browse files
dylanjeffersclaude
andcommitted
fix(identity): repair broken Notification migration
PR #14207 removed src/models/notification.js but left 20191107223636-create-viewed-field.js calling models.Notification.update(). On a fresh DB the migration crashes with "Cannot read properties of undefined (reading 'update')". The break went undetected because CircleCI was disabled before that PR landed. Replace the ORM call with a raw UPDATE — the Notifications table itself is still created by 20191025193919-create-notification.js and was never dropped, so the migration still has a real table to write to. Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
1 parent 4267519 commit 9aa5863

1 file changed

Lines changed: 6 additions & 6 deletions

File tree

packages/identity-service/sequelize/migrations/20191107223636-create-viewed-field.js

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
'use strict'
2-
const models = require('../../src/models')
32

43
module.exports = {
54
up: (queryInterface, Sequelize) => {
@@ -14,11 +13,12 @@ module.exports = {
1413
{ transaction }
1514
)
1615

17-
await models.Notification.update(
18-
{
19-
isViewed: false
20-
},
21-
{ transaction, where: { isRead: { [models.Sequelize.Op.ne]: null } } }
16+
// Raw SQL instead of models.Notification.update — the Notification model
17+
// was removed in #14207 but the Notifications table still exists in the
18+
// schema, so this migration must keep running on fresh databases.
19+
await queryInterface.sequelize.query(
20+
'UPDATE "Notifications" SET "isViewed" = false WHERE "isRead" IS NOT NULL',
21+
{ transaction }
2222
)
2323

2424
await queryInterface.changeColumn(

0 commit comments

Comments
 (0)