forked from graphprotocol/indexer
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
indexer-agent,-common,-cli: Add subgraphDeployementID to POIDisputes
- Loading branch information
Showing
8 changed files
with
83 additions
and
9 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
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
46 changes: 46 additions & 0 deletions
46
packages/indexer-agent/src/migrations/03-poi-disputes-add-subgraph-deployment-id.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,46 @@ | ||
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 | ||
|
||
logger.info(`Checking if POI disputes table exists`) | ||
const tables = await queryInterface.showAllTables() | ||
if (!tables.includes('POIDisputes')) { | ||
logger.info(`POI disputes table does not exist, migration not necessary`) | ||
return | ||
} | ||
|
||
logger.info(`Checking if POI disputes table needs to be migrated`) | ||
const table = await queryInterface.describeTable('POIDisputes') | ||
const subgraphDeploymentIDColumn = table.subgraphDeploymentID | ||
if (subgraphDeploymentIDColumn) { | ||
logger.info( | ||
`Subgraph deployment ID column already exists, migration not necessary`, | ||
) | ||
return | ||
} | ||
|
||
logger.info(`Adding subgraphDeploymentID column to POIDisputes table`) | ||
await queryInterface.addColumn('POIDisputes', 'subgraphDeploymentID', { | ||
type: DataTypes.STRING, | ||
allowNull: false, | ||
defaultValue: 'notSet', | ||
}) | ||
} | ||
|
||
export async function down({ context }: Context): Promise<void> { | ||
await context.queryInterface.removeColumn( | ||
'POIDisputes', | ||
'subgraphDeploymentID', | ||
) | ||
} |
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
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