mirror of
https://github.com/OneUptime/oneuptime.git
synced 2026-01-11 19:56:44 +00:00
feat: add declaredAt field to Incident model with migration and default value
This commit is contained in:
parent
66efe2d2fa
commit
ac66cee4aa
4 changed files with 26 additions and 3 deletions
|
|
@ -250,15 +250,16 @@ export default class Incident extends BaseModel {
|
|||
})
|
||||
@Index()
|
||||
@TableColumn({
|
||||
required: false,
|
||||
required: true,
|
||||
type: TableColumnType.Date,
|
||||
title: "Declared At",
|
||||
description: "Date and time when this incident was declared.",
|
||||
isDefaultValueColumn: false,
|
||||
isDefaultValueColumn: true,
|
||||
})
|
||||
@Column({
|
||||
type: ColumnType.Date,
|
||||
nullable: true,
|
||||
nullable: false,
|
||||
default: () => "now()",
|
||||
})
|
||||
public declaredAt?: Date = undefined;
|
||||
|
||||
|
|
|
|||
|
|
@ -0,0 +1,19 @@
|
|||
import { MigrationInterface, QueryRunner } from "typeorm";
|
||||
|
||||
export class MigrationName1764324618043 implements MigrationInterface {
|
||||
public name = 'MigrationName1764324618043'
|
||||
|
||||
public async up(queryRunner: QueryRunner): Promise<void> {
|
||||
await queryRunner.query(`ALTER TABLE "Incident" ADD "declaredAt" TIMESTAMP WITH TIME ZONE`);
|
||||
await queryRunner.query(`UPDATE "Incident" SET "declaredAt" = "createdAt" WHERE "declaredAt" IS NULL`);
|
||||
await queryRunner.query(`ALTER TABLE "Incident" ALTER COLUMN "declaredAt" SET DEFAULT now()`);
|
||||
await queryRunner.query(`ALTER TABLE "Incident" ALTER COLUMN "declaredAt" SET NOT NULL`);
|
||||
await queryRunner.query(`CREATE INDEX "IDX_b26979b9f119310661734465a4" ON "Incident" ("declaredAt") `);
|
||||
}
|
||||
|
||||
public async down(queryRunner: QueryRunner): Promise<void> {
|
||||
await queryRunner.query(`DROP INDEX "public"."IDX_b26979b9f119310661734465a4"`);
|
||||
await queryRunner.query(`ALTER TABLE "Incident" DROP COLUMN "declaredAt"`);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -186,6 +186,7 @@ import { MigrationName1763471659817 } from "./1763471659817-MigrationName";
|
|||
import { MigrationName1763477560906 } from "./1763477560906-MigrationName";
|
||||
import { MigrationName1763480947474 } from "./1763480947474-MigrationName";
|
||||
import { MigrationName1763643080445 } from "./1763643080445-MigrationName";
|
||||
import { MigrationName1764324618043 } from "./1764324618043-MigrationName";
|
||||
|
||||
export default [
|
||||
InitialMigration,
|
||||
|
|
@ -376,4 +377,5 @@ export default [
|
|||
MigrationName1763477560906,
|
||||
MigrationName1763480947474,
|
||||
MigrationName1763643080445,
|
||||
MigrationName1764324618043
|
||||
];
|
||||
|
|
|
|||
1
vscode-copilot-chat
Submodule
1
vscode-copilot-chat
Submodule
|
|
@ -0,0 +1 @@
|
|||
Subproject commit 17b20ceffad14beca81f3c06c1e267d58aa0ffc5
|
||||
Loading…
Add table
Reference in a new issue