From 4ae01b81d89b0397db2c5c25f6239e05a36bc460 Mon Sep 17 00:00:00 2001 From: Luis Guilherme de Souza Munhoz Date: Mon, 9 Oct 2023 15:23:14 -0300 Subject: [PATCH] Fixing appointment sync --- calendar/src/models/appointment.ts | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/calendar/src/models/appointment.ts b/calendar/src/models/appointment.ts index 6ccebcf..2814868 100644 --- a/calendar/src/models/appointment.ts +++ b/calendar/src/models/appointment.ts @@ -62,7 +62,6 @@ AppointmentModel.init( underscored: true, } ); -sequelize.sync(); const updateUpdatedAtTrigger = ` CREATE OR REPLACE FUNCTION update_updated_at_column() RETURNS TRIGGER AS $$ @@ -78,8 +77,15 @@ BEFORE UPDATE ON appointments FOR EACH ROW EXECUTE FUNCTION update_updated_at_column(); `; - -sequelize.query("SET DATESTYLE TO DMY"); -sequelize.query(updateUpdatedAtTrigger); +sequelize.sync().then( + () => { + console.log("Appointment table created"); + sequelize.query("SET DATESTYLE TO DMY"); + sequelize.query(updateUpdatedAtTrigger); + }, + (err) => { + console.error("Error creating appointment table:", err); + } +); export default AppointmentModel;