-
Notifications
You must be signed in to change notification settings - Fork 136
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat!: Add new column to invalid_receipts table
- Loading branch information
Showing
2 changed files
with
57 additions
and
0 deletions.
There are no files selected for viewing
51 changes: 51 additions & 0 deletions
51
packages/indexer-agent/src/db/migrations/16-modify-invalid-receipts-table.ts
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,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') | ||
} |
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