fix(storage-*): allow prefix to always exist as a field via alwaysInsertFields flag#14949
Merged
denolfe merged 4 commits intoJan 5, 2026
Merged
Conversation
denolfe
requested changes
Dec 16, 2025
Member
denolfe
left a comment
There was a problem hiding this comment.
This is looking good. However, none of this code will get hit if enabled is being set to false. If we want this behind a flag, we should also handle pushing this field inside https://github.com/payloadcms/payload/blob/main/packages/plugin-cloud-storage/src/plugin.ts#L24-L27
Contributor
📦 esbuild Bundle Analysis for payloadThis analysis was generated by esbuild-bundle-analyzer. 🤖 |
denolfe
approved these changes
Jan 5, 2026
Contributor
|
🚀 This is included in version v3.70.0 |
zubricks
pushed a commit
that referenced
this pull request
Jan 6, 2026
…ertFields flag (#14949) This PR adds a new top-level flag `alwaysInsertFields` in the storage adapter plugin options to ensure the prefix field is always present in the schema. Some configurations have prefix dynamically set by environment, but this can cause schema/db drift and issues where db migrations are needed, as well as generated types being different between environments. Now you can add `alwaysInsertFields: true` at the plugin level so that the prefix field is always present regardless of what you set in `prefix`, even when the plugin is disabled: ``` s3Storage({ alwaysInsertFields: true, // prefix field will always exist in schema collections: { 'media': true, 'media-with-prefix': { prefix: process.env.MEDIA_PREFIX, // can be undefined without causing schema drift }, }, enabled: process.env.USE_S3 === 'true', // works even when disabled // ... }) ``` This is particularly useful for: - Multi-tenant setups where prefix is set dynamically - Environments where cloud storage is conditionally enabled (e.g., local dev vs production) - Ensuring consistent database schema across all environments **This will be enabled by default and removed as a flag in Payload v4.**
teastudiopl
pushed a commit
to teastudiopl/payload
that referenced
this pull request
Jan 8, 2026
…ertFields flag (payloadcms#14949) This PR adds a new top-level flag `alwaysInsertFields` in the storage adapter plugin options to ensure the prefix field is always present in the schema. Some configurations have prefix dynamically set by environment, but this can cause schema/db drift and issues where db migrations are needed, as well as generated types being different between environments. Now you can add `alwaysInsertFields: true` at the plugin level so that the prefix field is always present regardless of what you set in `prefix`, even when the plugin is disabled: ``` s3Storage({ alwaysInsertFields: true, // prefix field will always exist in schema collections: { 'media': true, 'media-with-prefix': { prefix: process.env.MEDIA_PREFIX, // can be undefined without causing schema drift }, }, enabled: process.env.USE_S3 === 'true', // works even when disabled // ... }) ``` This is particularly useful for: - Multi-tenant setups where prefix is set dynamically - Environments where cloud storage is conditionally enabled (e.g., local dev vs production) - Ensuring consistent database schema across all environments **This will be enabled by default and removed as a flag in Payload v4.**
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.
This PR adds a new top-level flag
alwaysInsertFieldsin the storage adapter plugin options to ensure the prefix field is always present in the schema.Some configurations have prefix dynamically set by environment, but this can cause schema/db drift and issues where db migrations are needed, as well as generated types being different between environments.
Now you can add
alwaysInsertFields: trueat the plugin level so that the prefix field is always present regardless of what you set inprefix, even when the plugin is disabled:This is particularly useful for:
This will be enabled by default and removed as a flag in Payload v4.