from pathlib import Path from alembic import command from alembic.config import Config from app.modules.ai_memory.models import AIMemoryEntry from app.modules.audit.models import AuditLog from app.modules.business.models import ( AttendanceRecord, Expense, Employee, FundAccount, LegacySyncRun, MarketAnnouncement, MarketDailyQuote, MarketFinancialMetric, MarketInstrument, MarketMacroIndicator, MarketWatchlist, PerformanceMetric, Policy, Procurement, Project, ProjectCashFlow, ProjectContract, ProjectMember, ProjectMilestone, ReportPushRun, RiskEvent, RiskEventAction, Standard, Supplier, SourceSyncCursor, WorkReport, WorkTask, ) from app.modules.feishu.models import FeishuEventReceipt from app.modules.feishu_users.models import ( FeishuAdminBootstrapTombstone, FeishuUser, ) from app.modules.events.models import DomainEvent from app.modules.observability.models import SystemHeartbeat from app.modules.personalization.models import ( AIConversation, AIConversationMessage, PersonalDataErasureRequest, UserPreference, ) from app.modules.subscriptions.models import PushDelivery, PushSubscription from app.modules.workflows.models import WorkflowAction, WorkflowInstance _MODELS = [ AuditLog, Employee, FeishuEventReceipt, FeishuUser, FeishuAdminBootstrapTombstone, Project, ProjectCashFlow, ProjectContract, ProjectMember, ProjectMilestone, WorkTask, Procurement, Expense, FundAccount, Policy, Standard, PerformanceMetric, Supplier, AttendanceRecord, WorkReport, RiskEvent, RiskEventAction, LegacySyncRun, MarketAnnouncement, MarketInstrument, MarketDailyQuote, MarketFinancialMetric, MarketMacroIndicator, MarketWatchlist, ReportPushRun, DomainEvent, WorkflowInstance, WorkflowAction, AIMemoryEntry, UserPreference, AIConversation, AIConversationMessage, PersonalDataErasureRequest, PushSubscription, PushDelivery, SystemHeartbeat, SourceSyncCursor, ] def main() -> None: project_root = Path(__file__).resolve().parents[2] config = Config(str(project_root / "alembic.ini")) config.set_main_option("script_location", str(project_root / "alembic")) command.upgrade(config, "head") print("Database schema migrated to Alembic head.") if __name__ == "__main__": main()