Skip to content

Instantly share code, notes, and snippets.

@jourdanrodrigues
Created April 23, 2020 17:00
Show Gist options
  • Save jourdanrodrigues/4b132195786f1b15df5a53f84b2a58ab to your computer and use it in GitHub Desktop.
Save jourdanrodrigues/4b132195786f1b15df5a53f84b2a58ab to your computer and use it in GitHub Desktop.
from django.conf import settings
from django.core.management.commands.migrate import Command as MigrateCommand
# The value is the key that goes in the `DATABASES` settings.
# Ideally set in the Django settings as well, so it can be project-wide accessible
SOURCE_DB_LABEL = 'source_db'
class Command(MigrateCommand):
def handle(self, *args, **options):
if options['database'] == SOURCE_DB_LABEL and settings.PRODUCTION:
raise NotImplementedError('Not allowed to migrate source database in production as of now.')
super().handle(*args, **options)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment