"""Add scripts captureoutput Backs the per-script "may a successful run send its output back" field. The agent already captures a script's full output and always writes it to the endpoint log. What this controls is narrower: whether that output also crosses to the server and is persisted in the command's resultjson, where the Run Scripts history can show it. Failures have always sent output and still do - a failed run has to be diagnosable without walking to the machine. Success is the case in question, and it is opt-in because output carries whatever the body happened to print: hostnames, share paths, an account name, a token an author echoed while debugging. Accepting that exposure for every routine green run is a poor trade, so the author decides per script, after reading the body. BOOLEAN NOT NULL defaulting FALSE, so every script row written before this migration keeps exactly today's behaviour: metadata on success, output only on failure. Same rule as errormode - never retroactive, because a library-wide flip would start persisting output from bodies nobody re-read with this question in mind. Revision ID: 7d50_script_captureoutput Revises: 7d49_script_errormode Create Date: 2026-09-09 """ from alembic import op import sqlalchemy as sa revision = '7d50_script_captureoutput' down_revision = '7d49_script_errormode' branch_labels = None depends_on = None def upgrade(): op.add_column('scripts', sa.Column( 'captureoutput', sa.Boolean(), nullable=False, server_default=sa.false(), comment='When true, a successful run also returns its output to the ' 'server; failures always do. Off by default because script ' 'output can contain whatever the body printed.')) def downgrade(): op.drop_column('scripts', 'captureoutput')