-
Notifications
You must be signed in to change notification settings - Fork 0
Chore: Update ProjectType Enum in Prisma Schema #54
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
…', and ensure 'newsletter' is present.
WalkthroughThe ProjectType enum in the Prisma schema is updated from lowercase values (article, ebook, newsletter) to capitalized values (Article, Blog, Email, Tweet, Newsletter). The CreateProjectForm component is correspondingly updated to use the new enum values and options, including renaming Ebook to Blog and adding Email and Tweet options. Changes
Estimated code review effort🎯 2 (Simple) | ⏱️ ~10 minutes Consistent enum renaming and form option updates across two files with no complex logic changes. However, review should verify no other files reference the old lowercase enum values. Possibly related PRs
Suggested reviewers
Poem
Pre-merge checks and finishing touches❌ Failed checks (1 warning)
✅ Passed checks (2 passed)
✨ Finishing touches
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 1
🧹 Nitpick comments (1)
src/components/models/projects/CreateProjectForm.tsx (1)
61-82: Prefer enum constants over string literals for type safety.The FormSelect options use string literals ('Article', 'Blog', etc.) instead of the ProjectType enum constants. This bypasses TypeScript's type checking and could lead to typos or mismatches.
Apply this diff to use enum constants:
<FormSelect control={form.control} items={[ { label: 'Article', - value: 'Article' + value: ProjectType.Article }, { label: 'Blog', - value: 'Blog' + value: ProjectType.Blog }, { label: 'Email', - value: 'Email' + value: ProjectType.Email }, { label: 'Tweet', - value: 'Tweet' + value: ProjectType.Tweet }, { label: 'Newsletter', - value: 'Newsletter' + value: ProjectType.Newsletter } ]} name='type' required label='Type' helperText='Select what sort of project you want to create' />This ensures compile-time type safety and prevents potential runtime errors from typos.
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (2)
prisma/schema.prisma(1 hunks)src/components/models/projects/CreateProjectForm.tsx(2 hunks)
🔇 Additional comments (1)
src/components/models/projects/CreateProjectForm.tsx (1)
28-28: LGTM: Default value correctly updated.The default form value has been correctly updated to use the new capitalized enum value
ProjectType.Article.
| enum ProjectType { | ||
| article | ||
| ebook | ||
| newsletter | ||
| Article | ||
| Blog | ||
| Tweet | ||
| Newsletter | ||
| } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🧩 Analysis chain
Critical: Verify data migration for existing Project records.
Changing enum values from lowercase (article, ebook, newsletter) to capitalized (Article, Blog, Email, Tweet, Newsletter) is a breaking change. Any existing Project records in the database with the old enum values will become invalid and cause runtime errors.
Please confirm that:
- A Prisma migration file was generated and includes a data migration step to update existing Project records
- The migration properly maps: article→Article, ebook→Blog, newsletter→Newsletter
Run the following script to verify that all ProjectType references in the codebase have been updated:
Additionally, note that the PR objectives mention removing 'post' and 'script' values, but these don't appear to be in the schema. Please clarify this discrepancy.
🏁 Script executed:
#!/bin/bash
# Description: Find all references to ProjectType enum values to ensure consistency
# Search for lowercase enum values that should have been updated
echo "=== Searching for old lowercase enum values ==="
rg -n --type ts --type tsx --type js -i "projecttype\.(article|ebook)" -g '!node_modules' -g '!.next' -C 2
# Search for all ProjectType usages to verify consistency
echo -e "\n=== All ProjectType enum usages ==="
rg -n --type ts --type tsx --type js "ProjectType\." -g '!node_modules' -g '!.next' -C 2
# Check if migration files exist
echo -e "\n=== Prisma migration files ==="
fd -e sql -p "prisma/migrations"Length of output: 352
I need to examine the migration files and search the codebase with corrected commands to verify the enum change and data migration.
Now let me examine the migration files and search the codebase with corrected commands:
🏁 Script executed:
#!/bin/bash
# Display the migration files to see if enum change and data migration are present
echo "=== Migration: 20250909132930_added_projects (likely contains ProjectType) ==="
cat prisma/migrations/20250909132930_added_projects/migration.sql
echo -e "\n=== Migration: 20250906060838_init ==="
cat prisma/migrations/20250906060838_init/migration.sql
echo -e "\n=== Prisma Schema ==="
cat prisma/schema.prisma
echo -e "\n=== Search for ProjectType enum references using corrected command ==="
rg -n "ProjectType\." -g '!node_modules' -g '!.next' -C 2
echo -e "\n=== Search for old lowercase enum values ==="
rg -n "article|ebook|newsletter" -g '!node_modules' -g '!.next' -C 2
echo -e "\n=== Search for Project model usage ==="
rg -n "Project\." -g '!node_modules' -g '!.next' -C 2Length of output: 4708
Let me check if there are any newer migration files that might handle the enum change:
🏁 Script executed:
#!/bin/bash
echo "=== All migration files in chronological order ==="
ls -la prisma/migrations/
echo -e "\n=== Check for migration files after 20250917 ==="
fd . prisma/migrations/ -type d | sort
echo -e "\n=== Check all migration SQL files for ALTER TYPE or UPDATE statements ==="
grep -r "ALTER TYPE\|UPDATE.*projects\|post\|tweet\|email\|blog" prisma/migrations/ --include="*.sql" 2>/dev/null || echo "No ALTER TYPE or UPDATE statements found"
echo -e "\n=== Full content of latest migration ==="
cat prisma/migrations/20250917091926_required_user_name/migration.sqlLength of output: 1358
Critical: Missing migration for ProjectType enum change — breaking change confirmed.
The database schema and application code are out of sync. The migration file 20250909132930_added_projects created the ProjectType enum with lowercase values: post, article, ebook, script. However, the current schema.prisma defines a completely different enum with capitalized values: Article, Blog, Email, Tweet, Newsletter.
No migration file exists to update the enum in the database or migrate existing Project records. This causes a critical mismatch: any existing records with old enum values will fail at runtime when the application tries to query them.
Required:
- Create a new migration that:
- Alters the ProjectType enum to the new values
- Updates all existing Project records to valid new enum values (or clear them if a mapping strategy hasn't been decided)
- Clarify the intended enum mapping since the change is a complete replacement, not just a rename
Note: The discrepancy about 'post' and 'script' values mentioned in the PR objectives is now clear — these values exist in the database migration but don't appear in the final schema, indicating an incomplete or misaligned schema update.
🤖 Prompt for AI Agents
In prisma/schema.prisma around lines 36 to 42, the ProjectType enum in the
schema has been completely replaced (Article, Blog, Email, Tweet, Newsletter)
while the existing migration (20250909132930_added_projects) and DB contain old
lowercase values (post, article, ebook, script), causing a breaking mismatch;
create a new migration that (1) updates the database enum values to match the
new capitalized enum (or creates a new enum and migrates values), and (2) runs a
data migration step that maps existing rows to the new values (or clears them) —
decide and document the exact mapping between old and new values (e.g., post ->
Blog or post -> Article as appropriate), implement SQL in the migration to
ALTER/CREATE enum and UPDATE Project records accordingly, and add a migration
note describing the mapping choice so the schema and DB stay in sync.
Overview: This PR ensures the
ProjectTypeenum inprisma/schema.prismais correctly defined.Changes
postandscripttypes are removed from theProjectTypeenum.newslettertype is present in theProjectTypeenum.Summary by CodeRabbit