Add a photos table and content preflight SQL to every demo schema - #29
Conversation
…tate plus its content.sql visibility and state-setter functions and reader grants with photos published writable in the recipes
|
Important
This repository does not receive automatic reviews because it has fewer than 10 stars. ⚙️ Run configurationConfiguration used: Repository: LucaCappelletti94/coderabbit/.coderabbit.yaml Review profile: ASSERTIVE Plan: Advanced Run ID: Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Sorry @LucaCappelletti94, you've used your own review budget of 250,000 diff characters for the last 7 days.
You can request another review in 4 days and 14 hours by commenting @sourcery-ai review. Upgrade to get a review now.
Codex Review SummaryThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
Reviewer's GuideThe PR equips all demo schemas with synchronized photos metadata and wires it through embedded client schemas, replication/writability configuration, reader permissions, RLS, and file-server preflight SQL, keeping PostgreSQL-only replica identity settings outside translated base schemas. Sequence diagram for photo upload and content-state commitsequenceDiagram
actor User
participant Client
participant Server
participant FileServer
participant Photos
User->>Client: Create photo row
Client->>Server: INSERT photos
Server->>Photos: Write content_id, content_state
Client->>FileServer: Upload content_id
FileServer->>Photos: connetto_visible_files
Photos-->>FileServer: Visible file IDs
FileServer->>Photos: connetto_set_content_state
Photos-->>Server: content_state = available
Server-->>Client: Synced photo update
Entity relationship diagram for photos metadataerDiagram
ORDERS ||--o{ PHOTOS : has
ORDERS {
UUID id PK
}
PHOTOS {
UUID id PK
UUID order_id FK
BYTEA content_id
TEXT content_state
}
File-Level Changes
Tips and commandsInteracting with Sourcery
Customizing Your ExperienceAccess your dashboard to:
Getting Help
|
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: f4b586b154
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| /// relayed patch applies to main. The hub, not the tab, keeps the tiers apart. | ||
| const DEMO_TAB_DDL: &str = "CREATE TABLE orders (id BLOB PRIMARY KEY DEFAULT (uuidv4()) CHECK (length(id) = 16) NOT NULL, quantity INTEGER NOT NULL CHECK (quantity >= 0)) STRICT; \ | ||
| CREATE TABLE order_lines (order_id BLOB NOT NULL REFERENCES orders(id) CHECK (length(order_id) = 16), line_no INTEGER NOT NULL, quantity INTEGER NOT NULL CHECK (quantity >= 0), PRIMARY KEY (order_id, line_no)) STRICT; \ | ||
| CREATE TABLE photos (id BLOB PRIMARY KEY DEFAULT (uuidv4()) CHECK (length(id) = 16) NOT NULL, order_id BLOB NOT NULL REFERENCES orders(id) CHECK (length(order_id) = 16), content_id BLOB NOT NULL, content_state TEXT) STRICT; \ |
There was a problem hiding this comment.
Add photos to the Yew worker DDL
This adds photos only to the tab mirror, while DEMO_SQLITE_DDL at lines 68–69—passed to the DB worker via with_replica_ddl—still creates only orders and order_lines. When a Yew tab authors the newly supported photo row, the relay classifies it as a synced mutation and attempts to apply it to a worker database with no photos table, causing the mutation to be rejected instead of uploaded and synchronized. The worker DDL needs the same photos definition added here.
Useful? React with 👍 / 👎.
There was a problem hiding this comment.
Fixed in b2b4a12. DEMO_SQLITE_DDL in the Yew demo now carries the photos table, matching schema.sql and the dioxus demo, so synced photo rows land on the worker replica instead of being refused.
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #29 +/- ##
==========================================
+ Coverage 81.12% 82.72% +1.60%
==========================================
Files 115 114 -1
Lines 25485 24926 -559
Branches 25485 24926 -559
==========================================
- Hits 20674 20620 -54
+ Misses 3620 3116 -504
+ Partials 1191 1190 -1
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
|



Every demo schema now carries a photos table with the two content columns,
content_idandcontent_state, next to its existing tables, and each demo gains the content preflight SQL chapter 18 asks for: the visibility helper the content policy calls and the state-setter trigger functions the upload protocol writes through. The typeddiesel::table!entries land in the demo binaries that declare their schema in code, and the browser-stack recipe publishes photos and writes them back under RLS.Two decisions here are deliberate deviations worth a reviewer's eye.
REPLICA IDENTITY FULLlives in the preflight SQL rather than the base schema because pg2sqlite refuses the statement inside translated DDL. And the roles grant full DML on the new table because the plan's decision list omitsINSERTwhile every demo's row write needs it, so the grant is what the demos actually require rather than what the list literally says.Summary by Sourcery
Enable file-backed photo content across all demo schemas and deployment setups, including synchronization, authorization, and content lifecycle support.
New Features:
Enhancements:
CI:
Deployment: