From 506d47d75f504421886f67d68149fe8b48bc7668 Mon Sep 17 00:00:00 2001 From: Michael Bryzek Date: Thu, 6 Jun 2024 16:16:55 -0400 Subject: [PATCH] Adjust invariants based on purge job --- api/app/invariants/PurgeInvariants.scala | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/api/app/invariants/PurgeInvariants.scala b/api/app/invariants/PurgeInvariants.scala index a297d6efe..19f555a69 100644 --- a/api/app/invariants/PurgeInvariants.scala +++ b/api/app/invariants/PurgeInvariants.scala @@ -3,15 +3,18 @@ package invariants import io.flow.postgresql.Query object PurgeInvariants { + private[this] case class PurgeTable(name: String, retentionMonths: Int) private[this] val Tables = Seq( - "organizations", "applications", "versions" + PurgeTable("organizations", 12), + PurgeTable("applications", 6), + PurgeTable("versions", 6) ) val all: Seq[Invariant] = Tables.map { t => Invariant( - s"old_deleted_records_purged_from_$t", + s"old_deleted_records_purged_from_${t.name}", Query( - s"select count(*) from $t where deleted_at < now() - interval '1 year'" + s"select count(*) from ${t.name} where deleted_at < now() - interval '${t.retentionMonths + 1} months'" ) ) }