diff --git a/.github/workflows/schema-review-curl.yml b/.github/workflows/schema-review-curl.yml index ef807b8..22dfbd5 100644 --- a/.github/workflows/schema-review-curl.yml +++ b/.github/workflows/schema-review-curl.yml @@ -67,56 +67,29 @@ jobs: # Read the SQL file content SQL_CONTENT=$(cat "$sql_file") - # Build the review prompt - PROMPT="You are an expert PostgreSQL schema reviewer. + # Build review prompt using a temp file to avoid YAML issues + cat > prompt_temp.txt <<'EOF' +You are an expert PostgreSQL schema reviewer. Review this SQL file. -Review this SQL file against ISV Schema Review Guidelines: - -**File:** $sql_file - -**SQL Content:** -\`\`\`sql -$SQL_CONTENT -\`\`\` - -**Check for:** -1. Primary key must start with tenant_id (or partition_id, tenant_id if partitioned) -2. Use TIMESTAMPTZ for all timestamp fields (not TIMESTAMP) -3. Tables must have 'created' and 'last_modified' TIMESTAMPTZ fields -4. No foreign key constraints (application handles referential integrity) -5. Use TEXT instead of VARCHAR or CHAR +Check for: +1. Primary key must start with tenant_id +2. Use TIMESTAMPTZ for timestamps (not TIMESTAMP) +3. Tables must have created and last_modified TIMESTAMPTZ fields +4. No foreign key constraints +5. Use TEXT instead of VARCHAR 6. No LISTEN/NOTIFY usage -7. Meaningful table and column names -8. Comments on tables and columns -9. Clustering index specified - -**Output Format:** -Generate a detailed markdown report with: - -## 📄 File: \`$sql_file\` - -### ❌ Critical Issues (count) -For each critical issue: -- **Line X:** Description -- **Current:** \`problematic code\` -- **Fix:** \`corrected code\` -- **Why:** Explanation - -### ⚠️ Warnings (count) -For each warning: -- **Line X:** Description -- **Suggestion:** Recommendation +7. Meaningful names and comments -### ✅ Passed Checks (count) -List checks that passed +Provide a detailed markdown report with critical issues, warnings, and passed checks. -### Summary -- Critical: X 🔴 -- Warnings: X 🟡 -- Status: BLOCKED/NEEDS_REVIEW/APPROVED" +SQL Content: +EOF + + # Append SQL content to prompt + cat "$sql_file" >> prompt_temp.txt # Escape the prompt for JSON - PROMPT_JSON=$(echo "$PROMPT" | jq -Rs .) + PROMPT_JSON=$(cat prompt_temp.txt | jq -Rs .) # Call Bob AI API echo "🔄 Calling Bob AI API..." @@ -191,7 +164,7 @@ EOF echo "📝 Generating combined report..." # Start the report - cat > combined_review.md << 'HEADER' + cat > combined_review.md << HEADER ## 🤖 Bob AI Schema Review **PR:** #${{ github.event.pull_request.number }} @@ -241,7 +214,7 @@ SUMMARY fi # Add footer - cat >> combined_review.md << 'FOOTER' + cat >> combined_review.md << FOOTER --- @@ -333,4 +306,3 @@ FOOTER fi echo "" -# Made with Bob