-
Notifications
You must be signed in to change notification settings - Fork 430
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #2248 from constantine2nd/develop
Metric; Timeout
- Loading branch information
Showing
6 changed files
with
99 additions
and
12 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
63 changes: 63 additions & 0 deletions
63
obp-api/src/main/scala/code/api/util/migration/MigrationOfMetricTable.scala
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
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.metrics.MappedMetric | ||
import net.liftweb.common.Full | ||
import net.liftweb.mapper.{DB, Schemifier} | ||
import net.liftweb.util.DefaultConnectionIdentifier | ||
|
||
object MigrationOfMetricTable { | ||
|
||
val oneDayAgo = ZonedDateTime.now(ZoneId.of("UTC")).minusDays(1) | ||
val oneYearInFuture = ZonedDateTime.now(ZoneId.of("UTC")).plusYears(1) | ||
val formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd'T'HH:mm'Z'") | ||
|
||
def alterColumnCorrelationidLength(name: String): Boolean = { | ||
DbFunction.tableExists(MappedMetric, (DB.use(DefaultConnectionIdentifier){ conn => conn})) | ||
match { | ||
case true => | ||
val startDate = System.currentTimeMillis() | ||
val commitId: String = APIUtil.gitCommit | ||
var isSuccessful = false | ||
|
||
val executedSql = | ||
DbFunction.maybeWrite(true, Schemifier.infoF _, DB.use(DefaultConnectionIdentifier){ conn => conn}) { | ||
APIUtil.getPropsValue("db.driver") match { | ||
case Full(value) if value.contains("com.microsoft.sqlserver.jdbc.SQLServerDriver") => | ||
() => | ||
""" | ||
|ALTER TABLE metric ALTER COLUMN correlationid varchar(256); | ||
|""".stripMargin | ||
case _ => | ||
() => | ||
""" | ||
|ALTER TABLE metric ALTER COLUMN correlationid TYPE character varying(256); | ||
|""".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"""${MappedMetric._dbTableNameLC} table does not exist""".stripMargin | ||
saveLog(name, commitId, isSuccessful, startDate, endDate, comment) | ||
isSuccessful | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters