Skip to content

Commit ef0b246

Browse files
committed
feat(deps)!: upgrade shibuya-pgmq-adapter and the pgmq-hs family
Bump shibuya-pgmq-adapter to 0.12.0.0 and the pgmq-* family to 0.4.0.0, which puts the PGMQ path on the pg-migrate 1.1 family alongside kiroku and keiro. Picks up the adapter fix where idle streams now observe shutdown instead of polling until forcibly cancelled. shibuya-core is already at its latest 0.8.0.1. pgmq-migration 0.4 removed its migrate/upgrade/validate runner in favor of a native pg-migrate component, so the keiro-pgmq suite no longer installs the PGMQ schema with a second, standalone migration. A pg-migrate ledger is shared by every component in it, and a pgmq-only plan failed strict verification with UnknownStoredMigration against a template that already carried the kiroku and keiro components. The component is now composed into the framework plan so one ledger owns all three. Drop the hasql-migration source-repository-package pin: it existed only for pgmq-migration 0.3, and nothing in the build plan depends on it now. BREAKING CHANGE: Keiro.Test.Postgres.withMigratedSuiteWith takes [MigrationComponent] appended to the framework plan instead of a Text -> IO () hook that ran its own migration against the template database.
1 parent 87bf3ff commit ef0b246

6 files changed

Lines changed: 67 additions & 49 deletions

File tree

CHANGELOG.md

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,13 @@ packages follow the [Haskell Package Versioning Policy](https://pvp.haskell.org/
1010

1111
- `keiro-migrate check` now takes the manifest as `--manifest PATH` instead of a
1212
positional argument, following the `pg-migrate-cli` 1.1.0.0 parser.
13+
- `Keiro.Test.Postgres.withMigratedSuiteWith` now takes `[MigrationComponent]`
14+
extra `pg-migrate` components appended to the framework plan — instead of a
15+
`Text -> IO ()` hook that ran its own migration against the template database.
16+
A `pg-migrate` ledger is shared by every component in it, so a second plan that
17+
omitted Kiroku's and Keiro's components failed strict verification with
18+
`UnknownStoredMigration`. Suites that installed extra schema (such as PGMQ) now
19+
pass the component itself: `withMigratedSuiteWith [pgmqMigrations]`.
1320

1421
### Changed
1522

@@ -21,6 +28,17 @@ packages follow the [Haskell Package Versioning Policy](https://pvp.haskell.org/
2128
From `kiroku-store` 0.3.0.1, a failure raised inside an opaque `runTransaction`
2229
body now preserves its SQLSTATE and server message instead of surfacing as
2330
`StreamNotFound (StreamName "<transaction>")`.
31+
- Upgraded `keiro-pgmq` to `shibuya-pgmq-adapter` 0.12.0.0 and the `pgmq-*` 0.4
32+
package family, which is what aligns the PGMQ path with pg-migrate 1.1. The
33+
adapter's own API is unchanged; the notable fix is that idle streams now observe
34+
shutdown, so a processor with nothing to consume finishes on request instead of
35+
polling until it is forcibly cancelled. `shibuya-core` stays at 0.8.0.1 (already
36+
the latest).
37+
- Dropped the `hasql-migration` `source-repository-package` pin from
38+
`cabal.project`. It existed only because `pgmq-migration` 0.3 depended on
39+
`hasql-migration`, whose Hackage release does not build against hasql 1.10;
40+
`pgmq-migration` 0.4 is a native `pg-migrate` component and nothing in the build
41+
plan depends on it now.
2442

2543
## 0.2.0.0 — 2026-07-13
2644

cabal.project

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -12,15 +12,5 @@ source-repository-package
1212
location: https://github.com/mzabani/codd.git
1313
tag: v0.1.8
1414

15-
-- The keiro-pgmq test suite installs the PGMQ schema with pgmq-migration, which
16-
-- depends on hasql-migration. The Hackage hasql-migration 0.3.1 does not build
17-
-- against the hasql 1.10 ecosystem this repo uses (it uses Statement as a
18-
-- term-level constructor). Pin the patched fork, matching pgmq-hs's own
19-
-- cabal.project. Only the test build pulls this in; the library does not.
20-
source-repository-package
21-
type: git
22-
location: https://github.com/shinzui/hasql-migration
23-
tag: 4aaff6c0919d1fe8e1c248c3ce4ce05775c59c8c
24-
2515
allow-newer:
2616
haxl:time

keiro-pgmq/CHANGELOG.md

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,17 @@ All notable changes to `keiro-pgmq` are recorded here. The format follows
66

77
## [Unreleased]
88

9-
_No unreleased changes._
9+
### Changed
10+
11+
- Upgraded to `shibuya-pgmq-adapter` 0.12.0.0 and the `pgmq-*` 0.4 package family
12+
(`pgmq-core`, `pgmq-config`, `pgmq-effectful`, `pgmq-hasql`, and `pgmq-migration`
13+
in the test suite). `keiro-pgmq`'s own API is unchanged. The adapter's 0.12 fix
14+
makes idle streams observe shutdown: a processor with nothing to consume now
15+
finishes on request instead of polling until it is forcibly cancelled.
16+
- The test suite installs the PGMQ schema by appending `pgmq-migration`'s native
17+
`pgmqMigrations` component to the suite's framework plan, rather than calling the
18+
`migrate` runner that `pgmq-migration` 0.4 removed. One pg-migrate ledger now owns
19+
the kiroku, keiro, and pgmq components together.
1020

1121
## 0.2.0.0 — 2026-07-13
1222

keiro-pgmq/keiro-pgmq.cabal

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -59,12 +59,12 @@ library
5959
, hasql-pool >=1.2
6060
, hs-opentelemetry-api >=1.0 && <1.1
6161
, keiro-core ^>=0.2.0.0
62-
, pgmq-config >=0.3 && <0.4
63-
, pgmq-core >=0.3 && <0.4
64-
, pgmq-effectful >=0.3 && <0.4
65-
, pgmq-hasql >=0.3 && <0.4
62+
, pgmq-config >=0.4 && <0.5
63+
, pgmq-core >=0.4 && <0.5
64+
, pgmq-effectful >=0.4 && <0.5
65+
, pgmq-hasql >=0.4 && <0.5
6666
, shibuya-core >=0.8.0.1 && <0.9
67-
, shibuya-pgmq-adapter >=0.11 && <0.12
67+
, shibuya-pgmq-adapter >=0.12 && <0.13
6868
, streamly-core >=0.3
6969
, text >=2.1
7070
, time >=1.12
@@ -88,10 +88,10 @@ test-suite keiro-pgmq-test
8888
, keiro-core ^>=0.2.0.0
8989
, keiro-pgmq
9090
, keiro-test-support
91-
, pgmq-config >=0.3 && <0.4
92-
, pgmq-core >=0.3 && <0.4
93-
, pgmq-effectful >=0.3 && <0.4
94-
, pgmq-migration >=0.3 && <0.4
91+
, pgmq-config >=0.4 && <0.5
92+
, pgmq-core >=0.4 && <0.5
93+
, pgmq-effectful >=0.4 && <0.5
94+
, pgmq-migration >=0.4 && <0.5
9595
, shibuya-core >=0.8.0.1 && <0.9
96-
, shibuya-pgmq-adapter >=0.11 && <0.12
96+
, shibuya-pgmq-adapter >=0.12 && <0.13
9797
, text >=2.1

keiro-pgmq/test/Main.hs

Lines changed: 6 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -76,22 +76,16 @@ data Ping = Ping
7676
type Stack = '[Reader PgmqAdapterEnv, Pgmq, Tracing, Error PgmqRuntimeError, IOE]
7777

7878
main :: IO ()
79-
main =
80-
Postgres.withMigratedSuiteWith installPgmq \fixture ->
79+
main = do
80+
-- PGMQ's schema is installed by appending pgmq-migration's native component to
81+
-- the suite's framework plan, so one pg-migrate ledger owns kiroku, keiro, and
82+
-- pgmq together.
83+
pgmq <- either (fail . show) pure Migration.pgmqMigrations
84+
Postgres.withMigratedSuiteWith [pgmq] \fixture ->
8185
hspec $
8286
describe "Keiro.PGMQ" $
8387
around (Postgres.withFreshDatabase fixture) spec
8488

85-
-- | Install the PGMQ schema into the ephemeral database via @pgmq-migration@.
86-
installPgmq :: Text -> IO ()
87-
installPgmq connStr =
88-
withPool connStr $ \pool -> do
89-
result <- Pool.use pool Migration.migrate
90-
case result of
91-
Left usageErr -> fail ("pgmq pool error during migration: " <> show usageErr)
92-
Right (Left migErr) -> fail ("pgmq migration error: " <> show migErr)
93-
Right (Right ()) -> pure ()
94-
9589
withPool :: Text -> (Pool -> IO a) -> IO a
9690
withPool connStr =
9791
bracket

keiro-test-support/src/Keiro/Test/Postgres.hs

Lines changed: 22 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ Usage from @hspec@:
1717
@
1818
main :: IO ()
1919
main =
20-
'withMigratedSuiteWith' installExtraSchema \\fixture ->
20+
'withMigratedSuiteWith' [pgmqMigrations] \\fixture ->
2121
hspec $
2222
describe "..." $ around ('withFreshStore' fixture) $ do
2323
it "..." $ \\store -> ...
@@ -39,17 +39,18 @@ where
3939

4040
import Control.Concurrent.STM (TVar, atomically, newTVarIO, stateTVar)
4141
import Control.Exception (bracket, onException)
42+
import Data.List.NonEmpty (NonEmpty (..))
4243
import Data.Text (Text)
4344
import Data.Text qualified as Text
44-
import Database.PostgreSQL.Migrate (defaultRunOptions, runMigrationPlan)
45+
import Database.PostgreSQL.Migrate (MigrationComponent, defaultRunOptions, migrationPlan, runMigrationPlan)
4546
import Effectful (Eff, IOE, UnliftStrategy (..), runEff, withEffToIO)
4647
import Effectful.Error.Static (Error, runErrorNoCallStack)
4748
import EphemeralPg qualified as Pg
4849
import Hasql.Connection.Settings qualified as Conn
4950
import Hasql.Pool qualified as Pool
5051
import Hasql.Pool.Config qualified as Pool.Config
5152
import Hasql.Session qualified as Session
52-
import Keiro.Migrations (frameworkMigrationPlan, keiroMigrations)
53+
import Keiro.Migrations (keiroMigrations)
5354
import Kiroku.Store qualified as Store
5455
import Kiroku.Store.Effect (Store, runStoreResource)
5556
import Kiroku.Store.Effect.Resource (KirokuStoreResource, getKirokuStore, withKirokuStore)
@@ -77,15 +78,21 @@ Kiroku event-store schema and Keiro framework schema to it once, then run
7778
are applied here against the template before any example clones it.
7879
-}
7980
withMigratedSuite :: (Fixture -> IO a) -> IO a
80-
withMigratedSuite = withMigratedSuiteWith \_ -> pure ()
81-
82-
{- | Like 'withMigratedSuite', but runs an extra migration hook against the
83-
template database after the Kiroku and Keiro migrations and before any example
84-
database is cloned. Use this for suites that need additional schema, such as
85-
PGMQ tables, in every fresh database.
81+
withMigratedSuite = withMigratedSuiteWith []
82+
83+
{- | Like 'withMigratedSuite', but appends extra @pg-migrate@ components to the
84+
framework plan so the template database also carries their schema — for example
85+
@pgmq-migration@'s @pgmqMigrations@. The extra components are applied after
86+
Kiroku's and Keiro's, in the order given, and before any example database is
87+
cloned.
88+
89+
They join the framework plan rather than running as a separate plan because a
90+
@pg-migrate@ ledger is shared by every component in it: a plan that omits a
91+
component already recorded in the ledger fails strict verification with
92+
@UnknownStoredMigration@.
8693
-}
87-
withMigratedSuiteWith :: (Text -> IO ()) -> (Fixture -> IO a) -> IO a
88-
withMigratedSuiteWith extraTemplateMigration action = do
94+
withMigratedSuiteWith :: [MigrationComponent] -> (Fixture -> IO a) -> IO a
95+
withMigratedSuiteWith extraComponents action = do
8996
started <- Pg.startCached Pg.defaultConfig Pg.defaultCacheConfig
9097
case started of
9198
Left err -> fail (Text.unpack (Pg.renderStartError err))
@@ -102,8 +109,7 @@ withMigratedSuiteWith extraTemplateMigration action = do
102109
-- Apply migrations through short-lived pg-migrate connections, all of which are
103110
-- released before any clone, so the template has no active sessions when
104111
-- PostgreSQL copies it.
105-
migrateTemplate templateConnStr
106-
extraTemplateMigration templateConnStr
112+
migrateTemplate extraComponents templateConnStr
107113
pure (Fixture server templateDbName counter)
108114

109115
{- | Clone a fresh, empty, migrated database from the template, open a
@@ -195,11 +201,11 @@ withFreshDatabase fixture action =
195201
runSql fixture.server $
196202
"DROP DATABASE IF EXISTS " <> quoteIdentifier dbName <> " WITH (FORCE)"
197203

198-
migrateTemplate :: Text -> IO ()
199-
migrateTemplate connStr = do
204+
migrateTemplate :: [MigrationComponent] -> Text -> IO ()
205+
migrateTemplate extraComponents connStr = do
200206
kiroku <- either (fail . show) pure Kiroku.kirokuMigrations
201207
keiro <- either (fail . show) pure keiroMigrations
202-
plan <- either (fail . show) pure (frameworkMigrationPlan kiroku keiro)
208+
plan <- either (fail . show) pure (migrationPlan (kiroku :| keiro : extraComponents))
203209
result <-
204210
runMigrationPlan
205211
defaultRunOptions

0 commit comments

Comments
 (0)