Fix migration script log issue

This commit is contained in:
Marko Milić 2020-04-02 18:40:37 +02:00
parent 68d1826465
commit b02f70eeee

View File

@ -1,19 +1,32 @@
package code.migration
import code.util.Helper.MdcLoggable
import net.liftweb.common.Full
import net.liftweb.mapper.By
object MappedMigrationScriptLogProvider extends MigrationScriptLogProvider with MdcLoggable {
override def saveLog(name: String, commitId: String, isSuccessful: Boolean, startDate: Long, endDate: Long, comment: String): Boolean = {
MigrationScriptLog
.create
.Name(name)
.CommitId(commitId)
.IsSuccessful(isSuccessful)
.StartDate(startDate)
.EndDate(endDate)
.Remark(comment)
.save()
MigrationScriptLog.find(By(MigrationScriptLog.Name, name), By(MigrationScriptLog.IsSuccessful, isSuccessful)) match {
case Full(log) =>
log
.Name(name)
.CommitId(commitId)
.IsSuccessful(isSuccessful)
.StartDate(startDate)
.EndDate(endDate)
.Remark(comment)
.save()
case _ =>
MigrationScriptLog
.create
.Name(name)
.CommitId(commitId)
.IsSuccessful(isSuccessful)
.StartDate(startDate)
.EndDate(endDate)
.Remark(comment)
.save()
}
}
override def isExecuted(name: String): Boolean = {
MigrationScriptLog.find(