-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #204 from sidetracklabs/initial-cron-jobs-support
feat(sidetrack): cron jobs
- Loading branch information
Showing
11 changed files
with
390 additions
and
30 deletions.
There are no files selected for viewing
This file contains 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
This file contains 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,32 @@ | ||
import { MigrationBuilder } from "@sidetrack/pg-migrate"; | ||
|
||
export default { | ||
up: async (pgm: MigrationBuilder) => { | ||
pgm.sql(` | ||
CREATE TYPE sidetrack_cron_job_status_enum AS ENUM ( | ||
'active', | ||
'inactive' | ||
); | ||
CREATE TABLE IF NOT EXISTS sidetrack_cron_jobs ( | ||
id uuid PRIMARY KEY DEFAULT gen_random_uuid(), | ||
queue TEXT NOT NULL, | ||
cron_expression TEXT NOT NULL, | ||
payload JSONB NOT NULL, | ||
status sidetrack_cron_job_status_enum NOT NULL DEFAULT 'active', | ||
created_at TIMESTAMP WITH TIME ZONE DEFAULT NOW(), | ||
updated_at TIMESTAMP WITH TIME ZONE DEFAULT NOW(), | ||
UNIQUE(queue, cron_expression) | ||
); | ||
ALTER TABLE sidetrack_jobs ADD COLUMN cron_job_id uuid REFERENCES sidetrack_cron_jobs(id); | ||
ALTER TABLE sidetrack_jobs ADD COLUMN unique_key TEXT; | ||
CREATE UNIQUE INDEX ON sidetrack_jobs (unique_key); | ||
`); | ||
}, | ||
down: async (_pgm: MigrationBuilder) => {}, | ||
name: "2", | ||
}; |
This file contains 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
This file contains 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
Oops, something went wrong.