fix: align plugin SQL with actual DB schema (mime_type, no content_hash on files)#1012
Merged
pyramation merged 2 commits intomainfrom Apr 19, 2026
Merged
Conversation
…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
Contributor
🤖 Devin AI EngineerI'll be helping with this pull request! Here's what you should know: ✅ I will automatically:
Note: I can only respond to comments from users who have write access to this repository. ⚙️ Control Options:
|
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).
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Fixes a schema mismatch between the presigned-url-plugin's raw SQL and the actual
filestable generated bystorage_module.sqlin constructive-db.The generated files table uses
mime_type(notcontent_type) and has nocontent_hashcolumn —content_hashonly exists on theupload_requeststable. The file's S3 key (stored in thekeycolumn) already equals the content hash sincebuildS3Key(contentHash)returns the hash directly.Changes:
plugin.ts):WHERE content_hash = $1→WHERE key = $1plugin.ts): Column list usesmime_typeinstead ofcontent_type; dropscontent_hash(and adjusts positional$Nparams accordingly)plugin.ts):file.content_type→file.mime_typein S3 HEAD verification and error messagesstorage-module-cache.ts): SELECT and TypeScript types updated fromcontent_typetomime_typeschema.sql):filestable updated to usemime_typeand dropcontent_hashto match the generated schemaThe
upload_requestsINSERT is intentionally unchanged — that table does havecontent_typeandcontent_hashcolumns.Review & Testing Checklist for Human
content_hashshifted all positional params ($N). Confirm the with-owner branch (7 columns → 7 values) and without-owner branch (6 columns → 6 values) are correctly alignedkeyon files stores the S3 key which equals the content hash. ConfirmWHERE key = $1 AND bucket_id = $2is a valid dedup strategy (there should be a unique index or constraint backing this)graphql/server-test) end-to-end against a provisioned database to confirm requestUploadUrl → PUT → confirmUpload works with the corrected column namesNotes
Link to Devin session: https://app.devin.ai/sessions/18879be982854a40abe5c9b915aa4a84
Requested by: @pyramation