-- Remove triggers
DROP TRIGGER IF EXISTS moderation_flags_updated_at ON moderation_flags;
DROP TRIGGER IF EXISTS user_status_change_log ON users;

-- Remove trigger functions
DROP FUNCTION IF EXISTS update_moderation_flags_updated_at();
DROP FUNCTION IF EXISTS log_user_status_change();

-- Remove indexes
DROP INDEX IF EXISTS idx_moderation_flags_post_id;
DROP INDEX IF EXISTS idx_moderation_flags_comment_id;
DROP INDEX IF EXISTS idx_moderation_flags_status;
DROP INDEX IF EXISTS idx_moderation_flags_created_at;
DROP INDEX IF EXISTS idx_moderation_flags_scores_gin;
DROP INDEX IF EXISTS idx_users_status;
DROP INDEX IF EXISTS idx_user_status_history_user_id;
DROP INDEX IF EXISTS idx_user_status_history_created_at;

-- Remove tables
DROP TABLE IF EXISTS user_status_history;
DROP TABLE IF EXISTS moderation_flags;

-- Remove status column from users table
ALTER TABLE users DROP COLUMN IF EXISTS status;

-- Remove comments
COMMENT ON TABLE moderation_flags IS NULL;
COMMENT ON TABLE user_status_history IS NULL;
COMMENT ON COLUMN users.status IS NULL;
