feat: add sidecar + processing migrations and postgres adapters

007_sidecar, 008_processing, 009_duplicate_groups migrations.
Tag, sidecar, job, batch, plugin, pipeline, duplicate repos.
This commit is contained in:
2026-05-31 11:04:13 +02:00
parent 3399e25441
commit 19be8c2adf
13 changed files with 1094 additions and 0 deletions

View File

@@ -0,0 +1,8 @@
CREATE TABLE sidecar_records (
asset_id UUID PRIMARY KEY REFERENCES assets(asset_id),
sync_status TEXT NOT NULL DEFAULT 'pending_write',
sidecar_storage_path TEXT NOT NULL,
last_synced_at TIMESTAMPTZ,
last_known_file_hash TEXT,
error_message TEXT
);

View File

@@ -0,0 +1,42 @@
CREATE TABLE jobs (
job_id UUID PRIMARY KEY,
job_type TEXT NOT NULL,
target_asset_id UUID,
batch_id UUID,
status TEXT NOT NULL DEFAULT 'queued',
priority INTEGER NOT NULL DEFAULT 0,
payload JSONB NOT NULL DEFAULT '{}',
result_data JSONB,
retry_count INTEGER NOT NULL DEFAULT 0,
max_retries INTEGER NOT NULL DEFAULT 3,
created_at TIMESTAMPTZ NOT NULL DEFAULT NOW(),
started_at TIMESTAMPTZ,
completed_at TIMESTAMPTZ,
error_message TEXT
);
CREATE INDEX idx_jobs_status_priority ON jobs(status, priority DESC);
CREATE INDEX idx_jobs_batch ON jobs(batch_id);
CREATE TABLE job_batches (
batch_id UUID PRIMARY KEY,
batch_type TEXT NOT NULL,
total_jobs INTEGER NOT NULL DEFAULT 0,
completed_count INTEGER NOT NULL DEFAULT 0,
failed_count INTEGER NOT NULL DEFAULT 0,
status TEXT NOT NULL DEFAULT 'in_progress'
);
CREATE TABLE plugins (
plugin_id UUID PRIMARY KEY,
name TEXT NOT NULL,
plugin_type TEXT NOT NULL,
is_enabled BOOLEAN NOT NULL DEFAULT true,
configuration JSONB NOT NULL DEFAULT '{}'
);
CREATE TABLE processing_pipelines (
pipeline_id UUID PRIMARY KEY,
trigger_event TEXT NOT NULL,
steps JSONB NOT NULL DEFAULT '[]'
);

View File

@@ -0,0 +1,6 @@
CREATE TABLE duplicate_groups (
group_id UUID PRIMARY KEY,
detection_method TEXT NOT NULL DEFAULT 'exact_hash',
status TEXT NOT NULL DEFAULT 'unresolved',
candidates JSONB NOT NULL DEFAULT '[]'
);