feat(04-01): add tasks migration and sqlc query source
- CREATE TYPE task_status ENUM (todo, in_progress, in_review, done)
- CREATE TABLE tasks with tablo_id FK, position, status columns
- DROP order: table before type in Down migration (Pitfall 3)
- sqlc queries: ListTasksByTablo, InsertTask, GetTaskByID, UpdateTask, DeleteTask, MaxPositionByTabloAndStatus
- migration applied cleanly, sqlc generate produces TaskStatus type and Task struct
2026-05-15 07:22:18 +00:00
|
|
|
-- name: ListTasksByTablo :many
|
2026-05-15 20:40:25 +00:00
|
|
|
SELECT id, tablo_id, title, description, status, position, created_at, updated_at, etape_id
|
feat(04-01): add tasks migration and sqlc query source
- CREATE TYPE task_status ENUM (todo, in_progress, in_review, done)
- CREATE TABLE tasks with tablo_id FK, position, status columns
- DROP order: table before type in Down migration (Pitfall 3)
- sqlc queries: ListTasksByTablo, InsertTask, GetTaskByID, UpdateTask, DeleteTask, MaxPositionByTabloAndStatus
- migration applied cleanly, sqlc generate produces TaskStatus type and Task struct
2026-05-15 07:22:18 +00:00
|
|
|
FROM tasks
|
|
|
|
|
WHERE tablo_id = $1
|
|
|
|
|
ORDER BY status, position, created_at;
|
|
|
|
|
|
|
|
|
|
-- name: InsertTask :one
|
2026-05-15 20:40:25 +00:00
|
|
|
INSERT INTO tasks (tablo_id, title, description, status, position, etape_id)
|
|
|
|
|
VALUES ($1, $2, $3, $4, $5, $6)
|
|
|
|
|
RETURNING id, tablo_id, title, description, status, position, created_at, updated_at, etape_id;
|
feat(04-01): add tasks migration and sqlc query source
- CREATE TYPE task_status ENUM (todo, in_progress, in_review, done)
- CREATE TABLE tasks with tablo_id FK, position, status columns
- DROP order: table before type in Down migration (Pitfall 3)
- sqlc queries: ListTasksByTablo, InsertTask, GetTaskByID, UpdateTask, DeleteTask, MaxPositionByTabloAndStatus
- migration applied cleanly, sqlc generate produces TaskStatus type and Task struct
2026-05-15 07:22:18 +00:00
|
|
|
|
|
|
|
|
-- name: GetTaskByID :one
|
2026-05-15 20:40:25 +00:00
|
|
|
SELECT id, tablo_id, title, description, status, position, created_at, updated_at, etape_id
|
feat(04-01): add tasks migration and sqlc query source
- CREATE TYPE task_status ENUM (todo, in_progress, in_review, done)
- CREATE TABLE tasks with tablo_id FK, position, status columns
- DROP order: table before type in Down migration (Pitfall 3)
- sqlc queries: ListTasksByTablo, InsertTask, GetTaskByID, UpdateTask, DeleteTask, MaxPositionByTabloAndStatus
- migration applied cleanly, sqlc generate produces TaskStatus type and Task struct
2026-05-15 07:22:18 +00:00
|
|
|
FROM tasks
|
|
|
|
|
WHERE id = $1 AND tablo_id = $2;
|
|
|
|
|
|
|
|
|
|
-- name: UpdateTask :one
|
|
|
|
|
UPDATE tasks
|
2026-05-15 20:40:25 +00:00
|
|
|
SET title = $2, description = $3, status = $4, position = $5, etape_id = $6, updated_at = now()
|
feat(04-01): add tasks migration and sqlc query source
- CREATE TYPE task_status ENUM (todo, in_progress, in_review, done)
- CREATE TABLE tasks with tablo_id FK, position, status columns
- DROP order: table before type in Down migration (Pitfall 3)
- sqlc queries: ListTasksByTablo, InsertTask, GetTaskByID, UpdateTask, DeleteTask, MaxPositionByTabloAndStatus
- migration applied cleanly, sqlc generate produces TaskStatus type and Task struct
2026-05-15 07:22:18 +00:00
|
|
|
WHERE id = $1
|
2026-05-15 20:40:25 +00:00
|
|
|
RETURNING id, tablo_id, title, description, status, position, created_at, updated_at, etape_id;
|
feat(04-01): add tasks migration and sqlc query source
- CREATE TYPE task_status ENUM (todo, in_progress, in_review, done)
- CREATE TABLE tasks with tablo_id FK, position, status columns
- DROP order: table before type in Down migration (Pitfall 3)
- sqlc queries: ListTasksByTablo, InsertTask, GetTaskByID, UpdateTask, DeleteTask, MaxPositionByTabloAndStatus
- migration applied cleanly, sqlc generate produces TaskStatus type and Task struct
2026-05-15 07:22:18 +00:00
|
|
|
|
|
|
|
|
-- name: DeleteTask :exec
|
|
|
|
|
DELETE FROM tasks WHERE id = $1 AND tablo_id = $2;
|
|
|
|
|
|
|
|
|
|
-- name: MaxPositionByTabloAndStatus :one
|
|
|
|
|
SELECT COALESCE(MAX(position), 0)::integer AS max_position
|
|
|
|
|
FROM tasks
|
|
|
|
|
WHERE tablo_id = $1 AND status = $2;
|
2026-05-15 20:40:25 +00:00
|
|
|
|
|
|
|
|
-- name: ListTasksByTabloAndEtape :many
|
|
|
|
|
SELECT id, tablo_id, title, description, status, position, created_at, updated_at, etape_id
|
|
|
|
|
FROM tasks
|
|
|
|
|
WHERE tablo_id = $1 AND etape_id = $2
|
|
|
|
|
ORDER BY status, position, created_at;
|
|
|
|
|
|
|
|
|
|
-- name: ListUnassignedTasksByTablo :many
|
|
|
|
|
SELECT id, tablo_id, title, description, status, position, created_at, updated_at, etape_id
|
|
|
|
|
FROM tasks
|
|
|
|
|
WHERE tablo_id = $1 AND etape_id IS NULL
|
|
|
|
|
ORDER BY status, position, created_at;
|