-- 045_microdao_stats.sql
-- Migration: Add statistics columns to microdaos table

ALTER TABLE microdaos
    ADD COLUMN IF NOT EXISTS citizens_count INTEGER NOT NULL DEFAULT 0,
    ADD COLUMN IF NOT EXISTS rooms_count     INTEGER NOT NULL DEFAULT 0,
    ADD COLUMN IF NOT EXISTS agents_count    INTEGER NOT NULL DEFAULT 0,
    ADD COLUMN IF NOT EXISTS last_update_at  TIMESTAMPTZ;

COMMENT ON COLUMN microdaos.citizens_count IS 'Cached count of citizens (public agents) linked to this MicroDAO';
COMMENT ON COLUMN microdaos.rooms_count IS 'Cached count of rooms belonging to this MicroDAO';
COMMENT ON COLUMN microdaos.agents_count IS 'Cached count of agents (all) linked to this MicroDAO';
COMMENT ON COLUMN microdaos.last_update_at IS 'Last time statistics were updated';

