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:
JSC
2025-09-16 13:45:14 +02:00
parent e8f979c137
commit 83239cb4fa
16 changed files with 828 additions and 29 deletions

View File

@@ -92,14 +92,14 @@ class TestTaskHandlerRegistry:
parameters={"user_id": str(test_user_id)},
)
mock_credit_service.recharge_user_credits.return_value = {
"user_id": str(test_user_id),
"credits_added": 100,
}
# Mock transaction object
mock_transaction = MagicMock()
mock_transaction.amount = 100
mock_credit_service.recharge_user_credits_auto.return_value = mock_transaction
await task_registry.execute_task(task)
mock_credit_service.recharge_user_credits.assert_called_once_with(test_user_id)
mock_credit_service.recharge_user_credits_auto.assert_called_once_with(test_user_id)
async def test_handle_credit_recharge_uuid_user_id(
self,
@@ -117,7 +117,7 @@ class TestTaskHandlerRegistry:
await task_registry.execute_task(task)
mock_credit_service.recharge_user_credits.assert_called_once_with(test_user_id)
mock_credit_service.recharge_user_credits_auto.assert_called_once_with(test_user_id)
async def test_handle_play_sound_success(
self,