- 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
404 lines
8.7 KiB
Go
404 lines
8.7 KiB
Go
// Code generated by sqlc. DO NOT EDIT.
|
|
// versions:
|
|
// sqlc v1.30.0
|
|
|
|
package db
|
|
|
|
import (
|
|
"database/sql/driver"
|
|
"fmt"
|
|
"time"
|
|
|
|
"github.com/google/uuid"
|
|
"github.com/shopspring/decimal"
|
|
)
|
|
|
|
type Currency string
|
|
|
|
const (
|
|
CurrencyRUB Currency = "RUB"
|
|
CurrencyEUR Currency = "EUR"
|
|
CurrencyUSD Currency = "USD"
|
|
)
|
|
|
|
func (e *Currency) Scan(src interface{}) error {
|
|
switch s := src.(type) {
|
|
case []byte:
|
|
*e = Currency(s)
|
|
case string:
|
|
*e = Currency(s)
|
|
default:
|
|
return fmt.Errorf("unsupported scan type for Currency: %T", src)
|
|
}
|
|
return nil
|
|
}
|
|
|
|
type NullCurrency struct {
|
|
Currency Currency
|
|
Valid bool // Valid is true if Currency is not NULL
|
|
}
|
|
|
|
// Scan implements the Scanner interface.
|
|
func (ns *NullCurrency) Scan(value interface{}) error {
|
|
if value == nil {
|
|
ns.Currency, ns.Valid = "", false
|
|
return nil
|
|
}
|
|
ns.Valid = true
|
|
return ns.Currency.Scan(value)
|
|
}
|
|
|
|
// Value implements the driver Valuer interface.
|
|
func (ns NullCurrency) Value() (driver.Value, error) {
|
|
if !ns.Valid {
|
|
return nil, nil
|
|
}
|
|
return string(ns.Currency), nil
|
|
}
|
|
|
|
type RecipeDifficulty string
|
|
|
|
const (
|
|
RecipeDifficultyBeginner RecipeDifficulty = "beginner"
|
|
RecipeDifficultyEasy RecipeDifficulty = "easy"
|
|
RecipeDifficultyMedium RecipeDifficulty = "medium"
|
|
RecipeDifficultyHard RecipeDifficulty = "hard"
|
|
RecipeDifficultyExpert RecipeDifficulty = "expert"
|
|
)
|
|
|
|
func (e *RecipeDifficulty) Scan(src interface{}) error {
|
|
switch s := src.(type) {
|
|
case []byte:
|
|
*e = RecipeDifficulty(s)
|
|
case string:
|
|
*e = RecipeDifficulty(s)
|
|
default:
|
|
return fmt.Errorf("unsupported scan type for RecipeDifficulty: %T", src)
|
|
}
|
|
return nil
|
|
}
|
|
|
|
type NullRecipeDifficulty struct {
|
|
RecipeDifficulty RecipeDifficulty
|
|
Valid bool // Valid is true if RecipeDifficulty is not NULL
|
|
}
|
|
|
|
// Scan implements the Scanner interface.
|
|
func (ns *NullRecipeDifficulty) Scan(value interface{}) error {
|
|
if value == nil {
|
|
ns.RecipeDifficulty, ns.Valid = "", false
|
|
return nil
|
|
}
|
|
ns.Valid = true
|
|
return ns.RecipeDifficulty.Scan(value)
|
|
}
|
|
|
|
// Value implements the driver Valuer interface.
|
|
func (ns NullRecipeDifficulty) Value() (driver.Value, error) {
|
|
if !ns.Valid {
|
|
return nil, nil
|
|
}
|
|
return string(ns.RecipeDifficulty), nil
|
|
}
|
|
|
|
type Weight string
|
|
|
|
const (
|
|
WeightMg Weight = "mg"
|
|
WeightG Weight = "g"
|
|
WeightKg Weight = "kg"
|
|
WeightLb Weight = "lb"
|
|
WeightOz Weight = "oz"
|
|
)
|
|
|
|
func (e *Weight) Scan(src interface{}) error {
|
|
switch s := src.(type) {
|
|
case []byte:
|
|
*e = Weight(s)
|
|
case string:
|
|
*e = Weight(s)
|
|
default:
|
|
return fmt.Errorf("unsupported scan type for Weight: %T", src)
|
|
}
|
|
return nil
|
|
}
|
|
|
|
type NullWeight struct {
|
|
Weight Weight
|
|
Valid bool // Valid is true if Weight is not NULL
|
|
}
|
|
|
|
// Scan implements the Scanner interface.
|
|
func (ns *NullWeight) Scan(value interface{}) error {
|
|
if value == nil {
|
|
ns.Weight, ns.Valid = "", false
|
|
return nil
|
|
}
|
|
ns.Valid = true
|
|
return ns.Weight.Scan(value)
|
|
}
|
|
|
|
// Value implements the driver Valuer interface.
|
|
func (ns NullWeight) Value() (driver.Value, error) {
|
|
if !ns.Valid {
|
|
return nil, nil
|
|
}
|
|
return string(ns.Weight), nil
|
|
}
|
|
|
|
type Account struct {
|
|
Guid uuid.UUID
|
|
Username string
|
|
CreatedAt time.Time
|
|
UpdatedAt time.Time
|
|
DeletedAt *time.Time
|
|
}
|
|
|
|
type ActiveAccount struct {
|
|
Guid uuid.UUID
|
|
Username string
|
|
CreatedAt time.Time
|
|
UpdatedAt time.Time
|
|
DeletedAt *time.Time
|
|
}
|
|
|
|
type ActiveDish struct {
|
|
Guid uuid.UUID
|
|
Title string
|
|
Description *string
|
|
Instructions *string
|
|
PreparationTimeMinutes *int16
|
|
CookingTimeMinutes *int16
|
|
Difficulty RecipeDifficulty
|
|
ThumbnailS3Key *uuid.UUID
|
|
MadePublicAt *time.Time
|
|
Tags []string
|
|
Author *uuid.UUID
|
|
CreatedAt time.Time
|
|
UpdatedAt time.Time
|
|
DeletedAt *time.Time
|
|
}
|
|
|
|
type ActiveDishCategory struct {
|
|
Guid uuid.UUID
|
|
Title string
|
|
Description *string
|
|
Color *string
|
|
SortOrder *int16
|
|
ThumbnailS3Key *uuid.UUID
|
|
Author *uuid.UUID
|
|
CreatedAt time.Time
|
|
UpdatedAt time.Time
|
|
DeletedAt *time.Time
|
|
}
|
|
|
|
type ActiveDishCategoryDish struct {
|
|
Guid uuid.UUID
|
|
DishCategoryGuid uuid.UUID
|
|
DishGuid uuid.UUID
|
|
Author *uuid.UUID
|
|
CreatedAt time.Time
|
|
UpdatedAt time.Time
|
|
DeletedAt *time.Time
|
|
}
|
|
|
|
type ActiveDishIngredient struct {
|
|
Guid uuid.UUID
|
|
DishGuid uuid.UUID
|
|
IngredientGuid uuid.UUID
|
|
Amount *decimal.Decimal
|
|
Weight *decimal.Decimal
|
|
WeightUnit Weight
|
|
Notes *string
|
|
Author *uuid.UUID
|
|
CreatedAt time.Time
|
|
UpdatedAt time.Time
|
|
DeletedAt *time.Time
|
|
}
|
|
|
|
type ActiveIngredient struct {
|
|
Guid uuid.UUID
|
|
Title string
|
|
Description *string
|
|
ThumbnailS3Key *uuid.UUID
|
|
MadePublicAt *time.Time
|
|
Tags []string
|
|
Author *uuid.UUID
|
|
CreatedAt time.Time
|
|
UpdatedAt time.Time
|
|
DeletedAt *time.Time
|
|
}
|
|
|
|
type ActiveIngredientPrice struct {
|
|
Guid uuid.UUID
|
|
IngredientGuid uuid.UUID
|
|
Price decimal.Decimal
|
|
PriceCurrency Currency
|
|
Weight decimal.Decimal
|
|
WeightUnit Weight
|
|
StoreGuid uuid.UUID
|
|
Author *uuid.UUID
|
|
CreatedAt time.Time
|
|
UpdatedAt time.Time
|
|
DeletedAt *time.Time
|
|
}
|
|
|
|
type ActiveLoginInfo struct {
|
|
Guid uuid.UUID
|
|
AccountGuid uuid.UUID
|
|
Email *string
|
|
PasswordHash string
|
|
SuspendedAt *time.Time
|
|
SuspendedReason *string
|
|
CreatedAt time.Time
|
|
UpdatedAt time.Time
|
|
DeletedAt *time.Time
|
|
}
|
|
|
|
type ActiveProfile struct {
|
|
Guid uuid.UUID
|
|
AccountGuid uuid.UUID
|
|
Name string
|
|
Surname *string
|
|
Patronymic *string
|
|
CreatedAt time.Time
|
|
UpdatedAt time.Time
|
|
DeletedAt *time.Time
|
|
}
|
|
|
|
type ActiveStore struct {
|
|
Guid uuid.UUID
|
|
Title string
|
|
Description *string
|
|
ThumbnailS3Key *uuid.UUID
|
|
Author *uuid.UUID
|
|
CreatedAt time.Time
|
|
UpdatedAt time.Time
|
|
DeletedAt *time.Time
|
|
}
|
|
|
|
type Dish struct {
|
|
Guid uuid.UUID
|
|
Title string
|
|
Description *string
|
|
Instructions *string
|
|
PreparationTimeMinutes *int16
|
|
CookingTimeMinutes *int16
|
|
Difficulty RecipeDifficulty
|
|
ThumbnailS3Key *uuid.UUID
|
|
MadePublicAt *time.Time
|
|
Tags []string
|
|
Author *uuid.UUID
|
|
CreatedAt time.Time
|
|
UpdatedAt time.Time
|
|
DeletedAt *time.Time
|
|
}
|
|
|
|
type DishCategoriesDish struct {
|
|
Guid uuid.UUID
|
|
DishCategoryGuid uuid.UUID
|
|
DishGuid uuid.UUID
|
|
Author *uuid.UUID
|
|
CreatedAt time.Time
|
|
UpdatedAt time.Time
|
|
DeletedAt *time.Time
|
|
}
|
|
|
|
type DishCategory struct {
|
|
Guid uuid.UUID
|
|
Title string
|
|
Description *string
|
|
Color *string
|
|
SortOrder *int16
|
|
ThumbnailS3Key *uuid.UUID
|
|
Author *uuid.UUID
|
|
CreatedAt time.Time
|
|
UpdatedAt time.Time
|
|
DeletedAt *time.Time
|
|
}
|
|
|
|
type DishIngredient struct {
|
|
Guid uuid.UUID
|
|
DishGuid uuid.UUID
|
|
IngredientGuid uuid.UUID
|
|
Amount *decimal.Decimal
|
|
Weight *decimal.Decimal
|
|
WeightUnit Weight
|
|
Notes *string
|
|
Author *uuid.UUID
|
|
CreatedAt time.Time
|
|
UpdatedAt time.Time
|
|
DeletedAt *time.Time
|
|
}
|
|
|
|
type Ingredient struct {
|
|
Guid uuid.UUID
|
|
Title string
|
|
Description *string
|
|
ThumbnailS3Key *uuid.UUID
|
|
MadePublicAt *time.Time
|
|
Tags []string
|
|
Author *uuid.UUID
|
|
CreatedAt time.Time
|
|
UpdatedAt time.Time
|
|
DeletedAt *time.Time
|
|
}
|
|
|
|
type IngredientPrice struct {
|
|
Guid uuid.UUID
|
|
IngredientGuid uuid.UUID
|
|
Price decimal.Decimal
|
|
PriceCurrency Currency
|
|
Weight decimal.Decimal
|
|
WeightUnit Weight
|
|
StoreGuid uuid.UUID
|
|
Author *uuid.UUID
|
|
CreatedAt time.Time
|
|
UpdatedAt time.Time
|
|
DeletedAt *time.Time
|
|
}
|
|
|
|
type LoginInfo struct {
|
|
Guid uuid.UUID
|
|
AccountGuid uuid.UUID
|
|
Email *string
|
|
PasswordHash string
|
|
SuspendedAt *time.Time
|
|
SuspendedReason *string
|
|
CreatedAt time.Time
|
|
UpdatedAt time.Time
|
|
DeletedAt *time.Time
|
|
}
|
|
|
|
type Profile struct {
|
|
Guid uuid.UUID
|
|
AccountGuid uuid.UUID
|
|
Name string
|
|
Surname *string
|
|
Patronymic *string
|
|
CreatedAt time.Time
|
|
UpdatedAt time.Time
|
|
DeletedAt *time.Time
|
|
}
|
|
|
|
type Store struct {
|
|
Guid uuid.UUID
|
|
Title string
|
|
Description *string
|
|
ThumbnailS3Key *uuid.UUID
|
|
Author *uuid.UUID
|
|
CreatedAt time.Time
|
|
UpdatedAt time.Time
|
|
DeletedAt *time.Time
|
|
}
|
|
|
|
type ViewAccountProfile struct {
|
|
Guid uuid.UUID
|
|
Username string
|
|
Name string
|
|
Surname *string
|
|
Patronymic *string
|
|
CreatedAt time.Time
|
|
DeletedAt *time.Time
|
|
}
|