Merge pull request #2591 from constantine2nd/develop

Change type of Consumer.aud from char 250 to text
This commit is contained in:
Simon Redfern 2025-08-06 10:38:43 +01:00 committed by GitHub
commit 821ebf9736
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 58 additions and 3 deletions

View File

@ -100,6 +100,7 @@ object Migration extends MdcLoggable {
// populateViewDefinitionCanSeeTransactionStatus()
alterCounterpartyLimitFieldType()
populateMigrationOfViewPermissions(startedBeforeSchemifier)
changeTypeOfAudFieldAtConsumerTable()
}
private def dummyScript(): Boolean = {
@ -254,6 +255,12 @@ object Migration extends MdcLoggable {
MigrationOfConsumer.populateAzpAndSub(name)
}
}
private def changeTypeOfAudFieldAtConsumerTable(): Boolean = {
val name = nameOf(changeTypeOfAudFieldAtConsumerTable)
runOnce(name) {
MigrationOfConsumer.alterTypeofAud(name)
}
}
private def alterTableMappedUserAuthContext(startedBeforeSchemifier: Boolean): Boolean = {
if(startedBeforeSchemifier == true) {
logger.warn(s"Migration.database.alterTableMappedUserAuthContext(true) cannot be run before Schemifier.")

View File

@ -2,11 +2,11 @@ package code.api.util.migration
import java.time.format.DateTimeFormatter
import java.time.{ZoneId, ZonedDateTime}
import code.api.util.APIUtil
import code.api.util.migration.Migration.{DbFunction, saveLog}
import code.model.{AppType, Consumer}
import net.liftweb.mapper.DB
import net.liftweb.common.Full
import net.liftweb.mapper.{DB, Schemifier}
import net.liftweb.util.{DefaultConnectionIdentifier, Helpers}
object MigrationOfConsumer {
@ -107,4 +107,52 @@ object MigrationOfConsumer {
isSuccessful
}
}
def alterTypeofAud(name: String): Boolean = {
DbFunction.tableExists(Consumer) match {
case true =>
val startDate = System.currentTimeMillis()
val commitId: String = APIUtil.gitCommit
var isSuccessful = false
val executedSql =
DbFunction.maybeWrite(true, Schemifier.infoF _) {
APIUtil.getPropsValue("db.driver") match {
case Full(dbDriver) if dbDriver.contains("com.microsoft.sqlserver.jdbc.SQLServerDriver") =>
() =>
"""
|ALTER TABLE consumer ALTER COLUMN aud VARCHAR(MAX) NULL;
|""".stripMargin
case _ =>
() =>
"""
|ALTER TABLE consumer ALTER COLUMN aud TYPE text;
|""".stripMargin
}
}
val endDate = System.currentTimeMillis()
val comment: String =
s"""Executed SQL:
|$executedSql
|""".stripMargin
isSuccessful = true
saveLog(name, commitId, isSuccessful, startDate, endDate, comment)
isSuccessful
case false =>
val startDate = System.currentTimeMillis()
val commitId: String = APIUtil.gitCommit
val isSuccessful = false
val endDate = System.currentTimeMillis()
val comment: String =
s"""${Consumer._dbTableNameLC} table does not exist""".stripMargin
saveLog(name, commitId, isSuccessful, startDate, endDate, comment)
isSuccessful
}
}
}

View File

@ -541,7 +541,7 @@ class Consumer extends LongKeyedMapper[Consumer] with CreatedUpdated{
// because different databases treat unique indexes on NULL values differently.
override def defaultValue = APIUtil.generateUUID()
}
object aud extends MappedString(this, 250) {
object aud extends MappedText(this) {
override def defaultValue = null
}
object iss extends MappedString(this, 250) {