mirror of
https://github.com/pacnpal/thrilltrack-explorer.git
synced 2025-12-23 02:11:12 -05:00
Refactor: Implement database queue infrastructure
This commit is contained in:
@@ -208,55 +208,79 @@ export type Database = {
|
||||
content_submissions: {
|
||||
Row: {
|
||||
approval_mode: string | null
|
||||
assigned_at: string | null
|
||||
assigned_to: string | null
|
||||
content: Json
|
||||
created_at: string
|
||||
escalated: boolean | null
|
||||
escalated_at: string | null
|
||||
escalated_by: string | null
|
||||
escalation_reason: string | null
|
||||
first_reviewed_at: string | null
|
||||
id: string
|
||||
locked_until: string | null
|
||||
original_submission_id: string | null
|
||||
priority: number
|
||||
resolved_at: string | null
|
||||
review_count: number | null
|
||||
reviewed_at: string | null
|
||||
reviewer_id: string | null
|
||||
reviewer_notes: string | null
|
||||
status: string
|
||||
submission_type: string
|
||||
submitted_at: string
|
||||
updated_at: string
|
||||
user_id: string
|
||||
}
|
||||
Insert: {
|
||||
approval_mode?: string | null
|
||||
assigned_at?: string | null
|
||||
assigned_to?: string | null
|
||||
content: Json
|
||||
created_at?: string
|
||||
escalated?: boolean | null
|
||||
escalated_at?: string | null
|
||||
escalated_by?: string | null
|
||||
escalation_reason?: string | null
|
||||
first_reviewed_at?: string | null
|
||||
id?: string
|
||||
locked_until?: string | null
|
||||
original_submission_id?: string | null
|
||||
priority?: number
|
||||
resolved_at?: string | null
|
||||
review_count?: number | null
|
||||
reviewed_at?: string | null
|
||||
reviewer_id?: string | null
|
||||
reviewer_notes?: string | null
|
||||
status?: string
|
||||
submission_type: string
|
||||
submitted_at?: string
|
||||
updated_at?: string
|
||||
user_id: string
|
||||
}
|
||||
Update: {
|
||||
approval_mode?: string | null
|
||||
assigned_at?: string | null
|
||||
assigned_to?: string | null
|
||||
content?: Json
|
||||
created_at?: string
|
||||
escalated?: boolean | null
|
||||
escalated_at?: string | null
|
||||
escalated_by?: string | null
|
||||
escalation_reason?: string | null
|
||||
first_reviewed_at?: string | null
|
||||
id?: string
|
||||
locked_until?: string | null
|
||||
original_submission_id?: string | null
|
||||
priority?: number
|
||||
resolved_at?: string | null
|
||||
review_count?: number | null
|
||||
reviewed_at?: string | null
|
||||
reviewer_id?: string | null
|
||||
reviewer_notes?: string | null
|
||||
status?: string
|
||||
submission_type?: string
|
||||
submitted_at?: string
|
||||
updated_at?: string
|
||||
user_id?: string
|
||||
}
|
||||
|
||||
@@ -0,0 +1,27 @@
|
||||
-- Create moderation queue in pgmq
|
||||
SELECT pgmq.create('moderation_queue');
|
||||
|
||||
-- Add queue management columns to content_submissions
|
||||
ALTER TABLE content_submissions
|
||||
ADD COLUMN IF NOT EXISTS priority INTEGER NOT NULL DEFAULT 3,
|
||||
ADD COLUMN IF NOT EXISTS assigned_to UUID REFERENCES auth.users(id),
|
||||
ADD COLUMN IF NOT EXISTS assigned_at TIMESTAMP WITH TIME ZONE,
|
||||
ADD COLUMN IF NOT EXISTS locked_until TIMESTAMP WITH TIME ZONE,
|
||||
ADD COLUMN IF NOT EXISTS submitted_at TIMESTAMP WITH TIME ZONE NOT NULL DEFAULT NOW(),
|
||||
ADD COLUMN IF NOT EXISTS first_reviewed_at TIMESTAMP WITH TIME ZONE,
|
||||
ADD COLUMN IF NOT EXISTS resolved_at TIMESTAMP WITH TIME ZONE,
|
||||
ADD COLUMN IF NOT EXISTS review_count INTEGER DEFAULT 0;
|
||||
|
||||
-- Create indexes for queue operations
|
||||
CREATE INDEX IF NOT EXISTS idx_submissions_queue_status
|
||||
ON content_submissions(status, priority DESC, submitted_at ASC)
|
||||
WHERE status IN ('pending', 'partially_approved');
|
||||
|
||||
CREATE INDEX IF NOT EXISTS idx_submissions_assigned
|
||||
ON content_submissions(assigned_to, locked_until)
|
||||
WHERE assigned_to IS NOT NULL;
|
||||
|
||||
-- Simple index on locked_until for expired lock cleanup
|
||||
CREATE INDEX IF NOT EXISTS idx_submissions_locked_until
|
||||
ON content_submissions(locked_until)
|
||||
WHERE locked_until IS NOT NULL;
|
||||
Reference in New Issue
Block a user