fly4s.data.ValidatedMigrateResult.scala Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of fly4s_3 Show documentation
Show all versions of fly4s_3 Show documentation
A functional wrapper for Flywayy
The newest version!
package fly4s.data
import cats.{MonadThrow, Show}
import cats.data.NonEmptyList
import cats.data.Validated.{Invalid, Valid}
object ValidatedMigrateResult {
import cats.implicits.*
def valid(migrateResult: MigrateResult): ValidatedMigrateResult =
Valid(migrateResult)
def invalid(validateOutputs: NonEmptyList[ValidateOutput]): ValidatedMigrateResult =
Invalid(validateOutputs)
def liftTo[F[_]](
result: ValidatedMigrateResult
)(implicit F: MonadThrow[F], S: Show[Iterable[ValidateOutput]]): F[MigrateResult] =
result match {
case Valid(result) => F.pure(result)
case Invalid(errors) => F.raiseError(new RuntimeException(errors.toIterable.show))
}
}