AI Agents & MCPs & AI Workflow Automation • (~400 MCP servers for AI agents) • AI Automation / AI Agent with MCPs • AI Workflows & AI Agents • MCPs for AI Agents
TypeScript ai-agentai-agent-toolsai-agentsai-agents-frameworkmcpmcp-servermcp-toolsmcpsn8n-alternativeno-code-automationworkflowworkflow-automationworkflows
import { AIProviderName, apId } from '@activepieces/core-utils'
import { MigrationInterface, QueryRunner } from 'typeorm'
import { encryptUtils } from '../../../helper/encryption'
export class RemoveOpenRounterKeysFromPlatformPlan1766094015801 implements MigrationInterface {
name = 'RemoveOpenRounterKeysFromPlatformPlan1766094015801'
public async up(queryRunner: QueryRunner): Promise<void> {
const plans = await queryRunner.query(`
SELECT id, "platformId", "openRouterApiKey", "openRouterApiKeyHash"
FROM "platform_plan"
WHERE "openRouterApiKey" IS NOT NULL
`)
for (const plan of plans) {
const config: Record<string, string> = {
apiKey: plan.openRouterApiKey as string,
apiKeyHash: plan.openRouterApiKeyHash as string,
}
const encryptedConfig = await encryptUtils.encryptObject(config)
await queryRunner.query(`
INSERT INTO "ai_provider" ("id", "platformId", "provider", "displayName", "config", "created", "updated")
VALUES ($1, $2, $3, $4, $5, NOW(), NOW())
`, [
apId(),
plan.platformId,
AIProviderName.ACTIVEPIECES,
'Activepieces',
encryptedConfig,
])
}
await queryRunner.query(`
ALTER TABLE "platform_plan" DROP COLUMN "openRouterApiKeyHash"
`)
await queryRunner.query(`
ALTER TABLE "platform_plan" DROP COLUMN "openRouterApiKey"
`)
}
public async down(queryRunner: QueryRunner): Promise<void> {
await queryRunner.query(`
ALTER TABLE "platform_plan"
ADD "openRouterApiKey" character varying
`)
await queryRunner.query(`
ALTER TABLE "platform_plan"
ADD "openRouterApiKeyHash" character varying
`)
}
}