2025-11-26 12:06:54 -05:00
|
|
|
# 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):
|
|
|
|
|
|
|
|
|
|
```sql
|
|
|
|
|
-- 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,
|
2026-05-20 13:28:37 -04:00
|
|
|
account_login_first_seen TEXT NULL,
|
|
|
|
|
input_ip_address TEXT NULL
|
2025-11-26 12:06:54 -05:00
|
|
|
);
|
|
|
|
|
|
|
|
|
|
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);
|
2026-05-20 13:28:37 -04:00
|
|
|
CREATE INDEX IF NOT EXISTS idx_thx_input_ip_address ON thx(input_ip_address);
|
2025-11-26 12:06:54 -05:00
|
|
|
```
|
|
|
|
|
|
2026-05-20 13:28:37 -04:00
|
|
|
For an existing table, apply the additive migration before deploying the block change:
|
|
|
|
|
|
|
|
|
|
```sql
|
|
|
|
|
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);
|
|
|
|
|
```
|