feat(generatedmodels): add ThoughtCount to ModelPublicProjects
Some checks failed
CI / build-and-test (push) Failing after -31m42s
Some checks failed
CI / build-and-test (push) Failing after -31m42s
* Introduced ThoughtCount field for scanning computed column * Added patch script to ensure ThoughtCount is included in generated model
This commit is contained in:
@@ -15,6 +15,7 @@ type ModelPublicProjects struct {
|
|||||||
GUID resolvespec_common.SqlUUID `bun:"guid,type:uuid,default:gen_random_uuid(),notnull," json:"guid"`
|
GUID resolvespec_common.SqlUUID `bun:"guid,type:uuid,default:gen_random_uuid(),notnull," json:"guid"`
|
||||||
LastActiveAt resolvespec_common.SqlTimeStamp `bun:"last_active_at,type:timestamptz,default:now(),nullzero," json:"last_active_at"`
|
LastActiveAt resolvespec_common.SqlTimeStamp `bun:"last_active_at,type:timestamptz,default:now(),nullzero," json:"last_active_at"`
|
||||||
Name resolvespec_common.SqlString `bun:"name,type:text,notnull," json:"name"`
|
Name resolvespec_common.SqlString `bun:"name,type:text,notnull," json:"name"`
|
||||||
|
ThoughtCount resolvespec_common.SqlInt64 `bun:"thought_count,scanonly" json:"thought_count"`
|
||||||
RelProjectIDPublicThoughts []*ModelPublicThoughts `bun:"rel:has-many,join:guid=project_id" json:"relprojectidpublicthoughts,omitempty"` // Has many ModelPublicThoughts
|
RelProjectIDPublicThoughts []*ModelPublicThoughts `bun:"rel:has-many,join:guid=project_id" json:"relprojectidpublicthoughts,omitempty"` // Has many ModelPublicThoughts
|
||||||
RelProjectIDPublicStoredFiles []*ModelPublicStoredFiles `bun:"rel:has-many,join:guid=project_id" json:"relprojectidpublicstoredfiles,omitempty"` // Has many ModelPublicStoredFiles
|
RelProjectIDPublicStoredFiles []*ModelPublicStoredFiles `bun:"rel:has-many,join:guid=project_id" json:"relprojectidpublicstoredfiles,omitempty"` // Has many ModelPublicStoredFiles
|
||||||
RelProjectIDPublicChatHistories []*ModelPublicChatHistories `bun:"rel:has-many,join:guid=project_id" json:"relprojectidpublicchathistories,omitempty"` // Has many ModelPublicChatHistories
|
RelProjectIDPublicChatHistories []*ModelPublicChatHistories `bun:"rel:has-many,join:guid=project_id" json:"relprojectidpublicchathistories,omitempty"` // Has many ModelPublicChatHistories
|
||||||
|
|||||||
@@ -53,4 +53,6 @@ for file in "${out_dir}"/*.go; do
|
|||||||
fi
|
fi
|
||||||
done
|
done
|
||||||
|
|
||||||
|
bash "${repo_root}/scripts/patch-generated-models.sh"
|
||||||
|
|
||||||
gofmt -w "${out_dir}"/*.go
|
gofmt -w "${out_dir}"/*.go
|
||||||
|
|||||||
26
scripts/patch-generated-models.sh
Normal file
26
scripts/patch-generated-models.sh
Normal file
@@ -0,0 +1,26 @@
|
|||||||
|
#!/usr/bin/env bash
|
||||||
|
set -euo pipefail
|
||||||
|
|
||||||
|
repo_root="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)"
|
||||||
|
models_dir="${repo_root}/internal/generatedmodels"
|
||||||
|
projects_model="${models_dir}/sql_public_projects.go"
|
||||||
|
|
||||||
|
if [[ ! -f "${projects_model}" ]]; then
|
||||||
|
echo "generated projects model not found: ${projects_model}" >&2
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Ensure ModelPublicProjects can scan ResolveSpec computed column "thought_count".
|
||||||
|
if ! grep -q "ThoughtCount" "${projects_model}"; then
|
||||||
|
tmp_file="$(mktemp)"
|
||||||
|
awk '
|
||||||
|
/Name[[:space:]]+resolvespec_common\.SqlString[[:space:]]+`bun:"name,type:text,notnull," json:"name"`/ {
|
||||||
|
print
|
||||||
|
print "\tThoughtCount resolvespec_common.SqlInt64 `bun:\"thought_count,scanonly\" json:\"thought_count\"`"
|
||||||
|
next
|
||||||
|
}
|
||||||
|
{ print }
|
||||||
|
' "${projects_model}" > "${tmp_file}"
|
||||||
|
mv "${tmp_file}" "${projects_model}"
|
||||||
|
fi
|
||||||
|
|
||||||
Reference in New Issue
Block a user