How to Change a Column Datatype Without Affecting Existing Users Postgresql
dev.to·4d·
Discuss: DEV
💿IndexedDB
Preview
Report Post

Imagine you’re building a dating app. You’ve hit a major milestone: one million users. Congratulations! But then, requirements change. In the early days, you kept things simple. To track whether a user had children, you used a single column called kids that stored a simple string, like: ‘yes- they live with me’ or ‘no.’

const updatePreferencesSchema = Joi.object({
kids: Joi.string().valid(
"Yes- they live with me",
"Yes- they don't live with me",
"no"
).optional()
});

However, as your app matures, your product team wants better data. They want to know if a user has kids or if their current kids live away from home. You need to transform that single string into a nested object:

const updatePreferencesSchema = Joi.object({
kids: Joi.object({
hasKids: Joi.boole...

Similar Posts

Loading similar posts...