-- 015: Travel Rule compliance records (compliance-service)
-- FATF Travel Rule: transfers >= $3,000 require identity info
CREATE TABLE IF NOT EXISTS travel_rule_records (
    id UUID PRIMARY KEY DEFAULT gen_random_uuid(),
    sender_id UUID NOT NULL REFERENCES users(id),
    receiver_id UUID NOT NULL REFERENCES users(id),
    amount NUMERIC(15,2) NOT NULL,
    sender_address VARCHAR(42),
    receiver_address VARCHAR(42),
    sender_identity_hash VARCHAR(66),
    receiver_identity_hash VARCHAR(66),
    is_external BOOLEAN NOT NULL DEFAULT false,
    trisa_message_id VARCHAR(100),
    tx_hash VARCHAR(66),
    status VARCHAR(20) NOT NULL DEFAULT 'completed',
    created_at TIMESTAMPTZ NOT NULL DEFAULT NOW()
);

CREATE INDEX idx_travel_rule_sender ON travel_rule_records(sender_id);
CREATE INDEX idx_travel_rule_receiver ON travel_rule_records(receiver_id);
CREATE INDEX idx_travel_rule_amount ON travel_rule_records(amount);
