-
Notifications
You must be signed in to change notification settings - Fork 112
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
…s data (#11287)
- Loading branch information
Showing
17 changed files
with
705 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
--- | ||
"@audius/sdk": minor | ||
--- | ||
|
||
Add support for fetching collectibles |
31 changes: 31 additions & 0 deletions
31
packages/discovery-provider/ddl/migrations/0118_add_collectibles.sql
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
begin; | ||
|
||
create table if not exists collectibles ( | ||
user_id INTEGER NOT NULL, | ||
data JSONB NOT NULL, | ||
blockhash TEXT NOT NULL, | ||
blocknumber INTEGER NOT NULL, | ||
created_at TIMESTAMP WITH TIME ZONE DEFAULT now(), | ||
updated_at TIMESTAMP WITH TIME ZONE DEFAULT now(), | ||
CONSTRAINT pk_user_id PRIMARY KEY (user_id), | ||
FOREIGN KEY (blocknumber) REFERENCES blocks(number) ON DELETE CASCADE | ||
); | ||
|
||
COMMENT ON TABLE collectibles IS 'Stores collectibles data for users'; | ||
COMMENT ON COLUMN collectibles.user_id IS 'User ID of the person who owns the collectibles'; | ||
COMMENT ON COLUMN collectibles.data IS 'Data about the collectibles'; | ||
COMMENT ON COLUMN collectibles.blockhash IS 'Blockhash of the most recent block that changed the collectibles data'; | ||
COMMENT ON COLUMN collectibles.blocknumber IS 'Block number of the most recent block that changed the collectibles data'; | ||
|
||
INSERT INTO collectibles (user_id, data, blockhash, blocknumber) | ||
SELECT | ||
u.user_id, | ||
cid.data->'collectibles' AS data, | ||
u.blockhash, | ||
u.blocknumber | ||
FROM users u | ||
LEFT JOIN cid_data cid ON u.metadata_multihash = cid.cid | ||
WHERE u.has_collectibles = TRUE | ||
ON CONFLICT (user_id) DO NOTHING; | ||
|
||
commit; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.