from django.core.management.base import BaseCommand
from django.db import transaction, connection

class Command(BaseCommand):
    def handle(self, *args, **options):
        tables_with_cascade = [
            "tt_activity_type",
            "tt_department",
            "tt_activity",
            "tt_academic_term",
            "tt_staff",
            "tt_location",
        ]
        tables = [

        ]

        with transaction.atomic():
            with connection.cursor() as cursor:
                if tables_with_cascade:
                    cascade_str = ", ".join(tables_with_cascade)
                    cascade_query = (
                        f"TRUNCATE TABLE {cascade_str} RESTART IDENTITY CASCADE;"
                    )
                    cursor.execute(cascade_query)

                if tables:
                    standard_str = ", ".join(tables)
                    standard_query = (
                        f"TRUNCATE TABLE {standard_str} RESTART IDENTITY RESTRICT;"
                    )
                    cursor.execute(standard_query)