Publier Globinours 1.0.0-rc.3
This commit is contained in:
parent
ea8c24d622
commit
9a2b4068da
325 changed files with 38230 additions and 20 deletions
16
migrations/046_structured_animal_intake.sql
Normal file
16
migrations/046_structured_animal_intake.sql
Normal file
|
|
@ -0,0 +1,16 @@
|
|||
ALTER TABLE animals ADD COLUMN intake_type TEXT NOT NULL DEFAULT 'unknown'
|
||||
CHECK (intake_type IN ('unknown','found','owner_surrender','transfer','born_in_care','return','seizure','other'));
|
||||
ALTER TABLE animals ADD COLUMN intake_reason TEXT NOT NULL DEFAULT 'unknown'
|
||||
CHECK (intake_reason IN ('unknown','stray_found','unwanted_litter','owner_health','owner_death','allergy','housing','financial','behavior','abandonment','danger','transfer','birth','other'));
|
||||
ALTER TABLE animals ADD COLUMN depositor_contact_id INTEGER REFERENCES directory_contacts(id) ON DELETE SET NULL;
|
||||
ALTER TABLE animals ADD COLUMN intake_circumstances TEXT;
|
||||
CREATE INDEX idx_animals_intake_type ON animals(intake_type);
|
||||
CREATE INDEX idx_animals_intake_reason ON animals(intake_reason);
|
||||
CREATE INDEX idx_animals_depositor ON animals(depositor_contact_id);
|
||||
|
||||
INSERT INTO animal_movements(animal_id,kind,place,lieu,note,created_at)
|
||||
SELECT a.id,'entry',COALESCE(NULLIF(trim(a.rescue_location_name),''),NULLIF(trim(a.rescue_address),'')),
|
||||
'Entrée historique','Informations d’entrée à compléter dans la fiche animale',
|
||||
COALESCE(NULLIF(a.intake_date,'')||' 12:00:00',a.created_at,datetime('now'))
|
||||
FROM animals a
|
||||
WHERE NOT EXISTS(SELECT 1 FROM animal_movements m WHERE m.animal_id=a.id AND m.kind='entry');
|
||||
Loading…
Add table
Add a link
Reference in a new issue