From 48d3ff4e3eb175f1adf47e29c810854f00c68c5e Mon Sep 17 00:00:00 2001 From: Hugo Tiburtino Date: Thu, 11 Jul 2024 16:08:19 +0200 Subject: [PATCH 1/2] feat(db-migration): fix events that were wrongly saved as entity link remove, while taxomony dissociate would the right. --- ...ate-wrongly-saved-as-entity-link-remove.ts | 27 +++++++++++++++++++ 1 file changed, 27 insertions(+) create mode 100644 packages/db-migrations/src/20240711142800-fix-events-taxonomy-disassociate-wrongly-saved-as-entity-link-remove.ts diff --git a/packages/db-migrations/src/20240711142800-fix-events-taxonomy-disassociate-wrongly-saved-as-entity-link-remove.ts b/packages/db-migrations/src/20240711142800-fix-events-taxonomy-disassociate-wrongly-saved-as-entity-link-remove.ts new file mode 100644 index 000000000..8be759ebe --- /dev/null +++ b/packages/db-migrations/src/20240711142800-fix-events-taxonomy-disassociate-wrongly-saved-as-entity-link-remove.ts @@ -0,0 +1,27 @@ +import { Database, SlackLogger } from './utils' + +export async function up(db: Database) { + const logger = new SlackLogger( + '20240711142800-fix-events-taxonomy-disassociate-wrongly-saved-as-entity-link-remove', + ) + console.log('here') + await db.runSql( + `UPDATE event + JOIN ( + SELECT event.id AS eventId, + uuid_parameter AS taxonomyId, + uuid_id AS entityId + FROM event + JOIN event_type ON event_type_id = event_type.id + JOIN uuid ON uuid_parameter = uuid.id + WHERE event_type.name = 'entity/link/remove' + AND discriminator = 'taxonomyTerm' + ) AS wrongEvent + ON event.id = wrongEvent.eventId + SET event.event_type_id = 17, + event.uuid_id = wrongEvent.taxonomyId, + event.uuid_parameter = wrongEvent.entityId`, + ) + + await logger.closeAndSend() +} From f04a4aeb772dfa6a49686f71007d939265312a79 Mon Sep 17 00:00:00 2001 From: Hugo Tiburtino Date: Thu, 11 Jul 2024 18:05:34 +0200 Subject: [PATCH 2/2] chore(dbmigration): release version 1.2.0 staging 2 --- packages/db-migrations/package.json | 2 +- ...taxonomy-disassociate-wrongly-saved-as-entity-link-remove.ts | 1 - 2 files changed, 1 insertion(+), 2 deletions(-) diff --git a/packages/db-migrations/package.json b/packages/db-migrations/package.json index 12af08b24..097866608 100644 --- a/packages/db-migrations/package.json +++ b/packages/db-migrations/package.json @@ -1,6 +1,6 @@ { "name": "@serlo/db-migrations", - "version": "1.2.0-staging.1", + "version": "1.2.0-staging.2", "private": true, "license": "Apache-2.0", "type": "module", diff --git a/packages/db-migrations/src/20240711142800-fix-events-taxonomy-disassociate-wrongly-saved-as-entity-link-remove.ts b/packages/db-migrations/src/20240711142800-fix-events-taxonomy-disassociate-wrongly-saved-as-entity-link-remove.ts index 8be759ebe..5516a3821 100644 --- a/packages/db-migrations/src/20240711142800-fix-events-taxonomy-disassociate-wrongly-saved-as-entity-link-remove.ts +++ b/packages/db-migrations/src/20240711142800-fix-events-taxonomy-disassociate-wrongly-saved-as-entity-link-remove.ts @@ -4,7 +4,6 @@ export async function up(db: Database) { const logger = new SlackLogger( '20240711142800-fix-events-taxonomy-disassociate-wrongly-saved-as-entity-link-remove', ) - console.log('here') await db.runSql( `UPDATE event JOIN (