feat(database): add script to reset product data and related tables

This commit is contained in:
Nils-Johan Gynther
2026-04-17 21:20:45 +02:00
parent cc8be88462
commit befa15609a
+21
View File
@@ -0,0 +1,21 @@
-- reset_products.sql
-- Rensar all produktdata och relaterade tabeller.
-- Behåller: User, Category (med seed-data), Recipe, MealPlanEntry, RecipeShare
-- Kör: docker exec -i recipe-db mariadb -u recipe_user -pSITT_LÖSENORD recipe_db < db/reset_products.sql
SET FOREIGN_KEY_CHECKS = 0;
TRUNCATE TABLE `ReceiptAlias`;
TRUNCATE TABLE `InventoryConsumption`;
TRUNCATE TABLE `InventoryItem`;
TRUNCATE TABLE `PantryItem`;
TRUNCATE TABLE `Nutrition`;
TRUNCATE TABLE `ProductTag`;
TRUNCATE TABLE `Tag`;
TRUNCATE TABLE `UserProduct`;
TRUNCATE TABLE `RecipeIngredient`;
TRUNCATE TABLE `Product`;
SET FOREIGN_KEY_CHECKS = 1;
SELECT 'Klar! Produktdata borttagen.' AS status;