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:
@@ -144,6 +144,25 @@ class SchedulerService:
|
||||
logger.info("Cancelled task: %s (%s)", task.name, task_id)
|
||||
return True
|
||||
|
||||
async def delete_task(self, task_id: int) -> bool:
|
||||
"""Delete a scheduled task completely."""
|
||||
async with self.db_session_factory() as session:
|
||||
repo = ScheduledTaskRepository(session)
|
||||
|
||||
task = await repo.get_by_id(task_id)
|
||||
if not task:
|
||||
return False
|
||||
|
||||
# Remove from APScheduler first (job might not exist in scheduler)
|
||||
with suppress(Exception):
|
||||
self.scheduler.remove_job(str(task_id))
|
||||
|
||||
# Delete from database
|
||||
await repo.delete(task)
|
||||
|
||||
logger.info("Deleted task: %s (%s)", task.name, task_id)
|
||||
return True
|
||||
|
||||
async def get_user_tasks(
|
||||
self,
|
||||
user_id: int,
|
||||
|
||||
Reference in New Issue
Block a user