Created
April 23, 2020 17:00
-
-
Save jourdanrodrigues/4b132195786f1b15df5a53f84b2a58ab to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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