Skip to content

fix: align plugin SQL with actual DB schema (mime_type, no content_hash on files)#1012

Merged
pyramation merged 2 commits intomainfrom
devin/1776593883-fix-plugin-column-names
Apr 19, 2026
Merged

fix: align plugin SQL with actual DB schema (mime_type, no content_hash on files)#1012
pyramation merged 2 commits intomainfrom
devin/1776593883-fix-plugin-column-names

Conversation

@pyramation
Copy link
Copy Markdown
Contributor

@pyramation pyramation commented Apr 19, 2026

Summary

Fixes a schema mismatch between the presigned-url-plugin's raw SQL and the actual files table generated by storage_module.sql in constructive-db.

The generated files table uses mime_type (not content_type) and has no content_hash column — content_hash only exists on the upload_requests table. The file's S3 key (stored in the key column) already equals the content hash since buildS3Key(contentHash) returns the hash directly.

Changes:

  • Dedup check (plugin.ts): WHERE content_hash = $1WHERE key = $1
  • File INSERT (plugin.ts): Column list uses mime_type instead of content_type; drops content_hash (and adjusts positional $N params accordingly)
  • confirmUpload (plugin.ts): file.content_typefile.mime_type in S3 HEAD verification and error messages
  • resolveStorageModuleByFileId (storage-module-cache.ts): SELECT and TypeScript types updated from content_type to mime_type
  • Test fixture (schema.sql): files table updated to use mime_type and drop content_hash to match the generated schema

The upload_requests INSERT is intentionally unchanged — that table does have content_type and content_hash columns.

Review & Testing Checklist for Human

  • Verify column/value alignment in the file INSERT: Removing content_hash shifted all positional params ($N). Confirm the with-owner branch (7 columns → 7 values) and without-owner branch (6 columns → 6 values) are correctly aligned
  • Verify the dedup check is semantically correct: key on files stores the S3 key which equals the content hash. Confirm WHERE key = $1 AND bucket_id = $2 is a valid dedup strategy (there should be a unique index or constraint backing this)
  • Run the upload integration test (graphql/server-test) end-to-end against a provisioned database to confirm requestUploadUrl → PUT → confirmUpload works with the corrected column names

Notes

Link to Devin session: https://app.devin.ai/sessions/18879be982854a40abe5c9b915aa4a84
Requested by: @pyramation

…sh on files)

The files table generated by storage_module.sql uses:
- mime_type (not content_type)
- key column stores the content hash (no separate content_hash column)

The content_hash and content_type columns only exist on upload_requests.

Changes:
- plugin.ts: dedup check uses key instead of content_hash
- plugin.ts: file INSERT uses mime_type instead of content_type, drops content_hash
- plugin.ts: confirmUpload references file.mime_type instead of file.content_type
- storage-module-cache.ts: resolveStorageModuleByFileId SELECT/types use mime_type
@devin-ai-integration
Copy link
Copy Markdown
Contributor

🤖 Devin AI Engineer

I'll be helping with this pull request! Here's what you should know:

✅ I will automatically:

  • Address comments on this PR. Add '(aside)' to your comment to have me ignore it.
  • Look at CI failures and help fix them

Note: I can only respond to comments from users who have write access to this repository.

⚙️ Control Options:

  • Disable automatic comment and CI monitoring

The test fixture's files table was using the old column names (content_type,
content_hash) which don't match the actual generated schema from
storage_module.sql (mime_type, no content_hash on files).
@pyramation pyramation merged commit 39f2b10 into main Apr 19, 2026
51 checks passed
@pyramation pyramation deleted the devin/1776593883-fix-plugin-column-names branch April 19, 2026 10:37
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.

1 participant