diff --git a/.claude/settings.local.json b/.claude/settings.local.json index 6359427..cbc53dd 100644 --- a/.claude/settings.local.json +++ b/.claude/settings.local.json @@ -142,7 +142,13 @@ "Bash(mv AT001M_* \"Polo T Shirts/\")", "Bash(mv AT002B_* \"Striped collar/\")", "Bash(mv AT002M_* \"Striped collar/\")", - "Bash(cd \"/c/Users/Lyons/OneDrive/Desktop/Products/AWD T Shirts\" *)" + "Bash(cd \"/c/Users/Lyons/OneDrive/Desktop/Products/AWD T Shirts\" *)", + "Bash(psql postgresql://craft2prints:@192.168.0.190:5432/craft2prints)", + "Bash(node scripts/apply-migration.js)", + "Bash(awk '{print $2}')", + "Bash(xargs kill -9)", + "Bash(taskkill /F /PID 30912)", + "Bash(curl -s http://localhost:3000)" ] } } diff --git a/scripts/apply-migration.js b/scripts/apply-migration.js new file mode 100644 index 0000000..421dfc3 --- /dev/null +++ b/scripts/apply-migration.js @@ -0,0 +1,34 @@ +const { PrismaClient } = require('@prisma/client'); + +const prisma = new PrismaClient(); + +async function main() { + try { + console.log('Applying migration...'); + + // Add parentId column if it doesn't exist + await prisma.$executeRawUnsafe(` + ALTER TABLE "Category" ADD COLUMN "parentId" TEXT; + `).catch(() => { + console.log('Column parentId already exists or has an issue'); + }); + + // Add foreign key constraint if it doesn't exist + await prisma.$executeRawUnsafe(` + ALTER TABLE "Category" ADD CONSTRAINT "Category_parentId_fkey" + FOREIGN KEY ("parentId") REFERENCES "Category"("id") + ON DELETE CASCADE ON UPDATE CASCADE; + `).catch(() => { + console.log('Foreign key already exists or has an issue'); + }); + + console.log('Migration applied successfully!'); + } catch (error) { + console.error('Error applying migration:', error); + process.exit(1); + } finally { + await prisma.$disconnect(); + } +} + +main();