Fix DB issues

This commit is contained in:
nemunaire 2020-05-16 03:49:27 +02:00
commit 16abc95b4f
2 changed files with 7 additions and 6 deletions

View file

@ -235,7 +235,9 @@ func (e Exercice) Delete() (int64, error) {
func (e Exercice) DeleteCascade() (int64, error) {
if _, err := DBExec("UPDATE exercices SET id_depend = NULL WHERE id_depend = ?", e.Id); err != nil {
return 0, err
} else if _, err := DBExec("DELETE FROM exercice_files_deps WHERE id_file IN (SELECT id_file FROM exercice_files WHERE id_exercice = ?)", e.Id); err != nil {
} else if _, err := DBExec("DELETE FROM exercice_files_okey_deps WHERE id_file IN (SELECT id_file FROM exercice_files WHERE id_exercice = ?)", e.Id); err != nil {
return 0, err
} else if _, err := DBExec("DELETE FROM exercice_files_omcq_deps WHERE id_file IN (SELECT id_file FROM exercice_files WHERE id_exercice = ?)", e.Id); err != nil {
return 0, err
} else if _, err := DBExec("DELETE FROM exercice_files WHERE id_exercice = ?", e.Id); err != nil {
return 0, err