Skip to content

Commit

Permalink
Update TelemetryException model to use VeryLongText type for message …
Browse files Browse the repository at this point in the history
…fields and add migration for database schema changes
  • Loading branch information
simlarsen committed Nov 25, 2024
1 parent 0ad5ee5 commit d6dacb6
Show file tree
Hide file tree
Showing 3 changed files with 38 additions and 6 deletions.
12 changes: 6 additions & 6 deletions Common/Models/DatabaseModels/TelemetryException.ts
Original file line number Diff line number Diff line change
Expand Up @@ -221,14 +221,14 @@ export default class TelemetryException extends DatabaseBaseModel {
})
@TableColumn({
required: false,
type: TableColumnType.LongText,
type: TableColumnType.VeryLongText,
canReadOnRelationQuery: false,
title: "Exception Message",
description: "Exception message that was thrown by the telemetry service",
})
@Column({
nullable: true,
type: ColumnType.LongText,
type: ColumnType.VeryLongText,
})
public message?: string = undefined;

Expand All @@ -252,15 +252,15 @@ export default class TelemetryException extends DatabaseBaseModel {
})
@TableColumn({
required: false,
type: TableColumnType.LongText,
type: TableColumnType.VeryLongText,
canReadOnRelationQuery: false,
title: "Stack Trace",
description:
"Stack trace of the exception that was thrown by the telemetry service",
})
@Column({
nullable: true,
type: ColumnType.LongText,
type: ColumnType.VeryLongText,
})
public stackTrace?: string = undefined;

Expand All @@ -284,15 +284,15 @@ export default class TelemetryException extends DatabaseBaseModel {
})
@TableColumn({
required: false,
type: TableColumnType.LongText,
type: TableColumnType.VeryLongText,
canReadOnRelationQuery: false,
title: "Exception Type",
description:
"Type of the exception that was thrown by the telemetry service",
})
@Column({
nullable: true,
type: ColumnType.LongText,
type: ColumnType.VeryLongText,
})
public exceptionType?: string = undefined;

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
import { MigrationInterface, QueryRunner } from "typeorm";

export class MigrationName1732553444010 implements MigrationInterface {
public name = "MigrationName1732553444010";

public async up(queryRunner: QueryRunner): Promise<void> {
await queryRunner.query(
`ALTER TABLE "TelemetryException" ALTER COLUMN "message" TYPE text`,
);
await queryRunner.query(
`ALTER TABLE "TelemetryException" ALTER COLUMN "stackTrace" TYPE text`,
);
await queryRunner.query(
`ALTER TABLE "TelemetryException" ALTER COLUMN "exceptionType" TYPE text`,
);
}

public async down(queryRunner: QueryRunner): Promise<void> {
// revert changes made in up method - text to varchar
await queryRunner.query(
`ALTER TABLE "TelemetryException" ALTER COLUMN "message" TYPE varchar`,
);
await queryRunner.query(
`ALTER TABLE "TelemetryException" ALTER COLUMN "stackTrace" TYPE varchar`,
);
await queryRunner.query(
`ALTER TABLE "TelemetryException" ALTER COLUMN "exceptionType" TYPE varchar`,
);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,7 @@ import { MigrationName1731433043136 } from "./1731433043136-MigrationName";
import { MigrationName1731433309124 } from "./1731433309124-MigrationName";
import { MigrationName1731435267537 } from "./1731435267537-MigrationName";
import { MigrationName1731435514287 } from "./1731435514287-MigrationName";
import { MigrationName1732553444010 } from "./1732553444010-MigrationName";

export default [
InitialMigration,
Expand Down Expand Up @@ -168,4 +169,5 @@ export default [
MigrationName1731433309124,
MigrationName1731435267537,
MigrationName1731435514287,
MigrationName1732553444010,
];

0 comments on commit d6dacb6

Please sign in to comment.