Skip to content

Commit

Permalink
uncomment logic (#792)
Browse files Browse the repository at this point in the history
  • Loading branch information
bryzettler authored Jan 30, 2025
1 parent cdbf530 commit 80799e0
Showing 1 changed file with 22 additions and 23 deletions.
45 changes: 22 additions & 23 deletions packages/account-postgres-sink-service/src/utils/defineIdlModels.ts
Original file line number Diff line number Diff line change
Expand Up @@ -98,29 +98,28 @@ export const defineIdlModels = async ({
}
);

// const columns = Object.keys(model.getAttributes()).map((att) =>
// camelize(att, true)
// );

// const existingColumns = (
// await sequelize.query(
// `
// SELECT column_name
// FROM information_schema.columns
// WHERE table_schema = '${underscore(accConfig.schema || "public")}'
// AND table_name = '${underscore(accConfig.table || acc.name)}'
// `,
// { type: QueryTypes.SELECT }
// )
// ).map((x: any) => camelize(x.column_name, true));

// if (
// !existingColumns.length ||
// !columns.every((col) => existingColumns.includes(col))
// ) {
// model.sync({ alter: true });
// }
model.sync({ alter: true });
const columns = Object.keys(model.getAttributes()).map((att) =>
camelize(att, true)
);

const existingColumns = (
await sequelize.query(
`
SELECT column_name
FROM information_schema.columns
WHERE table_schema = '${underscore(accConfig.schema || "public")}'
AND table_name = '${underscore(accConfig.table || acc.name)}'
`,
{ type: QueryTypes.SELECT }
)
).map((x: any) => camelize(x.column_name, true));

if (
!existingColumns.length ||
!columns.every((col) => existingColumns.includes(col))
) {
model.sync({ alter: true });
}
}
}
};
Expand Down

0 comments on commit 80799e0

Please sign in to comment.