Skip to content

Commit

Permalink
Merge pull request #4316 from alkem-io/develop
Browse files Browse the repository at this point in the history
Release: Migration fix
  • Loading branch information
valentinyanakiev authored Jul 25, 2024
2 parents 435acd2 + 9708ed2 commit 6a7e89a
Show file tree
Hide file tree
Showing 3 changed files with 39 additions and 10 deletions.
4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -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,
Expand Down
43 changes: 36 additions & 7 deletions src/migrations/1721767553604-vcStorage.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,42 @@ export class VcStorage1721767553604 implements MigrationInterface {
name = 'VcStorage1721767553604';

public async up(queryRunner: QueryRunner): Promise<void> {
// 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
Expand Down

0 comments on commit 6a7e89a

Please sign in to comment.