QA: Add new script to migrate QA content from a DB to another

This commit is contained in:
nemunaire 2021-02-05 16:56:27 +01:00
parent 2cf9723c6c
commit f4dcaa23a3
8 changed files with 208 additions and 9 deletions

View file

@ -422,7 +422,7 @@ CREATE TABLE IF NOT EXISTS claim_descriptions(
CREATE TABLE IF NOT EXISTS exercices_qa(
id_qa INTEGER NOT NULL PRIMARY KEY AUTO_INCREMENT,
id_exercice INTEGER NOT NULL,
id_team INTEGER NOT NULL,
id_team INTEGER NULL,
authuser VARCHAR(255) NOT NULL,
subject VARCHAR(255) NOT NULL,
creation TIMESTAMP NOT NULL,
@ -439,7 +439,7 @@ CREATE TABLE IF NOT EXISTS exercices_qa(
CREATE TABLE IF NOT EXISTS qa_comments(
id_comment INTEGER NOT NULL PRIMARY KEY AUTO_INCREMENT,
id_qa INTEGER NOT NULL,
id_team INTEGER NOT NULL,
id_team INTEGER NULL,
authuser VARCHAR(255) NOT NULL,
date TIMESTAMP NOT NULL,
content TEXT NOT NULL,

View file

@ -9,7 +9,7 @@ import (
type QAQuery struct {
Id int64 `json:"id"`
IdExercice int64 `json:"id_exercice"`
IdTeam int64 `json:"id_team"`
IdTeam *int64 `json:"id_team"`
User string `json:"user"`
Creation time.Time `json:"creation"`
State string `json:"state"`
@ -91,7 +91,7 @@ func (e Exercice) GetQAQuery(id int64) (q QAQuery, err error) {
}
// NewQAQuery creates and fills a new struct QAQuery and registers it into the database.
func (e Exercice) NewQAQuery(subject string, teamId int64, user string, state string) (QAQuery, error) {
func (e Exercice) NewQAQuery(subject string, teamId *int64, user string, state string) (QAQuery, error) {
if res, err := DBExec("INSERT INTO exercices_qa (id_exercice, id_team, authuser, creation, state, subject) VALUES (?, ?, ?, ?, ?, ?)", e.Id, teamId, user, time.Now(), state, subject); err != nil {
return QAQuery{}, err
} else if qid, err := res.LastInsertId(); err != nil {
@ -139,7 +139,7 @@ func ClearQAQueries() (int64, error) {
// QAComment represents some text describing a QAQuery.
type QAComment struct {
Id int64 `json:"id"`
IdTeam int64 `json:"id_team"`
IdTeam *int64 `json:"id_team"`
User string `json:"user"`
Date time.Time `json:"date"`
Content string `json:"content"`
@ -172,7 +172,7 @@ func (q QAQuery) GetComment(id int64) (c QAComment, err error) {
}
// AddComment append in the database a new description; then returns the corresponding structure.
func (q QAQuery) AddComment(content string, teamId int64, user string) (QAComment, error) {
func (q QAQuery) AddComment(content string, teamId *int64, user string) (QAComment, error) {
if res, err := DBExec("INSERT INTO qa_comments (id_qa, id_team, authuser, date, content) VALUES (?, ?, ?, ?, ?)", q.Id, teamId, user, time.Now(), content); err != nil {
return QAComment{}, err
} else if cid, err := res.LastInsertId(); err != nil {