Skip to content

fix(oceanbase): reject legacy schema collations - #1389

Open
Vanillaxi wants to merge 2 commits into
oceanbase:masterfrom
Vanillaxi:fix/ob-schema-upgrade
Open

fix(oceanbase): reject legacy schema collations#1389
Vanillaxi wants to merge 2 commits into
oceanbase:masterfrom
Vanillaxi:fix/ob-schema-upgrade

Conversation

@Vanillaxi

Copy link
Copy Markdown

Which issue or RFC does this PR close?

Closes #1320 .

Rationale for this change

The fresh-schema fix in #1277 makes opaque identity columns use utf8mb4_bin, but SQLAlchemy's create_all(checkfirst=True) neither alters nor rejects tables created by earlier PowerContext versions. Therefore,upgraded deployments can start with legacy utf8mb4_general_ci identity columns and still collapse case- or accent-variant scope and source IDs.

What changes are included in this PR?

  • Inspect existing PowerContext VARCHAR identity columns through information_schema.COLUMNS before create_tables(),
  • Reject every incompatible identity column with IncompatibleOceanBaseSchemaError.
  • Add a deterministic regression test that verifies rejection happens before table creation.
  • Add a real OceanBase integration test that creates the legacy pc_sources schema with utf8mb4_general_ci and verifies that the current profile rejects it.
  • Document the data-only migration procedure in the English and Chinese troubleshooting guides.

Are there any user-facing changes?

Existing OceanBase/MySQL-mode deployments with incompatible identity-column collations now fail during Server startup .The error identifies the affected columns and directs operators to a backup, rebuild, and data-only restore procedure.

How was this change tested?

  • uv run pytest -q tests/builtin/persistence/test_oceanbase_profile.py
    tests/builtin/persistence/test_mysql_schema.py — 17 passed, 2 skipped
  • The regression failed before the fix with DID NOT RAISE IncompatibleOceanBaseSchemaError; the opt-in live OceanBase case passed with POWERCONTEXT_TEST_OCEANBASE_URL.
  • make check — passed
  • make test943 passed, 10 skipped
  • make docs-test — passed

AI usage statement

OpenAI Codex was used to implement and review.

@CLAassistant

CLAassistant commented Aug 28, 2026

Copy link
Copy Markdown

CLA assistant check
All committers have signed the CLA.

Comment thread tests/builtin/persistence/test_oceanbase_profile.py Outdated
Comment thread src/powercontext/builtin/persistence/oceanbase/profile.py Outdated
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.

bug: OceanBase collation fix does not upgrade existing schemas

3 participants