Skip to content

Commit

Permalink
feat(database): add unique constraint on workspace subdomain
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
AMoreaux committed Dec 16, 2024
1 parent 3c1d0a6 commit da731db
Showing 1 changed file with 15 additions and 10 deletions.
Original file line number Diff line number Diff line change
@@ -1,14 +1,19 @@
import { MigrationInterface, QueryRunner } from "typeorm";
import { MigrationInterface, QueryRunner } from 'typeorm';

export class AddUniqueIndexOnSubdomain1734355945585 implements MigrationInterface {
name = 'AddUniqueIndexOnSubdomain1734355945585'
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"`);
}
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"`,
);
}
}

0 comments on commit da731db

Please sign in to comment.