Repository navigation
feat: Prisma @relation field support with FK generation (Issue #10) - #25
Merged
Merged
Conversation
…sue #10) - Add full @relation parsing: fields, references, onDelete, onUpdate - Generate schema.ForeignKey constraints from @relation attributes - Handle composite FKs (multi-column foreign keys) - Map Prisma field names to DB column names (respect @Map) - Map Prisma model names to DB table names (respect @@Map) - Validate FK reference columns exist in target tables - Add CreateForeignKey operations in differ for initial migrations Test coverage: - 7 integration tests in converter_relation_integration_test.go - 3 E2E pipeline tests in converter_e2e_test.go (Prisma→SQL) - 1 manual test for real-world schema verification - All 11 tests pass with full FK generation and validation Fixes: - FK names use actual table names (fk_posts_author_id not fk_Post_author_id) - RefColumns correctly mapped from Prisma field names to DB column names - Three-pass conversion: (1) collect metadata, (2) convert models, (3) validate FKs - Build modelFieldToDbCol map in first pass to handle forward references Closes #10
- Remove Issue #10 from Known Issues section (now implemented) - Update test count: 57 → 68 integration tests - Add Relations test coverage line - Reorder v0.2 roadmap priorities - Update implementation status date to 2026-09-21
Phathdt
force-pushed
the
feat/issue-10-prisma-relation-support
branch
from
September 22, 2026 02:59
b7329ad to
ccdbbb0
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Implements full support for Prisma
@relationfields, enabling FK constraint generation in migrations.Changes
Core Implementation
schema.ForeignKeyfrom @relation attributesDiffer Enhancement
CreateForeignKeyoperations for initial migrationsTest Coverage (+11 tests)
Integration Tests (7)
E2E Pipeline Tests (3)
Manual Test (1)
Example Output
Verification
✅ All 68 integration tests pass
✅ FK names use actual table names
✅ RefColumns correctly mapped
✅ Handles forward references
Closes #10