forked from ytgov/safety
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
5fd6ef8
commit 5bb3d63
Showing
63 changed files
with
1,424 additions
and
388 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
import * as knex from "knex"; | ||
|
||
export async function up(knex: knex.Knex) { | ||
await knex.schema.createTable("urgencies", function (table) { | ||
table.string("code", 8).primary().notNullable(); | ||
table.string("name", 256).notNullable(); | ||
table.string("description", 4000).nullable(); | ||
}); | ||
} | ||
|
||
export async function down(knex: knex.Knex) { | ||
await knex.schema.dropTable("urgencies"); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,28 +1,31 @@ | ||
import * as knex from "knex"; | ||
|
||
export async function up(knex: knex.Knex) { | ||
await knex.schema.createTable("incidents", function(table) { | ||
table.increments("id").primary().notNullable(); | ||
table.integer("proxy_role_type_id").nullable(); | ||
table.integer("incident_type_id").notNullable(); | ||
table.string("sensitivity_code", 8).notNullable(); | ||
table.string("status_code", 8).notNullable(); | ||
table.string("department_code", 8).notNullable(); | ||
table.string("reporting_person_email", 250).nullable(); | ||
table.string("supervisor_email", 250).nullable(); | ||
table.integer("proxy_user_id").nullable(); | ||
table.string("description", 4000).notNullable(); | ||
table.datetime("created_at").notNullable().defaultTo(knex.fn.now()); | ||
await knex.schema.createTable("incidents", function (table) { | ||
table.increments("id").primary().notNullable(); | ||
table.integer("proxy_role_type_id").nullable(); | ||
table.integer("incident_type_id").notNullable(); | ||
table.string("sensitivity_code", 8).notNullable(); | ||
table.string("status_code", 8).notNullable(); | ||
table.string("department_code", 8).notNullable(); | ||
table.string("reporting_person_email", 250).nullable(); | ||
table.string("supervisor_email", 250).nullable(); | ||
table.integer("proxy_user_id").nullable(); | ||
table.string("description", 4000).notNullable(); | ||
table.datetime("created_at").notNullable().defaultTo(knex.fn.now()); | ||
table.datetime("reported_at").nullable(); | ||
table.string("urgency_code").notNullable(); | ||
|
||
table.foreign("sensitivity_code").references("sensitivities.code"); | ||
table.foreign("status_code").references("incident_statuses.code"); | ||
table.foreign("department_code").references("departments.code"); | ||
table.foreign("incident_type_id").references("incident_types.id"); | ||
table.foreign("proxy_user_id").references("users.id"); | ||
table.foreign("proxy_role_type_id").references("role_types.id"); | ||
}); | ||
}; | ||
table.foreign("sensitivity_code").references("sensitivities.code"); | ||
table.foreign("status_code").references("incident_statuses.code"); | ||
table.foreign("department_code").references("departments.code"); | ||
table.foreign("incident_type_id").references("incident_types.id"); | ||
table.foreign("proxy_user_id").references("users.id"); | ||
table.foreign("proxy_role_type_id").references("role_types.id"); | ||
table.foreign("urgency_code").references("urgencies.code"); | ||
}); | ||
} | ||
|
||
export async function down(knex: knex.Knex) { | ||
await knex.schema.dropTable("incidents"); | ||
}; | ||
await knex.schema.dropTable("incidents"); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,28 +1,31 @@ | ||
import * as knex from "knex"; | ||
|
||
export async function up(knex: knex.Knex) { | ||
await knex.schema.createTable("hazards", function(table) { | ||
table.increments("id").primary().notNullable(); | ||
table.integer("hazard_type_id").notNullable(); | ||
table.string("location_code", 8).nullable(); | ||
table.string("department_code", 8).nullable(); | ||
table.string("scope_code", 8).nullable(); | ||
table.string("status_code", 8).nullable(); | ||
table.string("sensitivity_code", 8).nullable(); | ||
table.string("description", 4000).nullable(); | ||
table.string("location_detail", 1000).nullable(); | ||
table.datetime("created_at").nullable().defaultTo(knex.fn.now()); | ||
table.integer("reopen_count").notNullable().defaultTo(0); | ||
await knex.schema.createTable("hazards", function (table) { | ||
table.increments("id").primary().notNullable(); | ||
table.integer("hazard_type_id").notNullable(); | ||
table.string("location_code", 8).nullable(); | ||
table.string("department_code", 8).nullable(); | ||
table.string("scope_code", 8).nullable(); | ||
table.string("status_code", 8).nullable(); | ||
table.string("sensitivity_code", 8).nullable(); | ||
table.string("description", 4000).nullable(); | ||
table.string("location_detail", 1000).nullable(); | ||
table.datetime("created_at").nullable().defaultTo(knex.fn.now()); | ||
table.datetime("reported_at").nullable() | ||
table.integer("reopen_count").notNullable().defaultTo(0); | ||
table.string("urgency_code").notNullable(); | ||
|
||
table.foreign("hazard_type_id").references("hazard_types.id"); | ||
table.foreign("location_code").references("locations.code"); | ||
table.foreign("department_code").references("departments.code"); | ||
table.foreign("scope_code").references("scopes.code"); | ||
table.foreign("sensitivity_code").references("sensitivities.code"); | ||
table.foreign("status_code").references("hazard_statuses.code"); | ||
}); | ||
}; | ||
table.foreign("hazard_type_id").references("hazard_types.id"); | ||
table.foreign("location_code").references("locations.code"); | ||
table.foreign("department_code").references("departments.code"); | ||
table.foreign("scope_code").references("scopes.code"); | ||
table.foreign("sensitivity_code").references("sensitivities.code"); | ||
table.foreign("status_code").references("hazard_statuses.code"); | ||
table.foreign("urgency_code").references("urgencies.code"); | ||
}); | ||
} | ||
|
||
export async function down(knex: knex.Knex) { | ||
await knex.schema.dropTable("hazards"); | ||
}; | ||
await knex.schema.dropTable("hazards"); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,35 +1,36 @@ | ||
import * as knex from "knex"; | ||
|
||
export async function up(knex: knex.Knex) { | ||
await knex.schema.createTable("actions", function(table) { | ||
table.increments("id").primary().notNullable(); | ||
table.integer("hazard_id").nullable(); | ||
table.integer("incident_id").nullable(); | ||
table.integer("creator_user_id").nullable(); | ||
table.integer("creator_role_type_id").nullable(); | ||
table.integer("actor_user_id").nullable(); | ||
table.integer("actor_user_email").nullable(); | ||
table.integer("actor_role_type_id").nullable(); | ||
table.datetime("created_at").notNullable().defaultTo(knex.fn.now()); | ||
table.datetime("modified_at").nullable().defaultTo(knex.fn.now()); | ||
table.datetime("due_date").nullable(); | ||
table.string("description", 4000).notNullable(); | ||
table.string("action_type_code", 8).notNullable(); | ||
table.string("sensitivity_code", 8).nullable(); | ||
table.string("status_code", 8).nullable(); | ||
await knex.schema.createTable("actions", function (table) { | ||
table.increments("id").primary().notNullable(); | ||
table.integer("hazard_id").nullable(); | ||
table.integer("incident_id").nullable(); | ||
table.integer("creator_user_id").nullable(); | ||
table.integer("creator_role_type_id").nullable(); | ||
table.integer("actor_user_id").nullable(); | ||
table.string("actor_user_email", 250).nullable(); | ||
table.integer("actor_role_type_id").nullable(); | ||
table.datetime("created_at").notNullable().defaultTo(knex.fn.now()); | ||
table.datetime("modified_at").nullable().defaultTo(knex.fn.now()); | ||
table.datetime("due_date").nullable(); | ||
table.string("description", 4000).notNullable(); | ||
table.string("action_type_code", 8).notNullable(); | ||
table.string("sensitivity_code", 8).nullable(); | ||
table.string("status_code", 8).nullable(); | ||
table.string("notes", 4000).nullable(); | ||
|
||
table.foreign("hazard_id").references("hazards.id"); | ||
table.foreign("incident_id").references("incidents.id"); | ||
table.foreign("creator_user_id").references("users.id"); | ||
table.foreign("actor_user_id").references("users.id"); | ||
table.foreign("creator_role_type_id").references("role_types.id"); | ||
table.foreign("actor_role_type_id").references("role_types.id"); | ||
table.foreign("action_type_code").references("action_types.code"); | ||
table.foreign("sensitivity_code").references("sensitivities.code"); | ||
table.foreign("status_code").references("action_statuses.code"); | ||
}); | ||
}; | ||
table.foreign("hazard_id").references("hazards.id"); | ||
table.foreign("incident_id").references("incidents.id"); | ||
table.foreign("creator_user_id").references("users.id"); | ||
table.foreign("actor_user_id").references("users.id"); | ||
table.foreign("creator_role_type_id").references("role_types.id"); | ||
table.foreign("actor_role_type_id").references("role_types.id"); | ||
table.foreign("action_type_code").references("action_types.code"); | ||
table.foreign("sensitivity_code").references("sensitivities.code"); | ||
table.foreign("status_code").references("action_statuses.code"); | ||
}); | ||
} | ||
|
||
export async function down(knex: knex.Knex) { | ||
await knex.schema.dropTable("actions"); | ||
}; | ||
await knex.schema.dropTable("actions"); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,15 +1,18 @@ | ||
export interface Action { | ||
id: number; | ||
hazard_id: number; | ||
id?: number; | ||
hazard_id?: number; | ||
incident_id?: number; | ||
creator_user_id?: number; | ||
creator_role_type_id?: number; | ||
actor_user_id?: number; | ||
actor_user_email?: string; | ||
actor_role_type_id?: number; | ||
created_at: Date; | ||
modified_at?: Date; | ||
due_date?: Date ; | ||
due_date?: Date; | ||
description: string; | ||
action_type_code: string; | ||
sensitivity_code?: string; | ||
status_code?: string; | ||
notes?: string; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,13 +1,16 @@ | ||
import { Knex } from "knex"; | ||
|
||
export interface Hazard { | ||
id: number; | ||
id?: number; | ||
hazard_type_id: number; | ||
description?: string; | ||
location_code?: string; | ||
location_detail?: string; | ||
department_code?: string; | ||
scope_code?: string; | ||
sensitivity_code?: string; | ||
created_at: Date; | ||
status_code?: string; | ||
sensitivity_code?: string; | ||
description?: string; | ||
location_detail?: string; | ||
created_at: Date | Knex.Raw<any>; | ||
reopen_count: number; | ||
urgency_code: string; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,16 @@ | ||
import { Urgencies } from "./urgency-model"; | ||
|
||
export interface HazardType { | ||
id: number; | ||
create_user_id: number; | ||
searchable_user_id?: number; | ||
id?: number; | ||
name: string; | ||
description?: string; | ||
is_searchable: boolean; | ||
created_at?: Date; | ||
searchable_on?: Date; | ||
default_urgency_code?: string; | ||
} | ||
|
||
// This list matches the migration - changes should be made in both or | ||
export class HazardTypes { | ||
static ENVIRONMENTAL = { name: "Environ", default_urgency_code: Urgencies.MEDIUM.code } as HazardType; | ||
static PHYSICAL = { name: "Phys", default_urgency_code: Urgencies.HIGH.code } as HazardType; | ||
static PERSONAL = { name: "Pers", default_urgency_code: Urgencies.HIGH.code } as HazardType; | ||
static JOB = { name: "Job", default_urgency_code: Urgencies.LOW.code } as HazardType; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,13 @@ | ||
import { Hazard } from "./hazard-model"; | ||
import { Incident } from "./incident-model"; | ||
|
||
export interface IncidentHazard { | ||
id: number; | ||
incident_id: number; | ||
hazard_id: number; | ||
incident_hazard_type_code: string; | ||
priority_order: number; | ||
|
||
incident?: Incident; | ||
hazard?: Hazard; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.