Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion packages/database-jobs/Makefile
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
EXTENSION = pgpm-database-jobs
DATA = sql/pgpm-database-jobs--0.22.0.sql
DATA = sql/pgpm-database-jobs--0.26.0.sql

PG_CONFIG = pg_config
PGXS := $(shell $(PG_CONFIG) --pgxs)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ exports[`scheduled jobs schedule jobs 1`] = `
"actor_id": null,
"attempts": 0,
"database_id": "5b720132-17d5-424d-9bcb-ee7b17c13d43",
"entity_id": null,
"id": "1",
"is_available": true,
"key": null,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,8 @@ CREATE FUNCTION app_jobs.add_job (
queue_name text DEFAULT NULL,
run_at timestamptz DEFAULT now(),
max_attempts integer DEFAULT 25,
priority integer DEFAULT 0
priority integer DEFAULT 0,
entity_id uuid DEFAULT NULL
)
RETURNS app_jobs.jobs
AS $$
Expand All @@ -31,6 +32,7 @@ BEGIN
INSERT INTO app_jobs.jobs (
database_id,
actor_id,
entity_id,
task_identifier,
payload,
queue_name,
Expand All @@ -41,6 +43,7 @@ BEGIN
) VALUES (
v_database_id,
v_actor_id,
add_job.entity_id,
identifier,
coalesce(payload, '{}'::json),
queue_name,
Expand Down Expand Up @@ -84,6 +87,7 @@ BEGIN
INSERT INTO app_jobs.jobs (
database_id,
actor_id,
entity_id,
task_identifier,
payload,
queue_name,
Expand All @@ -93,6 +97,7 @@ BEGIN
) VALUES (
v_database_id,
v_actor_id,
add_job.entity_id,
identifier,
payload,
queue_name,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,8 @@ CREATE FUNCTION app_jobs.add_scheduled_job(
job_key text DEFAULT NULL,
queue_name text DEFAULT NULL,
max_attempts integer DEFAULT 25,
priority integer DEFAULT 0
priority integer DEFAULT 0,
entity_id uuid DEFAULT NULL
)
RETURNS app_jobs.scheduled_jobs
AS $$
Expand All @@ -32,6 +33,7 @@ BEGIN
INSERT INTO app_jobs.scheduled_jobs (
database_id,
actor_id,
entity_id,
task_identifier,
payload,
queue_name,
Expand All @@ -42,6 +44,7 @@ BEGIN
) VALUES (
v_database_id,
v_actor_id,
add_scheduled_job.entity_id,
identifier,
coalesce(payload, '{}'::json),
queue_name,
Expand Down Expand Up @@ -81,6 +84,7 @@ BEGIN
INSERT INTO app_jobs.scheduled_jobs (
database_id,
actor_id,
entity_id,
task_identifier,
payload,
queue_name,
Expand All @@ -90,6 +94,7 @@ BEGIN
) VALUES (
v_database_id,
v_actor_id,
add_scheduled_job.entity_id,
identifier,
payload,
queue_name,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ BEGIN
INSERT INTO app_jobs.jobs (
database_id,
actor_id,
entity_id,
queue_name,
task_identifier,
payload,
Expand All @@ -51,6 +52,7 @@ BEGIN
) SELECT
database_id,
actor_id,
entity_id,
queue_name,
task_identifier,
payload,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ CREATE TABLE app_jobs.jobs (
id bigserial PRIMARY KEY,
database_id uuid,
actor_id uuid,
entity_id uuid,
queue_name text DEFAULT NULL,
task_identifier text NOT NULL,
payload json DEFAULT '{}' ::json NOT NULL,
Expand All @@ -30,6 +31,7 @@ COMMENT ON TABLE app_jobs.jobs IS 'Background job queue: each row is a pending o
COMMENT ON COLUMN app_jobs.jobs.id IS 'Auto-incrementing job identifier';
COMMENT ON COLUMN app_jobs.jobs.database_id IS 'Database this job belongs to (nullable for system-level jobs without tenant context)';
COMMENT ON COLUMN app_jobs.jobs.actor_id IS 'User who triggered this job, read from JWT claims at enqueue time';
COMMENT ON COLUMN app_jobs.jobs.entity_id IS 'Entity (org/team) this job is scoped to for billing; NULL means platform-level (resolved via database_id → owner_id)';
COMMENT ON COLUMN app_jobs.jobs.queue_name IS 'Name of the queue this job belongs to; used for worker routing and concurrency control';
COMMENT ON COLUMN app_jobs.jobs.task_identifier IS 'Identifier for the task type (maps to a worker handler function)';
COMMENT ON COLUMN app_jobs.jobs.payload IS 'JSON payload of arguments passed to the task handler';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ CREATE TABLE app_jobs.scheduled_jobs (
id bigserial PRIMARY KEY,
database_id uuid,
actor_id uuid,
entity_id uuid,
queue_name text DEFAULT NULL,
task_identifier text NOT NULL,
payload json DEFAULT '{}' ::json NOT NULL,
Expand All @@ -29,6 +30,7 @@ COMMENT ON TABLE app_jobs.scheduled_jobs IS 'Recurring/cron-style job definition
COMMENT ON COLUMN app_jobs.scheduled_jobs.id IS 'Auto-incrementing scheduled job identifier';
COMMENT ON COLUMN app_jobs.scheduled_jobs.database_id IS 'Database this scheduled job belongs to (nullable for system-level schedules without tenant context)';
COMMENT ON COLUMN app_jobs.scheduled_jobs.actor_id IS 'User who created this scheduled job, read from JWT claims at creation time';
COMMENT ON COLUMN app_jobs.scheduled_jobs.entity_id IS 'Entity (org/team) this scheduled job is scoped to for billing; NULL means platform-level (resolved via database_id → owner_id)';
COMMENT ON COLUMN app_jobs.scheduled_jobs.queue_name IS 'Name of the queue spawned jobs are placed into';
COMMENT ON COLUMN app_jobs.scheduled_jobs.task_identifier IS 'Task type identifier for spawned jobs';
COMMENT ON COLUMN app_jobs.scheduled_jobs.payload IS 'JSON payload passed to each spawned job';
Expand Down
2 changes: 1 addition & 1 deletion packages/database-jobs/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -35,4 +35,4 @@
"bugs": {
"url": "https://github.com/constructive-io/pgpm-modules/issues"
}
}
}
2 changes: 1 addition & 1 deletion packages/database-jobs/pgpm-database-jobs.control
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# pgpm-database-jobs extension
comment = 'pgpm-database-jobs extension'
default_version = '0.22.0'
default_version = '0.26.0'
module_pathname = '$libdir/pgpm-database-jobs'
requires = 'plpgsql,pgcrypto,pgpm-verify,pgpm-jwt-claims'
relocatable = false
Expand Down
Loading
Loading