Fix DB issues
This commit is contained in:
parent
21cc875cc0
commit
16abc95b4f
2 changed files with 7 additions and 6 deletions
|
|
@ -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
|
||||
|
|
@ -44,7 +44,7 @@ func DSNGenerator() string {
|
|||
|
||||
// DBInit establishes the connection to the database
|
||||
func DBInit(dsn string) (err error) {
|
||||
if db, err = sql.Open("mysql", dsn + "?parseTime=true&foreign_key_checks=1"); err != nil {
|
||||
if db, err = sql.Open("mysql", dsn+"?parseTime=true&foreign_key_checks=1"); err != nil {
|
||||
return
|
||||
}
|
||||
|
||||
|
|
@ -409,16 +409,15 @@ 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 {
|
||||
return err
|
||||
}
|
||||
}
|
||||
|
||||
if _, err := db.Exec("CREATE OR REPLACE VIEW exercice_distinct_tries AS SELECT id_exercice, id_team, MAX(time) AS time, cksum, nbdiff FROM exercice_tries GROUP BY id_team, id_exercice, cksum;"); err != nil {
|
||||
return err
|
||||
|
|
|
|||
Reference in a new issue