Skip to content

Batch Table

Overview

Stores one project-scoped batch of up to 500 requests. Supported operations are Page Import, Code2Des, and Page Discovery (one homepage per batch).

Table Definition

Logical Name Physical Name Column Name Data Type Primary Key Relation Unique Nullable Default Value Remarks
Batch batch id string โ—ฏ Client UUID / ใ‚ฏใƒฉใ‚คใ‚ขใƒณใƒˆ UUID (varchar(255))
organization_id number organization:id Organization scope / ็ต„็น”
project_id number project:id Project scope / ใƒ—ใƒญใ‚ธใ‚งใ‚ฏใƒˆ
type string page_import, code2des, or page_discovery (varchar(32))
request_hash string SHA-256 of normalized input or retry source batch / ๅ…ฅๅŠ›ใพใŸใฏๅ†่ฉฆ่กŒๅ…ƒใƒใƒƒใƒใฎ SHA-256 (varchar(64))
created_at datetime CURRENT_TIMESTAMP Shared audit field / ๅ…ฑ้€š็›ฃๆŸป้ …็›ฎ
updated_at datetime CURRENT_TIMESTAMP Shared audit field / ๅ…ฑ้€š็›ฃๆŸป้ …็›ฎ
deleted_at datetime โ—ฏ Soft delete / ่ซ–็†ๅ‰Š้™คๆ—ฅๆ™‚
created_by string Cognito subject (varchar(50))
updated_by string Cognito subject (varchar(50))
deleted_by string โ—ฏ Cognito subject (varchar(50))

Relations

  • organization_id โ†’ organization.id (delete cascade)
  • project_id โ†’ project.id (delete cascade)
  • batch_item.batch_id โ†’ batch.id (delete cascade)

Indexes

  • PRIMARY KEY (id)
  • INDEX batch_org_project_idx (organization_id, project_id)

Notes

  • batch and batch_item are shared across operations. Adding an operation requires request validation and a registered job handler, not new batch tables.
  • services/batch-operations.ts registers job preparation, status lookup, retry validation, and dead-letter handling. Feature job tables remain the source of processing status and results.
  • The existing /page-batches API and internal dispatcher path remain unchanged for the plugin and schedule.
  • Aggregate status is derived from child jobs and dispatch metadata; counters are not stored separately.
  • Dispatch claims expire after 90 seconds. Row locks prevent concurrent claims. Queue delivery is attempted up to three times using the same child ID and message.
  • Workers do not connect to PostgreSQL. Existing webhooks update Page Import and Code2Des completion. Page Discovery publishes status and URL previews to S3; its registered handler reads those results without an additional job table.