Skip to content

Commit

Permalink
Remove unneeded condition on asset_authority upsert
Browse files Browse the repository at this point in the history
  • Loading branch information
danenbm committed Dec 20, 2023
1 parent 2c14eeb commit 4c39726
Showing 1 changed file with 6 additions and 11 deletions.
17 changes: 6 additions & 11 deletions nft_ingester/src/program_transformers/bubblegum/db.rs
Original file line number Diff line number Diff line change
Expand Up @@ -618,9 +618,9 @@ where
.build(DbBackend::Postgres);

query.sql = format!(
"{} WHERE (asset_creators.seq != 0 AND excluded.seq >= asset_creators.seq) OR asset_creators.seq IS NULL",
query.sql
);
"{} WHERE (asset_creators.seq != 0 AND excluded.seq >= asset_creators.seq) OR asset_creators.seq IS NULL",
query.sql
);

txn.execute(query).await?;

Expand All @@ -645,22 +645,17 @@ where
..Default::default()
};

// Do not attempt to modify any existing values:
// This value is only written during `mint_V1`` or after an item is decompressed, so do not
// attempt to modify any existing values:
// `ON CONFLICT ('asset_id') DO NOTHING`.
let mut query = asset_authority::Entity::insert(model)
let query = asset_authority::Entity::insert(model)
.on_conflict(
OnConflict::columns([asset_authority::Column::AssetId])
.do_nothing()
.to_owned(),
)
.build(DbBackend::Postgres);

// Do not overwrite changes that happened after decompression (asset_authority.seq = 0).
query.sql = format!(
"{} WHERE asset_authority.seq != 0 OR asset_authority.seq IS NULL",
query.sql
);

txn.execute(query)
.await
.map_err(|db_err| IngesterError::AssetIndexError(db_err.to_string()))?;
Expand Down

0 comments on commit 4c39726

Please sign in to comment.