-- Per-tenant license row (one server = one tenant)
CREATE TABLE license (
    tenant_id         TEXT PRIMARY KEY,
    token             TEXT NOT NULL,
    license_id        UUID NOT NULL,
    installed_at      TIMESTAMPTZ NOT NULL,
    installed_by      TEXT NOT NULL,
    expires_at        TIMESTAMPTZ NOT NULL,
    last_validated_at TIMESTAMPTZ NOT NULL
);

-- Per-env retention; defaults to default-tier values (1 day) so a fresh
-- server lands inside the cap without operator intervention.
ALTER TABLE environments
    ADD COLUMN execution_retention_days INTEGER NOT NULL DEFAULT 1,
    ADD COLUMN log_retention_days       INTEGER NOT NULL DEFAULT 1,
    ADD COLUMN metric_retention_days    INTEGER NOT NULL DEFAULT 1;
