feat: add migration framework with FastMigrate integration
- Add migrations.py with create_migration, run_migrations, get_db_version - Implement CLI migrate and create-migration commands - Use FastMigrate's sequential 0001-*.sql naming convention - Add comprehensive unit, integration, and E2E tests (35 tests) - Add fresh_db_path and temp_migrations_dir test fixtures 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
@@ -7,6 +7,33 @@ import tempfile
|
||||
import pytest
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
def temp_migrations_dir(tmp_path):
|
||||
"""Create a temporary migrations directory for testing."""
|
||||
migrations_path = tmp_path / "migrations"
|
||||
migrations_path.mkdir()
|
||||
return migrations_path
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
def fresh_db_path(tmp_path):
|
||||
"""Provide a path for a non-existent database file.
|
||||
|
||||
Unlike temp_db_path, this does not create the file - it just provides
|
||||
a path. This is needed for fastmigrate which expects to create the db.
|
||||
"""
|
||||
db_path = tmp_path / "test.db"
|
||||
yield db_path
|
||||
# Cleanup
|
||||
if db_path.exists():
|
||||
db_path.unlink()
|
||||
# Also clean up WAL files if they exist
|
||||
for suffix in ["-shm", "-wal", "-journal"]:
|
||||
wal_path = db_path.with_suffix(db_path.suffix + suffix)
|
||||
if wal_path.exists():
|
||||
wal_path.unlink()
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
def temp_db_path():
|
||||
"""Create a temporary database file path for testing."""
|
||||
|
||||
Reference in New Issue
Block a user