feat(cleanup): remove stale queued attachments after grace period
This commit is contained in:
@@ -11,7 +11,7 @@ CREATE TABLE attachments (
|
||||
content_type attachment_content_type NOT NULL,
|
||||
size_bytes int NOT NULL CHECK (size_bytes > 0 AND size_bytes <= 10485760),
|
||||
sha256 text NOT NULL CHECK (sha256 ~ '^[a-f0-9]{64}$'),
|
||||
status attachment_status NOT NULL DEFAULT 'ready',
|
||||
status attachment_status NOT NULL DEFAULT 'queued',
|
||||
error_code text,
|
||||
created_at timestamptz NOT NULL DEFAULT now(),
|
||||
updated_at timestamptz NOT NULL DEFAULT now()
|
||||
@@ -19,6 +19,7 @@ CREATE TABLE attachments (
|
||||
|
||||
CREATE INDEX idx_attachments_chat_id ON attachments (chat_id, created_at);
|
||||
CREATE INDEX idx_attachments_owner_id ON attachments (owner_id);
|
||||
CREATE INDEX idx_attachments_queued_created_at ON attachments (created_at) WHERE status = 'queued';
|
||||
|
||||
CREATE TABLE message_attachments (
|
||||
message_id uuid NOT NULL REFERENCES messages (id) ON DELETE CASCADE,
|
||||
|
||||
Reference in New Issue
Block a user