Skip to content

Commit

Permalink
Merge pull request #185 from roiLeo/fix/NFTEntity/type
Browse files Browse the repository at this point in the history
🔧 NFTEntity sn type
  • Loading branch information
roiLeo authored Jan 10, 2024
2 parents 027d964 + 1c945ee commit ff6c70a
Show file tree
Hide file tree
Showing 5 changed files with 22 additions and 5 deletions.
17 changes: 17 additions & 0 deletions db/migrations/1704901579526-Data.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
module.exports = class Data1704901579526 {
name = 'Data1704901579526'

async up(db) {
await db.query(`DROP INDEX "public"."IDX_fb5a810a729fee4b0b0d3301eb"`)
await db.query(`ALTER TABLE "nft_entity" DROP COLUMN "sn"`)
await db.query(`ALTER TABLE "nft_entity" ADD "sn" numeric NOT NULL`)
await db.query(`CREATE INDEX "IDX_fb5a810a729fee4b0b0d3301eb" ON "nft_entity" ("sn") `)
}

async down(db) {
await db.query(`CREATE INDEX "IDX_fb5a810a729fee4b0b0d3301eb" ON "nft_entity" ("sn") `)
await db.query(`ALTER TABLE "nft_entity" ADD "sn" text NOT NULL`)
await db.query(`ALTER TABLE "nft_entity" DROP COLUMN "sn"`)
await db.query(`DROP INDEX "public"."IDX_fb5a810a729fee4b0b0d3301eb"`)
}
}
2 changes: 1 addition & 1 deletion schema.graphql
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ type NFTEntity @entity {
price: BigInt @index
recipient: String
royalty: Float
sn: String! @index
sn: BigInt! @index
updatedAt: DateTime! @index
version: Int!
token: TokenEntity
Expand Down
2 changes: 1 addition & 1 deletion src/mappings/nfts/mint.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ export async function handleTokenCreate(context: Context): Promise<void> {
final.currentOwner = event.owner
final.blockNumber = BigInt(event.blockNumber)
final.collection = collection
final.sn = event.sn
final.sn = BigInt(event.sn)
final.metadata = event.metadata || collection.metadata
final.price = BigInt(0)
final.burned = false
Expand Down
2 changes: 1 addition & 1 deletion src/mappings/uniques/mint.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ export async function handleTokenCreate(context: Context): Promise<void> {
final.currentOwner = event.owner
final.blockNumber = BigInt(event.blockNumber)
final.collection = collection
final.sn = event.sn
final.sn = BigInt(event.sn)
final.metadata = event.metadata || collection.metadata
final.price = BigInt(0)
final.burned = false
Expand Down
4 changes: 2 additions & 2 deletions src/model/generated/nftEntity.model.ts
Original file line number Diff line number Diff line change
Expand Up @@ -77,8 +77,8 @@ export class NFTEntity {
royalty!: number | undefined | null

@Index_()
@Column_("text", {nullable: false})
sn!: string
@Column_("numeric", {transformer: marshal.bigintTransformer, nullable: false})
sn!: bigint

@Index_()
@Column_("timestamp with time zone", {nullable: false})
Expand Down

0 comments on commit ff6c70a

Please sign in to comment.