commit 6e4f4c1284eadf94fdf64dc33a290dcaf701f24d
parent 9df59880a76b927ba04c0b36ec5c1f5aee7ca43d
Author: Silas Brack <silasbrack@gmail.com>
Date: Sun, 7 Jun 2026 20:48:52 +0200
chore: update generate-types.sh for current schema
Update table list from old news_item names to current story,
comment, vote, user_profile, category, story_category.
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Diffstat:
1 file changed, 12 insertions(+), 7 deletions(-)
diff --git a/scripts/generate-types.sh b/scripts/generate-types.sh
@@ -10,8 +10,7 @@ mkdir -p "$SCHEMA_DIR"
echo "Exporting schemas from Trailbase..."
-# Export schemas for each table (filter out non-JSON lines)
-tables=(news_item category news_item_category)
+tables=(story comment vote user_profile category story_category)
for table in "${tables[@]}"; do
trail schema "$table" --mode select 2>/dev/null | grep -v "^Rust\|^Run " > "$SCHEMA_DIR/${table}.json"
echo " - $table"
@@ -19,23 +18,29 @@ done
echo "Generating Rust types with quicktype..."
-# Generate all types in one file using --src-lang schema
quicktype \
--src-lang schema \
--lang rust \
--visibility public \
--derive-debug \
--density dense \
- --src "$SCHEMA_DIR/news_item.json" \
+ --src "$SCHEMA_DIR/story.json" \
+ --src "$SCHEMA_DIR/comment.json" \
+ --src "$SCHEMA_DIR/vote.json" \
+ --src "$SCHEMA_DIR/user_profile.json" \
--src "$SCHEMA_DIR/category.json" \
- --src "$SCHEMA_DIR/news_item_category.json" \
+ --src "$SCHEMA_DIR/story_category.json" \
--out "$OUTPUT_FILE"
-# Add Clone derive to all structs
+# Add Clone derive
sed -i 's/#\[derive(Debug, Serialize, Deserialize)\]/#[derive(Debug, Clone, Serialize, Deserialize)]/g' "$OUTPUT_FILE"
-# Remove the example comments and add our module doc
+# Add module doc
sed -i '1,/^use serde/{ /^use serde/!d }' "$OUTPUT_FILE"
sed -i '1i //! Auto-generated types from Trailbase schema.\n//! Run `./scripts/generate-types.sh` to regenerate.\n' "$OUTPUT_FILE"
echo "Generated $OUTPUT_FILE"
+echo ""
+echo "NOTE: You may need to manually adjust:"
+echo " - Option<T> for nullable fields"
+echo " - Field comments (e.g. target_type: 1=story, 2=comment)"