Skip to content

Add a photos table and content preflight SQL to every demo schema - #29

Merged
LucaCappelletti94 merged 6 commits into
mainfrom
feat/r69-schema
Sep 17, 2026
Merged

LucaCappelletti94 merged 6 commits into
mainfrom
feat/r69-schema

Conversation

@LucaCappelletti94

@LucaCappelletti94 LucaCappelletti94 commented Sep 17, 2026

Copy link
Copy Markdown
Owner

Every demo schema now carries a photos table with the two content columns, content_id and content_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 typed diesel::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 FULL lives 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 omits INSERT while 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:

  • Add photos tables and client schema definitions to the demo applications, including content identifiers and availability state.
  • Add file-content preflight SQL and permissions to support visibility checks, content-state updates, and replication.
  • Integrate photos into browser-stack replication and writable-table configuration.

Enhancements:

  • Add row-level security coverage for photo records in the WASM smoke demo.
  • Align browser and client demo schemas with the new photos table across SQLite and typed Diesel definitions.

CI:

  • Pre-pull the identity-provider image in CI to reduce browser-suite startup delays.
  • Configure coverage and Sonar analysis to exclude generated or uninstrumented demo artifacts.

Deployment:

  • Document and provide the required deployment SQL ordering, grants, and PostgreSQL replica identity configuration for content-enabled demos.

…tate plus its content.sql visibility and state-setter functions and reader grants with photos published writable in the recipes
@coderabbitai

coderabbitai Bot commented Sep 17, 2026

Copy link
Copy Markdown

Important

  • 🔍 Trigger review

This repository does not receive automatic reviews because it has fewer than 10 stars.

⚙️ Run configuration

Configuration used: Repository: LucaCappelletti94/coderabbit/.coderabbit.yaml

Review profile: ASSERTIVE

Plan: Advanced

Run ID: 4f26bf42-f409-4f24-b0f6-02e1d733130d


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.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@sourcery-ai sourcery-ai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Sep 17, 2026

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review Completed 2026-09-17T04:56:17.068977Z f4b586b PR opened
ℹ️ 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" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@sourcery-ai

sourcery-ai Bot commented Sep 17, 2026

Copy link
Copy Markdown

Reviewer's Guide

The 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 commit

sequenceDiagram
    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
Loading

Entity relationship diagram for photos metadata

erDiagram
    ORDERS ||--o{ PHOTOS : has
    ORDERS {
        UUID id PK
    }
    PHOTOS {
        UUID id PK
        UUID order_id FK
        BYTEA content_id
        TEXT content_state
    }
Loading

File-Level Changes

Change Details Files
Add the photos content model to each demo's PostgreSQL and client-side schemas.
  • Create photos tables with identifiers, order linkage, content_id, content_state, and demo-specific ownership columns.
  • Add matching SQLite bootstrap/tab DDL where schemas are embedded in application code.
  • Add typed Diesel table definitions for demos that declare schemas in Rust.
examples/dioxus-desktop-demo/schema.sql
examples/dioxus-desktop-demo/src/main.rs
examples/dioxus-web-demo/schema.sql
examples/dioxus-web-demo/src/main.rs
examples/wasm-smoke/schema.sql
examples/yew-web-demo/schema.sql
examples/yew-web-demo/src/main.rs
Integrate the photos table into synchronization, writability, permissions, and RLS configuration.
  • Include photos in CONNETTO_WRITABLE and browser-stack replication setup.
  • Grant connetto_reader full DML access to photos to support demo writes.
  • Add the wasm-smoke photos RLS policy using the row's owner identity.
crates/connetto-client/tests/it/verified_topology.rs
crates/connetto-test-harness/src/bin/connetto-browser-stack.rs
examples/dioxus-desktop-demo/roles.sql
examples/dioxus-web-demo/roles.sql
examples/wasm-smoke/roles.sql
examples/wasm-smoke/policies.sql
Add file-server content preflight SQL to every demo deployment.
  • Define the SECURITY INVOKER visibility helper and pinned-search-path SECURITY DEFINER state setter.
  • Grant the file-server reader access to manifests, chunks, photos, and helper execution.
  • Apply REPLICA IDENTITY FULL in deployment-only SQL to avoid pg2sqlite translation failures.
examples/dioxus-desktop-demo/content.sql
examples/dioxus-web-demo/content.sql
examples/wasm-smoke/content.sql
examples/yew-web-demo/content.sql

Tips and commands

Interacting with Sourcery

  • Trigger a new review: Comment @sourcery-ai review on the pull request.
  • Continue discussions: Reply directly to Sourcery's review comments.
  • Generate a GitHub issue from a review comment: Ask Sourcery to create an
    issue from a review comment by replying to it. You can also reply to a
    review comment with @sourcery-ai issue to create an issue from it.
  • Generate a pull request title: Write @sourcery-ai anywhere in the pull
    request title to generate a title at any time. You can also comment
    @sourcery-ai title on the pull request to (re-)generate the title at any time.
  • Generate a pull request summary: Write @sourcery-ai summary anywhere in
    the pull request body to generate a PR summary at any time exactly where you
    want it. You can also comment @sourcery-ai summary on the pull request to
    (re-)generate the summary at any time.
  • Generate reviewer's guide: Comment @sourcery-ai guide on the pull
    request to (re-)generate the reviewer's guide at any time.
  • Resolve all Sourcery comments: Comment @sourcery-ai resolve on the
    pull request to resolve all Sourcery comments. Useful if you've already
    addressed all the comments and don't want to see them anymore.
  • Dismiss all Sourcery reviews: Comment @sourcery-ai dismiss on the pull
    request to dismiss all existing Sourcery reviews. Especially useful if you
    want to start fresh with a new review - don't forget to comment
    @sourcery-ai review to trigger a new review!

Customizing Your Experience

Access your dashboard to:

  • Enable or disable review features such as the Sourcery-generated pull request
    summary, the reviewer's guide, and others.
  • Change the review language.
  • Add, remove or edit custom review instructions.
  • Adjust other review settings.

Getting Help

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 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; \

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Badge 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 👍 / 👎.

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

codecov Bot commented Sep 17, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 82.72%. Comparing base (78e2a03) to head (b2b4a12).

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     
Flag Coverage Δ
client 64.21% <ø> (ø)
rest 55.31% <ø> (+1.31%) ⬆️
server 49.99% <ø> (ø)

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@sonarqubecloud

Copy link
Copy Markdown

@LucaCappelletti94
LucaCappelletti94 merged commit ea2bec3 into main Sep 17, 2026
57 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

Development

Successfully merging this pull request may close these issues.

1 participant