Skip to content

pgSQL Client + tests#600

Merged
devhawk merged 7 commits intomainfrom
devhawk/pg-sql-client
Mar 10, 2026
Merged

pgSQL Client + tests#600
devhawk merged 7 commits intomainfrom
devhawk/pg-sql-client

Conversation

@devhawk
Copy link
Copy Markdown
Contributor

@devhawk devhawk commented Mar 3, 2026

No description provided.

@devhawk devhawk marked this pull request as ready for review March 4, 2026 00:30
@dosubot
Copy link
Copy Markdown

dosubot bot commented Mar 4, 2026

Related Documentation

1 document(s) may need updating based on files changed in this PR:

DBOS Python

System Database Schema
View Suggested Changes
@@ -238,7 +238,7 @@
 
 ### PostgreSQL Migrations
 
-13 migrations are defined for PostgreSQL via `get_dbos_migrations()`:
+14 migrations are defined for PostgreSQL via `get_dbos_migrations()`:
 
 1. [Initial schema creation](https://github.com/dbos-inc/dbos-transact-py/blob/12049d833dddbcaaea18d921149e2c33aad37ecf/dbos/_migration.py#L84-L208) - Creates all core tables, indexes, and optional LISTEN/NOTIFY triggers
 2. [Add `queue_partition_key` column](https://github.com/dbos-inc/dbos-transact-py/blob/12049d833dddbcaaea18d921149e2c33aad37ecf/dbos/_migration.py#L211-L214)
@@ -253,10 +253,41 @@
 11. [Add `serialization` columns to all tables](https://github.com/dbos-inc/dbos-transact-py/blob/12049d833dddbcaaea18d921149e2c33aad37ecf/dbos/_migration.py#L295-L303)
 12. Add `consumed` column and `idx_notifications_unconsumed` index to notifications table
 13. Create `application_versions` table with `version_id`, `version_name`, `version_timestamp`, and `created_at` columns
+14. Create PostgreSQL stored functions for SQL-based workflow operations:
+    - **`enqueue_workflow`** - Direct SQL-based workflow enqueueing with the following parameters:
+      - `workflow_name` (TEXT, required) - The name of the workflow to enqueue
+      - `queue_name` (TEXT, required) - The queue name for the workflow
+      - `positional_args` (JSON[], optional, default empty array) - Positional arguments for the workflow
+      - `named_args` (JSON, optional, default empty object) - Named arguments for the workflow
+      - `class_name` (TEXT, optional) - The class name if using class-based workflows
+      - `config_name` (TEXT, optional) - Configuration name for the workflow
+      - `workflow_id` (TEXT, optional) - Custom workflow ID (auto-generated if not provided)
+      - `app_version` (TEXT, optional) - Application version string
+      - `timeout_ms` (BIGINT, optional) - Timeout in milliseconds
+      - `deadline_epoch_ms` (BIGINT, optional) - Absolute deadline timestamp
+      - `deduplication_id` (TEXT, optional) - ID for deduplication within a queue
+      - `priority` (INTEGER, optional, default 0) - Priority for queue ordering
+      - `queue_partition_key` (TEXT, optional) - Partition key for queue distribution
+      
+      Returns: `workflow_id` (TEXT) - The UUID of the enqueued workflow
+      
+      The function inserts workflows with 'ENQUEUED' status, validates parameters, handles deduplication, and ensures workflow metadata consistency on conflicts.
+    
+    - **`send_message`** - Direct SQL-based message sending to workflows:
+      - `destination_id` (TEXT, required) - The workflow UUID to send the message to
+      - `message` (JSON, required) - The message payload
+      - `topic` (TEXT, optional, default '__null__topic__') - Message topic for filtering
+      - `message_id` (TEXT, optional, auto-generated) - Unique message identifier
+      
+      Returns: VOID
+      
+      The function inserts notifications into the notifications table and handles deduplication via message_id.
 
 ### SQLite Migrations
 
-13 migrations are defined for SQLite (no migration 10), parallel to PostgreSQL with SQLite-specific syntax adaptations. SQLite version [does not include the `event_dispatch_kv` table](https://github.com/dbos-inc/dbos-transact-py/blob/12049d833dddbcaaea18d921149e2c33aad37ecf/dbos/_migration.py#L166-L174). Migration 13 creates the `application_versions` table with the same columns as PostgreSQL.
+13 migrations are defined for SQLite (no migration 10 or 14), parallel to PostgreSQL with SQLite-specific syntax adaptations. SQLite version [does not include the `event_dispatch_kv` table](https://github.com/dbos-inc/dbos-transact-py/blob/12049d833dddbcaaea18d921149e2c33aad37ecf/dbos/_migration.py#L166-L174). Migration 13 creates the `application_versions` table with the same columns as PostgreSQL.
+
+**Note:** SQLite does not have an equivalent for PostgreSQL migration 14 (stored functions `enqueue_workflow` and `send_message`), as these are PostgreSQL-specific features.
 
 ### Limitations
 

[Accept] [Decline]

Note: You must be authenticated to accept/decline updates.

How did I do? Any feedback?  Join Discord

Copy link
Copy Markdown
Member

@kraftp kraftp left a comment

Choose a reason for hiding this comment

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

We'll merge this after this week's release to give more time for testing

@devhawk devhawk merged commit e2d420b into main Mar 10, 2026
10 checks passed
@devhawk devhawk deleted the devhawk/pg-sql-client branch March 10, 2026 16:35
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.

2 participants