Add Alembic for database migrations and initial migration scripts
- Created alembic.ini configuration file for Alembic migrations. - Added README file for Alembic with a brief description. - Implemented env.py for Alembic to manage database migrations. - Created script.py.mako template for migration scripts. - Added initial migration script to create database tables. - Created a migration script to add initial plan and playlist data. - Updated database initialization to run Alembic migrations. - Enhanced credit service to automatically recharge user credits based on their plan. - Implemented delete_task method in scheduler service to remove scheduled tasks. - Updated scheduler API to reflect task deletion instead of cancellation. - Added CLI tool for managing database migrations. - Updated tests to cover new functionality for task deletion and credit recharge. - Updated pyproject.toml and lock files to include Alembic as a dependency.
This commit is contained in:
@@ -129,7 +129,7 @@ async def update_task(
|
||||
|
||||
|
||||
@router.delete("/tasks/{task_id}")
|
||||
async def cancel_task(
|
||||
async def delete_task(
|
||||
task_id: int,
|
||||
current_user: Annotated[User, Depends(get_current_active_user)] = ...,
|
||||
scheduler_service: Annotated[
|
||||
@@ -137,7 +137,7 @@ async def cancel_task(
|
||||
] = ...,
|
||||
db_session: Annotated[AsyncSession, Depends(get_db)] = ...,
|
||||
) -> dict:
|
||||
"""Cancel a scheduled task."""
|
||||
"""Delete a scheduled task completely."""
|
||||
repo = ScheduledTaskRepository(db_session)
|
||||
task = await repo.get_by_id(task_id)
|
||||
|
||||
@@ -148,11 +148,11 @@ async def cancel_task(
|
||||
if task.user_id != current_user.id and not current_user.is_admin:
|
||||
raise HTTPException(status_code=403, detail="Access denied")
|
||||
|
||||
success = await scheduler_service.cancel_task(task_id)
|
||||
success = await scheduler_service.delete_task(task_id)
|
||||
if not success:
|
||||
raise HTTPException(status_code=400, detail="Failed to cancel task")
|
||||
raise HTTPException(status_code=400, detail="Failed to delete task")
|
||||
|
||||
return {"message": "Task cancelled successfully"}
|
||||
return {"message": "Task deleted successfully"}
|
||||
|
||||
|
||||
# Admin-only endpoints
|
||||
|
||||
Reference in New Issue
Block a user