-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
32 changed files
with
2,767 additions
and
93 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
26 changes: 26 additions & 0 deletions
26
backend/.sqlc/migrations/20241226195458_add_default_questions.sql
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
-- +goose Up | ||
INSERT INTO project_questions (id, question, section, required, validations) VALUES | ||
( | ||
gen_random_uuid(), | ||
'What is the core product or service, and what problem does it solve?', | ||
'business_overview', | ||
true, | ||
'min=100' -- Warning if less than 100 chars | ||
), | ||
( | ||
gen_random_uuid(), | ||
'What is the unique value proposition?', | ||
'business_overview', | ||
true, | ||
'min=50' -- Warning if less than 50 chars | ||
), | ||
( | ||
gen_random_uuid(), | ||
'Company website', | ||
'business_overview', | ||
true, | ||
'url' -- Error if not valid URL | ||
); | ||
|
||
-- +goose Down | ||
DELETE FROM project_questions WHERE section = 'business_overview'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,136 @@ | ||
-- name: GetCompanyByUserID :one | ||
SELECT * FROM companies | ||
WHERE owner_id = $1 | ||
LIMIT 1; | ||
|
||
-- name: CreateProject :one | ||
INSERT INTO projects ( | ||
company_id, | ||
title, | ||
description, | ||
status, | ||
created_at, | ||
updated_at | ||
) VALUES ( | ||
$1, $2, $3, $4, $5, $6 | ||
) RETURNING *; | ||
|
||
-- name: GetProjectsByCompanyID :many | ||
SELECT * FROM projects | ||
WHERE company_id = $1 | ||
ORDER BY created_at DESC; | ||
|
||
-- name: GetProjectByID :one | ||
SELECT * FROM projects | ||
WHERE id = $1 AND company_id = $2 | ||
LIMIT 1; | ||
|
||
-- name: UpdateProjectAnswer :one | ||
UPDATE project_answers | ||
SET | ||
answer = $1, | ||
updated_at = extract(epoch from now()) | ||
WHERE | ||
project_answers.id = $2 | ||
AND project_id = $3 | ||
RETURNING *; | ||
|
||
-- name: GetProjectAnswers :many | ||
SELECT | ||
pa.id as answer_id, | ||
pa.answer, | ||
pq.id as question_id, | ||
pq.question, | ||
pq.section | ||
FROM project_answers pa | ||
JOIN project_questions pq ON pa.question_id = pq.id | ||
WHERE pa.project_id = $1 | ||
ORDER BY pq.section, pq.id; | ||
|
||
-- name: CreateProjectAnswers :many | ||
INSERT INTO project_answers (id, project_id, question_id, answer) | ||
SELECT | ||
gen_random_uuid(), | ||
$1, -- project_id | ||
pq.id, | ||
'' -- empty default answer | ||
FROM project_questions pq | ||
RETURNING *; | ||
|
||
-- name: CreateProjectDocument :one | ||
INSERT INTO project_documents ( | ||
id, | ||
project_id, | ||
name, | ||
url, | ||
section, | ||
created_at, | ||
updated_at | ||
) VALUES ( | ||
gen_random_uuid(), | ||
$1, -- project_id | ||
$2, -- name | ||
$3, -- url | ||
$4, -- section | ||
extract(epoch from now()), | ||
extract(epoch from now()) | ||
) RETURNING *; | ||
|
||
-- name: GetProjectDocuments :many | ||
SELECT * FROM project_documents | ||
WHERE project_id = $1 | ||
ORDER BY created_at DESC; | ||
|
||
-- name: DeleteProjectDocument :one | ||
DELETE FROM project_documents | ||
WHERE project_documents.id = $1 | ||
AND project_documents.project_id = $2 | ||
AND project_documents.project_id IN ( | ||
SELECT projects.id | ||
FROM projects | ||
WHERE projects.company_id = $3 | ||
) | ||
RETURNING id; | ||
|
||
-- name: GetProjectDocument :one | ||
SELECT project_documents.* FROM project_documents | ||
JOIN projects ON project_documents.project_id = projects.id | ||
WHERE project_documents.id = $1 | ||
AND project_documents.project_id = $2 | ||
AND projects.company_id = $3; | ||
|
||
-- name: ListCompanyProjects :many | ||
SELECT projects.* FROM projects | ||
WHERE company_id = $1 | ||
ORDER BY created_at DESC; | ||
|
||
-- name: GetProjectQuestions :many | ||
SELECT id, question, section, required, validations FROM project_questions; | ||
|
||
-- name: UpdateProjectStatus :exec | ||
UPDATE projects | ||
SET | ||
status = $1, | ||
updated_at = extract(epoch from now()) | ||
WHERE id = $2; | ||
|
||
-- name: GetQuestionByAnswerID :one | ||
SELECT q.* FROM project_questions q | ||
JOIN project_answers a ON a.question_id = q.id | ||
WHERE a.id = $1; | ||
|
||
-- name: GetProjectQuestion :one | ||
SELECT * FROM project_questions | ||
WHERE id = $1 | ||
LIMIT 1; | ||
|
||
-- name: CreateProjectAnswer :one | ||
INSERT INTO project_answers ( | ||
project_id, | ||
question_id, | ||
answer | ||
) VALUES ( | ||
$1, -- project_id | ||
$2, -- question_id | ||
$3 -- answer | ||
) RETURNING *; |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Oops, something went wrong.