fixed db export
All checks were successful
Deploy Nyla Frontend to Production / deploy (push) Successful in 45s
All checks were successful
Deploy Nyla Frontend to Production / deploy (push) Successful in 45s
This commit is contained in:
parent
5a5d24bbe2
commit
8f9d233d8c
1 changed files with 17 additions and 12 deletions
|
|
@ -888,19 +888,24 @@ const MigrationTab: React.FC = () => {
|
|||
const scope = isFullExport ? 'full' : 'partial';
|
||||
const filename = `db_backup_${instanceLabel}_${scope}_${ts}.json`;
|
||||
|
||||
const exportData = {
|
||||
meta: {
|
||||
exportedAt: new Date().toISOString(),
|
||||
version: '1.0',
|
||||
databaseCount: Object.keys(collectedDatabases).length,
|
||||
totalTables,
|
||||
totalRecords,
|
||||
},
|
||||
databases: collectedDatabases,
|
||||
};
|
||||
const meta = JSON.stringify({
|
||||
exportedAt: new Date().toISOString(),
|
||||
version: '1.0',
|
||||
databaseCount: Object.keys(collectedDatabases).length,
|
||||
totalTables,
|
||||
totalRecords,
|
||||
});
|
||||
|
||||
const content = JSON.stringify(exportData, null, 0);
|
||||
const blob = new Blob([content], { type: 'application/json' });
|
||||
const chunks: string[] = ['{"meta":', meta, ',"databases":{'];
|
||||
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 a = document.createElement('a');
|
||||
a.href = url;
|
||||
|
|
|
|||
Loading…
Reference in a new issue