2026-03-06 11:33:32 -06:00
|
|
|
CREATE TABLE IF NOT EXISTS employees (
|
|
|
|
|
id INTEGER PRIMARY KEY AUTOINCREMENT,
|
2026-03-06 12:53:40 -06:00
|
|
|
name TEXT NOT NULL,
|
2026-03-06 11:33:32 -06:00
|
|
|
department TEXT,
|
|
|
|
|
supervisor TEXT,
|
|
|
|
|
created_at DATETIME DEFAULT CURRENT_TIMESTAMP
|
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
CREATE TABLE IF NOT EXISTS violations (
|
2026-03-06 14:59:55 -06:00
|
|
|
id INTEGER PRIMARY KEY AUTOINCREMENT,
|
|
|
|
|
employee_id INTEGER NOT NULL REFERENCES employees(id),
|
|
|
|
|
violation_type TEXT NOT NULL,
|
|
|
|
|
violation_name TEXT NOT NULL,
|
|
|
|
|
category TEXT NOT NULL DEFAULT 'General',
|
|
|
|
|
points INTEGER NOT NULL,
|
|
|
|
|
incident_date TEXT NOT NULL,
|
|
|
|
|
incident_time TEXT,
|
|
|
|
|
location TEXT,
|
|
|
|
|
details TEXT,
|
|
|
|
|
submitted_by TEXT,
|
|
|
|
|
witness_name TEXT,
|
|
|
|
|
negated INTEGER NOT NULL DEFAULT 0,
|
|
|
|
|
negated_at DATETIME,
|
|
|
|
|
prior_active_points INTEGER, -- snapshot at time of logging
|
|
|
|
|
prior_tier_label TEXT, -- optional human-readable tier
|
2026-03-07 21:30:47 -06:00
|
|
|
acknowledged_by TEXT, -- employee name who acknowledged receipt
|
|
|
|
|
acknowledged_date TEXT, -- date of acknowledgment (YYYY-MM-DD)
|
2026-05-11 12:04:34 -05:00
|
|
|
amount TEXT, -- dollar amount in question for financial violations (record-keeping / repayment)
|
2026-03-06 14:59:55 -06:00
|
|
|
created_at DATETIME DEFAULT CURRENT_TIMESTAMP
|
2026-03-06 12:53:40 -06:00
|
|
|
);
|
|
|
|
|
|
|
|
|
|
CREATE TABLE IF NOT EXISTS violation_resolutions (
|
2026-03-06 11:33:32 -06:00
|
|
|
id INTEGER PRIMARY KEY AUTOINCREMENT,
|
2026-03-06 12:53:40 -06:00
|
|
|
violation_id INTEGER NOT NULL REFERENCES violations(id) ON DELETE CASCADE,
|
|
|
|
|
resolution_type TEXT NOT NULL,
|
2026-03-06 11:33:32 -06:00
|
|
|
details TEXT,
|
2026-03-06 12:53:40 -06:00
|
|
|
resolved_by TEXT,
|
2026-03-06 11:33:32 -06:00
|
|
|
created_at DATETIME DEFAULT CURRENT_TIMESTAMP
|
|
|
|
|
);
|
|
|
|
|
|
2026-05-27 21:41:57 -05:00
|
|
|
-- CPAS standing (active points + roll-off schedule) is computed in JS from the
|
|
|
|
|
-- clean-cycle model in lib/rolloff.js; see db/database.js for why the old
|
|
|
|
|
-- active_cpas_scores view was retired.
|