Skip to content

fix(migrations): preserve only reserved sqlite_ objects during reset … - #651

Merged
leo-aa88 merged 1 commit into
gombit-dev:mainfrom
SamCT86:henry/fix-491-sqlite-reset-prefix-20261104
Nov 5, 2026
Merged

leo-aa88 merged 1 commit into
gombit-dev:mainfrom
SamCT86:henry/fix-491-sqlite-reset-prefix-20261104

Conversation

@SamCT86

@SamCT86 SamCT86 commented Nov 4, 2026

Copy link
Copy Markdown
Contributor

Summary

Fixes #491.

SQLite LIKE treats _ as a single-character wildcard. The existing NOT LIKE 'sqlite_%' filter incorrectly preserves user tables such as sqlitex_cache and sqlite3_import, causing subsequent db reset migration runs to fail.

Escape the underscore so only SQLite's reserved sqlite_ prefix is preserved. Add a native SQLite regression test covering user tables, mixed-case names, views, and sqlite_sequence.

Acceptance criteria

The issue does not specify a formal acceptance checklist; these criteria follow its reported behavior and expected outcome.

  • Drop user tables starting with sqlite but not the reserved sqlite_ prefix.
  • Drop affected user views.
  • Preserve SQLite's internal sqlite_sequence.
  • Reproduce the failure on unmodified upstream code.
  • Verify the fix with native SQLite and CGO.
  • Verify that a second reset succeeds after migration and seeding.

Scope notes

Only migrations/reset.go and the new regression test are changed. No API, generator, or authentication changes.

Validation

Passed locally — Linux/amd64, Go 1.26.9, CGO enabled:

  • go test ./migrations -run TestDropSQLiteSchemaOnlyPreservesReservedPrefix -count=1
  • go test ./migrations ./database ./config -count=1
  • go build -p 4 ./...
  • go vet ./migrations ./database ./config
  • golangci-lint v2.12.2 run ./migrations ./database ./config — 0 issues
  • Native SQLite reset/reapply end-to-end regression — RED before fix, GREEN after fix

Not fully verified:

  • go test ./... — attempted; failed or timed out in unrelated CLI/client tests because WSL invoked Windows npx, producing filesystem path errors. The same failure was reproduced against unchanged upstream code.
  • Full PostgreSQL/MySQL/SQLite CI matrix — pending hosted CI.
  • Full-project lint — only the affected packages were linted.
  • Project code-review skill — not run.

Working agreement checklist

Documentation, generators, frontend assets and API-contract regeneration are outside the scope of this focused bug fix.

…ombit-dev#491)

SQLite LIKE treats '_' as a one-character wildcard. Escape it when filtering
sqlite_master so user tables and views such as sqlitex_cache or sqlite3_import
are dropped, while SQLite's reserved sqlite_ objects stay untouched.

Add a CGO-backed native SQLite regression covering mixed-case names,
views, and sqlite_sequence preservation.

Refs: gombit-dev#491

@leo-aa88 leo-aa88 left a comment

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.

LGTM

@leo-aa88
leo-aa88 merged commit ecc6775 into gombit-dev:main Nov 5, 2026
28 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

2 participants