Skip to content

Commit

Permalink
Merge pull request #9 from icefoganalytics/main
Browse files Browse the repository at this point in the history
7/2
  • Loading branch information
datajohnson authored Jul 2, 2024
2 parents 654eb87 + eab42be commit 626284d
Show file tree
Hide file tree
Showing 77 changed files with 6,754 additions and 1,475 deletions.
1 change: 1 addition & 0 deletions api/@types/express/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ namespace Express {
store?: any;
oidc?: any;
auth?: any;
files: any | any[];

isAuthenticated(): boolean;
}
Expand Down
2 changes: 1 addition & 1 deletion api/src/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ export const DB_CONFIG_DEV = {
},
};

export const MAIL_FROM = process.env.MAIL_FROM || "PMAPService@yukon.ca";
export const MAIL_FROM = process.env.MAIL_FROM || "SafetyPortal@yukon.ca";
export const MAIL_HOST = process.env.MAIL_HOST || "smtp.gov.yk.ca";
export const MAIL_PORT = process.env.MAIL_PORT || 25;
export const MAIL_USER = process.env.MAIL_USER || "";
Expand Down
13 changes: 13 additions & 0 deletions api/src/data/migrations/013.1.create-urgencies.ts
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");
}
9 changes: 2 additions & 7 deletions api/src/data/migrations/013.create-hazard-types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,16 +3,11 @@ import * as knex from "knex";
export async function up(knex: knex.Knex) {
await knex.schema.createTable("hazard_types", function (table) {
table.increments("id").primary().notNullable();
table.integer("create_user_id").notNullable();
table.integer("searchable_user_id").nullable();
table.string("name", 256).notNullable();
table.string("description", 4000).nullable();
table.boolean("is_searchable").notNullable().defaultTo(true);
table.datetime("created_at").nullable().defaultTo(knex.fn.now());
table.date("searchable_on").nullable();
table.string("default_urgency_code").nullable();

table.foreign("create_user_id").references("users.id");
table.foreign("searchable_user_id").references("users.id");
table.foreign("default_urgency_code").references("urgencies.code");
});
}

Expand Down
47 changes: 25 additions & 22 deletions api/src/data/migrations/016.create-incidents.ts
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");
}
47 changes: 25 additions & 22 deletions api/src/data/migrations/017.create-hazards.ts
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");
}
56 changes: 30 additions & 26 deletions api/src/data/migrations/019.create-actions.ts
Original file line number Diff line number Diff line change
@@ -1,32 +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").notNullable();
table.integer("creator_user_id").nullable();
table.integer("creator_role_type_id").nullable();
table.integer("actor_user_id").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("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");
}
21 changes: 11 additions & 10 deletions api/src/data/migrations/020.create-role-logs.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,21 +7,22 @@ export async function up(knex: knex.Knex) {
table.string("old_name", 256).nullable();
table.string("old_department_code", 8).nullable();
table.string("old_location_code", 8).nullable();
table.integer("old_role_type_id").notNullable();
table.integer("old_user_id").notNullable();
table.datetime("old_start_date").notNullable();
table.datetime("old_end_date").notNullable();
table.integer("old_role_type_id").nullable();
table.integer("old_user_id").nullable();
table.datetime("old_start_date").nullable();
table.datetime("old_end_date").nullable();
table.string("new_name", 256).nullable();
table.string("new_department_code", 8).nullable();
table.string("new_location_code", 8).nullable();
table.integer("new_role_type_id").notNullable();
table.integer("new_user_id").notNullable();
table.datetime("new_start_date").notNullable();
table.datetime("new_end_date").notNullable();
table.integer("new_role_type_id").nullable();
table.integer("new_user_id").nullable();
table.datetime("new_start_date").nullable();
table.datetime("new_end_date").nullable();
table.integer("changer_user_id").nullable();
table.integer("changer_role_id").nullable();
table.datetime("changed_date").notNullable(); // defaultTo now?
table.string("log_comment", 4000).notNullable();
table.datetime("changed_date").notNullable();
table.string("log_title", 200).notNullable();
table.string("log_comment", 4000).nullable();
table.string("user_action", 8).notNullable();

table.foreign("user_roles_id").references("user_roles.id");
Expand Down
9 changes: 5 additions & 4 deletions api/src/data/migrations/021.create-hazard-logs.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,20 +12,21 @@ export async function up(knex: knex.Knex) {
table.string("old_scope_code", 8).nullable();
table.string("old_sensitivity_code", 8).nullable();
table.string("old_status_code", 8).nullable();
table.integer("old_reopen_count").notNullable();
table.integer("new_hazard_type_id").notNullable();
table.integer("old_reopen_count").nullable();
table.integer("new_hazard_type_id").nullable();
table.string("new_description", 4000).nullable();
table.string("new_location_code", 8).nullable();
table.string("new_location_detail", 8).nullable();
table.string("new_department_code", 8).nullable();
table.string("new_scope_code", 8).nullable();
table.string("new_sensitivity_code", 8).nullable();
table.string("new_status_code", 8).nullable();
table.integer("new_reopen_count").notNullable();
table.integer("new_reopen_count").nullable();
table.integer("changer_user_id").nullable();
table.integer("changer_role_id").nullable();
table.datetime("changed_date").notNullable();
table.string("log_comment", 4000).notNullable();
table.string("log_title", 200).notNullable();
table.string("log_comment", 4000).nullable();
table.string("user_action", 8).notNullable();

table.foreign("hazard_id").references("hazards.id");
Expand Down
15 changes: 8 additions & 7 deletions api/src/data/migrations/022.create-action-logs.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,22 +7,23 @@ export async function up(knex: knex.Knex) {
table.integer("hazard_id").nullable();
table.integer("old_actor_user_id").nullable();
table.integer("old_actor_role_id").nullable();
table.datetime("old_due_date").notNullable();
table.string("old_description", 4000).notNullable();
table.string("old_action_type_code", 8).notNullable();
table.datetime("old_due_date").nullable();
table.string("old_description", 4000).nullable();
table.string("old_action_type_code", 8).nullable();
table.string("old_sensitivity_code", 8).nullable();
table.string("old_status_code", 8).nullable();
table.integer("new_actor_user_id").nullable();
table.integer("new_actor_role_id").nullable();
table.datetime("new_due_date").notNullable();
table.string("new_description", 4000).notNullable();
table.string("new_action_type_code", 8).notNullable();
table.datetime("new_due_date").nullable();
table.string("new_description", 4000).nullable();
table.string("new_action_type_code", 8).nullable();
table.string("new_sensitivity_code", 8).nullable();
table.string("new_status_code", 8).nullable();
table.integer("changer_user_id").nullable();
table.integer("changer_role_id").nullable();
table.datetime("changed_date").notNullable();
table.string("log_comment", 4000).notNullable();
table.string("log_title", 200).notNullable();
table.string("log_comment", 4000).nullable();
table.string("user_action", 8).notNullable();

table.foreign("action_id").references("actions.id");
Expand Down
11 changes: 6 additions & 5 deletions api/src/data/migrations/023.create-incident-logs.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,22 +4,23 @@ export async function up(knex: knex.Knex) {
await knex.schema.createTable("incident_logs", function(table) {
table.increments("id").primary().notNullable();
table.integer("incident_id").notNullable();
table.string("old_description", 4000).notNullable();
table.string("old_description", 4000).nullable();
table.string("old_sensitivity_code", 256).nullable();
table.string("old_supervisor", 8).nullable();
table.datetime("old_created_date").notNullable();
table.datetime("old_created_date").nullable();
table.string("old_status_code", 8).nullable();
table.integer("old_incident_type_id").nullable();
table.string("new_description", 4000).notNullable();
table.string("new_description", 4000).nullable();
table.string("new_supervisor", 8).nullable();
table.string("new_sensitivity_code", 8).nullable();
table.datetime("new_created_date").notNullable();
table.datetime("new_created_date").nullable();
table.string("new_status_code", 8).nullable();
table.integer("new_incident_type_id").nullable();
table.integer("changer_user_id").nullable();
table.integer("changer_role_id").nullable();
table.datetime("changed_date").notNullable();
table.string("log_comment", 4000).notNullable();
table.string("log_title", 200).notNullable();
table.string("log_comment", 4000).nullable();
table.string("user_action", 8).notNullable();

table.foreign("incident_id").references("incidents.id");
Expand Down
5 changes: 3 additions & 2 deletions api/src/data/migrations/024.create-incident-hazard-logs.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,12 @@ export async function up(knex: knex.Knex) {
await knex.schema.createTable("incident_hazard_logs", function(table) {
table.increments("id").primary().notNullable();
table.integer("incident_hazard_id").notNullable();
table.string("old_incident_hazard_type_code", 8).notNullable();
table.string("new_incident_hazard_type_code", 8).notNullable();
table.string("old_incident_hazard_type_code", 8).nullable();
table.string("new_incident_hazard_type_code", 8).nullable();
table.integer("changer_user_id").nullable();
table.integer("changer_role_id").nullable();
table.datetime("changed_date").notNullable();
table.string("log_title", 200).notNullable();
table.string("log_comment", 4000).notNullable();
table.string("user_action", 8).notNullable();

Expand Down
22 changes: 22 additions & 0 deletions api/src/data/migrations/028.create-incident-steps.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
import * as knex from "knex";

export async function up(knex: knex.Knex) {
await knex.schema.createTable("incident_steps", function (table) {
table.increments("id").primary().notNullable();
table.integer("incident_id").notNullable();
table.string("step_title", 150).notNullable();
table.integer("order").notNullable();
table.datetime("activate_date").nullable();
table.datetime("complete_date").nullable();
table.string("complete_name", 200).nullable();
table.integer("complete_user_id").nullable();

table.foreign("incident_id").references("incidents.id");
table.foreign("complete_user_id").references("users.id");
table.unique(["incident_id", "order"]);
});
}

export async function down(knex: knex.Knex) {
await knex.schema.dropTable("incident_steps");
}
Loading

0 comments on commit 626284d

Please sign in to comment.