-
Notifications
You must be signed in to change notification settings - Fork 14
chore: update demo app versions to snapshot #236
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Closed
Closed
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
103 changes: 103 additions & 0 deletions
103
...ayground/supabase/migrations/20251008044437_20250707210212_pgflow_add_opt_start_delay.sql
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,103 @@ | ||
| -- Modify "steps" table | ||
| ALTER TABLE "pgflow"."steps" ADD CONSTRAINT "opt_start_delay_is_nonnegative" CHECK ((opt_start_delay IS NULL) OR (opt_start_delay >= 0)), ADD COLUMN "opt_start_delay" integer NULL; | ||
| -- Modify "start_ready_steps" function | ||
| CREATE OR REPLACE FUNCTION "pgflow"."start_ready_steps" ("run_id" uuid) RETURNS void LANGUAGE sql SET "search_path" = '' AS $$ | ||
| WITH ready_steps AS ( | ||
| SELECT * | ||
| FROM pgflow.step_states AS step_state | ||
| WHERE step_state.run_id = start_ready_steps.run_id | ||
| AND step_state.status = 'created' | ||
| AND step_state.remaining_deps = 0 | ||
| ORDER BY step_state.step_slug | ||
| FOR UPDATE | ||
| ), | ||
| started_step_states AS ( | ||
| UPDATE pgflow.step_states | ||
| SET status = 'started', | ||
| started_at = now() | ||
| FROM ready_steps | ||
| WHERE pgflow.step_states.run_id = start_ready_steps.run_id | ||
| AND pgflow.step_states.step_slug = ready_steps.step_slug | ||
| RETURNING pgflow.step_states.* | ||
| ), | ||
| sent_messages AS ( | ||
| SELECT | ||
| started_step.flow_slug, | ||
| started_step.run_id, | ||
| started_step.step_slug, | ||
| pgmq.send( | ||
| started_step.flow_slug, | ||
| jsonb_build_object( | ||
| 'flow_slug', started_step.flow_slug, | ||
| 'run_id', started_step.run_id, | ||
| 'step_slug', started_step.step_slug, | ||
| 'task_index', 0 | ||
| ), | ||
| COALESCE(step.opt_start_delay, 0) | ||
| ) AS msg_id | ||
| FROM started_step_states AS started_step | ||
| JOIN pgflow.steps AS step | ||
| ON step.flow_slug = started_step.flow_slug | ||
| AND step.step_slug = started_step.step_slug | ||
| ), | ||
| broadcast_events AS ( | ||
| SELECT | ||
| realtime.send( | ||
| jsonb_build_object( | ||
| 'event_type', 'step:started', | ||
| 'run_id', started_step.run_id, | ||
| 'step_slug', started_step.step_slug, | ||
| 'status', 'started', | ||
| 'started_at', started_step.started_at, | ||
| 'remaining_tasks', 1, | ||
| 'remaining_deps', started_step.remaining_deps | ||
| ), | ||
| concat('step:', started_step.step_slug, ':started'), | ||
| concat('pgflow:run:', started_step.run_id), | ||
| false | ||
| ) | ||
| FROM started_step_states AS started_step | ||
| ) | ||
| INSERT INTO pgflow.step_tasks (flow_slug, run_id, step_slug, message_id) | ||
| SELECT | ||
| sent_messages.flow_slug, | ||
| sent_messages.run_id, | ||
| sent_messages.step_slug, | ||
| sent_messages.msg_id | ||
| FROM sent_messages; | ||
| $$; | ||
| -- Create "add_step" function | ||
| CREATE FUNCTION "pgflow"."add_step" ("flow_slug" text, "step_slug" text, "deps_slugs" text[], "max_attempts" integer DEFAULT NULL::integer, "base_delay" integer DEFAULT NULL::integer, "timeout" integer DEFAULT NULL::integer, "start_delay" integer DEFAULT NULL::integer) RETURNS "pgflow"."steps" LANGUAGE sql SET "search_path" = '' AS $$ | ||
| WITH | ||
| next_index AS ( | ||
| SELECT COALESCE(MAX(step_index) + 1, 0) as idx | ||
| FROM pgflow.steps | ||
| WHERE flow_slug = add_step.flow_slug | ||
| ), | ||
| create_step AS ( | ||
| INSERT INTO pgflow.steps (flow_slug, step_slug, step_index, deps_count, opt_max_attempts, opt_base_delay, opt_timeout, opt_start_delay) | ||
| SELECT add_step.flow_slug, add_step.step_slug, idx, COALESCE(array_length(deps_slugs, 1), 0), max_attempts, base_delay, timeout, start_delay | ||
| FROM next_index | ||
| ON CONFLICT (flow_slug, step_slug) | ||
| DO UPDATE SET step_slug = pgflow.steps.step_slug | ||
| RETURNING * | ||
| ), | ||
| insert_deps AS ( | ||
| INSERT INTO pgflow.deps (flow_slug, dep_slug, step_slug) | ||
| SELECT add_step.flow_slug, d.dep_slug, add_step.step_slug | ||
| FROM unnest(deps_slugs) AS d(dep_slug) | ||
| ON CONFLICT (flow_slug, dep_slug, step_slug) DO NOTHING | ||
| RETURNING 1 | ||
| ) | ||
| -- Return the created step | ||
| SELECT * FROM create_step; | ||
| $$; | ||
| -- Drop "add_step" function | ||
| DROP FUNCTION "pgflow"."add_step" (text, text, integer, integer, integer); | ||
| -- Drop "add_step" function | ||
| DROP FUNCTION "pgflow"."add_step" (text, text, text[], integer, integer, integer); | ||
| -- Create "add_step" function | ||
| CREATE FUNCTION "pgflow"."add_step" ("flow_slug" text, "step_slug" text, "max_attempts" integer DEFAULT NULL::integer, "base_delay" integer DEFAULT NULL::integer, "timeout" integer DEFAULT NULL::integer, "start_delay" integer DEFAULT NULL::integer) RETURNS "pgflow"."steps" LANGUAGE sql SET "search_path" = '' AS $$ | ||
| -- Call the original function with an empty array | ||
| SELECT * FROM pgflow.add_step(flow_slug, step_slug, ARRAY[]::text[], max_attempts, base_delay, timeout, start_delay); | ||
| $$; | ||
2 changes: 2 additions & 0 deletions
2
...layground/supabase/migrations/20251008044438_20250719205006_pgflow_worker_deprecation.sql
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,2 @@ | ||
| -- Rename a column from "stopped_at" to "deprecated_at" | ||
| ALTER TABLE "pgflow"."workers" RENAME COLUMN "stopped_at" TO "deprecated_at"; |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The migration adds
opt_start_delayand a non‑negative check in oneALTER TABLE, but the constraint is declared before the column exists (ALTER TABLE ... ADD CONSTRAINT …, ADD COLUMN …). PostgreSQL executes clauses left‑to‑right, so this statement fails because the constraint references a non‑existent column. The migration will halt on apply and none of the later changes run until the order is corrected.Useful? React with 👍 / 👎.