ToolJet/server/migrations/1747133448781-AddPluginIdUniqueConstraint.ts
Kushagra Srivastava 86d60336a8
Unique constraint on plugins to prevent plugin to be installed multiple times in a workspace (#12798)
* fixed plugin duplication bug

Signed-off-by: thesynthax <kushagra1403@gmail.com>

* changed it on DB level

Signed-off-by: thesynthax <kushagra1403@gmail.com>

* changed id to name in error dialog

Signed-off-by: thesynthax <kushagra1403@gmail.com>

* migrations run

Signed-off-by: thesynthax <kushagra1403@gmail.com>

---------

Signed-off-by: thesynthax <kushagra1403@gmail.com>
2025-05-27 12:13:16 +05:30

22 lines
637 B
TypeScript

import { MigrationInterface, QueryRunner, TableUnique } from "typeorm";
export class AddPluginIdUniqueConstraint1747133448781 implements MigrationInterface {
public async up(queryRunner: QueryRunner): Promise<void> {
await queryRunner.createUniqueConstraint(
"plugins",
new TableUnique({
name: "UQ_plugin_pluginId",
columnNames: ["plugin_id"],
})
);
}
public async down(queryRunner: QueryRunner): Promise<void> {
await queryRunner.dropUniqueConstraint(
"plugins",
"UQ_plugin_pluginId"
);
}
}