diff --git a/package-lock.json b/package-lock.json index 6a5a230ad5..014fb3e8f3 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "alkemio-server", - "version": "0.84.8", + "version": "0.84.9", "lockfileVersion": 2, "requires": true, "packages": { "": { "name": "alkemio-server", - "version": "0.84.8", + "version": "0.84.9", "license": "EUPL-1.2", "dependencies": { "@alkemio/matrix-adapter-lib": "^0.4.1", diff --git a/package.json b/package.json index 2b6008f34b..1e67e23da0 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "alkemio-server", - "version": "0.84.8", + "version": "0.84.9", "description": "Alkemio server, responsible for managing the shared Alkemio platform", "author": "Alkemio Foundation", "private": false, diff --git a/src/migrations/1721767553604-vcStorage.ts b/src/migrations/1721767553604-vcStorage.ts index 281de9ab1e..0d97d665cf 100644 --- a/src/migrations/1721767553604-vcStorage.ts +++ b/src/migrations/1721767553604-vcStorage.ts @@ -4,13 +4,42 @@ export class VcStorage1721767553604 implements MigrationInterface { name = 'VcStorage1721767553604'; public async up(queryRunner: QueryRunner): Promise { - // Drop FK constraing - await queryRunner.query( - `ALTER TABLE \`virtual_contributor\` DROP FOREIGN KEY \`FK_29a529635a2b2db9f37ca6d3521\`` - ); - await queryRunner.query( - `ALTER TABLE \`virtual_contributor\` DROP FOREIGN KEY \`FK_ce68cea88d194e0240b737c3f0c\`` - ); + // Check and drop FK constraints if they exist + await queryRunner + .query( + ` + SELECT CONSTRAINT_NAME + FROM information_schema.KEY_COLUMN_USAGE + WHERE TABLE_SCHEMA = DATABASE() + AND TABLE_NAME = 'virtual_contributor' + AND CONSTRAINT_NAME = 'FK_29a529635a2b2db9f37ca6d3521' +` + ) + .then(async result => { + if (result.length > 0) { + await queryRunner.query( + `ALTER TABLE \`virtual_contributor\` DROP FOREIGN KEY \`FK_29a529635a2b2db9f37ca6d3521\`` + ); + } + }); + + await queryRunner + .query( + ` + SELECT CONSTRAINT_NAME + FROM information_schema.KEY_COLUMN_USAGE + WHERE TABLE_SCHEMA = DATABASE() + AND TABLE_NAME = 'virtual_contributor' + AND CONSTRAINT_NAME = 'FK_ce68cea88d194e0240b737c3f0c' +` + ) + .then(async result => { + if (result.length > 0) { + await queryRunner.query( + `ALTER TABLE \`virtual_contributor\` DROP FOREIGN KEY \`FK_ce68cea88d194e0240b737c3f0c\`` + ); + } + }); // Logic is a) iterate over all VCs b) find the account storage bucket for each c) find all storage buckets // using the storage aggregator of the VC and update them to use the storage aggregator of the account