Introduce webhook v2 (#17456)

Migrate webhook to v2 entity
This commit is contained in:
Charles Bochet
2026-01-27 16:32:33 +01:00
committed by GitHub
parent 27e5b9797b
commit bc7791871f
83 changed files with 1574 additions and 975 deletions
@@ -21,7 +21,7 @@ import { PostgresCredentialsEntity } from 'src/engine/core-modules/postgres-cred
import { PublicDomainEntity } from 'src/engine/core-modules/public-domain/public-domain.entity';
import { WorkspaceSSOIdentityProviderEntity } from 'src/engine/core-modules/sso/workspace-sso-identity-provider.entity';
import { UserWorkspaceEntity } from 'src/engine/core-modules/user-workspace/user-workspace.entity';
import { WebhookEntity } from 'src/engine/core-modules/webhook/webhook.entity';
import { WebhookEntity } from 'src/engine/metadata-modules/webhook/entities/webhook.entity';
import { WorkspaceEntity } from 'src/engine/core-modules/workspace/workspace.entity';
import { AgentEntity } from 'src/engine/metadata-modules/ai/ai-agent/entities/agent.entity';
import { CronTriggerEntity } from 'src/engine/metadata-modules/cron-trigger/entities/cron-trigger.entity';
@@ -0,0 +1,35 @@
import { type MigrationInterface, type QueryRunner } from 'typeorm';
export class AddUniversalToWebhook1769517102605 implements MigrationInterface {
name = 'AddUniversalToWebhook1769517102605';
public async up(queryRunner: QueryRunner): Promise<void> {
await queryRunner.query(
`ALTER TABLE "core"."webhook" ADD "universalIdentifier" uuid`,
);
await queryRunner.query(
`ALTER TABLE "core"."webhook" ADD "applicationId" uuid`,
);
await queryRunner.query(
`CREATE UNIQUE INDEX "IDX_d48d713d01cc3c81bad1f39795" ON "core"."webhook" ("workspaceId", "universalIdentifier") `,
);
await queryRunner.query(
`ALTER TABLE "core"."webhook" ADD CONSTRAINT "FK_e755f49a9ef74b36e27932f7a6c" FOREIGN KEY ("applicationId") REFERENCES "core"."application"("id") ON DELETE CASCADE ON UPDATE NO ACTION`,
);
}
public async down(queryRunner: QueryRunner): Promise<void> {
await queryRunner.query(
`ALTER TABLE "core"."webhook" DROP CONSTRAINT "FK_e755f49a9ef74b36e27932f7a6c"`,
);
await queryRunner.query(
`DROP INDEX "core"."IDX_d48d713d01cc3c81bad1f39795"`,
);
await queryRunner.query(
`ALTER TABLE "core"."webhook" DROP COLUMN "applicationId"`,
);
await queryRunner.query(
`ALTER TABLE "core"."webhook" DROP COLUMN "universalIdentifier"`,
);
}
}
@@ -0,0 +1,63 @@
import { type MigrationInterface, type QueryRunner } from 'typeorm';
import { makeWebhookUniversalIdentifierAndApplicationIdNotNullQueries } from 'src/database/typeorm/core/migrations/utils/1769525557511-makeWebhookUniversalIdentifierAndApplicationIdNotNull.util';
export class MakeWebhookUnivesralIdentiferAndApplicationIdNotNull1769525557511
implements MigrationInterface
{
name = 'MakeWebhookUnivesralIdentiferAndApplicationIdNotNull1769525557511';
public async up(queryRunner: QueryRunner): Promise<void> {
const savepointName =
'sp_make_webhook_universal_identifier_and_application_id_not_null';
try {
await queryRunner.query(`SAVEPOINT ${savepointName}`);
await makeWebhookUniversalIdentifierAndApplicationIdNotNullQueries(
queryRunner,
);
await queryRunner.query(`RELEASE SAVEPOINT ${savepointName}`);
} catch (e) {
try {
await queryRunner.query(`ROLLBACK TO SAVEPOINT ${savepointName}`);
await queryRunner.query(`RELEASE SAVEPOINT ${savepointName}`);
} catch (rollbackError) {
// eslint-disable-next-line no-console
console.error(
'Failed to rollback to savepoint in MakeWebhookUnivesralIdentiferAndApplicationIdNotNull1769525557511',
rollbackError,
);
throw rollbackError;
}
// eslint-disable-next-line no-console
console.error(
'Swallowing MakeWebhookUnivesralIdentiferAndApplicationIdNotNull1769525557511 error',
e,
);
}
}
public async down(queryRunner: QueryRunner): Promise<void> {
await queryRunner.query(
`ALTER TABLE "core"."webhook" DROP CONSTRAINT "FK_e755f49a9ef74b36e27932f7a6c"`,
);
await queryRunner.query(
`DROP INDEX "core"."IDX_d48d713d01cc3c81bad1f39795"`,
);
await queryRunner.query(
`ALTER TABLE "core"."webhook" ALTER COLUMN "applicationId" DROP NOT NULL`,
);
await queryRunner.query(
`ALTER TABLE "core"."webhook" ALTER COLUMN "universalIdentifier" DROP NOT NULL`,
);
await queryRunner.query(
`CREATE UNIQUE INDEX "IDX_d48d713d01cc3c81bad1f39795" ON "core"."webhook" ("workspaceId", "universalIdentifier") `,
);
await queryRunner.query(
`ALTER TABLE "core"."webhook" ADD CONSTRAINT "FK_e755f49a9ef74b36e27932f7a6c" FOREIGN KEY ("applicationId") REFERENCES "core"."application"("id") ON DELETE CASCADE ON UPDATE NO ACTION`,
);
}
}
@@ -0,0 +1,23 @@
import { type QueryRunner } from 'typeorm';
export const makeWebhookUniversalIdentifierAndApplicationIdNotNullQueries =
async (queryRunner: QueryRunner): Promise<void> => {
await queryRunner.query(
`ALTER TABLE "core"."webhook" DROP CONSTRAINT "FK_e755f49a9ef74b36e27932f7a6c"`,
);
await queryRunner.query(
`DROP INDEX "core"."IDX_d48d713d01cc3c81bad1f39795"`,
);
await queryRunner.query(
`ALTER TABLE "core"."webhook" ALTER COLUMN "universalIdentifier" SET NOT NULL`,
);
await queryRunner.query(
`ALTER TABLE "core"."webhook" ALTER COLUMN "applicationId" SET NOT NULL`,
);
await queryRunner.query(
`CREATE UNIQUE INDEX "IDX_d48d713d01cc3c81bad1f39795" ON "core"."webhook" ("workspaceId", "universalIdentifier") `,
);
await queryRunner.query(
`ALTER TABLE "core"."webhook" ADD CONSTRAINT "FK_e755f49a9ef74b36e27932f7a6c" FOREIGN KEY ("applicationId") REFERENCES "core"."application"("id") ON DELETE CASCADE ON UPDATE NO ACTION`,
);
};