Files
pad/internal/models/collection.go
T
xarmian 157ca4e88f chore: bump Go toolchain to 1.26 (TASK-763) (#247)
* chore: bump Go toolchain to 1.26 (TASK-763)

Bump Go from 1.25 to 1.26 across all toolchain pins:

- go.mod — go 1.25.0 → go 1.26.0
- Dockerfile — golang:1.25-alpine → golang:1.26-alpine
- .github/workflows/ci.yml — three setup-go steps (Go, Go-Postgres, E2E jobs)
- .github/workflows/release.yml — release pipeline

No `toolchain` directive: the repo is pre-launch with no external
contributors yet, so we set the floor where we want it (hard requirement).

Verified locally before commit:
- golangci-lint v2.11.4 builds and runs under Go 1.26.2 (pinned in CI)
- golang:1.26-alpine and 1.26.2-alpine images present on Docker Hub
- go build ./... clean
- go vet ./... clean
- go test ./... all pass

Parent: PLAN-644 (OSS Repo Hygiene and Launch Polish).

* chore: gofmt -w under Go 1.26 (TASK-763)

Apply Go 1.26's gofmt to the codebase. ~41 files reformatted, all
struct-tag whitespace realignment — no semantic changes. Verified:

- gofmt -l ./cmd ./internal returns empty after
- go build ./... still clean
- go test ./... still passes (run before commit)

Bundling the gofmt diff with the toolchain bump in the same PR because
the formatting drift is a direct consequence of moving from 1.25 to
1.26; splitting them creates a mandatory two-PR ordering for no value.

Parent: PLAN-644.

* docs: bump documented Go floor to 1.26 (TASK-763)

Match go.mod's hard 1.26.0 requirement in the source-build instructions.
Caught by Codex review round 1 on PR #247.

- README.md:158 — "Go 1.25+" → "Go 1.26+"
- CONTRIBUTING.md:9 — "Go 1.25+" → "Go 1.26+"
2026-04-25 11:35:19 -04:00

91 lines
3.9 KiB
Go

package models
import "time"
type FieldDef struct {
Key string `json:"key"`
Label string `json:"label"`
Type string `json:"type"` // text, number, select, multi_select, date, checkbox, url, relation
Options []string `json:"options,omitempty"`
TerminalOptions []string `json:"terminal_options,omitempty"` // for select fields: which options represent a terminal/finalized state
Default any `json:"default,omitempty"`
Required bool `json:"required,omitempty"`
Computed bool `json:"computed,omitempty"`
Collection string `json:"collection,omitempty"` // for relation type
Suffix string `json:"suffix,omitempty"` // for number type display
}
type CollectionSchema struct {
Fields []FieldDef `json:"fields"`
}
// QuickAction defines a prompt template that can be triggered from the UI.
type QuickAction struct {
Label string `json:"label"` // display label for the button
Prompt string `json:"prompt"` // prompt template with {ref}, {title}, {status}, etc.
Scope string `json:"scope"` // "item" or "collection"
Icon string `json:"icon,omitempty"` // optional emoji/icon
}
type CollectionSettings struct {
Layout string `json:"layout,omitempty"` // fields-primary, content-primary, balanced
DefaultView string `json:"default_view,omitempty"` // list, board, table
BoardGroupBy string `json:"board_group_by,omitempty"`
ListSortBy string `json:"list_sort_by,omitempty"`
ListGroupBy string `json:"list_group_by,omitempty"`
QuickActions []QuickAction `json:"quick_actions,omitempty"`
ContentTemplate string `json:"content_template,omitempty"` // markdown template for new items
}
type Collection struct {
ID string `json:"id"`
WorkspaceID string `json:"workspace_id"`
Name string `json:"name"`
Slug string `json:"slug"`
Icon string `json:"icon"`
Description string `json:"description"`
Schema string `json:"schema"` // JSON string in DB, parsed via methods
Settings string `json:"settings"` // JSON string in DB
Prefix string `json:"prefix"`
SortOrder int `json:"sort_order"`
IsDefault bool `json:"is_default"`
IsSystem bool `json:"is_system"`
CreatedAt time.Time `json:"created_at"`
UpdatedAt time.Time `json:"updated_at"`
DeletedAt *time.Time `json:"deleted_at,omitempty"`
// Computed (not stored)
ItemCount int `json:"item_count"`
ActiveItemCount int `json:"active_item_count"`
}
type CollectionCreate struct {
Name string `json:"name"`
Slug string `json:"slug,omitempty"`
Prefix string `json:"prefix,omitempty"`
Icon string `json:"icon,omitempty"`
Description string `json:"description,omitempty"`
Schema string `json:"schema,omitempty"`
Settings string `json:"settings,omitempty"`
IsDefault bool `json:"is_default,omitempty"`
IsSystem bool `json:"is_system,omitempty"`
}
// FieldMigration describes a bulk update to apply to existing items when
// a collection schema changes (e.g. renaming select options).
type FieldMigration struct {
Field string `json:"field"` // field key to migrate
RenameOptions map[string]string `json:"rename_options,omitempty"` // old_value → new_value
}
type CollectionUpdate struct {
Name *string `json:"name,omitempty"`
Prefix *string `json:"prefix,omitempty"`
Icon *string `json:"icon,omitempty"`
Description *string `json:"description,omitempty"`
Schema *string `json:"schema,omitempty"`
Settings *string `json:"settings,omitempty"`
SortOrder *int `json:"sort_order,omitempty"`
Migrations []FieldMigration `json:"migrations,omitempty"`
}