Files
khb_microservices/packages/khb_common/migrations/078_acc_qbo_attachments.sql

17 lines
830 B
SQL

-- Вложения документов (чек, инвойс) к записям QuickBooks: что уже приложено или заменено ссылкой на Drive в Memo.
create table if not exists acc_qbo_attachments (
id uuid primary key default gen_random_uuid(),
qbo_entity_type text not null,
qbo_entity_id text not null,
drive_file_id text not null,
source text,
status text not null default 'pending' check (status in ('pending', 'attached', 'memo_link', 'failed')),
attachable_id text,
attempts int not null default 0,
error text,
created_at timestamptz not null default now(),
done_at timestamptz,
unique (qbo_entity_type, qbo_entity_id, drive_file_id)
);
alter table acc_qbo_attachments enable row level security;