CREATE TABLE IF NOT EXISTS services (
    name TEXT PRIMARY KEY,
    module_name TEXT NOT NULL,
    server_type TEXT NOT NULL DEFAULT 'internal',
    pid INTEGER,
    port INTEGER NOT NULL,
    status TEXT NOT NULL DEFAULT 'stopped',
    binary_mtime BIGINT,
    created_at TIMESTAMPTZ NOT NULL DEFAULT CURRENT_TIMESTAMP,
    updated_at TIMESTAMPTZ NOT NULL DEFAULT CURRENT_TIMESTAMP
);

CREATE INDEX IF NOT EXISTS idx_services_status ON services(status);
CREATE INDEX IF NOT EXISTS idx_services_module ON services(module_name);
