Skip to content

Commit

Permalink
feat!: Add new column to invalid_receipts table
Browse files Browse the repository at this point in the history
  • Loading branch information
carlosvdr committed Aug 16, 2024
1 parent 6f0a8ab commit f8675f6
Show file tree
Hide file tree
Showing 2 changed files with 57 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
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<void> {
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,
})
}
}

export async function down({ context }: Context): Promise<void> {
const { queryInterface, logger } = context
// Drop the scalar_tap_ravs table
logger.info(`Drop table`)
await queryInterface.dropTable('scalar_tap_ravs')

logger.info(`Drop function, trigger, indices, and table`)
await queryInterface.sequelize.query(
'DROP TRIGGER IF EXISTS receipt_update ON scalar_tap_receipts',
)
await queryInterface.sequelize.query(
'DROP FUNCTION IF EXISTS scalar_tap_receipt_notify',
)
await queryInterface.removeIndex(
'scalar_tap_receipts',
'scalar_tap_receipts_allocation_id_idx',
)
await queryInterface.removeIndex(
'scalar_tap_receipts',
'scalar_tap_receipts_timestamp_ns_idx',
)
await queryInterface.dropTable('scalar_tap_receipts')
}
6 changes: 6 additions & 0 deletions packages/indexer-common/src/query-fees/models.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ export interface ScalarTapReceiptsAttributes {
timestamp_ns: bigint
nonce: bigint
value: bigint
error_log?: string
}
export class ScalarTapReceipts
extends Model<ScalarTapReceiptsAttributes>
Expand Down Expand Up @@ -39,6 +40,7 @@ export class ScalarTapReceiptsInvalid
public nonce!: bigint
public value!: bigint
public signature!: Uint8Array
public error_log!: string

declare createdAt: CreationOptional<Date>
declare updatedAt: CreationOptional<Date>
Expand Down Expand Up @@ -657,6 +659,10 @@ export function defineQueryFeeModels(sequelize: Sequelize): QueryFeeModels {
type: DataTypes.BLOB,
allowNull: false,
},
error_log: {
type: DataTypes.TEXT,
allowNull: false,
},
},
{
underscored: true,
Expand Down

0 comments on commit f8675f6

Please sign in to comment.