Delete species
This commit is contained in:
parent
50bee9ab88
commit
20026ebfd9
4 changed files with 13 additions and 2 deletions
|
@ -155,3 +155,13 @@ func (s SpeciesService) Create(e *types.Entity, genus string, claims *types.Clai
|
|||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
// Delete deletes a single species
|
||||
func (s SpeciesService) Delete(id int64, genus string, claims *types.Claims) *types.AppError {
|
||||
q := `DELETE FROM species WHERE id=$1;`
|
||||
// TODO: fix this
|
||||
if _, err := models.DBH.Exec(q, id); err != nil {
|
||||
return newJSONError(err, http.StatusInternalServerError)
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
|
|
@ -74,6 +74,7 @@ func Handler() http.Handler {
|
|||
r{handleCreater(speciesService), "POST", "/species"},
|
||||
r{handleGetter(speciesService), "GET", "/species/{ID:.+}"},
|
||||
r{handleUpdater(speciesService), "PUT", "/species/{ID:.+}"},
|
||||
r{handleDeleter(speciesService), "DELETE", "/species/{ID:.+}"},
|
||||
r{handleLister(strainService), "GET", "/strains"},
|
||||
r{handleCreater(strainService), "POST", "/strains"},
|
||||
r{handleGetter(strainService), "GET", "/strains/{ID:.+}"},
|
||||
|
|
|
@ -21,7 +21,7 @@ CREATE TABLE strains (
|
|||
deleted_by BIGINT NULL,
|
||||
|
||||
CONSTRAINT strain_pkey PRIMARY KEY (id),
|
||||
FOREIGN KEY (species_id) REFERENCES species(id),
|
||||
FOREIGN KEY (species_id) REFERENCES species(id) ON DELETE CASCADE,
|
||||
FOREIGN KEY (created_by) REFERENCES users(id),
|
||||
FOREIGN KEY (updated_by) REFERENCES users(id),
|
||||
FOREIGN KEY (deleted_by) REFERENCES users(id)
|
||||
|
|
|
@ -20,7 +20,7 @@ CREATE TABLE measurements (
|
|||
updated_by BIGINT NOT NULL,
|
||||
|
||||
CONSTRAINT strainscharmeasurements_pkey PRIMARY KEY (id),
|
||||
FOREIGN KEY (strain_id) REFERENCES strains(id),
|
||||
FOREIGN KEY (strain_id) REFERENCES strains(id) ON DELETE CASCADE,
|
||||
FOREIGN KEY (characteristic_id) REFERENCES characteristics(id) ON DELETE CASCADE,
|
||||
FOREIGN KEY (text_measurement_type_id) REFERENCES text_measurement_types(id),
|
||||
FOREIGN KEY (unit_type_id) REFERENCES unit_types(id),
|
||||
|
|
Reference in a new issue