fix: upsert nft and ft metadata (#1193)

This commit is contained in:
M Hassan Tariq
2022-06-21 20:25:44 +05:00
committed by GitHub
parent 769110926e
commit c4eec5d060
4 changed files with 9 additions and 1 deletions

View File

@@ -1363,6 +1363,9 @@ export class PgWriteStore extends PgStore {
};
const result = await sql`
INSERT INTO ft_metadata ${sql(values)}
ON CONFLICT (contract_id)
DO
UPDATE SET ${sql(values)}
`;
await sql`
UPDATE token_metadata_queue
@@ -1392,6 +1395,9 @@ export class PgWriteStore extends PgStore {
};
const result = await sql`
INSERT INTO nft_metadata ${sql(values)}
ON CONFLICT (contract_id)
DO
UPDATE SET ${sql(values)}
`;
await sql`
UPDATE token_metadata_queue

View File

@@ -32,6 +32,7 @@ export async function up(pgm: MigrationBuilder): Promise<void> {
contract_id: {
type: 'string',
notNull: true,
unique: true,
},
tx_id: {
type: 'bytea',

View File

@@ -32,6 +32,7 @@ export async function up(pgm: MigrationBuilder): Promise<void> {
contract_id: {
type: 'string',
notNull: true,
unique: true,
},
symbol: {
type: 'string',

View File

@@ -323,7 +323,7 @@ describe('api tests', () => {
decimals: 5,
image_uri: 'ft-metadata image uri example',
image_canonical_uri: 'ft-metadata image canonical uri example',
contract_id: 'ABCDEFGHIJ.ft-metadata',
contract_id: 'ABCDEFGHIJ.ft-metadata' + i,
tx_id: '0x123456',
sender_address: 'ABCDEFGHIJ',
};