1
+ #! /bin/bash
2
+
3
+ # This script runs the prisma seed against the production database
4
+ # Usage: ./scripts/seed-production.sh
5
+
6
+ echo " 🌱 Production Database Seeding Script"
7
+ echo " ======================================"
8
+
9
+ # Check if we have the required environment file
10
+ if [ ! -f " .env.production" ]; then
11
+ echo " ❌ Error: .env.production file not found"
12
+ echo " Please create .env.production with your production database URLs"
13
+ exit 1
14
+ fi
15
+
16
+ # Get the production database URL (non-pooling for direct operations)
17
+ PROD_DB_URL=$( grep POSTGRES_URL_NON_POOLING .env.production | cut -d ' =' -f2- | tr -d ' "' )
18
+
19
+ if [ -z " $PROD_DB_URL " ]; then
20
+ echo " ❌ Error: Could not find POSTGRES_URL_NON_POOLING in .env.production"
21
+ echo " Please make sure you have POSTGRES_URL_NON_POOLING set in .env.production"
22
+ exit 1
23
+ fi
24
+
25
+ echo " 🔍 Found production database URL"
26
+ echo " ⚠️ WARNING: This will modify your PRODUCTION database!"
27
+ echo " ⚠️ This will DELETE all existing tools and replace them with the seed data"
28
+ echo " "
29
+ echo " Current seed data contains 25 tools:"
30
+ echo " - Anthropic Claude API, Mistral AI, Cursor, GitHub Copilot, etc."
31
+ echo " "
32
+ echo " Continue? (y/n)"
33
+ read -r confirm
34
+
35
+ if [ " $confirm " != " y" ]; then
36
+ echo " ❌ Operation cancelled"
37
+ exit 0
38
+ fi
39
+
40
+ echo " "
41
+ echo " 🚀 Running seed script against production database..."
42
+ echo " 📊 This will:"
43
+ echo " 1. Delete all existing tools"
44
+ echo " 2. Insert 25 new tools from seed data"
45
+ echo " 3. Update comparison URLs to work correctly"
46
+ echo " "
47
+
48
+ # Run the seed script with the production database URL
49
+ POSTGRES_URL=" $PROD_DB_URL " npm run prisma:seed
50
+
51
+ if [ $? -eq 0 ]; then
52
+ echo " "
53
+ echo " ✅ Production database seeding completed successfully!"
54
+ echo " 🎉 Your comparison URLs should now work correctly"
55
+ echo " "
56
+ echo " Next steps:"
57
+ echo " 1. Test a few comparison URLs to verify they work"
58
+ echo " 2. Check that the tools are displaying correctly on your site"
59
+ echo " 3. Monitor for any issues in production"
60
+ else
61
+ echo " "
62
+ echo " ❌ Seeding failed! Please check the error messages above"
63
+ echo " Your production database was not modified"
64
+ exit 1
65
+ fi
0 commit comments