Seeding Attachments, Disable ORM Logs, Seeding Parallelization (#15174)
Improvements to database seeding performance and developer experience. **Changes:** 1. **Attachment seeding**: Add sample files (PDF, XLSX, PPTX, PNG, ZIP) to dev seeds with proper file storage 2. **Seeding parallelization**: Process entities within batches in parallel while respecting dependencies 3. **ORM query logging**: Replace manual logger toggling with `ORM_QUERY_LOGGING` env var - Values: `disabled` (default), `server-only` (for local dev), `always` - Configured once in `core.datasource.ts`, removed from all seeder services **For .env:** ```bash ORM_QUERY_LOGGING=server-only ``` Net result: Faster seeding, cleaner code (-68 lines), better local dev experience.
This commit is contained in:
@@ -7,16 +7,32 @@ config({
|
||||
override: true,
|
||||
});
|
||||
|
||||
const getLoggingConfig = (): LogLevel[] => {
|
||||
if (process.env.NODE_ENV === 'development') {
|
||||
return ['query', 'error'];
|
||||
}
|
||||
const isRunningCommand = (): boolean => {
|
||||
const scriptPath = process.argv[1] || '';
|
||||
|
||||
return scriptPath.includes('/command/command.');
|
||||
};
|
||||
|
||||
const getLoggingConfig = (): LogLevel[] => {
|
||||
if (process.env.NODE_ENV === 'test') {
|
||||
return [];
|
||||
}
|
||||
const ormQueryLogging = process.env.ORM_QUERY_LOGGING || 'disabled';
|
||||
|
||||
return ['error'];
|
||||
switch (ormQueryLogging) {
|
||||
case 'disabled':
|
||||
return ['error'];
|
||||
case 'server-only':
|
||||
if (isRunningCommand()) {
|
||||
return ['error'];
|
||||
}
|
||||
|
||||
return ['query', 'error'];
|
||||
case 'always':
|
||||
return ['query', 'error'];
|
||||
default:
|
||||
return ['error'];
|
||||
}
|
||||
};
|
||||
|
||||
const isJest = process.argv.some((arg) => arg.includes('jest'));
|
||||
|
||||
Reference in New Issue
Block a user