From what I understand it goes to your discard pile and the card that was upgraded goes to either the starbase discard or, if it was a starter card like an ensign or lieutenant, it goes to the starbase stack for each starter. thats how I have been playing. I hope I'm doing it right. haha
This is correct. Also, if it is an actual "starter" card that says starter on it (i.e. - Tricorder, Evasive Maneuvers, etc) it is removed from the game instead. It's covered on pages 17 (for trashing) and 24 (upgrading) in the rulebook.
Upgrade = "trash the designated card" and "gain a card from starbase." when you gain a card it goes to your discard pile unless otherwise indicated.