From ade405e07dd46e30dc4e7807417974133b87f2b0 Mon Sep 17 00:00:00 2001 From: Carlos V Date: Fri, 16 Aug 2024 17:46:34 +0000 Subject: [PATCH] indexer-agent: Add new column to invalid_receipts table --- .../16-modify-invalid-receipts-table.ts | 34 +++++++++++++++++++ .../indexer-common/src/query-fees/models.ts | 7 ++++ 2 files changed, 41 insertions(+) create mode 100644 packages/indexer-agent/src/db/migrations/16-modify-invalid-receipts-table.ts diff --git a/packages/indexer-agent/src/db/migrations/16-modify-invalid-receipts-table.ts b/packages/indexer-agent/src/db/migrations/16-modify-invalid-receipts-table.ts new file mode 100644 index 000000000..854a90d49 --- /dev/null +++ b/packages/indexer-agent/src/db/migrations/16-modify-invalid-receipts-table.ts @@ -0,0 +1,34 @@ +import { Logger } from '@graphprotocol/common-ts' +import { QueryInterface, DataTypes } from 'sequelize' + +interface MigrationContext { + queryInterface: QueryInterface + logger: Logger +} + +interface Context { + context: MigrationContext +} + +export async function up({ context }: Context): Promise { + const { queryInterface, logger } = context + + const tables = await queryInterface.showAllTables() + logger.debug( + `Modifying tables scalar_tap_receipts_invalid to add extra column`, + ) + + if (tables.includes('scalar_tap_receipts_invalid')) { + await queryInterface.addColumn('scalar_tap_receipts_invalid', 'error_log', { + type: DataTypes.TEXT, + allowNull: false, + defaultValue: '', + }) + } +} + +export async function down({ context }: Context): Promise { + const { queryInterface, logger } = context + logger.info(`Drop function, trigger, indices, and table`) + queryInterface.removeColumn('scalar_tap_receipts_invalid', 'error_log') +} diff --git a/packages/indexer-common/src/query-fees/models.ts b/packages/indexer-common/src/query-fees/models.ts index 821875ee5..095d60fe0 100644 --- a/packages/indexer-common/src/query-fees/models.ts +++ b/packages/indexer-common/src/query-fees/models.ts @@ -11,6 +11,7 @@ export interface ScalarTapReceiptsAttributes { timestamp_ns: bigint nonce: bigint value: bigint + error_log?: string } export class ScalarTapReceipts extends Model @@ -39,6 +40,7 @@ export class ScalarTapReceiptsInvalid public nonce!: bigint public value!: bigint public signature!: Uint8Array + public error_log!: string declare createdAt: CreationOptional declare updatedAt: CreationOptional @@ -657,6 +659,11 @@ export function defineQueryFeeModels(sequelize: Sequelize): QueryFeeModels { type: DataTypes.BLOB, allowNull: false, }, + error_log: { + type: DataTypes.TEXT, + allowNull: false, + defaultValue: '', + }, }, { underscored: true,