{ "id": "bc8cffa0-a2ba-49cd-9c96-2b7ddc70329f", "prevId": "9f956116-7800-4428-8fdd-c21f012e29b7", "version": "7", "dialect": "postgresql", "tables": { "public.areas": { "name": "areas", "schema": "", "columns": { "id": { "name": "id", "type": "uuid", "primaryKey": true, "notNull": true, "default": "gen_random_uuid()" }, "site_id": { "name": "site_id", "type": "uuid", "primaryKey": false, "notNull": true }, "parent_id": { "name": "parent_id", "type": "uuid", "primaryKey": false, "notNull": false }, "name": { "name": "name", "type": "text", "primaryKey": false, "notNull": true }, "kind": { "name": "kind", "type": "area_kind", "typeSchema": "public", "primaryKey": false, "notNull": true, "default": "'area'" }, "archived_at": { "name": "archived_at", "type": "timestamp with time zone", "primaryKey": false, "notNull": false }, "created_at": { "name": "created_at", "type": "timestamp with time zone", "primaryKey": false, "notNull": true, "default": "now()" }, "updated_at": { "name": "updated_at", "type": "timestamp with time zone", "primaryKey": false, "notNull": true, "default": "now()" } }, "indexes": { "areas_site_idx": { "name": "areas_site_idx", "columns": [ { "expression": "site_id", "isExpression": false, "asc": true, "nulls": "last" } ], "isUnique": false, "concurrently": false, "method": "btree", "with": {} }, "areas_parent_idx": { "name": "areas_parent_idx", "columns": [ { "expression": "parent_id", "isExpression": false, "asc": true, "nulls": "last" } ], "isUnique": false, "concurrently": false, "method": "btree", "with": {} } }, "foreignKeys": { "areas_site_id_sites_id_fk": { "name": "areas_site_id_sites_id_fk", "tableFrom": "areas", "tableTo": "sites", "columnsFrom": [ "site_id" ], "columnsTo": [ "id" ], "onDelete": "cascade", "onUpdate": "no action" }, "areas_parent_id_areas_id_fk": { "name": "areas_parent_id_areas_id_fk", "tableFrom": "areas", "tableTo": "areas", "columnsFrom": [ "parent_id" ], "columnsTo": [ "id" ], "onDelete": "cascade", "onUpdate": "no action" } }, "compositePrimaryKeys": {}, "uniqueConstraints": {}, "policies": {}, "checkConstraints": {}, "isRLSEnabled": false }, "public.attachments": { "name": "attachments", "schema": "", "columns": { "id": { "name": "id", "type": "uuid", "primaryKey": true, "notNull": true, "default": "gen_random_uuid()" }, "incident_id": { "name": "incident_id", "type": "uuid", "primaryKey": false, "notNull": true }, "file_name": { "name": "file_name", "type": "text", "primaryKey": false, "notNull": true }, "content_type": { "name": "content_type", "type": "text", "primaryKey": false, "notNull": true }, "size_bytes": { "name": "size_bytes", "type": "integer", "primaryKey": false, "notNull": true }, "storage_key": { "name": "storage_key", "type": "text", "primaryKey": false, "notNull": true }, "uploaded_by_id": { "name": "uploaded_by_id", "type": "uuid", "primaryKey": false, "notNull": false }, "created_at": { "name": "created_at", "type": "timestamp with time zone", "primaryKey": false, "notNull": true, "default": "now()" } }, "indexes": { "attachments_incident_idx": { "name": "attachments_incident_idx", "columns": [ { "expression": "incident_id", "isExpression": false, "asc": true, "nulls": "last" } ], "isUnique": false, "concurrently": false, "method": "btree", "with": {} } }, "foreignKeys": { "attachments_incident_id_incidents_id_fk": { "name": "attachments_incident_id_incidents_id_fk", "tableFrom": "attachments", "tableTo": "incidents", "columnsFrom": [ "incident_id" ], "columnsTo": [ "id" ], "onDelete": "cascade", "onUpdate": "no action" }, "attachments_uploaded_by_id_users_id_fk": { "name": "attachments_uploaded_by_id_users_id_fk", "tableFrom": "attachments", "tableTo": "users", "columnsFrom": [ "uploaded_by_id" ], "columnsTo": [ "id" ], "onDelete": "set null", "onUpdate": "no action" } }, "compositePrimaryKeys": {}, "uniqueConstraints": { "attachments_storageKey_unique": { "name": "attachments_storageKey_unique", "nullsNotDistinct": false, "columns": [ "storage_key" ] } }, "policies": {}, "checkConstraints": {}, "isRLSEnabled": false }, "public.audit_log": { "name": "audit_log", "schema": "", "columns": { "id": { "name": "id", "type": "bigserial", "primaryKey": true, "notNull": true }, "organization_id": { "name": "organization_id", "type": "uuid", "primaryKey": false, "notNull": true }, "actor_id": { "name": "actor_id", "type": "uuid", "primaryKey": false, "notNull": false }, "entity_type": { "name": "entity_type", "type": "text", "primaryKey": false, "notNull": true }, "entity_id": { "name": "entity_id", "type": "text", "primaryKey": false, "notNull": true }, "action": { "name": "action", "type": "text", "primaryKey": false, "notNull": true }, "changes": { "name": "changes", "type": "jsonb", "primaryKey": false, "notNull": false }, "created_at": { "name": "created_at", "type": "timestamp with time zone", "primaryKey": false, "notNull": true, "default": "now()" } }, "indexes": { "audit_log_entity_idx": { "name": "audit_log_entity_idx", "columns": [ { "expression": "organization_id", "isExpression": false, "asc": true, "nulls": "last" }, { "expression": "entity_type", "isExpression": false, "asc": true, "nulls": "last" }, { "expression": "entity_id", "isExpression": false, "asc": true, "nulls": "last" } ], "isUnique": false, "concurrently": false, "method": "btree", "with": {} } }, "foreignKeys": { "audit_log_organization_id_organizations_id_fk": { "name": "audit_log_organization_id_organizations_id_fk", "tableFrom": "audit_log", "tableTo": "organizations", "columnsFrom": [ "organization_id" ], "columnsTo": [ "id" ], "onDelete": "no action", "onUpdate": "no action" }, "audit_log_actor_id_users_id_fk": { "name": "audit_log_actor_id_users_id_fk", "tableFrom": "audit_log", "tableTo": "users", "columnsFrom": [ "actor_id" ], "columnsTo": [ "id" ], "onDelete": "set null", "onUpdate": "no action" } }, "compositePrimaryKeys": {}, "uniqueConstraints": {}, "policies": {}, "checkConstraints": {}, "isRLSEnabled": false }, "public.auth_tokens": { "name": "auth_tokens", "schema": "", "columns": { "id": { "name": "id", "type": "text", "primaryKey": true, "notNull": true }, "user_id": { "name": "user_id", "type": "uuid", "primaryKey": false, "notNull": true }, "purpose": { "name": "purpose", "type": "auth_token_purpose", "typeSchema": "public", "primaryKey": false, "notNull": true }, "expires_at": { "name": "expires_at", "type": "timestamp with time zone", "primaryKey": false, "notNull": true }, "used_at": { "name": "used_at", "type": "timestamp with time zone", "primaryKey": false, "notNull": false }, "created_at": { "name": "created_at", "type": "timestamp with time zone", "primaryKey": false, "notNull": true, "default": "now()" } }, "indexes": { "auth_tokens_user_idx": { "name": "auth_tokens_user_idx", "columns": [ { "expression": "user_id", "isExpression": false, "asc": true, "nulls": "last" } ], "isUnique": false, "concurrently": false, "method": "btree", "with": {} } }, "foreignKeys": { "auth_tokens_user_id_users_id_fk": { "name": "auth_tokens_user_id_users_id_fk", "tableFrom": "auth_tokens", "tableTo": "users", "columnsFrom": [ "user_id" ], "columnsTo": [ "id" ], "onDelete": "cascade", "onUpdate": "no action" } }, "compositePrimaryKeys": {}, "uniqueConstraints": {}, "policies": {}, "checkConstraints": {}, "isRLSEnabled": false }, "public.comments": { "name": "comments", "schema": "", "columns": { "id": { "name": "id", "type": "uuid", "primaryKey": true, "notNull": true, "default": "gen_random_uuid()" }, "incident_id": { "name": "incident_id", "type": "uuid", "primaryKey": false, "notNull": true }, "author_id": { "name": "author_id", "type": "uuid", "primaryKey": false, "notNull": false }, "body": { "name": "body", "type": "text", "primaryKey": false, "notNull": true }, "created_at": { "name": "created_at", "type": "timestamp with time zone", "primaryKey": false, "notNull": true, "default": "now()" } }, "indexes": { "comments_incident_idx": { "name": "comments_incident_idx", "columns": [ { "expression": "incident_id", "isExpression": false, "asc": true, "nulls": "last" } ], "isUnique": false, "concurrently": false, "method": "btree", "with": {} } }, "foreignKeys": { "comments_incident_id_incidents_id_fk": { "name": "comments_incident_id_incidents_id_fk", "tableFrom": "comments", "tableTo": "incidents", "columnsFrom": [ "incident_id" ], "columnsTo": [ "id" ], "onDelete": "cascade", "onUpdate": "no action" }, "comments_author_id_users_id_fk": { "name": "comments_author_id_users_id_fk", "tableFrom": "comments", "tableTo": "users", "columnsFrom": [ "author_id" ], "columnsTo": [ "id" ], "onDelete": "set null", "onUpdate": "no action" } }, "compositePrimaryKeys": {}, "uniqueConstraints": {}, "policies": {}, "checkConstraints": {}, "isRLSEnabled": false }, "public.corrective_actions": { "name": "corrective_actions", "schema": "", "columns": { "id": { "name": "id", "type": "uuid", "primaryKey": true, "notNull": true, "default": "gen_random_uuid()" }, "incident_id": { "name": "incident_id", "type": "uuid", "primaryKey": false, "notNull": true }, "root_cause_id": { "name": "root_cause_id", "type": "uuid", "primaryKey": false, "notNull": false }, "kind": { "name": "kind", "type": "action_kind", "typeSchema": "public", "primaryKey": false, "notNull": true, "default": "'corrective'" }, "title": { "name": "title", "type": "text", "primaryKey": false, "notNull": true }, "description": { "name": "description", "type": "text", "primaryKey": false, "notNull": false }, "assignee_id": { "name": "assignee_id", "type": "uuid", "primaryKey": false, "notNull": false }, "due_date": { "name": "due_date", "type": "date", "primaryKey": false, "notNull": false }, "status": { "name": "status", "type": "action_status", "typeSchema": "public", "primaryKey": false, "notNull": true, "default": "'open'" }, "completed_at": { "name": "completed_at", "type": "timestamp with time zone", "primaryKey": false, "notNull": false }, "verified_by_id": { "name": "verified_by_id", "type": "uuid", "primaryKey": false, "notNull": false }, "verified_at": { "name": "verified_at", "type": "timestamp with time zone", "primaryKey": false, "notNull": false }, "reminder_sent_on": { "name": "reminder_sent_on", "type": "date", "primaryKey": false, "notNull": false }, "created_at": { "name": "created_at", "type": "timestamp with time zone", "primaryKey": false, "notNull": true, "default": "now()" }, "updated_at": { "name": "updated_at", "type": "timestamp with time zone", "primaryKey": false, "notNull": true, "default": "now()" } }, "indexes": { "corrective_actions_incident_idx": { "name": "corrective_actions_incident_idx", "columns": [ { "expression": "incident_id", "isExpression": false, "asc": true, "nulls": "last" } ], "isUnique": false, "concurrently": false, "method": "btree", "with": {} }, "corrective_actions_assignee_status_idx": { "name": "corrective_actions_assignee_status_idx", "columns": [ { "expression": "assignee_id", "isExpression": false, "asc": true, "nulls": "last" }, { "expression": "status", "isExpression": false, "asc": true, "nulls": "last" } ], "isUnique": false, "concurrently": false, "method": "btree", "with": {} } }, "foreignKeys": { "corrective_actions_incident_id_incidents_id_fk": { "name": "corrective_actions_incident_id_incidents_id_fk", "tableFrom": "corrective_actions", "tableTo": "incidents", "columnsFrom": [ "incident_id" ], "columnsTo": [ "id" ], "onDelete": "cascade", "onUpdate": "no action" }, "corrective_actions_root_cause_id_root_causes_id_fk": { "name": "corrective_actions_root_cause_id_root_causes_id_fk", "tableFrom": "corrective_actions", "tableTo": "root_causes", "columnsFrom": [ "root_cause_id" ], "columnsTo": [ "id" ], "onDelete": "set null", "onUpdate": "no action" }, "corrective_actions_assignee_id_users_id_fk": { "name": "corrective_actions_assignee_id_users_id_fk", "tableFrom": "corrective_actions", "tableTo": "users", "columnsFrom": [ "assignee_id" ], "columnsTo": [ "id" ], "onDelete": "set null", "onUpdate": "no action" }, "corrective_actions_verified_by_id_users_id_fk": { "name": "corrective_actions_verified_by_id_users_id_fk", "tableFrom": "corrective_actions", "tableTo": "users", "columnsFrom": [ "verified_by_id" ], "columnsTo": [ "id" ], "onDelete": "set null", "onUpdate": "no action" } }, "compositePrimaryKeys": {}, "uniqueConstraints": {}, "policies": {}, "checkConstraints": {}, "isRLSEnabled": false }, "public.hours_worked": { "name": "hours_worked", "schema": "", "columns": { "id": { "name": "id", "type": "uuid", "primaryKey": true, "notNull": true, "default": "gen_random_uuid()" }, "site_id": { "name": "site_id", "type": "uuid", "primaryKey": false, "notNull": true }, "month": { "name": "month", "type": "date", "primaryKey": false, "notNull": true }, "hours": { "name": "hours", "type": "numeric(12, 2)", "primaryKey": false, "notNull": true }, "average_employees": { "name": "average_employees", "type": "integer", "primaryKey": false, "notNull": false }, "created_at": { "name": "created_at", "type": "timestamp with time zone", "primaryKey": false, "notNull": true, "default": "now()" }, "updated_at": { "name": "updated_at", "type": "timestamp with time zone", "primaryKey": false, "notNull": true, "default": "now()" } }, "indexes": { "hours_worked_site_month_unique": { "name": "hours_worked_site_month_unique", "columns": [ { "expression": "site_id", "isExpression": false, "asc": true, "nulls": "last" }, { "expression": "month", "isExpression": false, "asc": true, "nulls": "last" } ], "isUnique": true, "concurrently": false, "method": "btree", "with": {} } }, "foreignKeys": { "hours_worked_site_id_sites_id_fk": { "name": "hours_worked_site_id_sites_id_fk", "tableFrom": "hours_worked", "tableTo": "sites", "columnsFrom": [ "site_id" ], "columnsTo": [ "id" ], "onDelete": "cascade", "onUpdate": "no action" } }, "compositePrimaryKeys": {}, "uniqueConstraints": {}, "policies": {}, "checkConstraints": {}, "isRLSEnabled": false }, "public.incident_counters": { "name": "incident_counters", "schema": "", "columns": { "organization_id": { "name": "organization_id", "type": "uuid", "primaryKey": true, "notNull": true }, "last_number": { "name": "last_number", "type": "integer", "primaryKey": false, "notNull": true, "default": 0 } }, "indexes": {}, "foreignKeys": { "incident_counters_organization_id_organizations_id_fk": { "name": "incident_counters_organization_id_organizations_id_fk", "tableFrom": "incident_counters", "tableTo": "organizations", "columnsFrom": [ "organization_id" ], "columnsTo": [ "id" ], "onDelete": "no action", "onUpdate": "no action" } }, "compositePrimaryKeys": {}, "uniqueConstraints": {}, "policies": {}, "checkConstraints": {}, "isRLSEnabled": false }, "public.incidents": { "name": "incidents", "schema": "", "columns": { "id": { "name": "id", "type": "uuid", "primaryKey": true, "notNull": true, "default": "gen_random_uuid()" }, "organization_id": { "name": "organization_id", "type": "uuid", "primaryKey": false, "notNull": true }, "number": { "name": "number", "type": "integer", "primaryKey": false, "notNull": true }, "title": { "name": "title", "type": "text", "primaryKey": false, "notNull": true }, "type": { "name": "type", "type": "incident_type", "typeSchema": "public", "primaryKey": false, "notNull": true }, "severity": { "name": "severity", "type": "severity", "typeSchema": "public", "primaryKey": false, "notNull": true }, "status": { "name": "status", "type": "incident_status", "typeSchema": "public", "primaryKey": false, "notNull": true, "default": "'reported'" }, "occurred_at": { "name": "occurred_at", "type": "timestamp with time zone", "primaryKey": false, "notNull": true }, "site_id": { "name": "site_id", "type": "uuid", "primaryKey": false, "notNull": true }, "area_id": { "name": "area_id", "type": "uuid", "primaryKey": false, "notNull": false }, "location_detail": { "name": "location_detail", "type": "text", "primaryKey": false, "notNull": false }, "description": { "name": "description", "type": "text", "primaryKey": false, "notNull": false }, "immediate_action": { "name": "immediate_action", "type": "text", "primaryKey": false, "notNull": false }, "reporter_id": { "name": "reporter_id", "type": "uuid", "primaryKey": false, "notNull": false }, "anonymous": { "name": "anonymous", "type": "boolean", "primaryKey": false, "notNull": true, "default": false }, "reporter_name": { "name": "reporter_name", "type": "text", "primaryKey": false, "notNull": false }, "channel": { "name": "channel", "type": "report_channel", "typeSchema": "public", "primaryKey": false, "notNull": true, "default": "'web'" }, "kiosk_id": { "name": "kiosk_id", "type": "uuid", "primaryKey": false, "notNull": false }, "client_id": { "name": "client_id", "type": "uuid", "primaryKey": false, "notNull": false }, "closed_at": { "name": "closed_at", "type": "timestamp with time zone", "primaryKey": false, "notNull": false }, "created_at": { "name": "created_at", "type": "timestamp with time zone", "primaryKey": false, "notNull": true, "default": "now()" }, "updated_at": { "name": "updated_at", "type": "timestamp with time zone", "primaryKey": false, "notNull": true, "default": "now()" } }, "indexes": { "incidents_organization_number_unique": { "name": "incidents_organization_number_unique", "columns": [ { "expression": "organization_id", "isExpression": false, "asc": true, "nulls": "last" }, { "expression": "number", "isExpression": false, "asc": true, "nulls": "last" } ], "isUnique": true, "concurrently": false, "method": "btree", "with": {} }, "incidents_organization_client_id_unique": { "name": "incidents_organization_client_id_unique", "columns": [ { "expression": "organization_id", "isExpression": false, "asc": true, "nulls": "last" }, { "expression": "client_id", "isExpression": false, "asc": true, "nulls": "last" } ], "isUnique": true, "concurrently": false, "method": "btree", "with": {} }, "incidents_organization_occurred_idx": { "name": "incidents_organization_occurred_idx", "columns": [ { "expression": "organization_id", "isExpression": false, "asc": true, "nulls": "last" }, { "expression": "occurred_at", "isExpression": false, "asc": true, "nulls": "last" } ], "isUnique": false, "concurrently": false, "method": "btree", "with": {} }, "incidents_organization_status_idx": { "name": "incidents_organization_status_idx", "columns": [ { "expression": "organization_id", "isExpression": false, "asc": true, "nulls": "last" }, { "expression": "status", "isExpression": false, "asc": true, "nulls": "last" } ], "isUnique": false, "concurrently": false, "method": "btree", "with": {} }, "incidents_reporter_idx": { "name": "incidents_reporter_idx", "columns": [ { "expression": "reporter_id", "isExpression": false, "asc": true, "nulls": "last" } ], "isUnique": false, "concurrently": false, "method": "btree", "with": {} } }, "foreignKeys": { "incidents_organization_id_organizations_id_fk": { "name": "incidents_organization_id_organizations_id_fk", "tableFrom": "incidents", "tableTo": "organizations", "columnsFrom": [ "organization_id" ], "columnsTo": [ "id" ], "onDelete": "no action", "onUpdate": "no action" }, "incidents_site_id_sites_id_fk": { "name": "incidents_site_id_sites_id_fk", "tableFrom": "incidents", "tableTo": "sites", "columnsFrom": [ "site_id" ], "columnsTo": [ "id" ], "onDelete": "no action", "onUpdate": "no action" }, "incidents_area_id_areas_id_fk": { "name": "incidents_area_id_areas_id_fk", "tableFrom": "incidents", "tableTo": "areas", "columnsFrom": [ "area_id" ], "columnsTo": [ "id" ], "onDelete": "set null", "onUpdate": "no action" }, "incidents_reporter_id_users_id_fk": { "name": "incidents_reporter_id_users_id_fk", "tableFrom": "incidents", "tableTo": "users", "columnsFrom": [ "reporter_id" ], "columnsTo": [ "id" ], "onDelete": "set null", "onUpdate": "no action" }, "incidents_kiosk_id_kiosks_id_fk": { "name": "incidents_kiosk_id_kiosks_id_fk", "tableFrom": "incidents", "tableTo": "kiosks", "columnsFrom": [ "kiosk_id" ], "columnsTo": [ "id" ], "onDelete": "set null", "onUpdate": "no action" } }, "compositePrimaryKeys": {}, "uniqueConstraints": {}, "policies": {}, "checkConstraints": {}, "isRLSEnabled": false }, "public.injured_persons": { "name": "injured_persons", "schema": "", "columns": { "id": { "name": "id", "type": "uuid", "primaryKey": true, "notNull": true, "default": "gen_random_uuid()" }, "incident_id": { "name": "incident_id", "type": "uuid", "primaryKey": false, "notNull": true }, "user_id": { "name": "user_id", "type": "uuid", "primaryKey": false, "notNull": false }, "name": { "name": "name", "type": "text", "primaryKey": false, "notNull": true }, "job_title": { "name": "job_title", "type": "text", "primaryKey": false, "notNull": false }, "employment_type": { "name": "employment_type", "type": "employment_type", "typeSchema": "public", "primaryKey": false, "notNull": true, "default": "'employee'" }, "body_part": { "name": "body_part", "type": "text", "primaryKey": false, "notNull": false }, "nature_of_injury": { "name": "nature_of_injury", "type": "text", "primaryKey": false, "notNull": false }, "treatment": { "name": "treatment", "type": "treatment_level", "typeSchema": "public", "primaryKey": false, "notNull": true, "default": "'none'" }, "days_away": { "name": "days_away", "type": "integer", "primaryKey": false, "notNull": true, "default": 0 }, "days_restricted": { "name": "days_restricted", "type": "integer", "primaryKey": false, "notNull": true, "default": 0 }, "privacy_case": { "name": "privacy_case", "type": "boolean", "primaryKey": false, "notNull": true, "default": false }, "case_number": { "name": "case_number", "type": "text", "primaryKey": false, "notNull": false }, "work_related": { "name": "work_related", "type": "boolean", "primaryKey": false, "notNull": false }, "new_case": { "name": "new_case", "type": "boolean", "primaryKey": false, "notNull": false }, "died": { "name": "died", "type": "boolean", "primaryKey": false, "notNull": true, "default": false }, "date_of_death": { "name": "date_of_death", "type": "date", "primaryKey": false, "notNull": false }, "days_away_from_work": { "name": "days_away_from_work", "type": "boolean", "primaryKey": false, "notNull": true, "default": false }, "restricted_or_transfer": { "name": "restricted_or_transfer", "type": "boolean", "primaryKey": false, "notNull": true, "default": false }, "medical_treatment": { "name": "medical_treatment", "type": "boolean", "primaryKey": false, "notNull": true, "default": false }, "loss_of_consciousness": { "name": "loss_of_consciousness", "type": "boolean", "primaryKey": false, "notNull": true, "default": false }, "significant_diagnosis": { "name": "significant_diagnosis", "type": "boolean", "primaryKey": false, "notNull": true, "default": false }, "special_case": { "name": "special_case", "type": "osha_special_case", "typeSchema": "public", "primaryKey": false, "notNull": true, "default": "'none'" }, "case_type": { "name": "case_type", "type": "osha_case_type", "typeSchema": "public", "primaryKey": false, "notNull": true, "default": "'injury'" }, "recordable": { "name": "recordable", "type": "boolean", "primaryKey": false, "notNull": true, "default": false }, "outcome": { "name": "outcome", "type": "osha_outcome", "typeSchema": "public", "primaryKey": false, "notNull": false }, "inpatient_hospitalization": { "name": "inpatient_hospitalization", "type": "boolean", "primaryKey": false, "notNull": true, "default": false }, "amputation": { "name": "amputation", "type": "boolean", "primaryKey": false, "notNull": true, "default": false }, "loss_of_eye": { "name": "loss_of_eye", "type": "boolean", "primaryKey": false, "notNull": true, "default": false }, "reported_to_osha_at": { "name": "reported_to_osha_at", "type": "timestamp with time zone", "primaryKey": false, "notNull": false }, "employee_address": { "name": "employee_address", "type": "text", "primaryKey": false, "notNull": false }, "date_of_birth": { "name": "date_of_birth", "type": "date", "primaryKey": false, "notNull": false }, "date_of_hire": { "name": "date_of_hire", "type": "date", "primaryKey": false, "notNull": false }, "sex": { "name": "sex", "type": "text", "primaryKey": false, "notNull": false }, "physician_name": { "name": "physician_name", "type": "text", "primaryKey": false, "notNull": false }, "treatment_facility": { "name": "treatment_facility", "type": "text", "primaryKey": false, "notNull": false }, "treated_in_emergency_room": { "name": "treated_in_emergency_room", "type": "boolean", "primaryKey": false, "notNull": true, "default": false }, "time_started_work": { "name": "time_started_work", "type": "text", "primaryKey": false, "notNull": false }, "activity_before": { "name": "activity_before", "type": "text", "primaryKey": false, "notNull": false }, "what_happened": { "name": "what_happened", "type": "text", "primaryKey": false, "notNull": false }, "object_substance": { "name": "object_substance", "type": "text", "primaryKey": false, "notNull": false }, "created_at": { "name": "created_at", "type": "timestamp with time zone", "primaryKey": false, "notNull": true, "default": "now()" }, "updated_at": { "name": "updated_at", "type": "timestamp with time zone", "primaryKey": false, "notNull": true, "default": "now()" } }, "indexes": { "injured_persons_incident_idx": { "name": "injured_persons_incident_idx", "columns": [ { "expression": "incident_id", "isExpression": false, "asc": true, "nulls": "last" } ], "isUnique": false, "concurrently": false, "method": "btree", "with": {} } }, "foreignKeys": { "injured_persons_incident_id_incidents_id_fk": { "name": "injured_persons_incident_id_incidents_id_fk", "tableFrom": "injured_persons", "tableTo": "incidents", "columnsFrom": [ "incident_id" ], "columnsTo": [ "id" ], "onDelete": "cascade", "onUpdate": "no action" }, "injured_persons_user_id_users_id_fk": { "name": "injured_persons_user_id_users_id_fk", "tableFrom": "injured_persons", "tableTo": "users", "columnsFrom": [ "user_id" ], "columnsTo": [ "id" ], "onDelete": "set null", "onUpdate": "no action" } }, "compositePrimaryKeys": {}, "uniqueConstraints": {}, "policies": {}, "checkConstraints": {}, "isRLSEnabled": false }, "public.investigations": { "name": "investigations", "schema": "", "columns": { "id": { "name": "id", "type": "uuid", "primaryKey": true, "notNull": true, "default": "gen_random_uuid()" }, "incident_id": { "name": "incident_id", "type": "uuid", "primaryKey": false, "notNull": true }, "lead_id": { "name": "lead_id", "type": "uuid", "primaryKey": false, "notNull": false }, "method": { "name": "method", "type": "rca_method", "typeSchema": "public", "primaryKey": false, "notNull": true, "default": "'five_whys'" }, "summary": { "name": "summary", "type": "text", "primaryKey": false, "notNull": false }, "started_at": { "name": "started_at", "type": "timestamp with time zone", "primaryKey": false, "notNull": true, "default": "now()" }, "completed_at": { "name": "completed_at", "type": "timestamp with time zone", "primaryKey": false, "notNull": false }, "created_at": { "name": "created_at", "type": "timestamp with time zone", "primaryKey": false, "notNull": true, "default": "now()" }, "updated_at": { "name": "updated_at", "type": "timestamp with time zone", "primaryKey": false, "notNull": true, "default": "now()" } }, "indexes": {}, "foreignKeys": { "investigations_incident_id_incidents_id_fk": { "name": "investigations_incident_id_incidents_id_fk", "tableFrom": "investigations", "tableTo": "incidents", "columnsFrom": [ "incident_id" ], "columnsTo": [ "id" ], "onDelete": "cascade", "onUpdate": "no action" }, "investigations_lead_id_users_id_fk": { "name": "investigations_lead_id_users_id_fk", "tableFrom": "investigations", "tableTo": "users", "columnsFrom": [ "lead_id" ], "columnsTo": [ "id" ], "onDelete": "set null", "onUpdate": "no action" } }, "compositePrimaryKeys": {}, "uniqueConstraints": { "investigations_incidentId_unique": { "name": "investigations_incidentId_unique", "nullsNotDistinct": false, "columns": [ "incident_id" ] } }, "policies": {}, "checkConstraints": {}, "isRLSEnabled": false }, "public.kiosks": { "name": "kiosks", "schema": "", "columns": { "id": { "name": "id", "type": "uuid", "primaryKey": true, "notNull": true, "default": "gen_random_uuid()" }, "organization_id": { "name": "organization_id", "type": "uuid", "primaryKey": false, "notNull": true }, "name": { "name": "name", "type": "text", "primaryKey": false, "notNull": true }, "token": { "name": "token", "type": "text", "primaryKey": false, "notNull": true }, "site_id": { "name": "site_id", "type": "uuid", "primaryKey": false, "notNull": false }, "created_by_id": { "name": "created_by_id", "type": "uuid", "primaryKey": false, "notNull": false }, "last_used_at": { "name": "last_used_at", "type": "timestamp with time zone", "primaryKey": false, "notNull": false }, "revoked_at": { "name": "revoked_at", "type": "timestamp with time zone", "primaryKey": false, "notNull": false }, "created_at": { "name": "created_at", "type": "timestamp with time zone", "primaryKey": false, "notNull": true, "default": "now()" } }, "indexes": { "kiosks_token_unique": { "name": "kiosks_token_unique", "columns": [ { "expression": "token", "isExpression": false, "asc": true, "nulls": "last" } ], "isUnique": true, "concurrently": false, "method": "btree", "with": {} }, "kiosks_organization_idx": { "name": "kiosks_organization_idx", "columns": [ { "expression": "organization_id", "isExpression": false, "asc": true, "nulls": "last" } ], "isUnique": false, "concurrently": false, "method": "btree", "with": {} } }, "foreignKeys": { "kiosks_organization_id_organizations_id_fk": { "name": "kiosks_organization_id_organizations_id_fk", "tableFrom": "kiosks", "tableTo": "organizations", "columnsFrom": [ "organization_id" ], "columnsTo": [ "id" ], "onDelete": "no action", "onUpdate": "no action" }, "kiosks_site_id_sites_id_fk": { "name": "kiosks_site_id_sites_id_fk", "tableFrom": "kiosks", "tableTo": "sites", "columnsFrom": [ "site_id" ], "columnsTo": [ "id" ], "onDelete": "set null", "onUpdate": "no action" }, "kiosks_created_by_id_users_id_fk": { "name": "kiosks_created_by_id_users_id_fk", "tableFrom": "kiosks", "tableTo": "users", "columnsFrom": [ "created_by_id" ], "columnsTo": [ "id" ], "onDelete": "set null", "onUpdate": "no action" } }, "compositePrimaryKeys": {}, "uniqueConstraints": {}, "policies": {}, "checkConstraints": {}, "isRLSEnabled": false }, "public.organizations": { "name": "organizations", "schema": "", "columns": { "id": { "name": "id", "type": "uuid", "primaryKey": true, "notNull": true, "default": "gen_random_uuid()" }, "name": { "name": "name", "type": "text", "primaryKey": false, "notNull": true }, "created_at": { "name": "created_at", "type": "timestamp with time zone", "primaryKey": false, "notNull": true, "default": "now()" } }, "indexes": {}, "foreignKeys": {}, "compositePrimaryKeys": {}, "uniqueConstraints": {}, "policies": {}, "checkConstraints": {}, "isRLSEnabled": false }, "public.root_causes": { "name": "root_causes", "schema": "", "columns": { "id": { "name": "id", "type": "uuid", "primaryKey": true, "notNull": true, "default": "gen_random_uuid()" }, "investigation_id": { "name": "investigation_id", "type": "uuid", "primaryKey": false, "notNull": true }, "category": { "name": "category", "type": "root_cause_category", "typeSchema": "public", "primaryKey": false, "notNull": true }, "description": { "name": "description", "type": "text", "primaryKey": false, "notNull": true }, "whys": { "name": "whys", "type": "jsonb", "primaryKey": false, "notNull": true, "default": "'[]'::jsonb" }, "created_at": { "name": "created_at", "type": "timestamp with time zone", "primaryKey": false, "notNull": true, "default": "now()" } }, "indexes": { "root_causes_investigation_idx": { "name": "root_causes_investigation_idx", "columns": [ { "expression": "investigation_id", "isExpression": false, "asc": true, "nulls": "last" } ], "isUnique": false, "concurrently": false, "method": "btree", "with": {} } }, "foreignKeys": { "root_causes_investigation_id_investigations_id_fk": { "name": "root_causes_investigation_id_investigations_id_fk", "tableFrom": "root_causes", "tableTo": "investigations", "columnsFrom": [ "investigation_id" ], "columnsTo": [ "id" ], "onDelete": "cascade", "onUpdate": "no action" } }, "compositePrimaryKeys": {}, "uniqueConstraints": {}, "policies": {}, "checkConstraints": {}, "isRLSEnabled": false }, "public.sessions": { "name": "sessions", "schema": "", "columns": { "id": { "name": "id", "type": "text", "primaryKey": true, "notNull": true }, "user_id": { "name": "user_id", "type": "uuid", "primaryKey": false, "notNull": true }, "expires_at": { "name": "expires_at", "type": "timestamp with time zone", "primaryKey": false, "notNull": true }, "created_at": { "name": "created_at", "type": "timestamp with time zone", "primaryKey": false, "notNull": true, "default": "now()" } }, "indexes": { "sessions_user_idx": { "name": "sessions_user_idx", "columns": [ { "expression": "user_id", "isExpression": false, "asc": true, "nulls": "last" } ], "isUnique": false, "concurrently": false, "method": "btree", "with": {} } }, "foreignKeys": { "sessions_user_id_users_id_fk": { "name": "sessions_user_id_users_id_fk", "tableFrom": "sessions", "tableTo": "users", "columnsFrom": [ "user_id" ], "columnsTo": [ "id" ], "onDelete": "cascade", "onUpdate": "no action" } }, "compositePrimaryKeys": {}, "uniqueConstraints": {}, "policies": {}, "checkConstraints": {}, "isRLSEnabled": false }, "public.sites": { "name": "sites", "schema": "", "columns": { "id": { "name": "id", "type": "uuid", "primaryKey": true, "notNull": true, "default": "gen_random_uuid()" }, "organization_id": { "name": "organization_id", "type": "uuid", "primaryKey": false, "notNull": true }, "name": { "name": "name", "type": "text", "primaryKey": false, "notNull": true }, "address": { "name": "address", "type": "text", "primaryKey": false, "notNull": false }, "timezone": { "name": "timezone", "type": "text", "primaryKey": false, "notNull": true, "default": "'UTC'" }, "street_address": { "name": "street_address", "type": "text", "primaryKey": false, "notNull": false }, "city": { "name": "city", "type": "text", "primaryKey": false, "notNull": false }, "state": { "name": "state", "type": "text", "primaryKey": false, "notNull": false }, "zip": { "name": "zip", "type": "text", "primaryKey": false, "notNull": false }, "naics_code": { "name": "naics_code", "type": "text", "primaryKey": false, "notNull": false }, "industry_description": { "name": "industry_description", "type": "text", "primaryKey": false, "notNull": false }, "ein": { "name": "ein", "type": "text", "primaryKey": false, "notNull": false }, "establishment_type": { "name": "establishment_type", "type": "integer", "primaryKey": false, "notNull": true, "default": 1 }, "archived_at": { "name": "archived_at", "type": "timestamp with time zone", "primaryKey": false, "notNull": false }, "created_at": { "name": "created_at", "type": "timestamp with time zone", "primaryKey": false, "notNull": true, "default": "now()" }, "updated_at": { "name": "updated_at", "type": "timestamp with time zone", "primaryKey": false, "notNull": true, "default": "now()" } }, "indexes": { "sites_organization_name_unique": { "name": "sites_organization_name_unique", "columns": [ { "expression": "organization_id", "isExpression": false, "asc": true, "nulls": "last" }, { "expression": "name", "isExpression": false, "asc": true, "nulls": "last" } ], "isUnique": true, "concurrently": false, "method": "btree", "with": {} } }, "foreignKeys": { "sites_organization_id_organizations_id_fk": { "name": "sites_organization_id_organizations_id_fk", "tableFrom": "sites", "tableTo": "organizations", "columnsFrom": [ "organization_id" ], "columnsTo": [ "id" ], "onDelete": "no action", "onUpdate": "no action" } }, "compositePrimaryKeys": {}, "uniqueConstraints": {}, "policies": {}, "checkConstraints": {}, "isRLSEnabled": false }, "public.users": { "name": "users", "schema": "", "columns": { "id": { "name": "id", "type": "uuid", "primaryKey": true, "notNull": true, "default": "gen_random_uuid()" }, "organization_id": { "name": "organization_id", "type": "uuid", "primaryKey": false, "notNull": true }, "email": { "name": "email", "type": "text", "primaryKey": false, "notNull": true }, "name": { "name": "name", "type": "text", "primaryKey": false, "notNull": true }, "role": { "name": "role", "type": "role", "typeSchema": "public", "primaryKey": false, "notNull": true, "default": "'reporter'" }, "password_hash": { "name": "password_hash", "type": "text", "primaryKey": false, "notNull": false }, "active": { "name": "active", "type": "boolean", "primaryKey": false, "notNull": true, "default": true }, "last_login_at": { "name": "last_login_at", "type": "timestamp with time zone", "primaryKey": false, "notNull": false }, "created_at": { "name": "created_at", "type": "timestamp with time zone", "primaryKey": false, "notNull": true, "default": "now()" }, "updated_at": { "name": "updated_at", "type": "timestamp with time zone", "primaryKey": false, "notNull": true, "default": "now()" } }, "indexes": { "users_email_unique": { "name": "users_email_unique", "columns": [ { "expression": "email", "isExpression": false, "asc": true, "nulls": "last" } ], "isUnique": true, "concurrently": false, "method": "btree", "with": {} }, "users_organization_idx": { "name": "users_organization_idx", "columns": [ { "expression": "organization_id", "isExpression": false, "asc": true, "nulls": "last" } ], "isUnique": false, "concurrently": false, "method": "btree", "with": {} } }, "foreignKeys": { "users_organization_id_organizations_id_fk": { "name": "users_organization_id_organizations_id_fk", "tableFrom": "users", "tableTo": "organizations", "columnsFrom": [ "organization_id" ], "columnsTo": [ "id" ], "onDelete": "no action", "onUpdate": "no action" } }, "compositePrimaryKeys": {}, "uniqueConstraints": {}, "policies": {}, "checkConstraints": {}, "isRLSEnabled": false } }, "enums": { "public.action_kind": { "name": "action_kind", "schema": "public", "values": [ "corrective", "preventive" ] }, "public.action_status": { "name": "action_status", "schema": "public", "values": [ "open", "in_progress", "done", "verified", "cancelled" ] }, "public.area_kind": { "name": "area_kind", "schema": "public", "values": [ "building", "area", "line", "other" ] }, "public.auth_token_purpose": { "name": "auth_token_purpose", "schema": "public", "values": [ "magic_link", "password_reset" ] }, "public.employment_type": { "name": "employment_type", "schema": "public", "values": [ "employee", "temporary", "contractor", "visitor" ] }, "public.incident_status": { "name": "incident_status", "schema": "public", "values": [ "reported", "triage", "investigation", "actions", "verification", "closed" ] }, "public.incident_type": { "name": "incident_type", "schema": "public", "values": [ "near_miss", "hazard", "injury", "illness", "property_damage", "environmental" ] }, "public.osha_case_type": { "name": "osha_case_type", "schema": "public", "values": [ "injury", "skin_disorder", "respiratory", "poisoning", "hearing_loss", "other_illness" ] }, "public.osha_outcome": { "name": "osha_outcome", "schema": "public", "values": [ "death", "days_away", "restricted", "other" ] }, "public.osha_special_case": { "name": "osha_special_case", "schema": "public", "values": [ "none", "needlestick", "medical_removal", "hearing_loss", "tuberculosis" ] }, "public.rca_method": { "name": "rca_method", "schema": "public", "values": [ "five_whys", "fishbone", "other" ] }, "public.report_channel": { "name": "report_channel", "schema": "public", "values": [ "web", "kiosk" ] }, "public.role": { "name": "role", "schema": "public", "values": [ "reporter", "supervisor", "safety_manager", "admin" ] }, "public.root_cause_category": { "name": "root_cause_category", "schema": "public", "values": [ "people", "process", "equipment", "materials", "environment", "management" ] }, "public.severity": { "name": "severity", "schema": "public", "values": [ "low", "medium", "high", "critical" ] }, "public.treatment_level": { "name": "treatment_level", "schema": "public", "values": [ "none", "first_aid", "medical_treatment", "hospitalized", "fatality" ] } }, "schemas": {}, "sequences": {}, "roles": {}, "policies": {}, "views": {}, "_meta": { "columns": {}, "schemas": {}, "tables": {} } }