Let's say that I have a table Payment with the following columns
payment_id - UUID
amount - Numeric
order_id - Unique VARCHAR
psp_order_id - Third Party Unique Order Id created by Payment Service Provider
psp_payment_id -Third Party Unique Payment Id created by Payment Service Provider
created_at - payment created at
ended_at - payment ended at
Now there is a requirement for integrating a new PSP. But since the Payment table is tightly bound to one PSP, I would like to move psp_order_id, psp_payment_id to another table Eg: razorpay_payment_details.
So the resulting schema could be :
Payment Table
payment_id - UUID
amount - Numeric
order_id - Unique VARCHAR
created_at - payment created at
ended_at - payment ended at
razorpay_payment_details
id - UUID (Primary Key)
psp_order_id (Unique String)
psp_payment_id (Unique String)
payment_id (Foreign Key which relates Payment Entity to razorpay_payment_details entity)
How should one go about changing the schema and migrating the existing production data into the new table ?
Technologies used - Spring Boot, PostgreSQL PS: I do not manage Database Migrations using Flyway/Liquibase.