Skip to content

feat(core): add SQLite in-memory database support#568

Draft
d-klotz wants to merge 4 commits intonextfrom
feature/sqlite-in-memory-db-support
Draft

feat(core): add SQLite in-memory database support#568
d-klotz wants to merge 4 commits intonextfrom
feature/sqlite-in-memory-db-support

Conversation

@d-klotz
Copy link
Copy Markdown
Contributor

@d-klotz d-klotz commented Apr 7, 2026

Summary

Add SQLite as a zero-config database option for Frigg, enabling AI agents to run Frigg without any database setup.

Changes

  • New SQLite schema () - Full schema matching PostgreSQL with JSON→String adaptations for SQLite
  • Auto-detection - Falls back to SQLite when no database is configured in app definition
  • Zero-config - Creates automatically on first run
  • Persistent - Data survives process restarts (file-based storage)

Benefits

  • AI agents can now run 🚀 Starting Frigg application... without Docker/PostgreSQL/MongoDB
  • Zero infrastructure setup for local development
  • All Frigg features work out of the box

Usage

Testing

Verified working:

  • ✅ SQLite connection established automatically
  • ✅ All 16 tables created correctly
  • ✅ CRUD operations work
  • ✅ Data persists across restarts

Built with Pi and MiniMax-M2.7

d-klotz added 4 commits April 7, 2026 14:28
- Add SQLite schema (prisma-sqlite/schema.prisma) as alternative to PostgreSQL/MongoDB
- Update database/config.js to detect SQLite and fallback when no database configured
- Update database/prisma.js to load SQLite client with auto-created .frigg/frigg.db
- Update handlers/database-migration-handler.js to support SQLite schema path
- Add npm scripts for SQLite prisma:generate and prisma:push
- Add tests for SQLite ensureSqliteDirectory() function

Benefits:
- AI agents can now run Frigg without database setup
- Zero-config local development experience
- Data persists across restarts (.frigg/frigg.db)
- All tables sync automatically on first connection
- Add SQLite repository classes for all database models:
  - Credential, Token, User, Integration
  - IntegrationMapping, Process, Module
  - WebsocketConnection, Sync, HealthCheck
- SQLite repositories extend PostgreSQL repositories since they share:
  - Int IDs with autoincrement
  - JSON stored as String
- Update all factory functions to support 'sqlite' database type
- Add basic tests for SQLite repositories
Bug fixes:
- Add _convertIntegrationIds to properly combine separate message
  fields (errors, warnings, info, logs) into a messages object
- Fix updateIntegrationMessages to read from correct message field
  instead of non-existent 'messages' field
- Fix findIntegrationByName to work with PostgreSQL (was using
  MongoDB JSON path syntax)
- Implement lazy initialization for tokenRepository in UserRepository
  to avoid circular dependency at module load time

The SQLite repository inherits these fixes since it extends PostgreSQL.
Critical fixes:
- Update updateIntegrationMessages to serialize array to JSON string
  for SQLite (which uses String fields instead of Json)
- Add config import to integration-repository-postgres.js
- Update JSDoc @returns type to include 'sqlite'

SQLite stores message fields as String, so we must JSON.stringify()
the array before writing. PostgreSQL accepts arrays directly.
@sonarqubecloud
Copy link
Copy Markdown

sonarqubecloud Bot commented Apr 7, 2026

Quality Gate Failed Quality Gate failed

Failed conditions
C Reliability Rating on New Code (required ≥ A)

See analysis details on SonarQube Cloud

Catch issues before they fail your Quality Gate with our IDE extension SonarQube for IDE

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