DROP INDEX IF EXISTS idx_swap_events_token1_price;
DROP INDEX IF EXISTS idx_swap_events_token0_price;
DROP INDEX IF EXISTS idx_swap_events_chain_tx_log;
CREATE UNIQUE INDEX IF NOT EXISTS idx_swap_events_unique_log
  ON swap_events (
    chain_id,
    pool_address,
    COALESCE(transaction_hash, ''),
    COALESCE(log_index, -1)
  );

ALTER TABLE IF EXISTS swap_events
  DROP COLUMN IF EXISTS to_address,
  DROP COLUMN IF EXISTS sender,
  DROP COLUMN IF EXISTS token1_price_usd,
  DROP COLUMN IF EXISTS token0_price_usd,
  DROP COLUMN IF EXISTS price_usd,
  DROP COLUMN IF EXISTS amount1_out,
  DROP COLUMN IF EXISTS amount0_out,
  DROP COLUMN IF EXISTS amount1_in,
  DROP COLUMN IF EXISTS amount0_in;
