Files
tazlin aef5f44d15 feat(kudos): partition the event tables by created and convert in place
- kudos_ledger and kudos_stat_events are range-partitioned on created with (id, created) primary keys, so retention removes whole partitions by age
- KudosPartitioning and ensure_kudos_event_partitions create upcoming partitions with the autovacuum storage parameters; init_db and the test fixtures call it after create_all
- The retention catalog, stat rollup, quarantine, ledger checkpoint, daily statement and idempotency key models and their enums are declared alongside the event tables, so one migration and the ORM build the same schema
- kudos_db gains a session-level retention advisory lock taken on a dedicated autocommit connection
- sql_statements/5.1.16.txt creates the retention tables, backfills idempotency keys inside the online window and converts the existing tables in place by attaching each as a legacy partition behind a validated range CHECK
- tests/integration/test_kudos_retention_migration.py checks the conversion, reruns, refusal guards and ORM parity with the migration
2026-11-03 12:29:05 -05:00

1.5 KiB

AI-Horde Database Information

  • postgresql >=15
  • pg_cron
  • 5.1.16.txt requires the psql client, because it uses \gexec. Apply it in one session with -v ON_ERROR_STOP=1 and without --single-transaction, as described in Kudos ledger operations.

pg_cron config

Warning

: All .sql files found in a directory deeper than sql_statements/ will be dynamically run, not only the ones specifically identified in this document. Only place .sql files you intend to run in these directories. This does not apply to the sql_statements level (i.e., sql_statements/4.35.1.sql is not automatically run, but sql_statements/cron/your_new_file.sql will be.)

  • cron/
    • schedule_cron_job.sql
      • Creates a stored procedure which schedules a new pg_cron job to execute a specified stored procedure at intervals defined by a cron schedule string, if a job with the same command doesn't already exist.
      • e.g., CALL schedule_cron_job('0-59 * * * *', 'compile_imagegen_stats_totals');
  • stored_procedures
    • compile_*gen_stats_*.sql
      • These files defined stored procedures which populated the compiled_* tables and generally represent minute/hour/day/total statistics about generations.
    • cron_jobs/
      • Schedules any stats compile jobs via schedule_cron_job.