-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Refactor/ibc message add tx hash staging (#399)
* refactor: cw20/cw721 index and add relation ( main ) (#306) * refactor: cw20 index and add relation * refactor: code * refactor: ibc message tx hash * refactor: ibc message add tx hash * refactor: ibc message add tx hash * refactor: resolve conflict
- Loading branch information
1 parent
865b230
commit bf362f4
Showing
4 changed files
with
45 additions
and
2 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,27 @@ | ||
import { Knex } from 'knex'; | ||
import { IbcMessage } from '../src/models'; | ||
|
||
export async function up(knex: Knex): Promise<void> { | ||
await knex.schema.alterTable('ibc_message', (table) => { | ||
table.string('tx_hash').defaultTo(''); | ||
}); | ||
await knex.transaction(async (trx) => { | ||
const ibcMsgs = await IbcMessage.query() | ||
.transacting(trx) | ||
.joinRelated('message.transaction') | ||
.select('ibc_message.*', 'message:transaction.hash as tx_hash'); | ||
if (ibcMsgs.length > 0) { | ||
await IbcMessage.query() | ||
.transacting(trx) | ||
.insert(ibcMsgs) | ||
.onConflict(['id']) | ||
.merge(); | ||
} | ||
}); | ||
} | ||
|
||
export async function down(knex: Knex): Promise<void> { | ||
await knex.schema.alterTable('ibc_message', (table) => { | ||
table.dropColumn('tx_hash'); | ||
}); | ||
} |
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
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