Koja Scripts

Database

All koja-mdt database tables with a one-line purpose, and how tables are created and migrated.

Database

koja-mdt uses oxmysql. All tables start with koja_mdt_.

How tables are created

On every start the resource runs koja-mdt.sql statement by statement. Every statement is CREATE TABLE IF NOT EXISTS, so nothing is overwritten. After that, a list of columns added since version 1 is checked and added with ALTER TABLE when missing (for example on koja_mdt_officers, koja_mdt_citations, koja_mdt_court_cases, koja_mdt_medical_bills). The web, custody, divisions and admin modules also run their own file from sql/ at start. You do not need to import anything by hand.

The only SQL file that is not run automatically is sql/jobs_fire.sql, an optional ESX script that adds a fire job with grades.

The MDT does not create or change your framework tables. It reads them through editable/server/framework.lua, see Integrations.

Tables

Staff and profiles

TablePurpose
koja_mdt_officersOne row per MDT member: department, callsign, badge, phone, photo banner, signature, suspension, duty seconds, last seen
koja_mdt_duty_sessionsDuty periods used for weekly hours and the duty heatmap
koja_mdt_commendationsRewards and strikes given to members
koja_mdt_avatarsProfile pictures captured in game, and whether the member set a custom one
koja_mdt_department_overridesDepartments created or changed in the Admin panel
koja_mdt_divisionsDivisions per department
koja_mdt_division_membersMembers of each division and their role
koja_mdt_certificationsCertification definitions per department
koja_mdt_officer_certificationsCertifications assigned to members

People, vehicles and records

TablePurpose
koja_mdt_profilesMDT data for a person: photo, notes, flags, fingerprint, DNA and gallery
koja_mdt_vehiclesMDT data for a vehicle: flags, notes, strike points, photo
koja_mdt_weaponsFirearm registry with serial, owner and status
koja_mdt_incidentsReports
koja_mdt_incident_officersOfficers on a report
koja_mdt_incident_peopleSuspects, victims and witnesses on a report, with charges, fine, months and processing state
koja_mdt_incident_vehiclesVehicles on a report
koja_mdt_chargesThe penal code, seeded from shared/penalcode.lua on first start
koja_mdt_warrantsWarrants with type, status and expiry
koja_mdt_bolosBe-on-the-lookout notices
koja_mdt_evidenceEvidence locker with chain of custody
koja_mdt_bulletinsDepartment bulletins
koja_mdt_citationsCitations, signature state and payment
koja_mdt_anpr_logPlate reader hits

Custody

TablePurpose
koja_mdt_jail_recordsJail sentences, release time and outcome
koja_mdt_impoundsImpounded vehicles with fee and hold

Court

TablePurpose
koja_mdt_court_casesCourt cases and docket data
koja_mdt_court_chargesCharges attached to a case
koja_mdt_court_hearingsScheduled hearings
koja_mdt_court_docketDocket entries (filings, motions, rulings, orders)
koja_mdt_court_linksRecords linked to a case
koja_mdt_expungementsExpungement requests
koja_mdt_expunged_recordsReports hidden from a person's record by an expungement
koja_mdt_bar_membersBar registry

Communication

TablePurpose
koja_mdt_mailMail messages
koja_mdt_mail_boxPer-recipient mailbox state (folder, read, starred, important)
koja_mdt_notificationsNotification center entries
koja_mdt_calendar_eventsCalendar events
koja_mdt_calendar_rsvpAttendance answers
koja_mdt_calendar_reactionsReactions on events
koja_mdt_calendar_commentsComments on events
koja_mdt_formsForm definitions
koja_mdt_form_submissionsSubmitted forms and their review state
koja_mdt_logsAudit log

Cameras

TablePurpose
koja_mdt_camerasCCTV camera positions and settings
koja_mdt_bodycam_sessionsBodycam recordings with route and shot count
koja_mdt_bodycam_eventsEvents inside a bodycam session

Medical

TablePurpose
koja_mdt_medical_profilesPatient medical profile: blood type, allergies, conditions, medications, emergency contact, DNR and donor state
koja_mdt_treatmentsePCR treatment reports
koja_mdt_medical_billsMedical bills
koja_mdt_admissionsHospital admissions and bed use

Web portal

TablePurpose
koja_mdt_web_accountsUsername and password hash for web sign in
koja_mdt_web_sessionsSigned-in devices
koja_mdt_web_codesOne-time login codes

Retention

Old rows are removed automatically according to the config:

DataOption
Audit logConfig.Logs.keepDays
NotificationsConfig.Notifications.keepDays
MailConfig.Mail.keepDays (0 keeps forever)
ANPR logConfig.Anpr.keepDays
Bodycam sessionsConfig.Bodycams.keepDays
Expired web sessions and codesCleaned every 15 minutes

The Admin panel can also purge old logs and expired web sessions manually.