From 8edf54382da96ca86b2acb6df834bd19913809ea Mon Sep 17 00:00:00 2001 From: MoonBoi9001 Date: Mon, 2 Mar 2026 20:41:27 -0500 Subject: [PATCH 1/3] feat: add migration for pending_rca_proposals table The indexer-rs v2 DIPs flow stores validated RCA proposals in a pending_rca_proposals table, which the agent will later pick up and accept on-chain. The indexer-service does not run migrations (by convention, the agent owns DDL), so this migration creates the table that indexer-service needs to write to. Co-Authored-By: Claude Opus 4.6 --- .../23-add-pending-rca-proposals.ts | 73 +++++++++++++++++++ 1 file changed, 73 insertions(+) create mode 100644 packages/indexer-agent/src/db/migrations/23-add-pending-rca-proposals.ts diff --git a/packages/indexer-agent/src/db/migrations/23-add-pending-rca-proposals.ts b/packages/indexer-agent/src/db/migrations/23-add-pending-rca-proposals.ts new file mode 100644 index 000000000..bbd4c738a --- /dev/null +++ b/packages/indexer-agent/src/db/migrations/23-add-pending-rca-proposals.ts @@ -0,0 +1,73 @@ +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() + + if (tables.includes('pending_rca_proposals')) { + logger.debug('pending_rca_proposals already exists, migration not necessary') + return + } + + logger.info('Create pending_rca_proposals table') + await queryInterface.createTable('pending_rca_proposals', { + id: { + type: DataTypes.UUID, + primaryKey: true, + }, + signed_payload: { + type: DataTypes.BLOB, + allowNull: false, + }, + version: { + type: DataTypes.SMALLINT, + allowNull: false, + defaultValue: 2, + }, + status: { + type: DataTypes.STRING(20), + allowNull: false, + defaultValue: 'pending', + }, + created_at: { + type: DataTypes.DATE, + allowNull: false, + defaultValue: DataTypes.NOW, + }, + updated_at: { + type: DataTypes.DATE, + allowNull: false, + defaultValue: DataTypes.NOW, + }, + }) + + await queryInterface.addIndex('pending_rca_proposals', ['status', 'created_at'], { + name: 'idx_pending_rca_status', + }) + + await queryInterface.sequelize.query( + 'CREATE INDEX idx_pending_rca_created ON pending_rca_proposals(created_at DESC)', + ) + + logger.info('Migration completed') +} + +export async function down({ context }: Context): Promise { + const { queryInterface, logger } = context + + logger.info('Drop pending_rca_proposals table') + await queryInterface.dropTable('pending_rca_proposals') + + logger.info('Migration completed') +} From a7aa1b62f400ea2e96fc0d0cda89e44d0125af9c Mon Sep 17 00:00:00 2001 From: MoonBoi9001 Date: Mon, 2 Mar 2026 20:48:42 -0500 Subject: [PATCH 2/3] style: fix prettier formatting Co-Authored-By: Claude Opus 4.6 --- .../db/migrations/23-add-pending-rca-proposals.ts | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/packages/indexer-agent/src/db/migrations/23-add-pending-rca-proposals.ts b/packages/indexer-agent/src/db/migrations/23-add-pending-rca-proposals.ts index bbd4c738a..7240db338 100644 --- a/packages/indexer-agent/src/db/migrations/23-add-pending-rca-proposals.ts +++ b/packages/indexer-agent/src/db/migrations/23-add-pending-rca-proposals.ts @@ -16,7 +16,9 @@ export async function up({ context }: Context): Promise { const tables = await queryInterface.showAllTables() if (tables.includes('pending_rca_proposals')) { - logger.debug('pending_rca_proposals already exists, migration not necessary') + logger.debug( + 'pending_rca_proposals already exists, migration not necessary', + ) return } @@ -52,9 +54,13 @@ export async function up({ context }: Context): Promise { }, }) - await queryInterface.addIndex('pending_rca_proposals', ['status', 'created_at'], { - name: 'idx_pending_rca_status', - }) + await queryInterface.addIndex( + 'pending_rca_proposals', + ['status', 'created_at'], + { + name: 'idx_pending_rca_status', + }, + ) await queryInterface.sequelize.query( 'CREATE INDEX idx_pending_rca_created ON pending_rca_proposals(created_at DESC)', From d33620db174165e82484c22e5489bbeb42c52bbe Mon Sep 17 00:00:00 2001 From: MoonBoi9001 Date: Tue, 3 Mar 2026 09:58:06 -0500 Subject: [PATCH 3/3] fix: use Sequelize addIndex API for descending index Replace raw SQL with queryInterface.addIndex using the fields object syntax for DESC ordering, per review feedback. Co-Authored-By: Claude Opus 4.6 --- .../src/db/migrations/23-add-pending-rca-proposals.ts | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/packages/indexer-agent/src/db/migrations/23-add-pending-rca-proposals.ts b/packages/indexer-agent/src/db/migrations/23-add-pending-rca-proposals.ts index 7240db338..791d2e14c 100644 --- a/packages/indexer-agent/src/db/migrations/23-add-pending-rca-proposals.ts +++ b/packages/indexer-agent/src/db/migrations/23-add-pending-rca-proposals.ts @@ -62,9 +62,10 @@ export async function up({ context }: Context): Promise { }, ) - await queryInterface.sequelize.query( - 'CREATE INDEX idx_pending_rca_created ON pending_rca_proposals(created_at DESC)', - ) + await queryInterface.addIndex('pending_rca_proposals', { + name: 'idx_pending_rca_created', + fields: [{ name: 'created_at', order: 'DESC' }], + }) logger.info('Migration completed') }