main #1
1 changed files with 17 additions and 12 deletions
|
|
@ -888,19 +888,24 @@ const MigrationTab: React.FC = () => {
|
||||||
const scope = isFullExport ? 'full' : 'partial';
|
const scope = isFullExport ? 'full' : 'partial';
|
||||||
const filename = `db_backup_${instanceLabel}_${scope}_${ts}.json`;
|
const filename = `db_backup_${instanceLabel}_${scope}_${ts}.json`;
|
||||||
|
|
||||||
const exportData = {
|
const meta = JSON.stringify({
|
||||||
meta: {
|
|
||||||
exportedAt: new Date().toISOString(),
|
exportedAt: new Date().toISOString(),
|
||||||
version: '1.0',
|
version: '1.0',
|
||||||
databaseCount: Object.keys(collectedDatabases).length,
|
databaseCount: Object.keys(collectedDatabases).length,
|
||||||
totalTables,
|
totalTables,
|
||||||
totalRecords,
|
totalRecords,
|
||||||
},
|
});
|
||||||
databases: collectedDatabases,
|
|
||||||
};
|
|
||||||
|
|
||||||
const content = JSON.stringify(exportData, null, 0);
|
const chunks: string[] = ['{"meta":', meta, ',"databases":{'];
|
||||||
const blob = new Blob([content], { type: 'application/json' });
|
const dbEntries = Object.entries(collectedDatabases);
|
||||||
|
for (let i = 0; i < dbEntries.length; i++) {
|
||||||
|
const [dbName, dbData] = dbEntries[i];
|
||||||
|
if (i > 0) chunks.push(',');
|
||||||
|
chunks.push(JSON.stringify(dbName), ':', JSON.stringify(dbData));
|
||||||
|
}
|
||||||
|
chunks.push('}}');
|
||||||
|
|
||||||
|
const blob = new Blob(chunks, { type: 'application/json' });
|
||||||
const url = URL.createObjectURL(blob);
|
const url = URL.createObjectURL(blob);
|
||||||
const a = document.createElement('a');
|
const a = document.createElement('a');
|
||||||
a.href = url;
|
a.href = url;
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue