Skip to content

Commit

Permalink
Adjust invariants based on purge job
Browse files Browse the repository at this point in the history
  • Loading branch information
mbryzek committed Jun 6, 2024
1 parent 77c7dd9 commit 506d47d
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions api/app/invariants/PurgeInvariants.scala
Original file line number Diff line number Diff line change
Expand Up @@ -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'"
)
)
}
Expand Down

0 comments on commit 506d47d

Please sign in to comment.