Skip to content

Conversation

@cto-new
Copy link

@cto-new cto-new bot commented Oct 20, 2025

Summary

This PR introduces Alembic database migrations to the project, setting up the initial database schema for core objects and integrating migrations into the app startup process.

Details

  • Adds Alembic and SQLAlchemy as install dependencies and generates Alembic scaffolding (ini, env.py, versions/ directory).
  • Defines core SQLModel/ORM models and an initial migration to create events, documents, chunks, entities, embeddings, and jobs tables with supporting indices and foreign keys (for SQLite).
  • Configures WAL mode, connection pooling, and PRAGMA settings on SQLite connections for concurrency and reliability.
  • Integrates an automatic migration step on process startup (opencontext start) so tables are always up-to-date with no manual intervention required.
  • Provides migration-aware DB session and engine helpers for use throughout the codebase.
  • Supplies basic test fixtures and CRUD integration tests for DB bring-up and future migrations.

… for core schema

This change introduces Alembic-based migrations with an initial database schema
for core objects, supporting future evolution and idempotent setup. It also
integrates automatic migration execution into CLI startup for reliable DB
initialization in all environments.

- Add Alembic and SQLAlchemy 2.0+ as project dependencies
- Scaffold Alembic config, env.py, migrations directory, and core models
- Define initial migration for events, documents, chunks, entities, embeddings,
  jobs tables with indices and FKs (SQLite-optimized)
- Apply SQLite PRAGMA settings (WAL, busy_timeout, synchronous) on connect
- Integrate run_migrations on CLI startup (before serving)
- Add seed/fixture helpers and migration/tests for core schema

No breaking changes; existing SQLite data is preserved and future-proofed.
@ldc861117 ldc861117 merged commit c8d6b22 into main Oct 20, 2025
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.

2 participants