Skip to content

Commit

Permalink
Merge pull request #109 from decentraland/fix/add-index-if-not-exists
Browse files Browse the repository at this point in the history
fix: Materialized builder items utility
  • Loading branch information
LautaroPetaccio authored May 15, 2024
2 parents 7ce0f72 + 2bea35f commit 466f5eb
Showing 1 changed file with 4 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -12,16 +12,14 @@ export async function up(pgm: MigrationBuilder): Promise<void> {
{ ifNotExists: true },
`SELECT
collections.contract_address || '-' || server_items.blockchain_item_id AS item_id,
server_items.utility as utility,
blockchain_items.created_at
server_items.utility as utility
FROM
builder_server_items server_items, builder_server_collections collections, dcl36.items blockchain_items
builder_server_items server_items, builder_server_collections collections
WHERE server_items.blockchain_item_id IS NOT NULL
AND server_items.utility IS NOT NULL
AND server_items.collection_id = collections.id
AND blockchain_items.id = (collections.contract_address || '-' || server_items.blockchain_item_id);`
AND server_items.collection_id = collections.id;`
)
pgm.addIndex(materializedViewName, ['item_id'], { name: 'idx_mv_builder_server_items_utility', unique: true })
pgm.addIndex(materializedViewName, ['item_id'], { name: 'idx_mv_builder_server_items_utility', unique: true, ifNotExists: true })
}

export async function down(pgm: MigrationBuilder): Promise<void> {
Expand Down

0 comments on commit 466f5eb

Please sign in to comment.