feat(db): add Postgres dialect against PGlite - #181
Merged
Conversation
A real Postgres engine in tests, not SQLite with a flag. Schema applies in one shot via schema_migrations; word search is tsvector. SQLite SQL is rewritten at the adapter. Production still refuses storage.provider postgres until a connection string is wired.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Feature Change
Summary
Run the data-access layer against a real Postgres engine in tests, with a dialect adapter and a one-shot schema. Production still refuses
postgresuntil a connection string is wired.Stakeholder
N/A
Links
Ticket: N/A
Design doc: N/A
Description
This is not SQLite with a config flag. Tests open PGlite (Postgres compiled to WASM). The same
insertFact/keywordSearch/insertEventfunctions run against it.Postgres schema is applied at the current version in one shot, recorded in
schema_migrations— SQLite keeps its incremental pragma history. Word search istsvectorplus GIN, not FTS5. An identityrowidcolumn preserves insert-order queries.SQLite SQL is rewritten at the adapter:
?becomes$n,INSERT OR IGNOREbecomesON CONFLICT DO NOTHING,json(?)becomes$n::jsonb. Keyword search chooses aplainto_tsquerypath whendb.dialectis postgres.The shipped server still refuses
storage.provider: postgresandOPENMEMORY_STORAGE=postgresbefore opening a file. PGlite is a devDependency so the npm package does not grow a WASM engine.Testing Evidence
npm run buildsucceedsnpm test— 803 passed, 6 skippeddatetime('now')Complexity
Checklist
npm run buildsucceedsnpm testpasses