recurrents

This commit is contained in:
xds
2025-11-17 15:02:47 +03:00
parent d0cae182b7
commit 12afd1f90e
48 changed files with 1479 additions and 120 deletions

View File

@@ -0,0 +1,19 @@
-- Очередь классификации категорий
CREATE TABLE IF NOT EXISTS finance.category_jobs (
id BIGSERIAL PRIMARY KEY,
tx_id INT NOT NULL UNIQUE, -- одна задача на транзакцию
status TEXT NOT NULL DEFAULT 'NEW', -- NEW | PROCESSING | DONE | FAILED
attempts INT NOT NULL DEFAULT 0,
created_at TIMESTAMPTZ NOT NULL DEFAULT NOW(),
started_at TIMESTAMPTZ,
finished_at TIMESTAMPTZ,
last_error TEXT
);
-- Быстрые выборки по статусу
CREATE INDEX IF NOT EXISTS ix_category_jobs_status ON finance.category_jobs(status);
-- (опционально) защита от «зависших» задач
CREATE INDEX IF NOT EXISTS ix_category_jobs_processing_time
ON finance.category_jobs(started_at)
WHERE status = 'PROCESSING';