-- Disable foreign key checks to allow safe constraint dropping
SET FOREIGN_KEY_CHECKS=0;

-- Drop foreign key constraints conditionally (only if they exist)
-- This prevents syntax errors across different MySQL versions

ALTER TABLE fish.thermometers DROP FOREIGN KEY IF EXISTS fk_thermometer_manufacturerID;
ALTER TABLE fish.tankStocking DROP FOREIGN KEY IF EXISTS fk_tankStocking_tank;
ALTER TABLE fish.tankStocking DROP FOREIGN KEY IF EXISTS fk_tankStocking_species;
ALTER TABLE fish.tankSizes DROP FOREIGN KEY IF EXISTS fk_tankSizes_manufacturerID;
ALTER TABLE fish.tanks DROP FOREIGN KEY IF EXISTS fk_tanks_tankGroup;
ALTER TABLE fish.tanks DROP FOREIGN KEY IF EXISTS fk_tanks_tankSize;
ALTER TABLE fish.tanks DROP FOREIGN KEY IF EXISTS fk_tanks_thermometer;
ALTER TABLE fish.tanks DROP FOREIGN KEY IF EXISTS fk_tanks_heater;
ALTER TABLE fish.tankPlants DROP FOREIGN KEY IF EXISTS fk_tankPlants_tank;
ALTER TABLE fish.tankPlants DROP FOREIGN KEY IF EXISTS fk_tankPlants_plant;
ALTER TABLE fish.tankPhotos DROP FOREIGN KEY IF EXISTS fk_tankPhotos_tank;
ALTER TABLE fish.tankLights DROP FOREIGN KEY IF EXISTS fk_tankLights_tank;
ALTER TABLE fish.tankLights DROP FOREIGN KEY IF EXISTS fk_tankLights_light;
ALTER TABLE fish.tankGroupStorage DROP FOREIGN KEY IF EXISTS fk_tankGroupStorage_tankGroup;
ALTER TABLE fish.tankFilters DROP FOREIGN KEY IF EXISTS fk_tankFilters_tank;
ALTER TABLE fish.tankFilters DROP FOREIGN KEY IF EXISTS fk_tankFilters_filter;
ALTER TABLE fish.speciesSources DROP FOREIGN KEY IF EXISTS fk_speciesSources_species;
ALTER TABLE fish.speciesPatterns DROP FOREIGN KEY IF EXISTS fk_speciesPatterns_species;
ALTER TABLE fish.speciesFeeding DROP FOREIGN KEY IF EXISTS fk_speciesFeeding_species;
ALTER TABLE fish.speciesFeeding DROP FOREIGN KEY IF EXISTS fk_speciesFeeding_foodType;
ALTER TABLE fish.speciesAlternateNames DROP FOREIGN KEY IF EXISTS fk_speciesAlternateNames_species;
ALTER TABLE fish.species DROP FOREIGN KEY IF EXISTS fk_species_category;
ALTER TABLE fish.species DROP FOREIGN KEY IF EXISTS fk_species_subCategory;
ALTER TABLE fish.photoGalleryPhotos DROP FOREIGN KEY IF EXISTS fk_photoGalleryPhotos_photoGallery;
ALTER TABLE fish.photoGalleries DROP FOREIGN KEY IF EXISTS fk_photoGalleries_photoGalleryGroup;
ALTER TABLE fish.lightTankSizes DROP FOREIGN KEY IF EXISTS fk_lightTankSizes_light;
ALTER TABLE fish.lightTankSizes DROP FOREIGN KEY IF EXISTS fk_lightTankSizes_tankSize;
ALTER TABLE fish.lights DROP FOREIGN KEY IF EXISTS fk_lights_manufacturer;
ALTER TABLE fish.heaters DROP FOREIGN KEY IF EXISTS fk_heaters_manufacturer;
ALTER TABLE fish.filters DROP FOREIGN KEY IF EXISTS fk_filters_manufacturer;
ALTER TABLE fish.airPumps DROP FOREIGN KEY IF EXISTS fk_airPumps_manufacturer;
ALTER TABLE fish.airPumpGroupTanks DROP FOREIGN KEY IF EXISTS fk_airPumpGroupTanks_tankID;
ALTER TABLE fish.airPumpGroups DROP FOREIGN KEY IF EXISTS fk_airPumpGroups_airPumpID;

-- Re-enable foreign key constraint checking
SET FOREIGN_KEY_CHECKS=1;
