feat: Implement video play count tracking, refactor user update API, add missing CMS delete functions, and update database transaction handling.

This commit is contained in:
2026-01-16 13:43:58 -03:00
parent 2dffbd8b71
commit 42976236b3
11 changed files with 138 additions and 39 deletions
@@ -0,0 +1,32 @@
-- Migration: Add missing delete functions
-- Adds fn_delete_module and fn_delete_lesson which were missing from the CRUD migration
CREATE OR REPLACE FUNCTION fn_delete_module(
p_id UUID,
p_organization_id UUID
) RETURNS BOOLEAN AS $$
DECLARE
v_deleted_count INTEGER;
BEGIN
DELETE FROM modules
WHERE id = p_id AND organization_id = p_organization_id;
GET DIAGNOSTICS v_deleted_count = ROW_COUNT;
RETURN v_deleted_count > 0;
END;
$$ LANGUAGE plpgsql;
CREATE OR REPLACE FUNCTION fn_delete_lesson(
p_id UUID,
p_organization_id UUID
) RETURNS BOOLEAN AS $$
DECLARE
v_deleted_count INTEGER;
BEGIN
DELETE FROM lessons
WHERE id = p_id AND organization_id = p_organization_id;
GET DIAGNOSTICS v_deleted_count = ROW_COUNT;
RETURN v_deleted_count > 0;
END;
$$ LANGUAGE plpgsql;