feat(database): add unique constraint on workspace subdomain (#9084)
Added a unique constraint to the "subdomain" column in the workspace entity to ensure no duplicate subdomains exist in the database. Included a TypeORM migration script to enforce this change at the database level.
This commit is contained in:
@ -0,0 +1,19 @@
|
|||||||
|
import { MigrationInterface, QueryRunner } from 'typeorm';
|
||||||
|
|
||||||
|
export class AddUniqueIndexOnSubdomain1734355945585
|
||||||
|
implements MigrationInterface
|
||||||
|
{
|
||||||
|
name = 'AddUniqueIndexOnSubdomain1734355945585';
|
||||||
|
|
||||||
|
public async up(queryRunner: QueryRunner): Promise<void> {
|
||||||
|
await queryRunner.query(
|
||||||
|
`ALTER TABLE "core"."workspace" ADD CONSTRAINT "UQ_cba6255a24deb1fff07dd7351b8" UNIQUE ("subdomain")`,
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
public async down(queryRunner: QueryRunner): Promise<void> {
|
||||||
|
await queryRunner.query(
|
||||||
|
`ALTER TABLE "core"."workspace" DROP CONSTRAINT "UQ_cba6255a24deb1fff07dd7351b8"`,
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -144,7 +144,7 @@ export class Workspace {
|
|||||||
databaseSchema: string;
|
databaseSchema: string;
|
||||||
|
|
||||||
@Field()
|
@Field()
|
||||||
@Column()
|
@Column({ unique: true })
|
||||||
subdomain: string;
|
subdomain: string;
|
||||||
|
|
||||||
@Field()
|
@Field()
|
||||||
|
|||||||
Reference in New Issue
Block a user