-- Drop existing functions from the previous schema to avoid conflicts
-- This file should be run before applying the new schema

-- Drop functions from the user_points system
DROP FUNCTION IF EXISTS increment_user_points;
DROP FUNCTION IF EXISTS get_current_points;
DROP FUNCTION IF EXISTS create_user_points;
DROP FUNCTION IF EXISTS create_point_transaction;
DROP FUNCTION IF EXISTS get_user_transactions;

-- Drop functions from schema updates
DROP FUNCTION IF EXISTS get_next_transaction_id;
DROP FUNCTION IF EXISTS insert_transaction_with_id;
DROP FUNCTION IF EXISTS insert_minimal_transaction;
DROP FUNCTION IF EXISTS ensure_user_exists;
DROP FUNCTION IF EXISTS get_user_points_by_id;
DROP FUNCTION IF EXISTS force_set_user_points;
DROP FUNCTION IF EXISTS create_user_with_raw_sql;
DROP FUNCTION IF EXISTS check_duplicate_upload;
DROP FUNCTION IF EXISTS get_user_total_points;

-- The following commands can be used to drop the user_points table after migrating all data
-- This is commented out as it should be run manually after ensuring successful data migration
-- DROP TABLE IF EXISTS user_points;