-- CCIP messages table

CREATE TABLE IF NOT EXISTS ccip_messages (
    message_id VARCHAR(255) PRIMARY KEY,
    source_chain_id INTEGER NOT NULL,
    dest_chain_id INTEGER NOT NULL,
    source_tx_hash VARCHAR(66),
    dest_tx_hash VARCHAR(66),
    status VARCHAR(20) NOT NULL CHECK (status IN ('pending', 'delivered', 'failed')),
    created_at TIMESTAMP DEFAULT NOW(),
    delivered_at TIMESTAMP
);

CREATE INDEX idx_ccip_source_chain ON ccip_messages(source_chain_id);
CREATE INDEX idx_ccip_dest_chain ON ccip_messages(dest_chain_id);
CREATE INDEX idx_ccip_status ON ccip_messages(status);
CREATE INDEX idx_ccip_source_tx ON ccip_messages(source_tx_hash);
CREATE INDEX idx_ccip_dest_tx ON ccip_messages(dest_tx_hash);

