- Add full database schema with accounts, dishes, ingredients, categories, and pricing - Implement custom types for weight, currency, recipe difficulty, and color hex - Add soft delete pattern with deleted_at and active views for all tables - Include journaling triggers for created_at/updated_at automation feat: add SQLC configuration with proper type overrides - Configure SQLC to use UUID, decimal, and timestamptz types with proper Go mappings - Add github.com/shopspring/decimal dependency for precise decimal handling - Set up proper pointer handling for nullable fields in generated structs refactor: replace simple food_items with full dish management system - Remove old FoodItem model and replace with comprehensive Dish model - Implement dish creation and retrieval queries with full field support - Add ingredient management with weight/amount tracking chore: update infrastructure dependencies - Switch to custom PostgreSQL image with pg_idkit extension for UUIDv7 support - Add DATABASE_URI environment variable configuration - Update Docker Compose configuration for new database image chore: organize SQL with fold markers and section comments - Add vim fold markers for better code navigation - Structure schema into clear sections: extensions, types, tables, triggers - Separate query files with organized comment blocks
81 lines
1.8 KiB
Go
81 lines
1.8 KiB
Go
// Code generated by sqlc. DO NOT EDIT.
|
|
// versions:
|
|
// sqlc v1.30.0
|
|
// source: query.sql
|
|
|
|
package db
|
|
|
|
import (
|
|
"context"
|
|
|
|
"github.com/google/uuid"
|
|
)
|
|
|
|
const createDish = `-- name: CreateDish :one
|
|
INSERT INTO dishes(title, description, difficulty, thumbnail_s3_key)
|
|
VALUES($1, $2, $3, $4)
|
|
RETURNING guid, title, description, instructions, preparation_time_minutes, cooking_time_minutes, difficulty, thumbnail_s3_key, made_public_at, tags, author, created_at, updated_at, deleted_at
|
|
`
|
|
|
|
type CreateDishParams struct {
|
|
Title string
|
|
Description *string
|
|
Difficulty RecipeDifficulty
|
|
ThumbnailS3Key *uuid.UUID
|
|
}
|
|
|
|
func (q *Queries) CreateDish(ctx context.Context, arg CreateDishParams) (Dish, error) {
|
|
row := q.db.QueryRow(ctx, createDish,
|
|
arg.Title,
|
|
arg.Description,
|
|
arg.Difficulty,
|
|
arg.ThumbnailS3Key,
|
|
)
|
|
var i Dish
|
|
err := row.Scan(
|
|
&i.Guid,
|
|
&i.Title,
|
|
&i.Description,
|
|
&i.Instructions,
|
|
&i.PreparationTimeMinutes,
|
|
&i.CookingTimeMinutes,
|
|
&i.Difficulty,
|
|
&i.ThumbnailS3Key,
|
|
&i.MadePublicAt,
|
|
&i.Tags,
|
|
&i.Author,
|
|
&i.CreatedAt,
|
|
&i.UpdatedAt,
|
|
&i.DeletedAt,
|
|
)
|
|
return i, err
|
|
}
|
|
|
|
const getDish = `-- name: GetDish :one
|
|
SELECT guid, title, description, instructions, preparation_time_minutes, cooking_time_minutes, difficulty, thumbnail_s3_key, made_public_at, tags, author, created_at, updated_at, deleted_at FROM active_dishes
|
|
WHERE guid = $1
|
|
LIMIT 1
|
|
`
|
|
|
|
func (q *Queries) GetDish(ctx context.Context, guid uuid.UUID) (ActiveDish, error) {
|
|
row := q.db.QueryRow(ctx, getDish, guid)
|
|
var i ActiveDish
|
|
err := row.Scan(
|
|
&i.Guid,
|
|
&i.Title,
|
|
&i.Description,
|
|
&i.Instructions,
|
|
&i.PreparationTimeMinutes,
|
|
&i.CookingTimeMinutes,
|
|
&i.Difficulty,
|
|
&i.ThumbnailS3Key,
|
|
&i.MadePublicAt,
|
|
&i.Tags,
|
|
&i.Author,
|
|
&i.CreatedAt,
|
|
&i.UpdatedAt,
|
|
&i.DeletedAt,
|
|
)
|
|
return i, err
|
|
}
|