Fix consulting order processing and display
- Fix consulting history to show continuous time range (09:00 - 11:00) instead of listing individual slots - Add foreign key relationships for consulting_slots (order_id and user_id) - Fix handle-order-paid to query profiles(email, name) instead of full_name - Add completed consulting sessions with recordings to Member Access page - Add user_id foreign key constraint to consulting_slots table - Add orders foreign key constraint for consulting_slots relationship 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
This commit is contained in:
16
supabase/migrations/20251226_configure_trigger_settings.sql
Normal file
16
supabase/migrations/20251226_configure_trigger_settings.sql
Normal file
@@ -0,0 +1,16 @@
|
||||
-- Configure database settings for handle-order-paid trigger
|
||||
-- These settings are required for the payment trigger to work
|
||||
|
||||
-- Set base URL (change if different)
|
||||
DELETE FROM pg_settings WHERE name = 'app.base_url';
|
||||
ALTER DATABASE postgres SET "app.base_url" = 'https://lovable.backoffice.biz.id';
|
||||
|
||||
-- Set service role key (you need to replace this with your actual service role key)
|
||||
-- Get it from: Supabase Dashboard > Project Settings > API > service_role (confidential)
|
||||
-- Uncomment and set the actual key:
|
||||
-- ALTER DATABASE postgres SET "app.service_role_key" = 'YOUR_SERVICE_ROLE_KEY_HERE';
|
||||
|
||||
-- Verify settings
|
||||
SELECT
|
||||
current_setting('app.base_url', true) as base_url,
|
||||
current_setting('app.service_role_key', true) as service_role_key;
|
||||
@@ -0,0 +1,37 @@
|
||||
-- Add foreign key relationship between consulting_slots and profiles (user_id)
|
||||
-- This enables the relationship query in ConsultingHistory component
|
||||
|
||||
-- First, check if the foreign key already exists
|
||||
DO $$
|
||||
BEGIN
|
||||
IF NOT EXISTS (
|
||||
SELECT 1 FROM information_schema.table_constraints
|
||||
WHERE table_name = 'consulting_slots'
|
||||
AND constraint_name = 'consulting_slots_user_id_fkey'
|
||||
) THEN
|
||||
-- Add foreign key constraint if it doesn't exist
|
||||
ALTER TABLE consulting_slots
|
||||
ADD CONSTRAINT consulting_slots_user_id_fkey
|
||||
FOREIGN KEY (user_id) REFERENCES auth.users(id) ON DELETE CASCADE;
|
||||
|
||||
RAISE NOTICE 'Foreign key constraint added for user_id';
|
||||
ELSE
|
||||
RAISE NOTICE 'Foreign key constraint for user_id already exists';
|
||||
END IF;
|
||||
END $$;
|
||||
|
||||
-- Verify the relationship
|
||||
SELECT
|
||||
tc.table_name,
|
||||
kcu.column_name,
|
||||
ccu.table_name AS foreign_table_name,
|
||||
ccu.column_name AS foreign_column_name
|
||||
FROM information_schema.table_constraints AS tc
|
||||
JOIN information_schema.key_column_usage AS kcu
|
||||
ON tc.constraint_name = kcu.constraint_name
|
||||
AND tc.table_schema = kcu.table_schema
|
||||
JOIN information_schema.constraint_column_usage AS ccu
|
||||
ON ccu.constraint_name = tc.constraint_name
|
||||
WHERE tc.constraint_type = 'FOREIGN KEY'
|
||||
AND tc.table_name = 'consulting_slots'
|
||||
AND kcu.column_name = 'user_id';
|
||||
36
supabase/migrations/20251227_add_orders_foreign_key.sql
Normal file
36
supabase/migrations/20251227_add_orders_foreign_key.sql
Normal file
@@ -0,0 +1,36 @@
|
||||
-- Add foreign key relationship between consulting_slots and orders
|
||||
-- This enables the relationship query in handle-order-paid edge function
|
||||
|
||||
-- First, check if the column exists
|
||||
DO $$
|
||||
BEGIN
|
||||
IF NOT EXISTS (
|
||||
SELECT 1 FROM information_schema.table_constraints
|
||||
WHERE table_name = 'consulting_slots'
|
||||
AND constraint_name = 'consulting_slots_order_id_fkey'
|
||||
) THEN
|
||||
-- Add foreign key constraint if it doesn't exist
|
||||
ALTER TABLE consulting_slots
|
||||
ADD CONSTRAINT consulting_slots_order_id_fkey
|
||||
FOREIGN KEY (order_id) REFERENCES orders(id) ON DELETE CASCADE;
|
||||
|
||||
RAISE NOTICE 'Foreign key constraint added successfully';
|
||||
ELSE
|
||||
RAISE NOTICE 'Foreign key constraint already exists';
|
||||
END IF;
|
||||
END $$;
|
||||
|
||||
-- Verify the relationship
|
||||
SELECT
|
||||
tc.table_name,
|
||||
kcu.column_name,
|
||||
ccu.table_name AS foreign_table_name,
|
||||
ccu.column_name AS foreign_column_name
|
||||
FROM information_schema.table_constraints AS tc
|
||||
JOIN information_schema.key_column_usage AS kcu
|
||||
ON tc.constraint_name = kcu.constraint_name
|
||||
AND tc.table_schema = kcu.table_schema
|
||||
JOIN information_schema.constraint_column_usage AS ccu
|
||||
ON ccu.constraint_name = tc.constraint_name
|
||||
WHERE tc.constraint_type = 'FOREIGN KEY'
|
||||
AND tc.table_name = 'consulting_slots';
|
||||
Reference in New Issue
Block a user