@miniaxolotl/grove-server 1.11.23 → 1.11.24

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/migrate.js CHANGED
@@ -31,6 +31,31 @@ var dailyNotes = {
31
31
  }
32
32
  };
33
33
 
34
+ // lib/database/src/cache-retention-migration.ts
35
+ var cacheRetention = {
36
+ name: "20261118_043_cache_retention",
37
+ async up(db2) {
38
+ const { rows } = await db2.raw(
39
+ "SELECT pg_get_functiondef('grove_schedule_cleanup()'::regprocedure) AS definition"
40
+ );
41
+ const definition = rows[0].definition;
42
+ const anchor = "OR EXISTS(SELECT 1 FROM rate_buckets r";
43
+ if (definition.split(anchor).length !== 2)
44
+ throw new Error("Unsupported retention scheduler baseline");
45
+ await db2.raw(
46
+ definition.replace(
47
+ anchor,
48
+ `OR EXISTS(SELECT 1 FROM ai_cache c WHERE c.account_id=a.id AND c.expires_at<=now())
49
+ OR EXISTS(SELECT 1 FROM ai_provider_backoff b WHERE b.account_id=a.id AND b.retry_at<now()-interval '1 day')
50
+ ${anchor}`
51
+ )
52
+ );
53
+ },
54
+ async down() {
55
+ throw new Error("Use a forward migration");
56
+ }
57
+ };
58
+
34
59
  // lib/database/src/writing-allowance-migration.ts
35
60
  var writingAllowance = {
36
61
  name: "20261107_041_writing_allowance",
@@ -3727,7 +3752,8 @@ var migrations = [
3727
3752
  nativeSharing,
3728
3753
  billingTrial,
3729
3754
  writingAllowance,
3730
- dailyNotes
3755
+ dailyNotes,
3756
+ cacheRetention
3731
3757
  ];
3732
3758
  var migrationSource = {
3733
3759
  getMigrations: async () => migrations,