Ankur Malik 62ed938d62
All checks were successful
Build and Push Docker Image / setup (push) Successful in 5s
Build and Push Docker Image / build_and_push (push) Successful in 45s
Add THX input IP persistence
2026-05-20 13:28:37 -04:00

1.4 KiB

Block for inserting/upserting THX attributes into the thx table

This block is responsible for inserting or updating THX-related records in the thx table using the same database configuration as db_push_v1.

Table DDL

The following DDL illustrates the thx table structure (Postgres style, conceptually compatible with DuckDB for tests):

-- creating thx table
CREATE TABLE IF NOT EXISTS thx (
    application_key TEXT PRIMARY KEY,
    application_timestamp TIMESTAMP NULL,
    digital_id_first_seen TEXT NULL,
    summary_risk_score TEXT NULL,
    cpu_clock TEXT NULL,
    true_ip_first_seen TEXT NULL,
    ssn_hash_first_seen TEXT NULL,
    account_email_attributes TEXT NULL,
    tps_ip_latitude TEXT NULL,
    tps_ip_longitude TEXT NULL,
    account_telephone_first_seen TEXT NULL,
    account_login_first_seen TEXT NULL,
    input_ip_address TEXT NULL
);

CREATE INDEX IF NOT EXISTS idx_thx_application_key ON thx(application_key);
CREATE INDEX IF NOT EXISTS idx_thx_application_timestamp ON thx(application_timestamp);
CREATE INDEX IF NOT EXISTS idx_thx_input_ip_address ON thx(input_ip_address);

For an existing table, apply the additive migration before deploying the block change:

ALTER TABLE public.thx
    ADD COLUMN IF NOT EXISTS input_ip_address TEXT NULL;

CREATE INDEX IF NOT EXISTS idx_thx_input_ip_address
    ON public.thx(input_ip_address);