Managed raw tables - #221
Draft
simolus3 wants to merge 7 commits into
Draft
Conversation
simolus3
added this pull request to stack #222
September 9, 2026 08:07
simolus3
force-pushed
the
raw-tables-by-default
branch
from
September 10, 2026 14:48
03e0e63 to
9542a89
Compare
Contributor
|
I think this feature will be great, but I wonder if we could remove the Or would that make the migration paths with JSON-based tables too difficult? In that case, maybe we can consider another change later (potentially breaking or opt-in) to remove |
Contributor
Author
|
I like that idea. Perhaps there could be a single flag (on the entire schema, not per-table) that does both.
|
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.
This adds a new type of table next to the existing ones based on JSON data + views (easy to manage and migrate, slower to query) and raw tables (fast queries and full customizability at the expense of a higher setup complexity). Direct tables (name tbd) have the shape of raw tables with proper SQLite columns that can be queried without decoding JSON on reads. At the same time, they still store the original JSON object they're derived from, which means they can be managed by the core extension.
A direct table has a shape like this:
The sync client treats this table like raw tables, automatically inferring statements to sync into it. There is no view to generate, but we generate triggers to forward writes into
ps_crud. For updates, the trigger also updates the__datacolumn.As an alternative to this table shape, I have considered keeping a
ps_data__-like table that just addsGENERATED ALWAYS AScolumns. This might seem simpler, but then you wouldn't be able to update these columns directly so we'd have to keep generating views andINSTEAD OFtriggers. The current pattern is closer to the shape one would expect SQLite tables to have.Direct tables are currently an opt-in, but we could make them the default in a future release.
TODOs
ps_untyped__dataset.