Skip to content

Commit

Permalink
Merge pull request #1668 from serlo/fix-events-entity-link-to-taxonom…
Browse files Browse the repository at this point in the history
…y-dissociate

feat(db-migration): fix events that were wrongly saved as entity link remove
  • Loading branch information
hugotiburtino authored Jul 11, 2024
2 parents 2eb173c + f04a4ae commit a4ddc33
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 1 deletion.
2 changes: 1 addition & 1 deletion packages/db-migrations/package.json
Original file line number Diff line number Diff line change
@@ -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",
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
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',
)
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()
}

0 comments on commit a4ddc33

Please sign in to comment.