Skip to content

fix(storage): ensure_schema converges a legacy SCHEMALESS change_log table - #232

Merged
acidkill merged 1 commit into
mainfrom
fix/change-log-schemaless-converge
Sep 7, 2026
Merged

acidkill merged 1 commit into
mainfrom
fix/change-log-schemaless-converge

Conversation

@acidkill

@acidkill acidkill commented Sep 7, 2026

Copy link
Copy Markdown
Owner

Summary

  • ensure_schema probes INFO FOR DB; when change_log exists as a legacy SCHEMALESS table it runs ALTER TABLE change_log SCHEMAFULL before the statement loop, so the DEFINE FIELD OVERWRITE payload … FLEXIBLE define becomes valid and the field finally converges.
  • Probe and ALTER are fail-soft: any failure leaves behaviour exactly as before (the startup warning), never blocks startup.

Why

Closes #230. Databases that predate the change_log declaration — including any carried through surreal export | import — keep the implicit SCHEMALESS table forever, so the 3.9.2 schema fix warned on every startup and the field kept its old none | object shape. ALTER TABLE … SCHEMAFULL is SurrealDB's documented transition for existing tables with data, and every column the writer produces is declared, so the tightening rejects nothing.

Test plan

  • pytest tests/ -m "not stress" -n auto — 7340 passed (5 new: schemaless→ALTER-before-defines, schemafull untouched, fresh DB untouched, ALTER-fail and probe-fail fail-soft).
  • ruff check / ruff format --check clean; mypy src/ clean.

Verified by

@acidkill

…table

Databases that wrote change_log rows before the table was declared in the
schema (an export/import preserves the shape) hold it as SCHEMALESS, where
the DEFINE FIELD OVERWRITE payload ... FLEXIBLE statement is rejected — so
every startup warned and the field never converged (issue #230). ensure_schema
now probes INFO FOR DB and runs ALTER TABLE change_log SCHEMAFULL first: the
documented schemaless-to-schemafull transition, keeping existing rows and
rejecting nothing the writer produces (every column is declared). Probe and
ALTER stay fail-soft — a failure merely preserves the previous behaviour.
@acidkill
acidkill merged commit db1f960 into main Sep 7, 2026
9 checks passed
@acidkill acidkill mentioned this pull request Sep 7, 2026
3 tasks
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.

ensure_schema warns on every startup when change_log exists as a legacy SCHEMALESS table (DEFINE FIELD … FLEXIBLE rejected)

1 participant