Skip to content

feat: make database optional for projects#140

Merged
Che-Zhu merged 1 commit intomainfrom
feature/optional-database
Mar 6, 2026
Merged

feat: make database optional for projects#140
Che-Zhu merged 1 commit intomainfrom
feature/optional-database

Conversation

@Che-Zhu
Copy link
Copy Markdown
Collaborator

@Che-Zhu Che-Zhu commented Mar 6, 2026

Summary

This PR makes the PostgreSQL database an optional, on-demand resource for projects. Previously, every project was created with a database automatically. Now, users can add a database only when needed, reducing resource consumption and simplifying the project creation flow.

Changes

Backend

  • lib/actions/database.ts (new): Server Actions for creating and deleting databases on-demand
  • lib/actions/project.ts: Removed automatic database creation during project creation
  • app/api/projects/route.ts: Removed database creation from project API endpoint
  • lib/util/type-guards.ts (new): Type guard utilities for project resources
  • lib/util/projectStatus.ts: Updated comments for empty resource array handling

Frontend

  • app/(dashboard)/projects/[id]/database/_components/add-database-card.tsx (new): UI component for adding a database
  • app/(dashboard)/projects/[id]/database/page.tsx: Show "Add Database" card when no database exists
  • components/layout/status-bar.tsx: Display "Database: Not Configured" when no database

Documentation

  • CLAUDE.md: Updated to reflect the new optional database architecture

User Experience

Before:

  • Every project automatically includes a PostgreSQL database
  • Database creation takes 2-3 minutes, blocking project readiness

After:

  • Projects are created with only a Sandbox (faster creation)
  • Users can add a database anytime from the Database tab
  • Clear UI indication when database is not configured

Architecture

This change follows the existing reconciliation pattern:

  • createDatabase action creates a Database record with status CREATING
  • The existing databaseReconcile job picks it up and provisions the K8s resources
  • Status updates flow through the event system as before

Testing

  • Create project without database
  • Add database to existing project
  • Status bar correctly shows database state
  • Database page shows "Add Database" card when no database

Breaking Changes

None. Existing projects with databases continue to work unchanged.~

- Remove database creation from project creation flow
- Add on-demand database creation via "Add Database" button
- Update StatusBar to show "Not Configured" when no database
- Add createDatabase() and deleteDatabase() server actions
- Add AddDatabaseCard component for database page
- Add type guards for optional database handling
- Update documentation to reflect optional database

Breaking Change: New projects will not automatically create a database.
Users can add a database on-demand from the project's database page.

Existing projects with databases are not affected.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@github-actions
Copy link
Copy Markdown

github-actions bot commented Mar 6, 2026

✅ PR Check Results: Passed

Build Checks

Check Status
Lint & Build ✅ Passed
Docker Build ✅ Passed

✨ Great work!

All checks passed successfully. Your PR is ready for review.

Details:

  • ✅ Code quality verified (linting passed)
  • ✅ Build successful
  • ✅ Docker image build verified (linux/amd64)
    Commit: a7488276acce6585287863725832a615d3237492
    Branch: feature/optional-database

🔗 View Details:

@Che-Zhu Che-Zhu merged commit 76d8f6c into main Mar 6, 2026
9 checks passed
@Che-Zhu Che-Zhu deleted the feature/optional-database branch March 8, 2026 09:30
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant