From 2f8a95005743384ba51aee472a727a9f99a9f5d9 Mon Sep 17 00:00:00 2001 From: stevensJourney Date: Wed, 27 Nov 2024 11:28:04 +0200 Subject: [PATCH 1/2] update PowerSync service Docker image --- CHANGELOG.md | 4 ++ demos/nodejs-mongodb/docker-compose.yaml | 2 - demos/nodejs-mysql/docker-compose.yaml | 2 - demos/nodejs/init-scripts/setup.sql | 49 ++++++++++++++++++++++++ services/powersync.yaml | 9 +---- 5 files changed, 54 insertions(+), 12 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 6c223f1..1de2b34 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,9 @@ # PowerSync Self Hosted Example +## 2024-11-27 + +- Updated `journeyapps/powersync-service:latest` image specifier which will target `>v.1.0.0` of the Docker image. This version of the Docker image contains support for MongoDB (alpha), MySQL (alpha) and the new modular architecture. + ## v0.6.1 - Updated `powersync/web` to version `1.11.0` in NodeJS demo app. diff --git a/demos/nodejs-mongodb/docker-compose.yaml b/demos/nodejs-mongodb/docker-compose.yaml index c0327f7..687430b 100644 --- a/demos/nodejs-mongodb/docker-compose.yaml +++ b/demos/nodejs-mongodb/docker-compose.yaml @@ -16,7 +16,5 @@ services: depends_on: mongo-rs-init: condition: service_completed_successfully - # MongoDB support is available via this image version - image: journeyapps/powersync-service:0.0.0-dev-20240923154849 volumes: - ./config:/config diff --git a/demos/nodejs-mysql/docker-compose.yaml b/demos/nodejs-mysql/docker-compose.yaml index 2df3b1a..a83dc1e 100644 --- a/demos/nodejs-mysql/docker-compose.yaml +++ b/demos/nodejs-mysql/docker-compose.yaml @@ -21,7 +21,5 @@ services: condition: service_healthy mongo-rs-init: condition: service_completed_successfully - # MySQL support is available via this image version - image: journeyapps/powersync-service:0.0.0-dev-20241024055608 volumes: - ./config:/config diff --git a/demos/nodejs/init-scripts/setup.sql b/demos/nodejs/init-scripts/setup.sql index 730e18f..3c1b7dd 100644 --- a/demos/nodejs/init-scripts/setup.sql +++ b/demos/nodejs/init-scripts/setup.sql @@ -30,3 +30,52 @@ INSERT INTO todos (description, list_id, completed) VALUES ('Create a todo here. -- Create publication for PowerSync create publication powersync for table lists, todos; + + +DO $$ +DECLARE + i INT; + description TEXT; + list_id UUID; + created_by UUID; + completed_by UUID; + photo_id UUID; +BEGIN + FOR i IN 1..20000 LOOP + -- Generate random data for each row + description := 'Task description ' || i; + list_id := gen_random_uuid(); + created_by := gen_random_uuid(); + -- 50% chance for completed rows + IF random() > 0.5 THEN + completed_by := gen_random_uuid(); + ELSE + completed_by := NULL; + END IF; + -- 30% chance to include a photo + IF random() > 0.7 THEN + photo_id := gen_random_uuid(); + ELSE + photo_id := NULL; + END IF; + + -- Insert into the todos table + INSERT INTO public.todos ( + description, + completed, + created_by, + completed_by, + list_id, + photo_id, + completed_at + ) VALUES ( + description, + completed_by IS NOT NULL, -- True if completed_by is not NULL + created_by, + completed_by, + list_id, + photo_id, + CASE WHEN completed_by IS NOT NULL THEN now() - (random() * interval '10 days') ELSE NULL END + ); + END LOOP; +END $$; diff --git a/services/powersync.yaml b/services/powersync.yaml index 67c67e9..398cde4 100644 --- a/services/powersync.yaml +++ b/services/powersync.yaml @@ -1,14 +1,7 @@ services: powersync: restart: unless-stopped - # This currently uses a development image for the Next version of the PowerSync - # service. This Next version contains a new module system which will enable plugable - # functionality in the future. Functionality in this version should be the same as the - # latest stable version. - # Please report any issues experienced. Thank you for testing. - # Feel free to revert to the stable version by using - # image: journeyapps/powersync-service:latest - image: journeyapps/powersync-service:0.0.0-dev-20240920084840 + image: journeyapps/powersync-service:latest # The unified service runs an API server and replication worker in the same container. # These services can be executed in different containers by using individual entry commands e.g. # Start only the API server with From 95845f3ed3d73966d2dfc0739b06c7abdf2d439b Mon Sep 17 00:00:00 2001 From: stevensJourney Date: Wed, 27 Nov 2024 11:29:22 +0200 Subject: [PATCH 2/2] cleanup --- demos/nodejs/init-scripts/setup.sql | 49 ----------------------------- 1 file changed, 49 deletions(-) diff --git a/demos/nodejs/init-scripts/setup.sql b/demos/nodejs/init-scripts/setup.sql index 3c1b7dd..730e18f 100644 --- a/demos/nodejs/init-scripts/setup.sql +++ b/demos/nodejs/init-scripts/setup.sql @@ -30,52 +30,3 @@ INSERT INTO todos (description, list_id, completed) VALUES ('Create a todo here. -- Create publication for PowerSync create publication powersync for table lists, todos; - - -DO $$ -DECLARE - i INT; - description TEXT; - list_id UUID; - created_by UUID; - completed_by UUID; - photo_id UUID; -BEGIN - FOR i IN 1..20000 LOOP - -- Generate random data for each row - description := 'Task description ' || i; - list_id := gen_random_uuid(); - created_by := gen_random_uuid(); - -- 50% chance for completed rows - IF random() > 0.5 THEN - completed_by := gen_random_uuid(); - ELSE - completed_by := NULL; - END IF; - -- 30% chance to include a photo - IF random() > 0.7 THEN - photo_id := gen_random_uuid(); - ELSE - photo_id := NULL; - END IF; - - -- Insert into the todos table - INSERT INTO public.todos ( - description, - completed, - created_by, - completed_by, - list_id, - photo_id, - completed_at - ) VALUES ( - description, - completed_by IS NOT NULL, -- True if completed_by is not NULL - created_by, - completed_by, - list_id, - photo_id, - CASE WHEN completed_by IS NOT NULL THEN now() - (random() * interval '10 days') ELSE NULL END - ); - END LOOP; -END $$;