Skip to content

Conversation

@simolus3
Copy link
Contributor

@simolus3 simolus3 commented Nov 5, 2025

This replaces intermediate SQL logic used to setup views with a simple filter implemented in Rust. This makes the flow much easier to understand, and avoids re-parsing tables from JSON multiple times.

Specifically, this removes the following internal SQL functions and views:

  • The powersync_views view and associated triggers.
  • powersync_exec
  • powersync_view_sql, powersync_trigger_delete_sql, powersync_trigger_insert_sql, powersync_trigger_update_sql.

Instead, it adds the ExistingView struct which holds the same fields as powersync_views and uses the same query to read views. When we apply a schema, we use the parsed schema struct to find necessary updates instead of expressing that in SQL. The functions to create SQL for views and triggers has also been refactored to be Rust-internal.

I've kept powersync_drop_view because it's used in a down migration we can't change. I had to migrate one up migration to use the new direct Rust calls in favor of the SQL layer, but the behavior should be the same.

These changes are covered by existing tests. This still keeps powersync_tables around, I will refactor that away in a follow-up PR.

@simolus3 simolus3 requested a review from rkistner November 5, 2025 14:47
Copy link
Contributor

@rkistner rkistner left a comment

Choose a reason for hiding this comment

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

Nice, this does appear to simplify the management

@simolus3 simolus3 merged commit 5c7421a into main Nov 5, 2025
25 checks passed
@simolus3 simolus3 deleted the view-admin-refactor branch November 5, 2025 15:19
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.

3 participants