Database diagrams editor that allows you to visualize and design your DB with a single query.
TypeScript databasedbdb-migrationeditorerdmariadbmssqlmysqlpostgresqlreactreact-flowschema-migrationssqlsqlitetypescriptvisualizationxyflow
fix undo delete tables
Guy Ben-Aharon4ede0f311762
diff --git a/src/context/chartdb-context/chartdb-context.tsx b/src/context/chartdb-context/chartdb-context.tsxindex c914729f..07ccb8ed 100644--- a/src/context/chartdb-context/chartdb-context.tsx+++ b/src/context/chartdb-context/chartdb-context.tsx@@ -44,7 +44,7 @@ export interface ChartDBContext {) => Promise<void>;updateTablesState: (updateFn: (tables: DBTable[]) => PartialExcept<DBTable, 'id'>[],- options?: { updateHistory: boolean }+ options?: { updateHistory: boolean; forceOverride?: boolean }) => Promise<void>;// Field operationsdiff --git a/src/context/chartdb-context/chartdb-provider.tsx b/src/context/chartdb-context/chartdb-provider.tsxindex 9562e210..21eb20cf 100644--- a/src/context/chartdb-context/chartdb-provider.tsx+++ b/src/context/chartdb-context/chartdb-provider.tsx@@ -177,31 +177,26 @@ export const ChartDBProvider: React.FC<React.PropsWithChildren> = ({const updateTablesState: ChartDBContext['updateTablesState'] = useCallback(async (updateFn: (tables: DBTable[]) => PartialExcept<DBTable, 'id'>[],- options = { updateHistory: true }+ options = { updateHistory: true, forceOverride: false }) => {const updateTables = (prevTables: DBTable[]) => {const updatedTables = updateFn(prevTables);+ if (options.forceOverride) {+ return updatedTables as DBTable[];+ }- const newTables = updatedTables.filter(- (t) =>- !prevTables.some((prevTable) => prevTable.id === t.id)- );-- return [- ...newTables,- ...prevTables- .map((prevTable) => {- const updatedTable = updatedTables.find(- (t) => t.id === prevTable.id- );- return updatedTable- ? { ...prevTable, ...updatedTable }- : prevTable;- })- .filter((prevTable) =>- updatedTables.some((t) => t.id === prevTable.id)- ),- ];+ return prevTables+ .map((prevTable) => {+ const updatedTable = updatedTables.find(+ (t) => t.id === prevTable.id+ );+ return updatedTable+ ? { ...prevTable, ...updatedTable }+ : prevTable;+ })+ .filter((prevTable) =>+ updatedTables.some((t) => t.id === prevTable.id)+ );};const prevTables = [...tables];diff --git a/src/context/history-context/history-provider.tsx b/src/context/history-context/history-provider.tsxindex e51fc9da..8f247801 100644--- a/src/context/history-context/history-provider.tsx+++ b/src/context/history-context/history-provider.tsx@@ -51,6 +51,7 @@ export const HistoryProvider: React.FC<React.PropsWithChildren> = ({updateTablesState: ({ redoData: { tables } }) => {return updateTablesState(() => tables, {updateHistory: false,+ forceOverride: true,});},addField: ({ redoData: { tableId, field } }) => {@@ -169,6 +170,7 @@ export const HistoryProvider: React.FC<React.PropsWithChildren> = ({updateTablesState: ({ undoData: { tables } }) => {return updateTablesState(() => tables, {updateHistory: false,+ forceOverride: true,});},addIndex: ({ undoData: { tableId, indexId } }) => {