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
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
-- migrate:up

-- For duplicate detection in publish jobs
CREATE INDEX IF NOT EXISTS idx_publish_jobs_name_version
ON publish_jobs (packageName, packageVersion);

-- For duplicate detection in unpublish jobs
CREATE INDEX IF NOT EXISTS idx_unpublish_jobs_name_version
ON unpublish_jobs (packageName, packageVersion);

-- For duplicate detection in transfer jobs
CREATE INDEX IF NOT EXISTS idx_transfer_jobs_name
ON transfer_jobs (packageName);

-- For job selection performance
CREATE INDEX IF NOT EXISTS idx_job_info_pending
ON job_info (createdAt)
WHERE finishedAt IS NULL AND startedAt IS NULL;

-- migrate:down

DROP INDEX IF EXISTS idx_publish_jobs_name_version;
DROP INDEX IF EXISTS idx_unpublish_jobs_name_version;
DROP INDEX IF EXISTS idx_transfer_jobs_name;
DROP INDEX IF EXISTS idx_job_info_pending;
12 changes: 11 additions & 1 deletion db/schema.sql
Original file line number Diff line number Diff line change
Expand Up @@ -54,9 +54,19 @@ CREATE TABLE logs (
message TEXT NOT NULL,
timestamp TEXT NOT NULL
);
CREATE INDEX idx_publish_jobs_name_version
ON publish_jobs (packageName, packageVersion);
CREATE INDEX idx_unpublish_jobs_name_version
ON unpublish_jobs (packageName, packageVersion);
CREATE INDEX idx_transfer_jobs_name
ON transfer_jobs (packageName);
CREATE INDEX idx_job_info_pending
ON job_info (createdAt)
WHERE finishedAt IS NULL AND startedAt IS NULL;
-- Dbmate schema migrations
INSERT INTO "schema_migrations" (version) VALUES
('20230711143615'),
('20230711143803'),
('20240914170550'),
('20240914171030');
('20240914171030'),
('20260721231201');