Skip to content

Commit 01f90c9

Browse files
tapartdevr1tsuu
andauthored
fix(db-postgres): add filenameCompoundIndex baseIndexes for upload collections (#15182)
Description: When using the filenameCompoundIndex property on an upload collection, this index was not being added to the database. By adding this rule, the compound index is now correctly applied. What? The filenameCompoundIndex property was ignored when defining upload collections, so compound indexes were not created in the database. Why? Without this index, queries that rely on the compound key (e.g., filename + some other field) are slower and may lead to unexpected duplicates. How? Updated the logic for creating upload collection indexes to include the filenameCompoundIndex rule. This ensures that the compound index is added to the database during collection setup. --------- Co-authored-by: Sasha <64744993+r1tsuu@users.noreply.github.com>
1 parent dcd4030 commit 01f90c9

1 file changed

Lines changed: 2 additions & 1 deletion

File tree

packages/drizzle/src/schema/buildRawSchema.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ export const buildRawSchema = ({
4848
const baseIndexes: Record<string, RawIndex> = {}
4949

5050
if (collection.upload.filenameCompoundIndex) {
51-
const indexName = buildIndexName({ name: `${tableName}_filename_compound_idx`, adapter })
51+
const indexName = buildIndexName({ name: `${tableName}_filename_compound`, adapter })
5252

5353
baseIndexes.filename_compound_index = {
5454
name: indexName,
@@ -59,6 +59,7 @@ export const buildRawSchema = ({
5959

6060
buildTable({
6161
adapter,
62+
baseIndexes,
6263
blocksTableNameMap: {},
6364
compoundIndexes: collection.sanitizedIndexes,
6465
disableNotNull: !!collection?.versions?.drafts,

0 commit comments

Comments
 (0)