Migrating from Firebase to PostgreSQL: how we do it
Why projects leave Firestore for PostgreSQL, how to design the schema, move data and users and cut over with zero downtime.
Published — 5 min read
Firestore is convenient at the start, but as a project grows you get complex reports, relations between entities and a read bill that is hard to predict. PostgreSQL fixes that: SQL queries, transactions and a predictable server price.
Steps
- Export collections and study the real document structure — it almost always differs from the plan.
- Design tables, relations and indexes for the app’s actual queries.
- Write an idempotent migration script that updates rather than duplicates.
- Move files from Firebase Storage to S3 storage.
- Reconcile record counts and spot-check content.
- Switch the app to the new database; the old one stays available for a week.
Users and login
Firebase Auth accounts move with email and phone. Firebase stores passwords in its own format, so login either keeps working via their hashes or the user signs in once with an email or SMS code.
| Data size | Time | Price |
|---|---|---|
| Up to 100k documents | 1 day | from $150 |
| Up to 1M documents | 2–3 days | from $300 |
| Larger, with files | on estimate | from $500 |