
ALTER TABLE kandangs
    DROP CONSTRAINT IF EXISTS kandangs_project_flock_id_fkey;

ALTER TABLE kandangs
    DROP COLUMN IF EXISTS project_flock_id;

ALTER TABLE project_chickins
  DROP CONSTRAINT fk_project_flock_kandang_id,
  ADD  CONSTRAINT fk_project_flock_kandang_id
       FOREIGN KEY (project_flock_kandang_id)
       REFERENCES project_flock_kandangs(id)
       ON UPDATE CASCADE
       ON DELETE CASCADE;

ALTER TABLE project_flock_populations
  DROP CONSTRAINT fk_project_flock_kandang_id,
  ADD  CONSTRAINT fk_project_flock_kandang_id
       FOREIGN KEY (project_flock_kandang_id)
       REFERENCES project_flock_kandangs(id)
       ON UPDATE CASCADE
       ON DELETE CASCADE;
