Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions internal/api/dbmodels/models.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

57 changes: 57 additions & 0 deletions internal/api/dbmodels/workshop.sql.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 3 additions & 0 deletions sql/migrations/000004_create_workshops.down.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
-- Language: sqlite

DROP TABLE IF EXISTS workshop;
10 changes: 10 additions & 0 deletions sql/migrations/000004_create_workshops.up.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
-- Language: sqlite

CREATE TABLE IF NOT EXISTS workshop (
uuid INT PRIMARY KEY,
title VARCHAR(100),
team VARCHAR(20),
semester CHAR(3),
start_at DATE,
link TEXT
);
51 changes: 51 additions & 0 deletions sql/queries/workshop.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
-- name: CreateWorkshop :exec
INSERT INTO
workshop (
uuid,
title,
team,
semester,
start_at,
link
)
VALUES
(?, ?, ?, ?, ?, ?)
RETURNING *;

-- name: GetWorkshop :one
SELECT
title,
team,
semester,
start_at,
link
FROM
workshop
WHERE
uuid = ?;

-- name: UpdateWorkshop :exec
UPDATE workshop
SET
title = COALESCE(sqlc.narg('title'), title),
team = COALESCE(sqlc.narg('team'), team),
semester = COALESCE(sqlc.narg('semester'), semester),
start_at = COALESCE(sqlc.narg('start_at'), start_at),
link = COALESCE(sqlc.narg('link'), link)
WHERE
uuid = sqlc.arg('uuid');

-- name: GetWorkshops :many
SELECT
uuid,
title,
team,
semester,
start_at,
link
FROM
workshop;

-- name: DeleteWorkshop :exec
DELETE FROM workshop
WHERE uuid = ?;
Loading