mirror of
https://github.com/OpenBankProject/OBP-API.git
synced 2026-02-06 17:17:09 +00:00
Merge pull request #2591 from constantine2nd/develop
Change type of Consumer.aud from char 250 to text
This commit is contained in:
commit
821ebf9736
@ -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.")
|
||||
|
||||
@ -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
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
@ -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) {
|
||||
|
||||
Loading…
Reference in New Issue
Block a user