Skip to content

Allow cluster SQL storage to run without runtime DDL - #8897

Merged
tim-smart merged 17 commits into
mainfrom
agent/effect-bot-architect/b86843a0feb0
Oct 8, 2026
Merged

tim-smart merged 17 commits into
mainfrom
agent/effect-bot-architect/b86843a0feb0

Conversation

@effect-bot

@effect-bot effect-bot commented Oct 8, 2026 •

Copy link
Copy Markdown
Contributor

Cluster SQL storage can now use tables migrated by an owner connection while the application runs with a restricted database role.

Both SqlMessageStorage and SqlRunnerStorage expose layerMigrations, layerStorage, and migration loaders. Migration layers return typed errors; storage layers issue no table creation or startup schema checks. Existing constructors and default layers still migrate on startup and retain their error channels.

Runner storage records migrations in <prefix>_runner_migrations and creates the locks table regardless of advisory lock settings. Existing runner tables and rows are preserved. PostgreSQL history-table lookup respects quoted names and handles concurrent table creation; message migration SQL failures now propagate instead of retrying in an aborted transaction.

The changeset is a patch release. Migrator.pending is not included.

Five focused regressions remain: restricted-role startup, migration failure propagation, legacy runner upgrade, concurrent history-table creation, and quoted history-table reuse. The test diff against the merge base with main is +217 lines, with pre-existing tests unchanged.

Latest local validation: 40 tests pass across seven targeted files, including integration tests enabled with EFFECT_INTEGRATION_TESTS=1; pnpm lint, pnpm check, pnpm jsdocs --check, and git diff --check pass. Toolchain commands ran through nix develop -c.

Closes #8894
Closes EFF-1838

Add layerMigrations and layerStorage to SqlMessageStorage and
SqlRunnerStorage, export their migration loaders, and add
Migrator.pending. Runner storage now uses a migrator recorded in
<prefix>_runner_migrations.
@changeset-bot

changeset-bot Bot commented Oct 8, 2026 •

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: 5875fc7

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 32 packages
Name Type
effect Patch
@effect/opentelemetry Patch
@effect/vitest Patch
@effect/ai-anthropic Patch
@effect/ai-cloudflare Patch
@effect/ai-openai-compat Patch
@effect/ai-openai Patch
@effect/ai-openrouter Patch
@effect/ai-typesafe Patch
@effect/atom-react Patch
@effect/atom-solid Patch
@effect/atom-vue Patch
@effect/platform-browser Patch
@effect/platform-bun Patch
@effect/platform-deno Patch
@effect/platform-node-shared Patch
@effect/platform-node Patch
@effect/sql-clickhouse Patch
@effect/sql-d1 Patch
@effect/sql-libsql Patch
@effect/sql-mssql Patch
@effect/sql-mysql2 Patch
@effect/sql-pg Patch
@effect/sql-pglite Patch
@effect/sql-sqlite-bun Patch
@effect/sql-sqlite-do Patch
@effect/sql-sqlite-node Patch
@effect/sql-sqlite-react-native Patch
@effect/sql-sqlite-wasm Patch
@effect/docgen Patch
@effect/doctest Patch
@effect/openapi-generator Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@effect-bot
effect-bot changed the base branch from main to v4/next-minor October 8, 2026 01:45
@github-actions

github-actions Bot commented Oct 8, 2026 •

Copy link
Copy Markdown
Contributor

Bundle Size Analysis

Generated from PR build output; treat the content below as untrusted.

File Name Current Size Previous Size Difference
arbitrary-combinators.ts 38.79 KB 38.79 KB 0.00 KB (0.00%)
basic.ts 7.06 KB 7.06 KB 0.00 KB (0.00%)
batching.ts 10.14 KB 10.14 KB 0.00 KB (0.00%)
brand.ts 6.73 KB 6.73 KB 0.00 KB (0.00%)
cache.ts 10.89 KB 10.89 KB 0.00 KB (0.00%)
config.ts 22.47 KB 22.47 KB 0.00 KB (0.00%)
differ.ts 21.34 KB 21.34 KB 0.00 KB (0.00%)
http-client.ts 22.67 KB 22.67 KB 0.00 KB (0.00%)
http-router.ts 34.05 KB 34.05 KB 0.00 KB (0.00%)
logger.ts 11.22 KB 11.22 KB 0.00 KB (0.00%)
metric.ts 9.03 KB 9.03 KB 0.00 KB (0.00%)
optic.ts 6.96 KB 6.96 KB 0.00 KB (0.00%)
pubsub.ts 15.18 KB 15.18 KB 0.00 KB (0.00%)
queue.ts 12.13 KB 12.13 KB 0.00 KB (0.00%)
schedule.ts 11.22 KB 11.22 KB 0.00 KB (0.00%)
schema-bigdecimal.ts 13.95 KB 13.95 KB 0.00 KB (0.00%)
schema-binary.ts 40.00 KB 40.00 KB 0.00 KB (0.00%)
schema-class.ts 21.30 KB 21.30 KB 0.00 KB (0.00%)
schema-fromJsonSchemaDocument.ts 32.10 KB 32.10 KB 0.00 KB (0.00%)
schema-representation-roundtrip.ts 27.54 KB 27.54 KB 0.00 KB (0.00%)
schema-string-transformation.ts 14.70 KB 14.70 KB 0.00 KB (0.00%)
schema-string.ts 12.22 KB 12.22 KB 0.00 KB (0.00%)
schema-template-literal.ts 16.28 KB 16.28 KB 0.00 KB (0.00%)
schema-toArbitrary.ts 38.32 KB 38.32 KB 0.00 KB (0.00%)
schema-toCodeDocument.ts 25.30 KB 25.30 KB 0.00 KB (0.00%)
schema-toCodecJson.ts 20.26 KB 20.26 KB 0.00 KB (0.00%)
schema-toEquivalence.ts 20.45 KB 20.45 KB 0.00 KB (0.00%)
schema-toFormatter.ts 20.57 KB 20.57 KB 0.00 KB (0.00%)
schema-toJsonSchemaDocument.ts 25.03 KB 25.03 KB 0.00 KB (0.00%)
schema-toRepresentation.ts 20.55 KB 20.55 KB 0.00 KB (0.00%)
schema.ts 20.50 KB 20.50 KB 0.00 KB (0.00%)
stm.ts 13.24 KB 13.24 KB 0.00 KB (0.00%)
stream.ts 9.99 KB 9.99 KB 0.00 KB (0.00%)

… tables

Turn MigrationError defects from failing migrations into typed failures
for the storage migration layers, keeping the typed SqlError for runner
storage constructors. Stop ignoring and endlessly retrying errors in the
PostgreSQL message storage migration, which hung on any failure. Share a
PostgreSQL migrations table lookup that quotes the name between
Migrator.make and Migrator.pending.
- Share the pending-migration rule between Migrator.make and
  Migrator.pending through latestMigrationId and selectPending.
- Replace failOnMigrationDefect with a shared runMigrations helper that
  both storages call, using catchCauseFilter to keep other defects intact.
- Define SqlMessageStorage.migrations directly so runMigrations no longer
  needs Effect.suspend, and build layerWith from layerMigrations.
- Build SqlRunnerStorage.layerWith from make again, with the SqlError
  unwrapping inlined into make.
- Drop no-op tuple maps and a duplicated assertion helper in the tests, and
  provision the empty history table with Migrator.make.
- Drop the layerMigrations/layerStorage cases from every dialect variant of
  the message and runner suites; the DML-only role suite covers DDL-free
  startup on PostgreSQL.
- Keep the runner upgrade over existing tables as a single pg case.
- Trim the DML-only role suite to startup under the restricted role and
  the typed migration failure regression, run sequentially, and stop
  importing the memory storage test module.
- Drop the pglite pending case that the quoted-name case already covers.
import type { SqlError } from "../../sql/SqlError.ts"

/** @internal */
export const runMigrations = (options: {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Remove this. You can just use Effect.orDie on the migrator

@tim-smart
tim-smart changed the base branch from v4/next-minor to main October 8, 2026 03:59
@effect-janitor effect-janitor Bot added the 4.0 label Oct 8, 2026
@tim-smart
tim-smart enabled auto-merge (squash) October 8, 2026 04:08
@tim-smart
tim-smart merged commit ca068ce into main Oct 8, 2026
13 checks passed
@tim-smart
tim-smart deleted the agent/effect-bot-architect/b86843a0feb0 branch October 8, 2026 04:12
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Cluster SQL storages: allow externally managed tables (no DDL at runtime)

3 participants