refactor: remove obsolete AI image and video generation traces from courses and lessons.
This commit is contained in:
@@ -0,0 +1,47 @@
|
||||
-- Migration: Remove obsolete AI image generation traces
|
||||
-- 1. Drop columns from courses
|
||||
ALTER TABLE courses
|
||||
DROP COLUMN IF EXISTS generation_status,
|
||||
DROP COLUMN IF EXISTS generation_progress,
|
||||
DROP COLUMN IF EXISTS generation_error;
|
||||
|
||||
-- 2. Drop columns from lessons
|
||||
ALTER TABLE lessons
|
||||
DROP COLUMN IF EXISTS video_generation_status,
|
||||
DROP COLUMN IF EXISTS video_generation_error;
|
||||
|
||||
-- 3. Update fn_update_course to remove p_generation_status
|
||||
CREATE OR REPLACE FUNCTION fn_update_course(
|
||||
p_id UUID,
|
||||
p_organization_id UUID,
|
||||
p_title VARCHAR(255),
|
||||
p_description TEXT,
|
||||
p_passing_percentage INTEGER,
|
||||
p_pacing_mode VARCHAR(50),
|
||||
p_start_date TIMESTAMPTZ,
|
||||
p_end_date TIMESTAMPTZ,
|
||||
p_certificate_template VARCHAR(255) DEFAULT NULL,
|
||||
p_price DOUBLE PRECISION DEFAULT 0.0,
|
||||
p_currency VARCHAR(10) DEFAULT 'USD',
|
||||
p_marketing_metadata JSONB DEFAULT NULL,
|
||||
p_course_image_url TEXT DEFAULT NULL
|
||||
) RETURNS SETOF courses AS $$
|
||||
BEGIN
|
||||
RETURN QUERY
|
||||
UPDATE courses
|
||||
SET title = COALESCE(p_title, title),
|
||||
description = COALESCE(p_description, description),
|
||||
passing_percentage = COALESCE(p_passing_percentage, passing_percentage),
|
||||
pacing_mode = COALESCE(p_pacing_mode, pacing_mode),
|
||||
start_date = p_start_date,
|
||||
end_date = p_end_date,
|
||||
certificate_template = COALESCE(p_certificate_template, certificate_template),
|
||||
price = COALESCE(p_price, price),
|
||||
currency = COALESCE(p_currency, currency),
|
||||
marketing_metadata = COALESCE(p_marketing_metadata, marketing_metadata),
|
||||
course_image_url = COALESCE(p_course_image_url, course_image_url),
|
||||
updated_at = NOW()
|
||||
WHERE id = p_id AND organization_id = p_organization_id
|
||||
RETURNING *;
|
||||
END;
|
||||
$$ LANGUAGE plpgsql;
|
||||
@@ -419,12 +419,6 @@ pub async fn update_course(
|
||||
.map(|s| s.to_string())
|
||||
.or(existing.course_image_url);
|
||||
|
||||
let generation_status = payload
|
||||
.get("generation_status")
|
||||
.and_then(|v| v.as_str())
|
||||
.map(|s| s.to_string())
|
||||
.or(existing.generation_status);
|
||||
|
||||
// BEGIN TRANSACTION
|
||||
let mut tx = pool
|
||||
.begin()
|
||||
@@ -442,7 +436,7 @@ pub async fn update_course(
|
||||
.map_err(|e| (StatusCode::INTERNAL_SERVER_ERROR, e.to_string()))?;
|
||||
|
||||
let course = sqlx::query_as::<_, Course>(
|
||||
"SELECT * FROM fn_update_course($1, $2, $3, $4, $5, $6, $7, $8, $9, $10, $11, $12, $13, $14)",
|
||||
"SELECT * FROM fn_update_course($1, $2, $3, $4, $5, $6, $7, $8, $9, $10, $11, $12, $13)",
|
||||
)
|
||||
.bind(id)
|
||||
.bind(org_ctx.id)
|
||||
@@ -457,7 +451,6 @@ pub async fn update_course(
|
||||
.bind(currency)
|
||||
.bind(marketing_metadata)
|
||||
.bind(course_image_url)
|
||||
.bind(generation_status)
|
||||
.fetch_one(&mut *tx)
|
||||
.await
|
||||
.map_err(|e| {
|
||||
|
||||
@@ -13,7 +13,7 @@ pub struct BackgroundTask {
|
||||
pub id: Uuid,
|
||||
pub title: String,
|
||||
pub course_title: Option<String>,
|
||||
pub task_type: String, // 'transcription', 'lesson_image', 'course_image'
|
||||
pub task_type: String, // 'transcription'
|
||||
pub status: String,
|
||||
pub progress: i32,
|
||||
pub updated_at: chrono::DateTime<chrono::Utc>,
|
||||
|
||||
@@ -20,9 +20,6 @@ pub struct Course {
|
||||
pub currency: String,
|
||||
pub marketing_metadata: Option<serde_json::Value>,
|
||||
pub course_image_url: Option<String>,
|
||||
pub generation_status: Option<String>,
|
||||
pub generation_progress: Option<i32>,
|
||||
pub generation_error: Option<String>,
|
||||
pub created_at: DateTime<Utc>,
|
||||
pub updated_at: DateTime<Utc>,
|
||||
}
|
||||
@@ -44,9 +41,6 @@ impl Default for Course {
|
||||
currency: "USD".to_string(),
|
||||
marketing_metadata: None,
|
||||
course_image_url: None,
|
||||
generation_status: None,
|
||||
generation_progress: None,
|
||||
generation_error: None,
|
||||
created_at: Utc::now(),
|
||||
updated_at: Utc::now(),
|
||||
}
|
||||
@@ -107,8 +101,6 @@ impl Default for Lesson {
|
||||
due_date: None,
|
||||
important_date_type: None,
|
||||
transcription_status: None,
|
||||
video_generation_status: None,
|
||||
video_generation_error: None,
|
||||
is_previewable: false,
|
||||
created_at: Utc::now(),
|
||||
}
|
||||
|
||||
@@ -45,9 +45,6 @@ export interface Course {
|
||||
certification_info?: string;
|
||||
};
|
||||
course_image_url?: string;
|
||||
generation_status?: 'idle' | 'queued' | 'processing' | 'completed' | 'error';
|
||||
generation_progress?: number;
|
||||
generation_error?: string;
|
||||
created_at: string;
|
||||
updated_at: string;
|
||||
modules?: Module[];
|
||||
|
||||
Reference in New Issue
Block a user