Compare commits

...

1 Commits

Author SHA1 Message Date
neo773 9eb4e07053 workspace export command followup
This change removes the hard‑coded path and format for the export file. Instead, the CLI now accepts a fully qualified FS path.
2026-04-08 18:55:55 +05:30
2 changed files with 11 additions and 11 deletions
@@ -6,7 +6,7 @@ import { WorkspaceExportService } from 'src/database/commands/workspace-export/w
type WorkspaceExportCommandOptions = {
workspaceId: string;
outputPath: string;
output: string;
tables?: string;
};
@@ -31,11 +31,11 @@ export class WorkspaceExportCommand extends CommandRunner {
}
@Option({
flags: '--output-path <outputPath>',
description: 'Directory to write the .sql file',
defaultValue: '/tmp/exports',
flags: '-o, --output <output>',
description: 'Output file path for the .sql export',
required: true,
})
parseOutputPath(value: string): string {
parseOutput(value: string): string {
return value;
}
@@ -57,7 +57,7 @@ export class WorkspaceExportCommand extends CommandRunner {
try {
const filePath = await this.workspaceExportService.exportWorkspace({
workspaceId: options.workspaceId,
outputPath: options.outputPath,
output: options.output,
tableFilter,
});
@@ -1,6 +1,7 @@
import { Injectable, Logger } from '@nestjs/common';
import { InjectDataSource, InjectRepository } from '@nestjs/typeorm';
import { once } from 'events';
import { dirname } from 'path';
import { type WriteStream, createWriteStream, mkdirSync } from 'fs';
import { finished } from 'stream/promises';
@@ -28,7 +29,7 @@ const BATCH_SIZE = 5000;
type WorkspaceExportParams = {
workspaceId: string;
outputPath: string;
output: string;
tableFilter?: string[];
};
@@ -63,7 +64,7 @@ export class WorkspaceExportService {
async exportWorkspace({
workspaceId,
outputPath,
output,
tableFilter,
}: WorkspaceExportParams): Promise<string> {
const workspace = await this.dataSource
@@ -96,10 +97,9 @@ export class WorkspaceExportService {
fieldsByObjectId.set(fieldMetadata.objectMetadataId, objectFields);
}
mkdirSync(outputPath, { recursive: true });
const filePath = output;
const timestamp = new Date().toISOString().replace(/[:.]/g, '-');
const filePath = `${outputPath}/${workspaceId}-${timestamp}.sql`;
mkdirSync(dirname(filePath), { recursive: true });
const stream = createWriteStream(filePath);
const queryRunner = this.dataSource.createQueryRunner();