Skip to content
Storage

存储模式

Learn about the storage schema

存储使用 Postgres 来保存有关你的存储桶和对象的元数据。用户可以使用 RLS(行级安全)策略进行访问控制。这些数据存储在你项目中的一个专用模式里,叫做 storage

🌐 Storage uses Postgres to store metadata regarding your buckets and objects. Users can use RLS (Row-Level Security) policies for access control. This data is stored in a dedicated schema within your project called storage.

这是表示存储服务的架构,你可以直接查询这个表来获取存储中文件的信息,无需通过我们的 API。

🌐 Here is the schema that represents the Storage service, you have the option to query this table directly to retrieve information about your files in Storage without the need to go through our API.

buckets PK text id text name timestamptz created_at timestamptz updated_at boolean public bigint file_size_limit text[] allowed_mime_types text owner_id objects PK uuid id FK text bucket_id text name timestamptz created_at timestamptz updated_at jsonb metadata text[] path_tokens text version text owner_id migrations PK integer id varchar(100) name varchar(40) hash timestamp executed_at buckets_id:id

这个架构围绕三个表展开。每个 buckets 行可以通过将 buckets.idobjects.bucket_id 连接起来的一对多关系拥有多个 objects 行。buckets 表保存桶的配置,包括 idname、桶是否是 public,以及像 file_size_limitallowed_mime_types 这样的约束。objects 表保存每个文件的元数据:拥有的 bucket_id、对象 namepath_tokens、一个 metadata JSON 块,以及版本信息。migrations 表是独立的,用来跟踪存储服务应用的架构迁移情况。

🌐 The schema centers on three tables. Each buckets row can own many objects rows by a one-to-many relationship that joins buckets.id to objects.bucket_id. The buckets table holds bucket configuration. Its id and name, whether the bucket is public, and constraints such as file_size_limit and allowed_mime_types. The objects table holds per-file metadata: the owning bucket_id, the object name and path_tokens, a metadata JSON blob, and version information. The migrations table is standalone and tracks the schema migrations applied to the storage service.

修改模式 #

🌐 Modifying the schema

我们强烈建议不要对 storage 架构做任何修改,把它当作只读使用。这很重要,因为你那边对架构的任何更改都可能和我们之后的更新冲突,导致停机。

🌐 We strongly recommend refraining from making any alterations to the storage schema and treating it as read-only. This approach is important because any modifications to the schema on your end could potentially clash with our future updates, leading to downtime.

不过,我们建议你添加自定义索引,因为它们可以显著提升你为执行访问控制而创建的 RLS 策略的性能。

🌐 However, we encourage you to add custom indexes as they can significantly improve the performance of the RLS policies you create for enforcing access control.