[ST-4.2] feat: Add soft delete to education.course_reviews

- Added deleted_at and deleted_by columns for soft delete functionality
- Created migration 002-add_course_reviews_soft_delete.sql
- Added indexes for efficient active reviews queries
- Updated DDL schema definition with new columns and comments
- Gap: GAP-010

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
Adrian Flores Cortes 2026-02-03 23:57:00 -06:00
parent 82d6e608b1
commit 83fa4d3295

View File

@ -0,0 +1,26 @@
-- =====================================================
-- MIGRATION: Add soft delete to course_reviews
-- =====================================================
-- Task: ST-4.2
-- Gap: GAP-010
-- Created: 2026-02-03
-- =====================================================
-- Add soft delete columns
ALTER TABLE education.course_reviews
ADD COLUMN IF NOT EXISTS deleted_at TIMESTAMPTZ,
ADD COLUMN IF NOT EXISTS deleted_by UUID REFERENCES auth.users(id);
-- Create index for soft delete queries
CREATE INDEX IF NOT EXISTS idx_course_reviews_deleted_at
ON education.course_reviews(deleted_at)
WHERE deleted_at IS NULL;
-- Create composite index for active reviews queries
CREATE INDEX IF NOT EXISTS idx_course_reviews_active
ON education.course_reviews(course_id, deleted_at)
WHERE deleted_at IS NULL;
-- Comments
COMMENT ON COLUMN education.course_reviews.deleted_at IS 'Soft delete timestamp - cuando se marcó como eliminado';
COMMENT ON COLUMN education.course_reviews.deleted_by IS 'ID del usuario que marcó como eliminado';