diff --git a/hasura/metadata/databases/minterop/tables/mb_views_nft_drops.yaml b/hasura/metadata/databases/minterop/tables/mb_views_nft_drops.yaml new file mode 100644 index 0000000..aadfe85 --- /dev/null +++ b/hasura/metadata/databases/minterop/tables/mb_views_nft_drops.yaml @@ -0,0 +1,49 @@ +table: + schema: mb_views + name: nft_drops +array_relationships: + - name: listings + using: + manual_configuration: + column_mapping: + id: indexer_metadata_id + nft_contract_id: nft_contract_id + insertion_order: null + remote_table: + name: active_listings + schema: mb_views +object_relationships: + - name: nft_contract + using: + manual_configuration: + remote_table: + schema: public + name: nft_contracts + insertion_order: null + column_mapping: + nft_contract_id: id +select_permissions: + - role: anonymous + permission: + columns: + - drop_url, + - nft_contract_id, + - sc_metadata_id, + - indexer_metadata_id, + - title + - description + - media + - reference + - reference_blob + - minter as creator + - max_supply + - minted + - royalties + - royalty_percent + - price + - minters_allowlist + - unique_minters + - starts_at + - expires_at + filter: {} + allow_aggregations: true diff --git a/hasura/metadata/databases/minterop/tables/tables.yaml b/hasura/metadata/databases/minterop/tables/tables.yaml index b283a9e..90a6d26 100644 --- a/hasura/metadata/databases/minterop/tables/tables.yaml +++ b/hasura/metadata/databases/minterop/tables/tables.yaml @@ -8,6 +8,7 @@ - "!include mb_views_auctions_with_offer.yaml" - "!include mb_views_nft_activities.yaml" - "!include mb_views_nft_activities_rollup.yaml" +- "!include mb_views_nft_drops.yaml" - "!include mb_views_nft_metadata_unburned.yaml" - "!include mb_views_nft_metadata.yaml" - "!include mb_views_nft_notifications.yaml" diff --git a/migrations/2024-05-28-120630_nft-drops/down.sql b/migrations/2024-05-28-120630_nft-drops/down.sql new file mode 100644 index 0000000..55bd05c --- /dev/null +++ b/migrations/2024-05-28-120630_nft-drops/down.sql @@ -0,0 +1 @@ +drop view mb_views.nft_drops; diff --git a/migrations/2024-05-28-120630_nft-drops/up.sql b/migrations/2024-05-28-120630_nft-drops/up.sql new file mode 100644 index 0000000..83ba646 --- /dev/null +++ b/migrations/2024-05-28-120630_nft-drops/up.sql @@ -0,0 +1,24 @@ +create view mb_views.nft_drops as + select + reference_blob->>'drop_url' as drop_url, + nft_contract_id, + mb_internal_id as sc_metadata_id, + id as indexer_metadata_id, + title, + description, + media, + reference, + reference_blob, + minter as creator, + max_supply, + count as minted, + royalties, + royalty_percent, + price, + minters_allowlist, + unique_minters, + starts_at, + expires_at + from (select * from nft_metadata where reference_blob->>'drop_url' is not null) m + left join (select metadata_id, count(*) from nft_tokens group by metadata_id) t + on t.metadata_id = m.id;