# Path: django_sharding_library/exceptions.py
# class InvalidShowMigrationsException(DjangoShardingException):
#     pass


from django.conf import settings
from django.core.management.commands.showmigrations import Command as ShowMigrationsCommand
from django_sharding_library.exceptions import InvalidShowMigrationsException



class Command(ShowMigrationsCommand):
    def handle(self, *args, **options):
        if not options['database'] or options['database'] == 'all':
            databases = self.get_all_but_replica_dbs()
        elif options['database'] not in self.get_all_but_replica_dbs():

# Path: django_sharding_library/exceptions.py
# class InvalidShowMigrationsException(DjangoShardingException):
#     pass


# Path: django_sharding_library/management/commands/showmigrations.py
from django.conf import settings
from django.core.management.commands.showmigrations import Command as ShowMigrationsCommand
from django_sharding_library.exceptions import InvalidShowMigrationsException




class Command(ShowMigrationsCommand):
    def handle(self, *args, **options):
        if not options['database'] or options['database'] == 'all':
            databases = self.get_all_but_replica_dbs()
        elif options['database'] not in self.get_all_but_replica_dbs():

            raise InvalidShowMigrationsException('You must use showmigrations an existing non-primary DB.')