Skip to content

Commit

Permalink
tapdb: drop and re-create genesis_info_view
Browse files Browse the repository at this point in the history
  • Loading branch information
GeorgeTsagk committed Nov 21, 2023
1 parent 61eeefb commit fbf356e
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 1 deletion.
2 changes: 1 addition & 1 deletion tapdb/sqlc/migrations/000002_assets.up.sql
Original file line number Diff line number Diff line change
Expand Up @@ -315,7 +315,7 @@ CREATE TABLE IF NOT EXISTS asset_seedlings (
CREATE VIEW genesis_info_view AS
SELECT
gen_asset_id, asset_id, asset_tag, assets_meta.meta_data_hash meta_hash,
output_index, asset_type, genesis_points.prev_out prev_out,
output_index, asset_type, genesis_points.prev_out prev_out,
chain_txns.txid anchor_txid, block_height
FROM genesis_assets
-- We do a LEFT JOIN here, as not every asset has a set of
Expand Down
1 change: 1 addition & 0 deletions tapdb/sqlc/migrations/000012_anchor_txid.down.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
DROP VIEW IF EXISTS genesis_info_view;
22 changes: 22 additions & 0 deletions tapdb/sqlc/migrations/000012_anchor_txid.up.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
DROP VIEW IF EXISTS genesis_info_view;

-- This view is used to fetch the base asset information from disk based on
-- the raw key of the batch that will ultimately create this set of assets.
-- To do so, we'll need to traverse a few tables to join the set of assets
-- with the genesis points, then with the batches that reference this
-- points, to the internal key that reference the batch, then restricted
-- for internal keys that match our main batch key.
CREATE VIEW genesis_info_view AS
SELECT
gen_asset_id, asset_id, asset_tag, assets_meta.meta_data_hash meta_hash,
output_index, asset_type, genesis_points.prev_out prev_out,
chain_txns.txid anchor_txid, block_height
FROM genesis_assets
-- We do a LEFT JOIN here, as not every asset has a set of
-- metadata that matches the asset.
LEFT JOIN assets_meta
ON genesis_assets.meta_data_id = assets_meta.meta_id
JOIN genesis_points
ON genesis_assets.genesis_point_id = genesis_points.genesis_id
LEFT JOIN chain_txns
ON genesis_points.anchor_tx_id = chain_txns.txn_id;

0 comments on commit fbf356e

Please sign in to comment.