Skip to content

Slick v4 migration#825

Draft
hvesalai wants to merge 1 commit into
tminglei:masterfrom
hvesalai:slick-v4-migration
Draft

Slick v4 migration#825
hvesalai wants to merge 1 commit into
tminglei:masterfrom
hvesalai:slick-v4-migration

Conversation

@hvesalai
Copy link
Copy Markdown

This PR is a bit early, but I'm working with releasing Slick 4 and would like to present this PR to show the kind of chanages needed to downstream libraries extending Slick (which I don't know many). The version referred to by the PR does not exist publicly. I will update the PR once it does.

This PR migrates slick-pg to Slick v4. The changes are straightforward and mostly limited to how tests obtain a database connection — the library code itself has only minor updates.

Changes

build.sbt

  • Slick updated from 3.6.1 to 4.0.0
  • Added slick-future, cats-effect, and fs2-core dependencies (required by the slick-future module)
  • Scala 3 updated from 3.3.1 to 3.8.3; cross-compilation retained for 2.12, 2.13 and 3
  • play-json dependency simplified: the Scala-version conditional is no longer needed since org.playframework supports all three versions

Core library

  • ExPostgresProfile: createModelBuilder and ExModelBuilder no longer take an implicit ExecutionContext parameter, which was removed from the Slick v4 signature.
  • lobj/LargeObjectStreamingDBIOAction: Replaced the Slick v3 emitStream/cancelStream pair (along with StreamState, implicit proof, and the 5-type-parameter SynchronousDatabaseAction) with the new Slick v4 openStream returning a CloseableIterator[Array[Byte]].
  • date/PgDateJdbcTypes: The mapTo helper's explicit implicit argument passing (ctag, this) to MappedJdbcType.base was replaced with implicit val self brought into scope. This is required for Scala 3 compatibility, where context bounds map to using parameters and can no longer be satisfied with explicit argument syntax.

Test infrastructure

  • PostgresContainer: db is no longer a lazy val defined per test class. It is now a lifecycle-managed shared resource — opened in afterStart() using slick.future.Database (from the new slick-future module) and closed in beforeStop(). Test suites continue to use Await.result(db.run(...), Duration.Inf) unchanged.
  • ScalaVersionShim (scala-2 / scala-3): WeekDay type converters for PgCompositeSupportSuite moved from an inline Scala-2-only block into version-specific shims. This is required for Scala 3 compatibility, where register() relies on implicit resolution and cannot be called with the same syntax as in Scala 2.

All test suites

Uniform mechanical change across every test suite: removed lazy val db = Database.forURL(...), which is now provided by PostgresContainer. All other test code is unchanged — Await.result(db.run(...), Duration.Inf) continues to work as before thanks to slick.future.Database providing the same run/stream API as Slick 3.

@hvesalai hvesalai marked this pull request as draft April 21, 2026 12:18
@hvesalai
Copy link
Copy Markdown
Author

Ping @tminglei can you check out this PR in preparation for the upcoming slick 4.

@hvesalai
Copy link
Copy Markdown
Author

hvesalai commented May 8, 2026

@tminglei have you had time to review this? I tried to contact you by email to agree on synchronizing the slick and slick-pg releases for slick4 support.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant