update KeyValuePairType enum and add IS_CONFIG_VAR_IN_DB_ENABLED config var (#11596)
closes https://github.com/twentyhq/core-team-issues/issues/758
This commit is contained in:
@ -75,4 +75,6 @@ FRONTEND_URL=http://localhost:3001
|
|||||||
# SSL_CERT_PATH="./certs/your-cert.crt"
|
# SSL_CERT_PATH="./certs/your-cert.crt"
|
||||||
# CLOUDFLARE_API_KEY=
|
# CLOUDFLARE_API_KEY=
|
||||||
# CLOUDFLARE_ZONE_ID=
|
# CLOUDFLARE_ZONE_ID=
|
||||||
# CLOUDFLARE_WEBHOOK_SECRET=
|
# CLOUDFLARE_WEBHOOK_SECRET=
|
||||||
|
# IS_CONFIG_VARIABLES_IN_DB_ENABLED=false
|
||||||
|
|
||||||
|
|||||||
@ -0,0 +1,69 @@
|
|||||||
|
import { MigrationInterface, QueryRunner } from 'typeorm';
|
||||||
|
|
||||||
|
export class UpdateKeyValuePairTypeEnum1743085000787
|
||||||
|
implements MigrationInterface
|
||||||
|
{
|
||||||
|
name = 'UpdateKeyValuePairTypeEnum1743085000787';
|
||||||
|
|
||||||
|
public async up(queryRunner: QueryRunner): Promise<void> {
|
||||||
|
await queryRunner.query(
|
||||||
|
`ALTER TABLE "core"."keyValuePair" ALTER COLUMN "type" DROP DEFAULT`,
|
||||||
|
);
|
||||||
|
|
||||||
|
await queryRunner.query(
|
||||||
|
`ALTER TABLE "core"."keyValuePair" ALTER COLUMN "type" TYPE text USING "type"::text`,
|
||||||
|
);
|
||||||
|
|
||||||
|
await queryRunner.query(
|
||||||
|
`UPDATE "core"."keyValuePair" SET "type" = 'USER_VARIABLE' WHERE "type" = 'USER_VAR'`,
|
||||||
|
);
|
||||||
|
await queryRunner.query(
|
||||||
|
`UPDATE "core"."keyValuePair" SET "type" = 'CONFIG_VARIABLE' WHERE "type" = 'SYSTEM_VAR'`,
|
||||||
|
);
|
||||||
|
|
||||||
|
await queryRunner.query(`DROP TYPE "core"."keyValuePair_type_enum"`);
|
||||||
|
|
||||||
|
await queryRunner.query(
|
||||||
|
`CREATE TYPE "core"."keyValuePair_type_enum" AS ENUM('USER_VARIABLE', 'FEATURE_FLAG', 'CONFIG_VARIABLE')`,
|
||||||
|
);
|
||||||
|
|
||||||
|
await queryRunner.query(
|
||||||
|
`ALTER TABLE "core"."keyValuePair" ALTER COLUMN "type" TYPE "core"."keyValuePair_type_enum" USING "type"::"core"."keyValuePair_type_enum"`,
|
||||||
|
);
|
||||||
|
|
||||||
|
await queryRunner.query(
|
||||||
|
`ALTER TABLE "core"."keyValuePair" ALTER COLUMN "type" SET DEFAULT 'USER_VARIABLE'`,
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
public async down(queryRunner: QueryRunner): Promise<void> {
|
||||||
|
await queryRunner.query(
|
||||||
|
`ALTER TABLE "core"."keyValuePair" ALTER COLUMN "type" DROP DEFAULT`,
|
||||||
|
);
|
||||||
|
|
||||||
|
await queryRunner.query(
|
||||||
|
`ALTER TABLE "core"."keyValuePair" ALTER COLUMN "type" TYPE text USING "type"::text`,
|
||||||
|
);
|
||||||
|
|
||||||
|
await queryRunner.query(
|
||||||
|
`UPDATE "core"."keyValuePair" SET "type" = 'USER_VAR' WHERE "type" = 'USER_VARIABLE'`,
|
||||||
|
);
|
||||||
|
await queryRunner.query(
|
||||||
|
`UPDATE "core"."keyValuePair" SET "type" = 'SYSTEM_VAR' WHERE "type" = 'CONFIG_VARIABLE'`,
|
||||||
|
);
|
||||||
|
|
||||||
|
await queryRunner.query(`DROP TYPE "core"."keyValuePair_type_enum"`);
|
||||||
|
|
||||||
|
await queryRunner.query(
|
||||||
|
`CREATE TYPE "core"."keyValuePair_type_enum" AS ENUM('USER_VAR', 'FEATURE_FLAG', 'SYSTEM_VAR')`,
|
||||||
|
);
|
||||||
|
|
||||||
|
await queryRunner.query(
|
||||||
|
`ALTER TABLE "core"."keyValuePair" ALTER COLUMN "type" TYPE "core"."keyValuePair_type_enum" USING "type"::"core"."keyValuePair_type_enum"`,
|
||||||
|
);
|
||||||
|
|
||||||
|
await queryRunner.query(
|
||||||
|
`ALTER TABLE "core"."keyValuePair" ALTER COLUMN "type" SET DEFAULT 'USER_VAR'`,
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -19,9 +19,9 @@ import { User } from 'src/engine/core-modules/user/user.entity';
|
|||||||
import { Workspace } from 'src/engine/core-modules/workspace/workspace.entity';
|
import { Workspace } from 'src/engine/core-modules/workspace/workspace.entity';
|
||||||
|
|
||||||
export enum KeyValuePairType {
|
export enum KeyValuePairType {
|
||||||
USER_VAR = 'USER_VAR',
|
USER_VARIABLE = 'USER_VARIABLE',
|
||||||
FEATURE_FLAG = 'FEATURE_FLAG',
|
FEATURE_FLAG = 'FEATURE_FLAG',
|
||||||
SYSTEM_VAR = 'SYSTEM_VAR',
|
CONFIG_VARIABLE = 'CONFIG_VARIABLE',
|
||||||
}
|
}
|
||||||
|
|
||||||
@Entity({ name: 'keyValuePair', schema: 'core' })
|
@Entity({ name: 'keyValuePair', schema: 'core' })
|
||||||
@ -75,7 +75,7 @@ export class KeyValuePair {
|
|||||||
type: 'enum',
|
type: 'enum',
|
||||||
enum: Object.values(KeyValuePairType),
|
enum: Object.values(KeyValuePairType),
|
||||||
nullable: false,
|
nullable: false,
|
||||||
default: KeyValuePairType.USER_VAR,
|
default: KeyValuePairType.USER_VARIABLE,
|
||||||
})
|
})
|
||||||
type: KeyValuePairType;
|
type: KeyValuePairType;
|
||||||
|
|
||||||
|
|||||||
@ -720,6 +720,15 @@ export class ConfigVariables {
|
|||||||
@IsOptional()
|
@IsOptional()
|
||||||
PG_SSL_ALLOW_SELF_SIGNED = false;
|
PG_SSL_ALLOW_SELF_SIGNED = false;
|
||||||
|
|
||||||
|
@ConfigVariablesMetadata({
|
||||||
|
group: ConfigVariablesGroup.ServerConfig,
|
||||||
|
description: 'Enable configuration variables to be stored in the database',
|
||||||
|
})
|
||||||
|
@CastToBoolean()
|
||||||
|
@IsBoolean()
|
||||||
|
@IsOptional()
|
||||||
|
IS_CONFIG_VARIABLES_IN_DB_ENABLED = false;
|
||||||
|
|
||||||
@ConfigVariablesMetadata({
|
@ConfigVariablesMetadata({
|
||||||
group: ConfigVariablesGroup.TokensDuration,
|
group: ConfigVariablesGroup.TokensDuration,
|
||||||
description: 'Time-to-live for cache storage in seconds',
|
description: 'Time-to-live for cache storage in seconds',
|
||||||
|
|||||||
@ -23,7 +23,7 @@ export class UserVarsService<
|
|||||||
|
|
||||||
if (workspaceId) {
|
if (workspaceId) {
|
||||||
userVarWorkspaceLevel = await this.keyValuePairService.get({
|
userVarWorkspaceLevel = await this.keyValuePairService.get({
|
||||||
type: KeyValuePairType.USER_VAR,
|
type: KeyValuePairType.USER_VARIABLE,
|
||||||
userId: null,
|
userId: null,
|
||||||
workspaceId,
|
workspaceId,
|
||||||
key,
|
key,
|
||||||
@ -40,7 +40,7 @@ export class UserVarsService<
|
|||||||
|
|
||||||
if (userId) {
|
if (userId) {
|
||||||
userVarUserLevel = await this.keyValuePairService.get({
|
userVarUserLevel = await this.keyValuePairService.get({
|
||||||
type: KeyValuePairType.USER_VAR,
|
type: KeyValuePairType.USER_VARIABLE,
|
||||||
userId,
|
userId,
|
||||||
workspaceId: null,
|
workspaceId: null,
|
||||||
key,
|
key,
|
||||||
@ -55,7 +55,7 @@ export class UserVarsService<
|
|||||||
|
|
||||||
if (userId && workspaceId) {
|
if (userId && workspaceId) {
|
||||||
userVarWorkspaceAndUserLevel = await this.keyValuePairService.get({
|
userVarWorkspaceAndUserLevel = await this.keyValuePairService.get({
|
||||||
type: KeyValuePairType.USER_VAR,
|
type: KeyValuePairType.USER_VARIABLE,
|
||||||
userId,
|
userId,
|
||||||
workspaceId,
|
workspaceId,
|
||||||
key,
|
key,
|
||||||
@ -88,7 +88,7 @@ export class UserVarsService<
|
|||||||
result = [
|
result = [
|
||||||
...result,
|
...result,
|
||||||
...(await this.keyValuePairService.get({
|
...(await this.keyValuePairService.get({
|
||||||
type: KeyValuePairType.USER_VAR,
|
type: KeyValuePairType.USER_VARIABLE,
|
||||||
userId,
|
userId,
|
||||||
workspaceId: null,
|
workspaceId: null,
|
||||||
})),
|
})),
|
||||||
@ -99,7 +99,7 @@ export class UserVarsService<
|
|||||||
result = [
|
result = [
|
||||||
...result,
|
...result,
|
||||||
...(await this.keyValuePairService.get({
|
...(await this.keyValuePairService.get({
|
||||||
type: KeyValuePairType.USER_VAR,
|
type: KeyValuePairType.USER_VARIABLE,
|
||||||
userId: null,
|
userId: null,
|
||||||
workspaceId,
|
workspaceId,
|
||||||
})),
|
})),
|
||||||
@ -110,7 +110,7 @@ export class UserVarsService<
|
|||||||
result = [
|
result = [
|
||||||
...result,
|
...result,
|
||||||
...(await this.keyValuePairService.get({
|
...(await this.keyValuePairService.get({
|
||||||
type: KeyValuePairType.USER_VAR,
|
type: KeyValuePairType.USER_VARIABLE,
|
||||||
userId,
|
userId,
|
||||||
workspaceId,
|
workspaceId,
|
||||||
})),
|
})),
|
||||||
@ -136,7 +136,7 @@ export class UserVarsService<
|
|||||||
workspaceId,
|
workspaceId,
|
||||||
key: key,
|
key: key,
|
||||||
value,
|
value,
|
||||||
type: KeyValuePairType.USER_VAR,
|
type: KeyValuePairType.USER_VARIABLE,
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -153,7 +153,7 @@ export class UserVarsService<
|
|||||||
userId,
|
userId,
|
||||||
workspaceId,
|
workspaceId,
|
||||||
key,
|
key,
|
||||||
type: KeyValuePairType.USER_VAR,
|
type: KeyValuePairType.USER_VARIABLE,
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user