twenty
twenty copied to clipboard
[Remotes] Update foreign table with new schema
What
When a table is out of sync, we should provide an update button that will re-sync the table structure
How
- create a new endpoint
updateRemoteTable - fetch distant table structure
- fetch foreign table structure and compare
- alter foreign table https://www.postgresql.org/docs/current/sql-alterforeigntable.html
- update metadata
- add button and call to frontend
Disclaimer: This comment was automatically generated with AI. It can give some useful hints as to where to look for, but sometimes it can also give very inaccurate answers so takes this with a pinch of salt :).
To implement the updateRemoteTable endpoint:
- Create a new method
updateRemoteTableinremote-table.service.ts. - Use
fetchDistantTableColumnsfromremote-postgres-table.service.tsto get the distant table structure. - Fetch the foreign table structure and compare it with the distant table structure.
- Use the
ALTER FOREIGN TABLESQL command to update the foreign table structure. - Update the metadata accordingly.
- Add a button in the frontend to trigger this update and call the new endpoint.