CREATE TABLE ship_messages (
    id INTEGER PRIMARY KEY AUTOINCREMENT,
    timestamp TEXT NOT NULL,
    subsystem TEXT NOT NULL,
    severity TEXT CHECK(
        severity IN ('CRITICAL', 'ALERT', 'WARNING', 'NOTICE', 'INFO')
    ) NOT NULL DEFAULT 'INFO',
    color TEXT NOT NULL,
    message TEXT NOT NULL
);

CREATE TABLE crew_member (
    id INTEGER PRIMARY KEY AUTOINCREMENT,
    rank TEXT NOT NULL,
    name TEXT NOT NULL
);

CREATE TABLE roster (
    id INTEGER PRIMARY KEY AUTOINCREMENT,
    crew_id INTEGER NOT NULL,
    on_duty timestamp,
    off_duty timestamp, 
    FOREIGN KEY (crew_id) REFERENCES crew_member(id)
);

CREATE TABLE events (
    id INTEGER PRIMARY KEY AUTOINCREMENT,
    created_at DATETIME DEFAULT CURRENT_TIMESTAMP,
    event_type TEXT NOT NULL,
    event_data   JSON NOT NULL
);

