Skip to content

ActivityPub-federated video streaming platform using P2P directly in your web browser

Fix migration

Chocobozzzd8cf69f48c56
diff --git a/packages/tests/src/api/notifications/user-notifications.ts b/packages/tests/src/api/notifications/user-notifications.ts
index 3805311d06..9d7cc6610f 100644
--- a/packages/tests/src/api/notifications/user-notifications.ts
+++ b/packages/tests/src/api/notifications/user-notifications.ts
@@ -670,7 +670,8 @@ describe('Test user notifications', function () {
expect(notification.type).to.equal(UserNotificationType.VIDEO_OWNERSHIP_CHANGED_REJECTED)
expect(notification.changeOwnership.id).to.exist
expect(notification.changeOwnership.video.name).to.equal(videoName)
- expect(notification.changeOwnership.initiatorAccount.name).to.equal('root') // root made the request on behalf of the nextOwner user
+ // root made the request on behalf of the nextOwner user, but the initiator is the current video owner
+ expect(notification.changeOwnership.initiatorAccount.name).to.equal(nextOwner)
expect(notification.changeOwnership.nextOwnerAccount.name).to.equal(nextNextOwner)
})
})
diff --git a/server/core/initializers/migrations/1130-user-notification-fkeys.ts b/server/core/initializers/migrations/1130-user-notification-fkeys.ts
index 0adb4dd0ac..94c9f3d1a7 100644
--- a/server/core/initializers/migrations/1130-user-notification-fkeys.ts
+++ b/server/core/initializers/migrations/1130-user-notification-fkeys.ts
@@ -24,30 +24,33 @@ async function up (utils: {
)
}
+ // Constraint names depend on the version the instance was installed with
{
await utils.sequelize.query(
- 'ALTER TABLE "userNotification" DROP CONSTRAINT "userNotification_pluginId_fkey", ' +
+ 'ALTER TABLE "userNotification" DROP CONSTRAINT IF EXISTS "userNotification_pluginId_fkey", ' +
'ADD CONSTRAINT "userNotification_pluginId_fkey" ' +
'FOREIGN KEY ("pluginId") REFERENCES "plugin" ("id") ON DELETE CASCADE ON UPDATE CASCADE',
{ transaction }
)
await utils.sequelize.query(
- 'ALTER TABLE "userNotification" DROP CONSTRAINT "userNotification_applicationId_fkey", ' +
+ 'ALTER TABLE "userNotification" DROP CONSTRAINT IF EXISTS "userNotification_applicationId_fkey", ' +
'ADD CONSTRAINT "userNotification_applicationId_fkey" ' +
'FOREIGN KEY ("applicationId") REFERENCES "application" ("id") ON DELETE CASCADE ON UPDATE CASCADE',
{ transaction }
)
await utils.sequelize.query(
- 'ALTER TABLE "userNotification" DROP CONSTRAINT "userNotification_videoAbuseId_fkey", ' +
+ 'ALTER TABLE "userNotification" DROP CONSTRAINT IF EXISTS "userNotification_videoAbuseId_fkey", ' +
+ 'DROP CONSTRAINT IF EXISTS "userNotification_abuseId_fkey", ' +
'ADD CONSTRAINT "userNotification_abuseId_fkey" ' +
'FOREIGN KEY ("abuseId") REFERENCES "abuse" ("id") ON DELETE CASCADE ON UPDATE CASCADE',
{ transaction }
)
await utils.sequelize.query(
- 'ALTER TABLE "userNotification" DROP CONSTRAINT "userNotification_videoOwnershipId_fkey", ' +
+ 'ALTER TABLE "userNotification" DROP CONSTRAINT IF EXISTS "userNotification_videoOwnershipId_fkey", ' +
+ 'DROP CONSTRAINT IF EXISTS "userNotification_changeOwnershipId_fkey", ' +
'ADD CONSTRAINT "userNotification_changeOwnershipId_fkey" ' +
'FOREIGN KEY ("changeOwnershipId") REFERENCES "changeOwnership" ("id") ON DELETE CASCADE ON UPDATE CASCADE',
{ transaction }
@@ -63,3 +66,4 @@ export {
up,
down
}
+