diff --git a/.github/workflows/deploy-sync-rules.yml b/.github/workflows/deploy-sync-streams.yml similarity index 72% rename from .github/workflows/deploy-sync-rules.yml rename to .github/workflows/deploy-sync-streams.yml index c29e87b..e434148 100644 --- a/.github/workflows/deploy-sync-rules.yml +++ b/.github/workflows/deploy-sync-streams.yml @@ -1,11 +1,12 @@ -name: Deploy Sync Rules +name: Deploy Sync Streams on: push: branches: - main + - new-cli paths: - - "sync-rules.yaml" + - "sync-config.yaml" permissions: contents: read @@ -26,12 +27,12 @@ jobs: - name: Install PowerSync CLI run: npm install powersync - - name: Deploy sync rules + - name: Deploy sync config env: - AUTH_TOKEN: ${{ secrets.POWERSYNC_AUTH_TOKEN }} + PS_ADMIN_TOKEN: ${{ secrets.POWERSYNC_AUTH_TOKEN }} INSTANCE_ID: ${{ secrets.POWERSYNC_INSTANCE_ID }} PROJECT_ID: ${{ secrets.POWERSYNC_PROJECT_ID }} ORG_ID: ${{ secrets.POWERSYNC_ORG_ID }} run: | - npx powersync instance sync-rules deploy --filePath ./sync-rules.yaml -s + npx powersync deploy sync-config --directory=. diff --git a/README.md b/README.md index c0eb03c..2f2aad4 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,6 @@ -## GitHub Actions Sync Rules Demo +## GitHub Actions Deploy Sync Streams Demo -This repository shows how to deploy PowerSync Sync Rules to an instance whenever a push to the `main` branch includes changes to `sync-rules.yaml`. The included GitHub Actions workflow installs the PowerSync CLI and runs the deployment command automatically. +This repository shows how to deploy PowerSync sync config to an instance whenever a push to the `main` branch includes changes to `sync_config.yaml`. The included GitHub Actions workflow installs the PowerSync CLI and runs the deployment command automatically. ## Prerequisites diff --git a/sync-config.yaml b/sync-config.yaml new file mode 100644 index 0000000..f910907 --- /dev/null +++ b/sync-config.yaml @@ -0,0 +1,11 @@ +streams: + owned_lists: + query: SELECT * FROM lists WHERE owner_id = auth.user_id() + list_todos: + query: SELECT * FROM todos WHERE list_id = subscription.parameter('list_id') AND list_id IN (SELECT id FROM lists WHERE owner_id = auth.user_id()) + +config: + # see https://docs.powersync.com/sync/advanced/compatibility + # this edition also deploys several backwards-incompatible fixes + # see the docs for details + edition: 3 \ No newline at end of file diff --git a/sync-rules.yaml b/sync-rules.yaml deleted file mode 100644 index 2c5d193..0000000 --- a/sync-rules.yaml +++ /dev/null @@ -1,5 +0,0 @@ -bucket_definitions: - global: - data: - - SELECT * FROM lists - - SELECT id FROM todos \ No newline at end of file