Skip to content

refactor(adapter-sqlite): drop redundant attachments table#40

Merged
cuibonobo merged 3 commits into
mainfrom
claude/apiadapter-attachment-headers-7xghjq
Jun 22, 2026
Merged

refactor(adapter-sqlite): drop redundant attachments table#40
cuibonobo merged 3 commits into
mainfrom
claude/apiadapter-attachment-headers-7xghjq

Conversation

@cuibonobo

@cuibonobo cuibonobo commented Jun 22, 2026

Copy link
Copy Markdown
Member

The attachments table in the SQLite adapter was originally the home for attachment metadata (mimeType, size, filename, created_at). When the _attachment@1 PR moved that metadata into records, the table was stripped to just (file_id TEXT PRIMARY KEY) — a SQLite-backed shadow of what's already on disk.

Since binary files are content-addressed by their SHA-256 hash, the filesystem is already the authoritative store. The table added no information and required its own migration path.

Changes

  • adapter-sqlite: Remove the attachments table from SCHEMA_SQL; runMigrations now drops the table if still present in older databases. Replace SELECT 1 FROM attachments dedup/existence checks with existsSync; remove INSERT/DELETE queries and the now-unnecessary persist() calls from attachment methods.

What didn't change

StackAdapter.putAttachment remains bytes-only — no mimeType or filename params at the adapter level. Metadata belongs exclusively on _attachment@1 records created by Stack/ScopedStack.putAttachment.

claude added 3 commits June 22, 2026 14:31
The adapter interface previously accepted only raw bytes, forcing callers
to omit Content-Type and Content-Disposition on upload. Now putAttachment
accepts optional mimeType and filename params: APIAdapter forwards them
as HTTP headers (defaulting to application/octet-stream), while the
SQLite and test adapters accept but ignore them since they store locally.

Stack.putAttachmentBytes / Stack.putAttachment / ScopedStack.putAttachment
all forward the params so the metadata that was already tracked in the
_attachment@1 record is also reflected in the binary upload request.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01RqkRy1ZDZqL6JDW9Xod5UX
…ource of truth

The attachments table was stripped to just (file_id TEXT PRIMARY KEY) when
_attachment@1 records took over metadata tracking. With content-addressed
storage the filesystem already deduplicates by SHA-256 filename, making the
table a redundant shadow of the disk.

- Remove attachments table from SCHEMA_SQL
- runMigrations: drop the table if still present in older databases
- putAttachment: dedup via existsSync instead of SELECT 1
- getAttachment: existence check via existsSync (no DB query)
- deleteAttachment: remove DELETE FROM attachments (only unlink needed)

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01RqkRy1ZDZqL6JDW9Xod5UX
…ilename params

The adapter layer is a raw bytes store — metadata belongs exclusively on
_attachment@1 records created by Stack/ScopedStack.putAttachment. Passing
mimeType and filename through the adapter interface leaked HTTP/semantic
concerns into a layer that has no use for them (SQLite accepted but ignored
them). The Stack layer already captures the right metadata at the right level.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01RqkRy1ZDZqL6JDW9Xod5UX
@cuibonobo cuibonobo changed the title feat: thread mimeType and filename through StackAdapter.putAttachment refactor(adapter-sqlite): drop redundant attachments table Jun 22, 2026
@cuibonobo cuibonobo merged commit c23536e into main Jun 22, 2026
5 checks passed
@cuibonobo cuibonobo deleted the claude/apiadapter-attachment-headers-7xghjq branch June 22, 2026 22:48
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants