···77 integer,
88 index,
99 type PgTableWithColumns,
1010- sql,
1110} from 'drizzle-orm/pg-core';
1111+import { sql } from 'drizzle-orm';
1212import { publishedRecords } from './publishedRecord.sql';
13131414export const cards: PgTableWithColumns<any> = pgTable(
···3939 // Optimizes sorting cards by type and update time in query results
4040 typeUpdatedAtIdx: index('idx_cards_type_updated_at')
4141 .on(table.type, table.updatedAt.desc()),
4242- // Covering index for getLibrariesForUrl - fast URL+type lookups with card ID included
4242+ // Index for getLibrariesForUrl - fast URL+type lookups
4343 urlTypeIdx: index('idx_cards_url_type')
4444- .on(table.url, table.type)
4545- .include(table.id),
4444+ .on(table.url, table.type),
4645 // Partial index for finding NOTE cards by parent - only indexes NOTE type cards
4746 parentTypeIdx: index('idx_cards_parent_type')
4847 .on(table.parentCardId, table.type)
···7373 table.collectionId,
7474 ),
7575 // Performance indexes
7676- // Covering index for getCardsInCollection - sorted by add time with cardId included
7676+ // Index for getCardsInCollection - sorted by add time
7777 collectionAddedIdx: index('idx_collection_cards_collection_added')
7878- .on(table.collectionId, table.addedAt.desc())
7979- .include(table.cardId),
8080- // Covering index for finding collections containing a card - avoids table lookups
7878+ .on(table.collectionId, table.addedAt.desc()),
7979+ // Index for finding collections containing a card
8180 cardCollectionIdx: index('idx_collection_cards_card_collection')
8282- .on(table.cardId)
8383- .include(table.collectionId),
8181+ .on(table.cardId),
8482 };
8583 },
8684);