Fix DB issues

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

View File

@ -2,10 +2,10 @@ package fic
import (
"database/sql"
_ "github.com/go-sql-driver/mysql"
"log"
"os"
"time"
_ "github.com/go-sql-driver/mysql"
)
// db stores the connection to the database
@ -409,11 +409,10 @@ CREATE TABLE IF NOT EXISTS claims(
CREATE TABLE IF NOT EXISTS claim_descriptions(
id_description INTEGER NOT NULL PRIMARY KEY AUTO_INCREMENT,
id_claim INTEGER NOT NULL,
id_assignee INTEGER NOT NULL,
id_assignee INTEGER,
date TIMESTAMP NOT NULL,
content TEXT NOT NULL,
publish BOOLEAN NOT NULL DEFAULT 0,
FOREIGN KEY(id_assignee) REFERENCES claim_assignees(id_assignee),
FOREIGN KEY(id_claim) REFERENCES claims(id_claim)
) DEFAULT CHARACTER SET = utf8mb4 COLLATE = utf8mb4_unicode_ci;
`); err != nil {

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