CREATE TABLE device (
    id INTEGER PRIMARY KEY NOT NULL,
    node_num INTEGER UNIQUE NOT NULL, -- meshtastic device node number (my_node_num)
    space VARCHAR(100) NOT NULL, -- Matrix space to use for this device
    control_room VARCHAR(100) NOT NULL -- control room within the space
);

CREATE TABLE remote_user (
    id INTEGER PRIMARY KEY NOT NULL,
    device INTEGER NOT NULL REFERENCES device(id),
    node_id INTEGER NOT NULL,
    node_short_name VARCHAR(4) NOT NULL,
    node_name VARCHAR(100) NOT NULL,
    room VARCHAR(100) NOT NULL
);

CREATE TABLE matrix_state (
    id INTEGER PRIMARY KEY NOT NULL,
    key TEXT UNIQUE NOT NULL,
    value TEXT NOT NULL
);
