I am using typeorm
as orm library in typescript to integrate with PostgreSQL database. I have a table in the db and created a class in typeorm
to map to that table like:
@Entity('contacts')
export class Contact extends Record {
@PrimaryColumn()
id!: string;
@Column()
firstName?: string;
@Column()
lastName?: string;
And I have a requirement to add a new column on the table. But if I add that column, the code will throw error complaining the table schema doesn’t match. So I have to do a code change and deploy the change along with the table column change. They are two different changes and I don’t think they can be done exactly the same time. There will be a gap (a few seconds at least) that the table has the new column but the code doesn’t have it.
My question is what the best way to handle that situation. My application is running 24/7 and it needs to response to customers every second. I can’t give some downtime because of this.