OK, a small company can just notify their users, then 404 their website while they upgrade their database / code. But this is kind of ugly, and discourages regular iterations.
How do really big companies (like Facebook) do migrations, without having downtime?
The key component is the database. A method that I’ve seen involves using replication to mirror data across two servers. Once this is setup, the primary database server can be upgraded while the application servers are pointed at the secondary (replicated) server. Once the primary DB upgrade is complete, application servers can be lazily upgraded and pointed at the upgraded DB. The trick is ensuring that the app servers can deal with multiple DB schemas. To do this, you’re looking at having several clusters of servers behind some sort of load balancing appliance. It’s not cheap :).