Skip to content

refactor!: always insert fields from storage adapters by default - #17871

Open
paulpopus wants to merge 2 commits into
mainfrom
refactor/always-insert-fields-from-storage-adapters-by-default
Open

refactor!: always insert fields from storage adapters by default#17871
paulpopus wants to merge 2 commits into
mainfrom
refactor/always-insert-fields-from-storage-adapters-by-default

Conversation

@paulpopus

@paulpopus paulpopus commented Aug 20, 2026

Copy link
Copy Markdown
Member

This PR makes storage adapters always insert the prefix field into the collection schema, and removes the alwaysInsertFields option that used to control this.

Summary

Storage adapters insert a prefix field into an upload collection only when the collection sets a prefix, or when the alwaysInsertFields option is true. This causes the collection schema to change when a project enables or disables cloud storage, or moves between environments. This PR removes that condition. Storage adapters now always insert the prefix field, even when the plugin is disabled or no prefix is set. The schema stays stable across all environments.

How

  • cloudStoragePlugin and the field builder in getFields no longer accept an alwaysInsertFields option. They insert the prefix field unconditionally.
  • Each storage adapter (S3, Azure, GCS, R2, Vercel Blob) still supports enabled: false. When disabled, the adapter now calls cloudStoragePlugin with adapter: null so the schema field is inserted without enabling upload functionality.
  • The unused admin-only stub files (admin/index.ts and admin/fields/getFields.ts) in plugin-cloud-storage are removed. Their logic duplicated the main plugin path and served no active import.

Breaking Changes

The alwaysInsertFields option is removed from PluginOptions and from each storage adapter's options (S3StorageOptions, AzureStorageOptions, GcsStorageOptions, R2StorageOptions, VercelBlobStorageOptions). Every upload collection configured with a storage adapter now gets a prefix field, even a collection that never sets a prefix, and even when the adapter is disabled.

Before:

s3Storage({
  alwaysInsertFields: true, // needed to keep the prefix field when disabling the plugin
  collections: { media: { prefix: '' } },
  enabled: false,
})

Without alwaysInsertFields, disabling the plugin removed the prefix field from the schema.

After:

s3Storage({
  collections: { media: { prefix: '' } },
  enabled: false,
})

The prefix field is now always present. Remove any alwaysInsertFields: true usage; it has no effect and will raise a type error. Collections that never configured a prefix now store an empty string in the prefix field instead of leaving it unset.

@github-actions

Copy link
Copy Markdown
Contributor

📦 esbuild Bundle Analysis for payload

This analysis was generated by esbuild-bundle-analyzer. 🤖
This PR introduced no changes to the esbuild bundle! 🙌

@nathanlentz
nathanlentz self-requested a review August 20, 2026 18:42
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant