ToolJet/server/data-migrations/1693309526388-addUniqueKeyConstrainForOrganizationUsers.ts
Midhun G S 50b5129058
Added unique key constrain to organization users table (#7207)
* added unique key constrain to organization users

* fix

* fix

* added logs and comments

* test case fixes

* resolve fail test

* resolve tests google auth

* comment out organization id checks

* remove all e2e tests changes

* comment tests

* test case fixes

* resolve fail test

* resolve tests google auth

* revert all changes

* fix for test cases

* test case fixes

* revert all test case changes

* refractor

---------

Co-authored-by: Anantshree Chandola <anantshreechandola23@gmail.com>
2023-09-26 11:28:59 +05:30

18 lines
723 B
TypeScript

import { DataBaseConstraints } from 'src/helpers/db_constraints.constants';
import { MigrationInterface, QueryRunner, TableUnique } from 'typeorm';
export class addUniqueKeyConstrainForOrganizationUsers1693309526388 implements MigrationInterface {
public async up(queryRunner: QueryRunner): Promise<void> {
await queryRunner.createUniqueConstraint(
'organization_users',
new TableUnique({
name: DataBaseConstraints.USER_ORGANIZATION_UNIQUE,
columnNames: ['user_id', 'organization_id'],
})
);
}
public async down(queryRunner: QueryRunner): Promise<void> {
await queryRunner.dropUniqueConstraint('organization_users', DataBaseConstraints.USER_ORGANIZATION_UNIQUE);
}
}