Skip to content

Conversation

@michelroegl-brunner
Copy link
Member

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

- Install Prisma dependencies and initialize with SQLite
- Create Prisma schema matching existing database structure
- Replace database.js with Prisma-based database service
- Update all API routes, tRPC routers, and WebSocket handler
- Convert TypeScript types to match Prisma schema
- Update build process to include Prisma migrations
- Remove better-sqlite3 dependency

All database operations now use Prisma while maintaining SQLite backend.
- Transform Prisma nested server objects to flattened fields expected by frontend
- Update getAllInstalledScripts, getInstalledScriptsByServer, and getInstalledScriptById
- Server names should now display correctly in the installed scripts table
- Use nullish coalescing operators for better null handling
- Add ensure_database_url() function to update.sh
- Function checks if .env exists and creates from .env.example if needed
- Automatically adds DATABASE_URL if not present
- Call function after restore_backup_files() in update flow
- Fixes Prisma client generation error during updates
@michelroegl-brunner michelroegl-brunner requested a review from a team as a code owner October 17, 2025 07:14
@michelroegl-brunner michelroegl-brunner merged commit b793c57 into main Oct 17, 2025
4 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant