Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 5 additions & 3 deletions prisma/schema.prisma
Original file line number Diff line number Diff line change
Expand Up @@ -34,9 +34,11 @@ enum Role {
}

enum ProjectType {
article
ebook
newsletter
Article
Blog
Email
Tweet
Newsletter
}
Comment on lines 36 to 42
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🔴 Critical

🧩 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:

  1. A Prisma migration file was generated and includes a data migration step to update existing Project records
  2. 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 2

Length 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.sql

Length 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:

  1. 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)
  2. 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.


model Project {
Expand Down
18 changes: 13 additions & 5 deletions src/components/models/projects/CreateProjectForm.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ export function CreateProjectForm({ selectedTemplateId, setDialogOpen }: CreateP
reValidateMode: 'onChange',
defaultValues: {
title: '',
type: ProjectType.article,
type: ProjectType.Article,
templateId: selectedTemplateId
}
});
Expand Down Expand Up @@ -61,15 +61,23 @@ export function CreateProjectForm({ selectedTemplateId, setDialogOpen }: CreateP
items={[
{
label: 'Article',
value: 'article'
value: 'Article'
},
{
label: 'Ebook',
value: 'ebook'
label: 'Blog',
value: 'Blog'
},
{
label: 'Email',
value: 'Email'
},
{
label: 'Tweet',
value: 'Tweet'
},
{
label: 'Newsletter',
value: 'newsletter'
value: 'Newsletter'
}
]}
name='type'
Expand Down
Loading