/
1700132368636-RemoveUnusedFieldsinBilling.ts
87 lines (84 loc) · 2.92 KB
/
1700132368636-RemoveUnusedFieldsinBilling.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
import { MigrationInterface, QueryRunner } from 'typeorm'
import { isNotOneOfTheseEditions } from '../../database-common'
import { ApEdition } from '@activepieces/shared'
export class RemoveUnusedFieldsinBilling1700132368636
implements MigrationInterface {
name = 'RemoveUnusedFieldsinBilling1700132368636'
public async up(queryRunner: QueryRunner): Promise<void> {
if (isNotOneOfTheseEditions([ApEdition.CLOUD, ApEdition.ENTERPRISE])) {
return
}
await queryRunner.query(`
ALTER TABLE "project_plan" DROP COLUMN "activeFlows"
`)
await queryRunner.query(`
ALTER TABLE "project_plan" DROP COLUMN "botPlanName"
`)
await queryRunner.query(`
ALTER TABLE "project_plan" DROP COLUMN "bots"
`)
await queryRunner.query(`
ALTER TABLE "project_plan" DROP COLUMN "datasourcesSize"
`)
await queryRunner.query(`
ALTER TABLE "project_plan" DROP COLUMN "datasources"
`)
await queryRunner.query(`
ALTER TABLE "chatbot"
ALTER COLUMN "visibilityStatus" DROP DEFAULT
`)
await queryRunner.query(`
ALTER TABLE "chatbot"
ALTER COLUMN "visibilityStatus" DROP DEFAULT
`)
await queryRunner.query(`
ALTER TABLE "project_usage" DROP COLUMN "datasourcesSize"
`)
await queryRunner.query(`
ALTER TABLE "project_usage" DROP COLUMN "bots"
`)
}
public async down(queryRunner: QueryRunner): Promise<void> {
if (isNotOneOfTheseEditions([ApEdition.CLOUD, ApEdition.ENTERPRISE])) {
return
}
await queryRunner.query(`
ALTER TABLE "project_usage"
ADD "bots" integer NOT NULL DEFAULT '0'
`)
await queryRunner.query(`
ALTER TABLE "project_usage"
ADD "datasourcesSize" integer NOT NULL DEFAULT '0'
`)
await queryRunner.query(`
ALTER TABLE "chatbot"
ALTER COLUMN "visibilityStatus"
SET DEFAULT 'PRIVATE'
`)
await queryRunner.query(`
ALTER TABLE "chatbot"
ALTER COLUMN "visibilityStatus"
SET DEFAULT 'PRIVATE'
`)
await queryRunner.query(`
ALTER TABLE "project_plan"
ADD "datasources" integer NOT NULL DEFAULT '1'
`)
await queryRunner.query(`
ALTER TABLE "project_plan"
ADD "datasourcesSize" integer NOT NULL DEFAULT '10485760'
`)
await queryRunner.query(`
ALTER TABLE "project_plan"
ADD "bots" integer NOT NULL DEFAULT '1'
`)
await queryRunner.query(`
ALTER TABLE "project_plan"
ADD "botPlanName" character varying NOT NULL DEFAULT 'free'
`)
await queryRunner.query(`
ALTER TABLE "project_plan"
ADD "activeFlows" integer NOT NULL
`)
}
}