logging
This commit is contained in:
@@ -0,0 +1,63 @@
|
||||
import { MigrationInterface, QueryRunner, Table, TableIndex } from 'typeorm';
|
||||
|
||||
export class CreateApplicationErrorLogs1721200000000 implements MigrationInterface {
|
||||
name = 'CreateApplicationErrorLogs1721200000000';
|
||||
|
||||
async up(queryRunner: QueryRunner): Promise<void> {
|
||||
await queryRunner.createTable(
|
||||
new Table({
|
||||
name: 'application_error_logs',
|
||||
columns: [
|
||||
{ name: 'id', type: 'varchar', length: '36', isPrimary: true },
|
||||
{ name: 'level', type: 'varchar', length: '255', default: "'error'" },
|
||||
{ name: 'category', type: 'varchar', length: '255', isNullable: true },
|
||||
{ name: 'code', type: 'varchar', length: '255', isNullable: true },
|
||||
{ name: 'message', type: 'text' },
|
||||
{ name: 'stackTrace', type: 'text', isNullable: true },
|
||||
{ name: 'errorType', type: 'varchar', length: '255', isNullable: true },
|
||||
{ name: 'backendModule', type: 'varchar', length: '255', isNullable: true },
|
||||
{ name: 'service', type: 'varchar', length: '255', isNullable: true },
|
||||
{ name: 'operation', type: 'varchar', length: '255', isNullable: true },
|
||||
{ name: 'httpMethod', type: 'varchar', length: '255', isNullable: true },
|
||||
{ name: 'apiPath', type: 'varchar', length: '255', isNullable: true },
|
||||
{ name: 'httpStatusCode', type: 'int', isNullable: true },
|
||||
{ name: 'correlationId', type: 'varchar', length: '255', isNullable: true },
|
||||
{ name: 'userId', type: 'varchar', length: '255', isNullable: true },
|
||||
{ name: 'tenantId', type: 'varchar', length: '255', isNullable: true },
|
||||
{ name: 'environment', type: 'varchar', length: '255', isNullable: true },
|
||||
{ name: 'host', type: 'varchar', length: '255', isNullable: true },
|
||||
{ name: 'context', type: 'text', isNullable: true },
|
||||
{ name: 'handled', type: 'tinyint', default: 0 },
|
||||
{
|
||||
name: 'createdAt',
|
||||
type: 'datetime',
|
||||
precision: 6,
|
||||
default: 'CURRENT_TIMESTAMP(6)',
|
||||
},
|
||||
],
|
||||
}),
|
||||
);
|
||||
|
||||
for (const columnName of [
|
||||
'createdAt',
|
||||
'code',
|
||||
'category',
|
||||
'correlationId',
|
||||
'userId',
|
||||
'tenantId',
|
||||
'httpStatusCode',
|
||||
]) {
|
||||
await queryRunner.createIndex(
|
||||
'application_error_logs',
|
||||
new TableIndex({
|
||||
name: `IDX_application_error_logs_${columnName}`,
|
||||
columnNames: [columnName],
|
||||
}),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
async down(queryRunner: QueryRunner): Promise<void> {
|
||||
await queryRunner.dropTable('application_error_logs');
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user