diff --git a/endpoints/projects.post.py b/endpoints/projects.post.py index f992a20..1ced032 100644 --- a/endpoints/projects.post.py +++ b/endpoints/projects.post.py @@ -1,19 +1,26 @@ -# Entity: Project +# Entity: Migration +```python from fastapi import APIRouter, Depends, HTTPException, status from sqlalchemy.orm import Session from core.database import get_db -from models.project import Project -from schemas.project import ProjectSchema, ProjectCreate -from helpers.project_helpers import create_project +from models.migration import Migration +from schemas.migration import MigrationSchema, MigrationFix +from helpers.migration_helpers import fix_migration router = APIRouter() -@router.post("/projects", status_code=status.HTTP_201_CREATED, response_model=ProjectSchema) -async def add_project( - project: ProjectCreate, +@router.post("/migrations/fix", status_code=200, response_model=MigrationSchema) +async def fix_migration_endpoint( + migration_data: MigrationFix, db: Session = Depends(get_db) ): - """Add a new final year project""" - new_project = create_project(db=db, project=project) - return new_project \ No newline at end of file + """Fix a database migration""" + fixed_migration = fix_migration(db, migration_data) + if not fixed_migration: + raise HTTPException( + status_code=status.HTTP_400_BAD_REQUEST, + detail="Failed to fix migration" + ) + return fixed_migration +``` \ No newline at end of file