update new queries with new bool var start
This commit is contained in:
parent
0adfe44ab8
commit
aadccd6571
@ -282,8 +282,7 @@ WHERE privilege_name = $2
|
||||
AND (amount < $3 OR created_at <= NOW() - INTERVAL '1 month');
|
||||
|
||||
-- name: GetAllAnswersByQuizID :many
|
||||
SELECT DISTINCT ON(question_id) content, created_at, question_id, id FROM answer WHERE session = $1 ORDER BY question_id ASC, created_at DESC;
|
||||
|
||||
SELECT DISTINCT ON(question_id) content, created_at, question_id, id FROM answer WHERE session = $1 AND start = false ORDER BY question_id ASC, created_at DESC;
|
||||
-- name: InsertAnswers :exec
|
||||
INSERT INTO answer(
|
||||
content,
|
||||
@ -297,12 +296,13 @@ INSERT INTO answer(
|
||||
device,
|
||||
os,
|
||||
browser,
|
||||
ip
|
||||
) VALUES ($1,$2,$3,$4,$5,$6,$7,$8,$9,$10,$11,$12);
|
||||
ip,
|
||||
start
|
||||
) VALUES ($1,$2,$3,$4,$5,$6,$7,$8,$9,$10,$11,$12,$13);
|
||||
|
||||
-- name: GetResultAnswers :many
|
||||
SELECT DISTINCT on (question_id) id, content, quiz_id, question_id, fingerprint, session,created_at, result, new,deleted FROM answer WHERE session = (
|
||||
SELECT session FROM answer WHERE answer.id = $1) ORDER BY question_id, created_at DESC;
|
||||
SELECT session FROM answer WHERE answer.id = $1) AND start = false ORDER BY question_id, created_at DESC;
|
||||
|
||||
-- name: GetQuestions :many
|
||||
SELECT id, quiz_id, title, description, questiontype, required, deleted, page, content, version, parent_ids, created_at, updated_at FROM question WHERE quiz_id = $1 AND deleted = FALSE;
|
||||
@ -314,7 +314,7 @@ UPDATE answer SET deleted = TRUE WHERE id = $1 AND deleted = FALSE;
|
||||
SELECT a.id
|
||||
FROM answer a
|
||||
JOIN quiz q ON a.quiz_id = q.id
|
||||
WHERE a.id = ANY($1::bigint[]) AND a.deleted = FALSE AND q.accountid = $2;
|
||||
WHERE a.id = ANY($1::bigint[]) AND a.deleted = FALSE AND q.accountid = $2 AND a.start = false;
|
||||
|
||||
-- name: CheckResultOwner :one
|
||||
SELECT q.accountid FROM answer a JOIN quiz q ON a.quiz_id = q.id WHERE a.id = $1 AND a.deleted = FALSE;
|
||||
SELECT q.accountid FROM answer a JOIN quiz q ON a.quiz_id = q.id WHERE a.id = $1 AND a.deleted = FALSE AND a.start = false;
|
2
dal/schema/000007_init.down.sql
Normal file
2
dal/schema/000007_init.down.sql
Normal file
@ -0,0 +1,2 @@
|
||||
ALTER TABLE answer
|
||||
DROP COLUMN start;
|
2
dal/schema/000007_init.up.sql
Normal file
2
dal/schema/000007_init.up.sql
Normal file
@ -0,0 +1,2 @@
|
||||
ALTER TABLE answer
|
||||
ADD COLUMN start BOOLEAN NOT NULL DEFAULT FALSE;
|
@ -16,6 +16,8 @@ packages:
|
||||
- "./dal/schema/000005_init.down.sql"
|
||||
- "./dal/schema/000006_init.up.sql"
|
||||
- "./dal/schema/000006_init.down.sql"
|
||||
- "./dal/schema/000007_init.up.sql"
|
||||
- "./dal/schema/000007_init.down.sql"
|
||||
engine: "postgresql"
|
||||
emit_json_tags: true
|
||||
emit_db_tags: true
|
||||
|
Loading…
Reference in New Issue
Block a user