Skip to content

Commit 7105c10

Browse files
committed
chore: rename
Signed-off-by: Uroš Marolt <uros@marolt.me>
1 parent 59a3321 commit 7105c10

2 files changed

Lines changed: 11 additions & 8 deletions

File tree

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
1-
create table "integrationsHistory" as
1+
create table "integrationsBackup" as
22
select *
33
from "integrations"
44
where 1 = 2;
55

6-
alter table "integrationsHistory"
7-
add column "historyCreatedAt" timestamptz not null default now();
6+
alter table "integrationsBackup"
7+
add column "backupCreatedAt" timestamptz not null default now();
88

9-
create index if not exists ix_integration_history_integration_id on "integrationsHistory" ("id");
10-
create index if not exists ix_integration_history_history_created_at on "integrationsHistory" ("historyCreatedAt");
9+
create index if not exists ix_integration_history_integration_id on "integrationsBackup" ("id");
10+
create index if not exists ix_integration_history_history_created_at on "integrationsBackup" ("backupCreatedAt");

services/apps/cron_service/src/jobs/integrationsBackup.job.ts

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,13 +7,16 @@ import { IJobDefinition } from '../types'
77

88
const job: IJobDefinition = {
99
name: 'integrations-backup',
10-
cronTime: CronTime.every(1).minutes(),
10+
cronTime: CronTime.every(1).days(),
1111
timeout: 60 * 60, // 1 hour = 60 * 60 seconds
12-
enabled: async () => true,
12+
enabled: async () => IS_PROD_ENV,
1313
process: async (ctx) => {
1414
ctx.log.info('Starting integrations backup job!')
1515
const dbConnection = await getDbConnection(WRITE_DB_CONFIG(), 1, 0)
16-
await dbConnection.query(`insert into "integrationsHistory" select * from "integrations";`)
16+
await dbConnection.query(`insert into "integrationsBackup" select * from "integrations";`)
17+
await dbConnection.query(
18+
`delete from "integrationsBackup" where "backupCreatedAt" < now() - interval '2 months'`,
19+
)
1720
ctx.log.info('Integrations backup job completed!')
1821
},
1922
}

0 commit comments

Comments
 (0)