<?php
$conn = new mysqli('localhost', 'root', '', 'granny_restaurant');
if ($conn->connect_error) die(json_encode(['success' => false, 'message' => 'Connection failed: ' . $conn->connect_error]));

// Clear existing recipes and ingredients
$conn->query('DELETE FROM ingredient_allocations');
$conn->query('DELETE FROM recipe_ingredients');
$conn->query('DELETE FROM recipes');
$conn->query('DELETE FROM kot_tickets');
$conn->query('DELETE FROM ingredients');

// Reset auto-increment
$conn->query('ALTER TABLE recipes AUTO_INCREMENT = 1');
$conn->query('ALTER TABLE recipe_ingredients AUTO_INCREMENT = 1');
$conn->query('ALTER TABLE ingredients AUTO_INCREMENT = 1');
$conn->query('ALTER TABLE ingredient_allocations AUTO_INCREMENT = 1');
$conn->query('ALTER TABLE kot_tickets AUTO_INCREMENT = 1');

echo json_encode(['success' => true, 'message' => 'All recipe data cleared successfully']);
