Repository navigation
Feat/fixing migrations - #178
Conversation
Pull Request Review: Feat/fixing migrations (PR #178)SummaryThis PR includes substantial improvements to the database migration system, comprehensive architecture documentation, and critical fixes for position count accuracy issues. The changes span 17 files with 2,385 additions and 28 deletions. 📋 Changes Overview1. Documentation (New Files) ✅
2. Database Migrations 🔧
3. Scripts & Tooling 📝
4. Hasura Metadata Updates
🎯 StrengthsDocumentation Quality ⭐The new documentation is exceptional:
Database Trigger Improvements ✅The consolidated trigger migration shows solid improvements: Before: UPDATE vault
SET position_count = position_count + 1
WHERE term_id = NEW.term_id AND curve_id = NEW.curve_id;After (infrastructure/hasura/migrations/intuition/1729947331635_consolidated_triggers/up.sql:315-348): DECLARE
affected_rows INTEGER;
retry_count INTEGER := 0;
max_retries INTEGER := 3;
BEGIN
IF NEW.shares > 0 THEN
LOOP
UPDATE vault
SET position_count = position_count + 1
WHERE term_id = NEW.term_id AND curve_id = NEW.curve_id;
GET DIAGNOSTICS affected_rows = ROW_COUNT;
IF affected_rows > 0 OR retry_count >= max_retries THEN
EXIT;
END IF;
PERFORM pg_sleep(0.01);
retry_count := retry_count + 1;
END LOOP;This adds:
Position Count Fix Functions 🛠️Three well-designed utility functions (infrastructure/hasura/migrations/intuition/1729947331638_fix_position_count_functions/up.sql):
These provide excellent operational tooling with proper down migration support.
|
Pull Request Review: Feat/fixing migrationsSummaryThis PR converts Hasura relationship definitions from using Code Quality & Best Practices ✅Strengths:
Observations:
Files Changed1.
|
Pull Request Review: Feat/fixing migrationsSummaryThis PR updates Hasura metadata configurations across 11 tables, converting foreign key constraint relationships to manual configurations and adding Code Quality & Best Practices✅ Positives
🔍 ObservationsRelationship Configuration ChangesThe PR converts several relationships from automatic foreign key tracking to manual configuration: public_atom.yaml (lines 20-46):
public_atom_value.yaml (lines 12-54):
public_term.yaml (lines 36-44, 53-61, 164-172):
public_triple_term.yaml (lines 11-28):
Potential Issues
|
tables
- Added frontend role permissions to predicate_object,
subject_predicate, event
- Added frontend role to all share_price_change tables
- Fixed relationships to use manual_configuration instead of
foreign_key_constraint_on
(atom, account, predicate_object, subject_predicate
relationships)
PR Review: Feat/fixing migrationsSummaryThis PR makes significant changes to Hasura metadata configuration, focusing on two main improvements:
Code Quality & Best Practices✅ Strengths
|
Pull Request Review: Feat/fixing migrations (#178)SummaryThis PR standardizes Hasura metadata configurations by converting relationships from 📊 Changes Overview1. Relationship Configuration MigrationPattern: Converting from automatic foreign key tracking to explicit manual configuration Files affected: 23 table metadata files
2. Permission AdditionAdding ✅ Strengths1. Consistent Pattern ApplicationThe conversion follows a systematic approach across all files: Before: - name: creator
using:
foreign_key_constraint_on: creator_idAfter: - name: creator
using:
manual_configuration:
column_mapping:
creator_id: id
insertion_order: null
remote_table:
name: account
schema: public2. Comprehensive CoverageAll relationships that needed conversion appear to have been addressed, showing thorough review of the codebase. 3. Proper StructureAll manual configurations include the required fields:
4. Permission ConsistencyThe
|
Signed-off-by: Luis Eduardo Boiko Ferreira <luiseduardo.boiko@gmail.com>
PR Review: Feat/fixing migrations (#178)Executive SummaryThis is a major consolidation PR that brings 7 comprehensive database migrations into a unified migration system. Overall Assessment: ✅ APPROVE with minor recommendations 📊 PR Scope
🎯 Strengths
🔍 Key Migration: Position Count Fix Functions ⭐What it solves:
Functions provided:
Usage recommendations:
🐛 Issues & RecommendationsHigh Priority (Before Merge)
Medium Priority
🔒 Security✅ No major concerns - All functions use parameterized queries, no privilege escalation risks Recommendations:
⚡ Performance
📝 Documentation✅ Excellent existing documentation Suggested additions:
🎯 Final VerdictStatus: ✅ APPROVE WITH CONDITIONS Excellent engineering work with:
Blocking Issue: Missing down.sql for consolidated_triggers migration Once the down migration is added, this is ready to merge! 🚀 👏 AcknowledgmentsOutstanding consolidation work! The position count fix functions are particularly well-designed and will provide valuable operational tooling. Great job on bringing the migration system into a clean, maintainable state! 🎉 Generated by Claude Code 🤖 |
* Adding functions to update term_ids
* Adding intructions
* Fixing triggers
* Fixing gitignore
* Remove backup files from git tracking
* Adding system architecture MD file
* Adding docs
* Fixing tags
* Updating docs
* Fixing triple relation
* Fixing migrations
* Updating migrations
* Fix frontend role permissions for Hasura
tables
- Added frontend role permissions to predicate_object,
subject_predicate, event
- Added frontend role to all share_price_change tables
- Fixed relationships to use manual_configuration instead of
foreign_key_constraint_on
(atom, account, predicate_object, subject_predicate
relationships)
* Updates
---------
Signed-off-by: Luis Eduardo Boiko Ferreira <luiseduardo.boiko@gmail.com>
* Add position PnL storage and query * Add chart-api PnL endpoints (#187) * Luis/eng 7988 deploy chart api (#180) * Adding caip-22 * Refactoring and adding docker missing env vars * Adding fetch tests * Addressing comments * Updating BE requirements * Adding integration test * Adding another mutations * Lates fixes * Removing unecessary file * Adding chart-api * Updating to include hasura actions to expose chart-api * feat(chart-api): Add graph_type parameter for extensible chart types Summary of Changes: Rust code (apps/chart-api/): - Added GraphType enum with sharePriceChange (default) and totalMarketCap - Renamed share_price to value in responses (breaking change) - Made curve_id optional in ChartResponse (null for term-level graphs) - Added graph_type field to responses - Updated route to /api/v1/curve/{curve_id}/term/{term_id}/data (singular) - Cache key now includes graph_type - Added InvalidGraphType and MissingCurveId errors - Refactored data_fetcher to use generic queries based on graph type - Updated gap_filler and svg_generator to use value field Hasura actions (infrastructure/hasura/metadata/): - Updated URL path to use singular curve/term - Added graph_type optional parameter to getChartJson and getChartSvg - Updated ChartDataPoint.value (renamed from share_price) - Made ChartDataOutput.curve_id optional API Usage: - Default: GET /api/v1/curve/1/term/0x.../data?interval=1d&format=json - With graph_type: GET /api/v1/curve/1/term/0x.../data?interval=1d&format=json&graph_type=totalMarketCap 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com> * fix(chart-api): Use correct column name for atom table lookup The atom table uses `term_id` column, not `id`. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com> * fix(chart-api): Replace count with start/end params, fix code review issues - Update Hasura actions to use start/end timestamps instead of count - Fix README URL pattern (curves→curve, terms→term) - Remove dead code (default_count, sql_interval methods) - Fix error message to include svg_json format - Remove redundant curve_id checks in data_fetcher - Fix Redis health check to use PING command - Remove unused schema field from AppState and Env 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com> * fix(chart-api): Rename start/end to start_time/end_time in Hasura actions The 'end' keyword is reserved in Kriti template engine, causing parse errors. Renamed to start_time/end_time to avoid the conflict. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com> * fix(chart-api): Return JSON error responses for Hasura compatibility Hasura actions require JSON responses. Changed error responses from plain text to JSON format with error message and code fields. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com> * fix(image-guard): Return JSON error responses with proper status codes - Return 4xx for client errors (invalid input, bad request) - Return 5xx only for actual server errors - JSON format with error message and code for Hasura compatibility 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com> * Revert "fix(image-guard): Return JSON error responses with proper status codes" This reverts commit 1e18413. * fix(chart-api): Add SVG color validation and dimension limits Security fixes from code review: - Validate SVG colors to prevent injection attacks (only allow hex colors and whitelisted CSS color names) - Add dimension limits (100-4000px) to prevent memory exhaustion - Invalid colors fall back to defaults instead of being passed through 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com> * fix(chart-api): Address security review - CORS, timeouts, SQL docs - Add SQL injection safety documentation explaining why dynamic SQL is safe - Fix CORS to be restrictive by default (empty config = no cross-origin) - Add Redis connection/response timeouts (10s/5s) - Add logging for CORS configuration state 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com> --------- Co-authored-by: Claude Opus 4.5 <noreply@anthropic.com> * Add PnL chart endpoints --------- Co-authored-by: Claude Opus 4.5 <noreply@anthropic.com> * Luis/eng 7988 deploy chart api (#180) * Adding caip-22 * Refactoring and adding docker missing env vars * Adding fetch tests * Addressing comments * Updating BE requirements * Adding integration test * Adding another mutations * Lates fixes * Removing unecessary file * Adding chart-api * Updating to include hasura actions to expose chart-api * feat(chart-api): Add graph_type parameter for extensible chart types Summary of Changes: Rust code (apps/chart-api/): - Added GraphType enum with sharePriceChange (default) and totalMarketCap - Renamed share_price to value in responses (breaking change) - Made curve_id optional in ChartResponse (null for term-level graphs) - Added graph_type field to responses - Updated route to /api/v1/curve/{curve_id}/term/{term_id}/data (singular) - Cache key now includes graph_type - Added InvalidGraphType and MissingCurveId errors - Refactored data_fetcher to use generic queries based on graph type - Updated gap_filler and svg_generator to use value field Hasura actions (infrastructure/hasura/metadata/): - Updated URL path to use singular curve/term - Added graph_type optional parameter to getChartJson and getChartSvg - Updated ChartDataPoint.value (renamed from share_price) - Made ChartDataOutput.curve_id optional API Usage: - Default: GET /api/v1/curve/1/term/0x.../data?interval=1d&format=json - With graph_type: GET /api/v1/curve/1/term/0x.../data?interval=1d&format=json&graph_type=totalMarketCap 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com> * fix(chart-api): Use correct column name for atom table lookup The atom table uses `term_id` column, not `id`. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com> * fix(chart-api): Replace count with start/end params, fix code review issues - Update Hasura actions to use start/end timestamps instead of count - Fix README URL pattern (curves→curve, terms→term) - Remove dead code (default_count, sql_interval methods) - Fix error message to include svg_json format - Remove redundant curve_id checks in data_fetcher - Fix Redis health check to use PING command - Remove unused schema field from AppState and Env 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com> * fix(chart-api): Rename start/end to start_time/end_time in Hasura actions The 'end' keyword is reserved in Kriti template engine, causing parse errors. Renamed to start_time/end_time to avoid the conflict. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com> * fix(chart-api): Return JSON error responses for Hasura compatibility Hasura actions require JSON responses. Changed error responses from plain text to JSON format with error message and code fields. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com> * fix(image-guard): Return JSON error responses with proper status codes - Return 4xx for client errors (invalid input, bad request) - Return 5xx only for actual server errors - JSON format with error message and code for Hasura compatibility 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com> * Revert "fix(image-guard): Return JSON error responses with proper status codes" This reverts commit 1e18413. * fix(chart-api): Add SVG color validation and dimension limits Security fixes from code review: - Validate SVG colors to prevent injection attacks (only allow hex colors and whitelisted CSS color names) - Add dimension limits (100-4000px) to prevent memory exhaustion - Invalid colors fall back to defaults instead of being passed through 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com> * fix(chart-api): Address security review - CORS, timeouts, SQL docs - Add SQL injection safety documentation explaining why dynamic SQL is safe - Fix CORS to be restrictive by default (empty config = no cross-origin) - Add Redis connection/response timeouts (10s/5s) - Add logging for CORS configuration state 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com> --------- Co-authored-by: Claude Opus 4.5 <noreply@anthropic.com> * Luis/eng 8013 document pnl implementation (#182) * Adding caip-22 * Refactoring and adding docker missing env vars * Adding fetch tests * Addressing comments * Updating BE requirements * Adding integration test * Adding another mutations * Lates fixes * Removing unecessary file * Adding chart-api * Updating to include hasura actions to expose chart-api * feat(chart-api): Add graph_type parameter for extensible chart types Summary of Changes: Rust code (apps/chart-api/): - Added GraphType enum with sharePriceChange (default) and totalMarketCap - Renamed share_price to value in responses (breaking change) - Made curve_id optional in ChartResponse (null for term-level graphs) - Added graph_type field to responses - Updated route to /api/v1/curve/{curve_id}/term/{term_id}/data (singular) - Cache key now includes graph_type - Added InvalidGraphType and MissingCurveId errors - Refactored data_fetcher to use generic queries based on graph type - Updated gap_filler and svg_generator to use value field Hasura actions (infrastructure/hasura/metadata/): - Updated URL path to use singular curve/term - Added graph_type optional parameter to getChartJson and getChartSvg - Updated ChartDataPoint.value (renamed from share_price) - Made ChartDataOutput.curve_id optional API Usage: - Default: GET /api/v1/curve/1/term/0x.../data?interval=1d&format=json - With graph_type: GET /api/v1/curve/1/term/0x.../data?interval=1d&format=json&graph_type=totalMarketCap 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com> * fix(chart-api): Use correct column name for atom table lookup The atom table uses `term_id` column, not `id`. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com> * Adding doc * Fixing error * Fixing wording --------- Co-authored-by: Claude Opus 4.5 <noreply@anthropic.com> * docs: hasura graphql (#181) * docs: hasura docs * chore: cleanup * Feat/fixing migrations (#178) * Adding functions to update term_ids * Adding intructions * Fixing triggers * Fixing gitignore * Remove backup files from git tracking * Adding system architecture MD file * Adding docs * Fixing tags * Updating docs * Fixing triple relation * Fixing migrations * Updating migrations * Fix frontend role permissions for Hasura tables - Added frontend role permissions to predicate_object, subject_predicate, event - Added frontend role to all share_price_change tables - Fixed relationships to use manual_configuration instead of foreign_key_constraint_on (atom, account, predicate_object, subject_predicate relationships) * Updates --------- Signed-off-by: Luis Eduardo Boiko Ferreira <luiseduardo.boiko@gmail.com> * Complete PnL requirements (#188) * Address PnL review comments (#189) * Complete PnL requirements * Address PnL review feedback --------- Signed-off-by: Luis Eduardo Boiko Ferreira <luiseduardo.boiko@gmail.com> * Fixing data fetcher * Updating migrations * Addressing comments * adding new endpoint to fetch raw data * Adding raw endpoint --------- Signed-off-by: Luis Eduardo Boiko Ferreira <luiseduardo.boiko@gmail.com> Co-authored-by: Claude Opus 4.5 <noreply@anthropic.com> Co-authored-by: Simonas Karuzas <simonas@not.cat>
No description provided.