nafg / slick-migration-api

Schema manipulation dialects and DSL for Slick

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

SqlMigrations don't work with slick-migration-api-flyway

PawelLipski opened this issue · comments

Since the result of slick.migration.api.SqlMigration.apply doesn't override toString, the generated description of a SqlMigration looks like SqlMigration$$anon$1@5becf99e, and is a different string each time a new object is created (incl. when a new JVM is launched).

This leads to Flyway failing with ``Migration description mismatch for migration version ...`.

As a workaround, once could do sth like:

    val initialSchema = new SqlMigration {
      override def sql: Seq[String] = Seq(Source.fromResource("initial-schema.sql").mkString)

      override def toString: String = s"${classOf[SqlMigration].getSimpleName}(${sql})"
    }

What do you recommend?

Well... if you could just override toString in trait SqlMigration :)

Hmmm same as in my implementation?... Possibly with getName instead of getSimpleName 🤔

Could you send a PR?