Skip to content

Commit

Permalink
release-2024.6.1-hotfix: add migration script to fix expirationDay fo…
Browse files Browse the repository at this point in the history
…r gold cards, set expiration only if card has expirationDay, add null check for startDay for static cards
  • Loading branch information
f1sh1918 committed Jul 1, 2024
1 parent 7856fbc commit 9e1262a
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ object MigrationsRegistry {
V0009_HashPasswordResetKey(),
V0010_ApplicationNote(),
V0011_AddRegionCardConfirmationMailActivation(),
V0012_AddApplicationCardCreated()
V0012_AddApplicationCardCreated(),
V0013_FixExpirationDateGoldCard()
)
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
package app.ehrenamtskarte.backend.migration.migrations

import app.ehrenamtskarte.backend.migration.Migration
import app.ehrenamtskarte.backend.migration.Statement

/**
* Set the expirationDay to null for gold cards where the expirationDay was accidentally set to 0.
*/
@Suppress("ClassName")
internal class V0013_FixExpirationDateGoldCard() : Migration() {
override val migrate: Statement = {
exec(
"""
UPDATE cards
SET "expirationDay" = null
WHERE "expirationDay" = 0;
""".trimIndent()
)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ class CardMutationService {
CardRepository.insert(
hashedCardInfo,
activationSecretHash,
cardInfo.expirationDay.toLong(),
expirationDay = if (cardInfo.hasExpirationDay()) cardInfo.expirationDay.toLong() else null,
cardInfo.extensions.extensionRegion.regionId,
userId,
CodeType.DYNAMIC,
Expand Down Expand Up @@ -101,11 +101,11 @@ class CardMutationService {
CardRepository.insert(
hashedCardInfo,
null,
cardInfo.expirationDay.toLong(),
expirationDay = if (cardInfo.hasExpirationDay()) cardInfo.expirationDay.toLong() else null,
cardInfo.extensions.extensionRegion.regionId,
userId,
CodeType.STATIC,
cardInfo.extensions.extensionStartDay.startDay.toLong()
cardInfo.extensions.extensionStartDayOrNull?.startDay?.toLong()
)

StaticVerificationCodeResult(
Expand Down

0 comments on commit 9e1262a

Please sign in to comment.