diff --git a/tui_rsync/core/components/backup_plan/application/commands/__init__.py b/tui_rsync/core/components/backup_plan/application/commands/__init__.py index 7d15909..f8095d5 100644 --- a/tui_rsync/core/components/backup_plan/application/commands/__init__.py +++ b/tui_rsync/core/components/backup_plan/application/commands/__init__.py @@ -1,3 +1,4 @@ from .remove_all_backup_plans_command import RemoveAllBackupBackupPlansCommand +from .remove_backup_plan_destinations_command import RemoveBackupBackupPlanDestinationsCommand -__all__ = ['RemoveAllBackupBackupPlansCommand'] +__all__ = ['RemoveAllBackupBackupPlansCommand', 'RemoveBackupBackupPlanDestinationsCommand'] diff --git a/tui_rsync/core/components/backup_plan/application/commands/remove_backup_plan_destinations_command.py b/tui_rsync/core/components/backup_plan/application/commands/remove_backup_plan_destinations_command.py new file mode 100644 index 0000000..1575705 --- /dev/null +++ b/tui_rsync/core/components/backup_plan/application/commands/remove_backup_plan_destinations_command.py @@ -0,0 +1,12 @@ +from tui_rsync.core.ports.orm import DatabaseManagerPort +from tui_rsync.core.shared_kernel.components.common import UUID +from tui_rsync.infrastructure.orm.models import DestinationModel + + +class RemoveBackupBackupPlanDestinationsCommand: + def __init__(self, database_manager: DatabaseManagerPort): + self.databaseManager = database_manager + + def execute(self, backup_plan_uuid: UUID) -> bool: + rows = DestinationModel.delete().where(DestinationModel.source == backup_plan_uuid.id).execute() + return rows != 0