ALTER TABLE animals ADD COLUMN identification_type TEXT NOT NULL DEFAULT 'unknown'
  CHECK(identification_type IN ('unknown','microchip','tattoo'));
ALTER TABLE animals ADD COLUMN identification_date TEXT;
ALTER TABLE animals ADD COLUMN identification_registration_status TEXT NOT NULL DEFAULT 'unknown'
  CHECK(identification_registration_status IN ('unknown','pending','registered'));
ALTER TABLE animals ADD COLUMN adoption_availability TEXT NOT NULL DEFAULT 'unknown'
  CHECK(adoption_availability IN ('unknown','not_available','available'));
ALTER TABLE animals ADD COLUMN adoption_available_from TEXT;
ALTER TABLE animals ADD COLUMN adoption_unavailability_reason TEXT;
UPDATE animals SET identification_type='microchip'
  WHERE COALESCE(NULLIF(TRIM(chip_id),''),NULLIF(TRIM(chip),'')) IS NOT NULL;
CREATE INDEX idx_animals_identification_type ON animals(identification_type);
CREATE INDEX idx_animals_identification_registration ON animals(identification_registration_status);
CREATE INDEX idx_animals_adoption_availability ON animals(adoption_availability);
