Escaping the Oracle dorm for our own PostgreSQL
· 3 min read · Oracle · PostgreSQL · SQL
You change something in your own product and worry about breaking things for the team next door. Someone else's changes could accidentally break something for you too. We shared one Oracle database across 10 product teams.
The applications had already moved to OpenShift by then. Our team had its own environment, but the data still lived alongside everyone else’s. In 2023, it was time to move out of the shared database too. Our product became the pilot, with a dedicated PostgreSQL database as the destination.
The migration used a full snapshot of the original database. It contained data from all 10 teams. We needed to keep our product working with all its dependencies and clear out everything belonging to the others.
Product keys separated the data. A key told us who owned a record. But not every table had one, so some records had to be traced back to a product through a chain of relationships.
For example, all the schedulers lived in one table, separated by team keys. Each scheduler referenced other tables: its server type and its settings. Cleaning it up meant understanding those records as well. There were many components like that in the database.

There were two tasks: work out what belonged to our product, and establish the order for deleting the rest. I mostly used foreign keys to trace the relationships. Deletion had to proceed from the bottom up: dependent records first, then the records they referenced. Our business processes needed to keep working with all the data they required.
The database engine was changing too. Both the application scripts stored in the database and the SQL migration scripts had to be rewritten for PostgreSQL syntax.
The application scripts referenced one another, so restoring them also required the right order. It was essentially a local build: I used the logs to find a missing relationship, worked through the dependency and recorded the order in the migration scripts. On the next run, I did not have to investigate the same error again.
I debugged the cleanup script against a local database until everything unnecessary was gone and everything of ours still worked. We checked the result through the application, connecting it to the new database and running the main business scenarios. We carried out full regression and load testing.

After debugging, I applied the script to the test environments with the new database. Only then did we let user traffic through. The final cutover involved downtime. Fortunately, ours was not a high-traffic service.
Other teams could use the scripts as a starting point, but each product needed its own adaptations. The migration order and the pitfalls we had found went into a roadmap. The chains of relationships in the shared tables had already been worked through, so that part could be reused.
In the end, we moved out of the shared Oracle database into our own PostgreSQL. We stopped worrying that our changes would affect other teams, or that someone else might accidentally break something for us.