The upgraded card goes to the trash pile if it is a starbase card, and to the appropriate stack of basic character cards if it is a basic character (ensign, lieutenant, commander). If it is one of the starter cards, they are set aside until the game is over.
The newly upgraded to card goes into your discard pile.
And remember Mr. Albright, the trash pile will be shuffled and turn to a new stardeck pile when that ends. It means the same character card can eventually return to the game!