twenty icon indicating copy to clipboard operation
twenty copied to clipboard

[Remotes] Update foreign table with new schema

Open thomtrp opened this issue 1 year ago • 1 comments

What

When a table is out of sync, we should provide an update button that will re-sync the table structure

Image

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

thomtrp avatar Apr 19 '24 16:04 thomtrp

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:

  1. Create a new method updateRemoteTable in remote-table.service.ts.
  2. Use fetchDistantTableColumns from remote-postgres-table.service.ts to get the distant table structure.
  3. Fetch the foreign table structure and compare it with the distant table structure.
  4. Use the ALTER FOREIGN TABLE SQL command to update the foreign table structure.
  5. Update the metadata accordingly.
  6. Add a button in the frontend to trigger this update and call the new endpoint.

References

greptile-apps[bot] avatar May 22 '24 16:05 greptile-apps[bot]