-
Notifications
You must be signed in to change notification settings - Fork 3.3k
fix(storage-*): allow prefix to always exist as a field via alwaysInsertFields flag #14949
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix(storage-*): allow prefix to always exist as a field via alwaysInsertFields flag #14949
Conversation
denolfe
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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
📦 esbuild Bundle Analysis for payloadThis analysis was generated by esbuild-bundle-analyzer. 🤖 |
|
🚀 This is included in version v3.70.0 |
…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.**
…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 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.