Skip to content

feature/issue 37 okapi table prefix#39

Open
pdudzinsky wants to merge 3 commits intomainfrom
feature/issue-37-okapi-table-prefix
Open

feature/issue 37 okapi table prefix#39
pdudzinsky wants to merge 3 commits intomainfrom
feature/issue-37-okapi-table-prefix

Conversation

@pdudzinsky
Copy link
Copy Markdown
Contributor

Summary

  • BREAKING: outbox domain table renamed outboxokapi_outbox. Indexes follow (idx_okapi_outbox_*). Host applications with a pre-existing outbox table are unaffected — okapi creates its own under the okapi_ prefix.
  • BREAKING: Liquibase tracking tables default to okapi_databasechangelog / okapi_databasechangeloglock, configurable via two new properties.
  • New configuration: okapi.liquibase.changelog-table / okapi.liquibase.changelog-lock-table (override the new defaults to keep the shared layout). The domain-table name is fixed.

Closes #37.

Motivation

okapi's autoconfigured SpringLiquibase previously inherited Liquibase's defaults and wrote its migration history into the host application's databasechangelog / databasechangeloglock, mixing library and application records. The domain table outbox likewise collided with applications that already have a table by that name. Issue #37 proposed isolating both under an okapi_ prefix.

What changed

Concern Before After
Outbox domain table outbox okapi_outbox (fixed)
Outbox indexes idx_outbox_* idx_okapi_outbox_*
Liquibase changelog table databasechangelog okapi_databasechangelog (configurable)
Liquibase changelog lock table databasechangeloglock okapi_databasechangeloglock (configurable)

Configuration:

okapi:
  liquibase:
    changelog-table: okapi_databasechangelog
    changelog-lock-table: okapi_databasechangeloglock

Validation rejects blank values at startup. Domain-table name is hardcoded in PostgresOutboxStore / MysqlOutboxStore SQL — no runtime configurability for it.

Migration from 0.2.x

Existing 0.2.x deployments must take action before the first 0.3.0 startup. Two paths documented in README — Upgrading from 0.2.x:

  1. Stay on legacy Liquibase changelog tables (zero-downtime opt-out for the tracking pair):

    okapi:
      liquibase:
        changelog-table: databasechangelog
        changelog-lock-table: databasechangeloglock

    The domain-table rename has no opt-out — run the SQL below regardless.

  2. Rename in place (PostgreSQL syntax shown):

    ALTER TABLE outbox RENAME TO okapi_outbox;
    ALTER INDEX idx_outbox_status_last_attempt RENAME TO idx_okapi_outbox_status_last_attempt;
    ALTER INDEX idx_outbox_status_created_at  RENAME TO idx_okapi_outbox_status_created_at;
    
    CREATE TABLE okapi_databasechangelog     (LIKE databasechangelog INCLUDING ALL);
    CREATE TABLE okapi_databasechangeloglock (LIKE databasechangeloglock INCLUDING ALL);
    INSERT INTO okapi_databasechangelog
        SELECT * FROM databasechangelog WHERE filename LIKE '%com/softwaremill/okapi/%';
    INSERT INTO okapi_databasechangeloglock SELECT * FROM databasechangeloglock;
    DELETE FROM databasechangelog WHERE filename LIKE '%com/softwaremill/okapi/%';

Without one of these steps, Liquibase will see an empty changelog table on the first 0.3.0 startup and try to re-run okapi's migrations — which fails because the legacy outbox already exists while okapi now writes to okapi_outbox.

CHANGELOG.md (Keep a Changelog 1.1.0) added; covers [Unreleased] plus retrofits [0.2.0] and [0.1.0].

Test plan

  • UnitLiquibaseAutoConfigurationTest (10 tests): bean wiring (Postgres + MySQL × default + custom), validation rejection (empty/whitespace × table + lock-table), okapi.liquibase.* Spring Binder contract, init-block validation propagation through Spring binding.
  • E2E (testcontainers)LiquibaseE2ETest (4 tests): real PostgreSQL 16 + MySQL 8.0 containers verify autoconfig creates okapi_outbox + okapi_databasechangelog + okapi_databasechangeloglock on startup; custom okapi.liquibase.changelog-table actually creates the named table in DDL.
  • Integration — existing *ConnectionLeakProofTest, MultiDataSourceTransactionTest, *ConcurrentClaimTest, *EndToEndTest, store contract tests adapted to okapi_outbox — all green.
  • Build & lint./gradlew build (105 tasks) green; ./gradlew ktlintCheck clean.
  • (For reviewer) Spot-check the migration SQL against your own database setup if you maintain a 0.2.x deployment.

pdudzinsky and others added 3 commits May 2, 2026 17:31
Configures okapiPostgresLiquibase / okapiMysqlLiquibase to track their
changesets in dedicated `okapi_databasechangelog` /
`okapi_databasechangeloglock` tables instead of sharing the host
application's defaults. Resetting application migration history no
longer affects okapi's tracked state, and uninstalling the library
leaves no orphaned changelog entries.
Adds a nested `OkapiProperties.Liquibase` block exposing both table
names as `okapi.liquibase.changelog-table` /
`okapi.liquibase.changelog-lock-table` so applications that prefer the
shared layout can opt back in. Validation rejects blank values at
startup.
Coverage: LiquibaseAutoConfigurationTest (bean wiring, blank
validation, Spring Binder contract) plus LiquibaseE2ETest (Postgres +
MySQL testcontainers verifying the actual DDL).
BREAKING CHANGE: Liquibase tracking-table defaults change from
`databasechangelog` / `databasechangeloglock` to
`okapi_databasechangelog` / `okapi_databasechangeloglock`. Existing
0.2.x deployments must either opt out via
`okapi.liquibase.changelog-table` / `changelog-lock-table`, or migrate
okapi's rows into the new tables before first 0.3.0 startup. See
README "Database migrations § Upgrading from 0.2.x".
Refs #37
Renames the okapi domain table from `outbox` to `okapi_outbox` so host
applications with a pre-existing `outbox` table stay untouched. Indexes
follow (`idx_okapi_outbox_*`); store SQL and Liquibase changesets stay
in lockstep. Migration path: README "Upgrading from 0.2.x".

Also: CHANGELOG.md (Keep a Changelog), KDoc on the autoconfigured
Liquibase beans, and a Spring binding-validation test pinning that
init-block validation propagates through `okapi.liquibase.*`.
@endrju19 endrju19 self-assigned this May 4, 2026
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.

Use dedicated okapi_databasechangelog tables to isolate library migration state

2 participants