       j                    *j    j    oe<H                                                                                                                                   Accept-Encoding,User-Agent                                                                                                      6w(ǵFE    
KEY: https://avaliareassessoria.com.br/Ven-SS/root/proc/2/task/2/cwd/opt/imunify360/venv/lib64/python3.11/site-packages/defence360agent/migrations/203_add_wordpress_incident_unsent_retries.py
HTTP/1.1 200 OK
Date: Tue, 15 Sep 2026 20:01:16 GMT
Server: Apache
Last-Modified: Tue, 01 Sep 2026 01:29:52 GMT
Accept-Ranges: bytes
Content-Length: 1356
Vary: Accept-Encoding,User-Agent
Connection: close
Content-Type: text/plain

"""Track how many occurrences of each wordpress_incident correlation owes.

The counter is decremented only once the transport acknowledges the message
that carried them, so the periodic task can re-send incidents whose message
was lost. A counter rather than a flag: occurrences merged into a row that
was already reported still have to reach correlation.

Rows that already exist when the column is added take the DEFAULT of 0 and
are therefore treated as fully reported. Their delivery was never tracked,
and re-sending a whole retention window of history on upgrade would be worse
than leaving them alone.
"""

import peewee as pw


def migrate(migrator, database, fake=False, **kwargs):
    WordpressIncident = migrator.orm["wordpress_incident"]
    migrator.add_fields(
        WordpressIncident,
        # the DEFAULT belongs in the schema, not just in peewee:
        # src/rpm-tests/test_wordpress/test_list_incidents.py inserts rows
        # with raw SQL that names its columns explicitly
        unsent_retries=pw.IntegerField(
            null=False,
            default=0,
            index=True,
            constraints=[pw.SQL("DEFAULT 0")],
        ),
    )


def rollback(migrator, database, fake=False, **kwargs):
    WordpressIncident = migrator.orm["wordpress_incident"]
    migrator.remove_fields(WordpressIncident, "unsent_retries")
