Create feature flag table (#2752)

* feature flag working

* wip

* wip

* Fix

---------

Co-authored-by: Charles Bochet <charles@twenty.com>
This commit is contained in:
bosiraphael
2023-11-28 20:19:39 +01:00
committed by GitHub
parent 9e9e1940f9
commit 18d30c45c4
6 changed files with 71 additions and 7 deletions

View File

@ -0,0 +1,38 @@
import {
Entity,
Unique,
PrimaryGeneratedColumn,
Column,
CreateDateColumn,
UpdateDateColumn,
ManyToOne,
} from 'typeorm';
import { Workspace } from 'src/core/workspace/workspace.entity';
@Entity({ name: 'featureFlag', schema: 'core' })
@Unique('IndexOnKeyAndWorkspaceIdUnique', ['key', 'workspaceId'])
export class FeatureFlagEntity {
@PrimaryGeneratedColumn('uuid')
id: string;
@Column({ nullable: false, type: 'text' })
key: string;
@Column({ nullable: false, type: 'uuid' })
workspaceId: string;
@ManyToOne(() => Workspace, (workspace) => workspace.featureFlags, {
onDelete: 'CASCADE',
})
workspace: Workspace;
@Column({ nullable: false })
value: boolean;
@CreateDateColumn()
createdAt: Date;
@UpdateDateColumn()
updatedAt: Date;
}

View File

@ -11,6 +11,7 @@ import {
} from 'typeorm';
import { User } from 'src/core/user/user.entity';
import { FeatureFlagEntity } from 'src/core/feature-flag/feature-flag.entity';
@Entity({ name: 'workspace', schema: 'core' })
@ObjectType('Workspace')
@ -53,4 +54,7 @@ export class Workspace {
@Field()
@Column({ default: true })
allowImpersonation: boolean;
@OneToMany(() => FeatureFlagEntity, (featureFlag) => featureFlag.workspace)
featureFlags: FeatureFlagEntity[];
}