-
Notifications
You must be signed in to change notification settings - Fork 138
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
indexer-agent, indexer-cli, indexer-common: reject unsupported subgraphs
- Loading branch information
Showing
23 changed files
with
201 additions
and
52 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -104,6 +104,7 @@ dist | |
.tern-port | ||
.npmrc | ||
.yarnrc | ||
.envrc | ||
|
||
# Terraform state files | ||
*.tfstate* | ||
|
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
60 changes: 60 additions & 0 deletions
60
packages/indexer-agent/src/db/migrations/07-indexing-rules-add-require-supported.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,60 @@ | ||
import { Logger } from '@graphprotocol/common-ts' | ||
import { DataTypes, QueryInterface } 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.debug(`Checking if indexing rules table exists`) | ||
const tables = await queryInterface.showAllTables() | ||
if (!tables.includes('IndexingRules')) { | ||
logger.info(`Indexing rules table does not exist, migration not necessary`) | ||
return | ||
} | ||
|
||
logger.debug(`Checking if 'IndexingRules' table needs to be migrated`) | ||
const table = await queryInterface.describeTable('IndexingRules') | ||
const requireSupportedColumn = table.requireSupported | ||
if (requireSupportedColumn) { | ||
logger.info( | ||
`'requireSupported' columns already exist, migration not necessary`, | ||
) | ||
return | ||
} | ||
|
||
logger.info(`Add 'requireSupported' column to 'IndexingRules' table`) | ||
await queryInterface.addColumn('IndexingRules', 'requireSupported', { | ||
type: DataTypes.BOOLEAN, | ||
defaultValue: false, | ||
}) | ||
} | ||
|
||
export async function down({ context }: Context): Promise<void> { | ||
const { queryInterface, logger } = context | ||
|
||
return await queryInterface.sequelize.transaction({}, async transaction => { | ||
const tables = await queryInterface.showAllTables() | ||
|
||
if (tables.includes('IndexingRules')) { | ||
logger.info(`Remove 'requireSupported' column`) | ||
await context.queryInterface.removeColumn( | ||
'IndexingRules', | ||
'requireSupported', | ||
{ transaction }, | ||
) | ||
|
||
logger.info(`Remove 'bool_IndexingRules_requireSupported' custom type`) | ||
await queryInterface.sequelize.query( | ||
`delete from pg_type where typname = 'bool_IndexingRules_requireSupported'`, | ||
) | ||
} | ||
}) | ||
} |
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
10 changes: 5 additions & 5 deletions
10
packages/indexer-cli/src/__tests__/references/indexer-rule-deployment-always.stdout
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 |
---|---|---|
@@ -1,5 +1,5 @@ | ||
┌────────────────────────────────────────────────┬────────────────┬──────────────────┬────────────────────┬─────────────────────┬─────────────────────────┬───────────┬───────────┬──────────┬─────────────────────┬────────┬───────────────┐ | ||
│ identifier │ identifierType │ allocationAmount │ allocationLifetime │ parallelAllocations │ maxAllocationPercentage │ minSignal │ maxSignal │ minStake │ minAverageQueryFees │ custom │ decisionBasis │ | ||
├────────────────────────────────────────────────┼────────────────┼──────────────────┼────────────────────┼─────────────────────┼─────────────────────────┼───────────┼───────────┼──────────┼─────────────────────┼────────┼───────────────┤ | ||
│ QmZZtzZkfzCWMNrajxBf22q7BC9HzoT5iJUK3S8qA6zNZr │ deployment │ null │ null │ null │ null │ null │ null │ null │ null │ null │ always │ | ||
└────────────────────────────────────────────────┴────────────────┴──────────────────┴────────────────────┴─────────────────────┴─────────────────────────┴───────────┴───────────┴──────────┴─────────────────────┴────────┴───────────────┘ | ||
┌────────────────────────────────────────────────┬────────────────┬──────────────────┬────────────────────┬─────────────────────┬─────────────────────────┬───────────┬───────────┬──────────┬─────────────────────┬────────┬───────────────┬──────────────────┐ | ||
│ identifier │ identifierType │ allocationAmount │ allocationLifetime │ parallelAllocations │ maxAllocationPercentage │ minSignal │ maxSignal │ minStake │ minAverageQueryFees │ custom │ decisionBasis │ requireSupported │ | ||
├────────────────────────────────────────────────┼────────────────┼──────────────────┼────────────────────┼─────────────────────┼─────────────────────────┼───────────┼───────────┼──────────┼─────────────────────┼────────┼───────────────┼──────────────────┤ | ||
│ QmZZtzZkfzCWMNrajxBf22q7BC9HzoT5iJUK3S8qA6zNZr │ deployment │ null │ null │ null │ null │ null │ null │ null │ null │ null │ always │ true │ | ||
└────────────────────────────────────────────────┴────────────────┴──────────────────┴────────────────────┴─────────────────────┴─────────────────────────┴───────────┴───────────┴──────────┴─────────────────────┴────────┴───────────────┴──────────────────┘ |
10 changes: 5 additions & 5 deletions
10
packages/indexer-cli/src/__tests__/references/indexer-rule-deployment-lifetime.stdout
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 |
---|---|---|
@@ -1,5 +1,5 @@ | ||
┌────────────────────────────────────────────────┬────────────────┬──────────────────┬────────────────────┬─────────────────────┬─────────────────────────┬───────────┬───────────┬──────────┬─────────────────────┬────────┬───────────────┐ | ||
│ identifier │ identifierType │ allocationAmount │ allocationLifetime │ parallelAllocations │ maxAllocationPercentage │ minSignal │ maxSignal │ minStake │ minAverageQueryFees │ custom │ decisionBasis │ | ||
├────────────────────────────────────────────────┼────────────────┼──────────────────┼────────────────────┼─────────────────────┼─────────────────────────┼───────────┼───────────┼──────────┼─────────────────────┼────────┼───────────────┤ | ||
│ QmZfeJYR86UARzp9HiXbURWunYgC9ywvPvoePNbuaATrEK │ deployment │ null │ 21 │ null │ null │ null │ null │ null │ null │ null │ offchain │ | ||
└────────────────────────────────────────────────┴────────────────┴──────────────────┴────────────────────┴─────────────────────┴─────────────────────────┴───────────┴───────────┴──────────┴─────────────────────┴────────┴───────────────┘ | ||
┌────────────────────────────────────────────────┬────────────────┬──────────────────┬────────────────────┬─────────────────────┬─────────────────────────┬───────────┬───────────┬──────────┬─────────────────────┬────────┬───────────────┬──────────────────┐ | ||
│ identifier │ identifierType │ allocationAmount │ allocationLifetime │ parallelAllocations │ maxAllocationPercentage │ minSignal │ maxSignal │ minStake │ minAverageQueryFees │ custom │ decisionBasis │ requireSupported │ | ||
├────────────────────────────────────────────────┼────────────────┼──────────────────┼────────────────────┼─────────────────────┼─────────────────────────┼───────────┼───────────┼──────────┼─────────────────────┼────────┼───────────────┼──────────────────┤ | ||
│ QmZfeJYR86UARzp9HiXbURWunYgC9ywvPvoePNbuaATrEK │ deployment │ null │ 21 │ null │ null │ null │ null │ null │ null │ null │ offchain │ true │ | ||
└────────────────────────────────────────────────┴────────────────┴──────────────────┴────────────────────┴─────────────────────┴─────────────────────────┴───────────┴───────────┴──────────┴─────────────────────┴────────┴───────────────┴──────────────────┘ |
Oops, something went wrong.