migration removed
This commit is contained in:
@@ -2,12 +2,9 @@
|
||||
|
||||
This module provides comprehensive database initialization functionality:
|
||||
- Schema creation and validation
|
||||
- Initial data migration
|
||||
- Database health checks
|
||||
- Schema versioning support
|
||||
- Migration utilities
|
||||
|
||||
For production deployments, consider using Alembic for managed migrations.
|
||||
"""
|
||||
from __future__ import annotations
|
||||
|
||||
@@ -354,8 +351,6 @@ async def create_schema_version_table(
|
||||
) -> None:
|
||||
"""Create schema version tracking table.
|
||||
|
||||
Future enhancement for tracking schema migrations with Alembic.
|
||||
|
||||
Args:
|
||||
engine: Optional database engine (uses default if not provided)
|
||||
"""
|
||||
@@ -587,60 +582,6 @@ def get_database_info() -> Dict[str, Any]:
|
||||
}
|
||||
|
||||
|
||||
def get_migration_guide() -> str:
|
||||
"""Get migration guide for production deployments.
|
||||
|
||||
Returns:
|
||||
Migration guide text
|
||||
"""
|
||||
return """
|
||||
Database Migration Guide
|
||||
========================
|
||||
|
||||
Current Setup: SQLAlchemy create_all()
|
||||
- Automatically creates tables on startup
|
||||
- Suitable for development and single-instance deployments
|
||||
- Schema changes require manual handling
|
||||
|
||||
For Production with Alembic:
|
||||
============================
|
||||
|
||||
1. Initialize Alembic (already installed):
|
||||
alembic init alembic
|
||||
|
||||
2. Configure alembic/env.py:
|
||||
from src.server.database.base import Base
|
||||
target_metadata = Base.metadata
|
||||
|
||||
3. Configure alembic.ini:
|
||||
sqlalchemy.url = <your-database-url>
|
||||
|
||||
4. Generate initial migration:
|
||||
alembic revision --autogenerate -m "Initial schema v1.0.0"
|
||||
|
||||
5. Review migration in alembic/versions/
|
||||
|
||||
6. Apply migration:
|
||||
alembic upgrade head
|
||||
|
||||
7. For future schema changes:
|
||||
- Modify models in src/server/database/models.py
|
||||
- Generate migration: alembic revision --autogenerate -m "Description"
|
||||
- Review generated migration
|
||||
- Test in staging environment
|
||||
- Apply: alembic upgrade head
|
||||
- For rollback: alembic downgrade -1
|
||||
|
||||
Best Practices:
|
||||
==============
|
||||
- Always backup database before migrations
|
||||
- Test migrations in staging first
|
||||
- Review auto-generated migrations carefully
|
||||
- Keep migrations in version control
|
||||
- Document breaking changes
|
||||
"""
|
||||
|
||||
|
||||
# =============================================================================
|
||||
# Public API
|
||||
# =============================================================================
|
||||
@@ -656,7 +597,6 @@ __all__ = [
|
||||
"check_database_health",
|
||||
"create_database_backup",
|
||||
"get_database_info",
|
||||
"get_migration_guide",
|
||||
"CURRENT_SCHEMA_VERSION",
|
||||
"EXPECTED_TABLES",
|
||||
]
|
||||
|
||||
Reference in New Issue
Block a user