[PR #170] [MERGED] refactor: migrate from better-sqlite3 to Prisma #226

Closed
opened 2025-11-20 04:13:37 -05:00 by saavagebueno · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/community-scripts/ProxmoxVE-Local/pull/170
Author: @michelroegl-brunner
Created: 10/17/2025
Status: Merged
Merged: 10/17/2025
Merged by: @michelroegl-brunner

Base: mainHead: refactor/change_to_prisma


📝 Commits (3)

  • 123dabe refactor: migrate from better-sqlite3 to Prisma
  • 14a3d99 fix: flatten server data in installed scripts API responses
  • 9fe91af fix: ensure DATABASE_URL is set in .env for Prisma during updates

📊 Changes

22 files changed (+1182 additions, -962 deletions)

View changed files

📝 .gitignore (+2 -1)
📝 VERSION (+1 -1)
📝 package-lock.json (+391 -397)
📝 package.json (+2 -1)
prisma/schema.prisma (+45 -0)
📝 server.js (+19 -19)
📝 src/app/_components/ServerForm.tsx (+1 -1)
📝 src/app/_components/ServerList.tsx (+3 -3)
📝 src/app/api/servers/[id]/public-key/route.ts (+2 -2)
📝 src/app/api/servers/[id]/route.ts (+10 -10)
📝 src/app/api/servers/[id]/test-connection/route.ts (+2 -2)
📝 src/app/api/servers/generate-keypair/route.ts (+2 -2)
📝 src/app/api/servers/route.ts (+5 -5)
📝 src/server/api/routers/installedScripts.ts (+82 -35)
📝 src/server/api/routers/servers.ts (+3 -3)
src/server/database-prisma.js (+254 -0)
src/server/database-prisma.ts (+279 -0)
src/server/database.js (+0 -476)
src/server/db.js (+7 -0)
src/server/db.ts (+9 -0)

...and 2 more files

📄 Description

Summary

This PR migrates the application from better-sqlite3 to Prisma ORM for better database management and type safety.

Changes

  • Migrated from better-sqlite3 to Prisma ORM
  • Added Prisma schema with Server and InstalledScript models
  • Updated API endpoints to use Prisma client
  • Fixed server data flattening in installed scripts API responses
  • Added ensure_database_url() function to update.sh to handle DATABASE_URL environment variable
  • Ensures Prisma client generation works during updates

Technical Details

  • Prisma schema defines Server and InstalledScript models with proper relationships
  • API endpoints now use Prisma client for database operations
  • Update script automatically ensures DATABASE_URL is set in .env file
  • Maintains backward compatibility with existing data structure

Testing

  • Prisma client generation now works correctly
  • API endpoints return properly formatted data
  • Update process handles environment configuration automatically

🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/community-scripts/ProxmoxVE-Local/pull/170 **Author:** [@michelroegl-brunner](https://github.com/michelroegl-brunner) **Created:** 10/17/2025 **Status:** ✅ Merged **Merged:** 10/17/2025 **Merged by:** [@michelroegl-brunner](https://github.com/michelroegl-brunner) **Base:** `main` ← **Head:** `refactor/change_to_prisma` --- ### 📝 Commits (3) - [`123dabe`](https://github.com/community-scripts/ProxmoxVE-Local/commit/123dabe22eba3c304da8670ab4e5d2c0d8be0803) refactor: migrate from better-sqlite3 to Prisma - [`14a3d99`](https://github.com/community-scripts/ProxmoxVE-Local/commit/14a3d999597fd5b2b1c4166d7a0346a6060028b0) fix: flatten server data in installed scripts API responses - [`9fe91af`](https://github.com/community-scripts/ProxmoxVE-Local/commit/9fe91afdedd8d3927863ffcae8531a8300955cac) fix: ensure DATABASE_URL is set in .env for Prisma during updates ### 📊 Changes **22 files changed** (+1182 additions, -962 deletions) <details> <summary>View changed files</summary> 📝 `.gitignore` (+2 -1) 📝 `VERSION` (+1 -1) 📝 `package-lock.json` (+391 -397) 📝 `package.json` (+2 -1) ➕ `prisma/schema.prisma` (+45 -0) 📝 `server.js` (+19 -19) 📝 `src/app/_components/ServerForm.tsx` (+1 -1) 📝 `src/app/_components/ServerList.tsx` (+3 -3) 📝 `src/app/api/servers/[id]/public-key/route.ts` (+2 -2) 📝 `src/app/api/servers/[id]/route.ts` (+10 -10) 📝 `src/app/api/servers/[id]/test-connection/route.ts` (+2 -2) 📝 `src/app/api/servers/generate-keypair/route.ts` (+2 -2) 📝 `src/app/api/servers/route.ts` (+5 -5) 📝 `src/server/api/routers/installedScripts.ts` (+82 -35) 📝 `src/server/api/routers/servers.ts` (+3 -3) ➕ `src/server/database-prisma.js` (+254 -0) ➕ `src/server/database-prisma.ts` (+279 -0) ➖ `src/server/database.js` (+0 -476) ➕ `src/server/db.js` (+7 -0) ➕ `src/server/db.ts` (+9 -0) _...and 2 more files_ </details> ### 📄 Description ## Summary This PR migrates the application from better-sqlite3 to Prisma ORM for better database management and type safety. ## Changes - Migrated from better-sqlite3 to Prisma ORM - Added Prisma schema with Server and InstalledScript models - Updated API endpoints to use Prisma client - Fixed server data flattening in installed scripts API responses - Added ensure_database_url() function to update.sh to handle DATABASE_URL environment variable - Ensures Prisma client generation works during updates ## Technical Details - Prisma schema defines Server and InstalledScript models with proper relationships - API endpoints now use Prisma client for database operations - Update script automatically ensures DATABASE_URL is set in .env file - Maintains backward compatibility with existing data structure ## Testing - Prisma client generation now works correctly - API endpoints return properly formatted data - Update process handles environment configuration automatically --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
saavagebueno added the pull-request label 2025-11-20 04:13:37 -05:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: SVI/ProxmoxVE-Local#226