Files
amcs/scripts/patch-generated-models.sh
Hein b39cd3ba72
Some checks failed
CI / build-and-test (push) Failing after -31m42s
feat(generatedmodels): add ThoughtCount to ModelPublicProjects
* Introduced ThoughtCount field for scanning computed column
* Added patch script to ensure ThoughtCount is included in generated model
2026-04-26 17:56:30 +02:00

27 lines
869 B
Bash

#!/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