Good morning ☀️noDB mode
Next.js app running on https://trmnl-vercel.vercel.app in production mode. (help)
-- Enable UUID Extension-- Enables the UUID generation extension for creating unique identifiersCREATE EXTENSION IF NOT EXISTS "uuid-ossp";-- Create Devices Table-- Creates the main devices table with all required fields and indexesCREATE TABLE public.devices (
id BIGSERIAL PRIMARY KEY,
friendly_id VARCHAR NOT NULL UNIQUE,
name VARCHAR NOT NULL,
mac_address VARCHAR NOT NULL UNIQUE,
api_key VARCHAR NOT NULL UNIQUE,
screen VARCHAR NULL DEFAULT NULL,
refresh_schedule JSONB NULL,
timezone TEXT NOT NULL DEFAULT 'UTC',
last_update_time TIMESTAMPTZ NULL,
next_expected_update TIMESTAMPTZ NULL,
last_refresh_duration INTEGER NULL,
battery_voltage NUMERIC NULL,
firmware_version TEXT NULL,
rssi INTEGER NULL,
created_at TIMESTAMPTZ DEFAULT CURRENT_TIMESTAMP,
updated_at TIMESTAMPTZ DEFAULT CURRENT_TIMESTAMP
);
CREATE INDEX idx_devices_refresh_schedule ON public.devices USING GIN (refresh_schedule);-- Create Logs Table-- Creates the logs table for device activity tracking with foreign key constraintsCREATE TABLE public.logs (
id BIGSERIAL PRIMARY KEY,
friendly_id TEXT NULL,
log_data TEXT NOT NULL,
created_at TIMESTAMPTZ DEFAULT CURRENT_TIMESTAMP,
CONSTRAINT logs_friendly_id_fkey FOREIGN KEY (friendly_id) REFERENCES public.devices (friendly_id)
);-- Create System Logs Table-- Creates the system logs table with indexes for efficient queryingCREATE TABLE public.system_logs (
id UUID DEFAULT uuid_generate_v4() PRIMARY KEY,
created_at TIMESTAMPTZ DEFAULT now(),
level VARCHAR NOT NULL,
message TEXT NOT NULL,
source VARCHAR NULL,
metadata TEXT NULL,
trace TEXT NULL
);
CREATE INDEX idx_system_logs_created_at ON public.system_logs (created_at);
CREATE INDEX idx_system_logs_level ON public.system_logs (level);
System Information
Latest Screen
System Status
Overview of all connected devices
Online Devices
Offline Devices
Recent System Logs
Latest system events and alerts
Time | Level | Message | Source | Metadata |
---|---|---|---|---|