SHARE
TWEET

Untitled

a guest Mar 19th, 2019 46 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. --
  2. -- subgraphs schema
  3. --
  4. drop schema if exists meta cascade;
  5. create schema meta;
  6.  
  7. create view meta.subgraphs as
  8. select id,
  9.        data->'name'->>'data' as name,
  10.        (data->'createdAt'->>'data')::int as created_at,
  11.        data->'currentVersion'->>'data' as current_version,
  12.        data->'pendingVersion'->>'data' as pending_version
  13.  from entities
  14. where subgraph = 'subgraphs'
  15.   and entity='Subgraph';
  16.  
  17. create view meta.manifests as
  18. select id,
  19.        data->'schema'->>'data' as schema
  20.  from entities
  21. where subgraph = 'subgraphs'
  22.   and entity='SubgraphManifest';
  23.  
  24. create view meta.assignments
  25. as select id,
  26.           (data->'cost'->>'data')::int as cost,
  27.           data->'nodeId' ->> 'data' as node_id
  28. from entities
  29. where subgraph = 'subgraphs'
  30.   and entity = 'SubgraphDeploymentAssignment';
  31.  
  32. create view meta.deployments as
  33. select id,
  34.  (data->'failed'->>'data')::bool as failed,
  35.  (data->'synced'->>'data')::bool as synced,
  36.  data->'manifest'->>'data' as manifest,
  37.  data->'latestEthereumBlockHash'->>'data' as latest_ethereum_block_hash,
  38.  (data->'totalEthereumBlocksCount' ->> 'data')::int
  39.     as total_ethereum_blocks_count,
  40.  (data->'latestEthereumBlockNumber' ->> 'data')::int
  41.     as latest_ethereum_block_number
  42. from entities
  43. where subgraph = 'subgraphs' and entity = 'SubgraphDeployment';
  44.  
  45. create view meta.versions as
  46. select id,
  47.        data->'subgraph'->>'data' as subgraph,
  48.        (data->'createdAt'->>'data')::int as created_at,
  49.        data->'deployment'->>'data' as deployment
  50.  from entities
  51. where subgraph = 'subgraphs'
  52.   and entity='SubgraphVersion';
  53.  
  54. create view meta.eth_contract_abi as
  55. select id,
  56.        data->'file'->>'data' as file,
  57.        data->'name'->>'data' as name
  58.  from entities
  59. where subgraph = 'subgraphs'
  60.   and entity='EthereumContractAbi';
  61.  
  62. create view meta.eth_contract_data_source as
  63. select id,
  64.        data->'kind'->>'data' as kind,
  65.        data->'name'->>'data' as name,
  66.        data->'network'->>'data' as network,
  67.        data->'source'->>'data' as source,
  68.        data->'mapping'->>'data' as mapping,
  69.        data
  70.  from entities
  71. where subgraph = 'subgraphs'
  72.   and entity='EthereumContractDataSource';
  73.  
  74. create view meta.eth_contract_event_handler as
  75. select id,
  76.        data->'event'->>'data' as event,
  77.        data->'handler'->>'data' as handler
  78.  from entities
  79. where subgraph = 'subgraphs'
  80.   and entity='EthereumContractEventHandler';
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
Not a member of Pastebin yet?
Sign Up, it unlocks many cool features!
 
Top