from django.db import connection from django.core.management import BaseCommand def drop_tables(): with connection.cursor() as cursor: for table in [ "gurps_character", "gurps_character_campaign", "gurps_character_campaign_gm", "gurps_character_campaignplayer", "gurps_character_gm", "gurps_character_player", "gurps_character_gamesystem", "gurps_character_gurpscharacter"]: cursor.execute(f'DROP TABLE IF EXISTS {table} cascade') cursor.execute("DELETE FROM django_migrations WHERE app = 'gurps_character'") class Command(BaseCommand): help = "Drop all the tables!" def handle(self, *args, **options): drop_tables()