Skip to content

Commit 82b6144

Browse files
ijreillyWeiko
authored andcommitted
[fix] Update remote table sync status in cache after schema update (#5553)
Upon schema update, sync status can change from synced to non_synced in case the update regards a table that was deleted. Let's update the sync status too to avoid displaying the table as still synchronized. https://github.com/twentyhq/twenty/assets/51697796/7ff2342b-ce9f-4179-9b76-940617cf1292
1 parent 6b6989b commit 82b6144

File tree

3 files changed

+7
-2
lines changed

3 files changed

+7
-2
lines changed

packages/twenty-front/src/modules/databases/hooks/useSyncRemoteTableSchemaChanges.ts

+1
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ export const useSyncRemoteTableSchemaChanges = () => {
3535
fieldModifiers: {
3636
schemaPendingUpdates: () =>
3737
data.syncRemoteTableSchemaChanges.schemaPendingUpdates || [],
38+
status: () => data.syncRemoteTableSchemaChanges.status,
3839
},
3940
});
4041
}

packages/twenty-server/src/engine/metadata-modules/remote-server/remote-table/distant-table/distant-table.service.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ export class DistantTableService {
5050
tableName,
5151
);
5252

53-
return distantTables[tableName] || [];
53+
return distantTables[tableName];
5454
}
5555

5656
private async getDistantTablesFromDynamicSchema(

packages/twenty-server/src/engine/metadata-modules/remote-server/remote-table/remote-table.service.ts

+5-1
Original file line numberDiff line numberDiff line change
@@ -194,6 +194,10 @@ export class RemoteTableService {
194194
input.name,
195195
);
196196

197+
if (!distantTableColumns) {
198+
throw new BadRequestException('Table not found');
199+
}
200+
197201
// We only support remote tables with an id column for now.
198202
const distantTableIdColumn = distantTableColumns.find(
199203
(column) => column.columnName === 'id',
@@ -315,7 +319,7 @@ export class RemoteTableService {
315319
remoteTable.distantTableName,
316320
);
317321

318-
if (isEmpty(distantTableColumns)) {
322+
if (!distantTableColumns) {
319323
await this.unsyncOne(workspaceId, remoteTable, remoteServer);
320324

321325
return {

0 commit comments

Comments
 (0)