-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1495 from bcgov/automate-make-release-target
Automate make release target
- Loading branch information
Showing
3 changed files
with
36 additions
and
6 deletions.
There are no files selected for viewing
This file contains 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
23 changes: 23 additions & 0 deletions
23
bc_obps/common/management/commands/create_empty_migrations.py
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
from django.core.management.base import BaseCommand, CommandError | ||
from django.core.management import call_command | ||
|
||
|
||
class Command(BaseCommand): | ||
help = 'Creates an empty migration file for each installed app.' | ||
|
||
def add_arguments(self, parser): | ||
parser.add_argument('migration_name', type=str, help='Name of the migration.') | ||
|
||
def handle(self, *args, **options): | ||
migration_name = options['migration_name'] | ||
if not migration_name: | ||
raise CommandError("Migration name is required.") | ||
|
||
# We need to add other apps here if we want to create empty migrations for them(like when they are in PROD) | ||
for app_label in ['common', 'registration']: | ||
try: | ||
# This command creates an empty migration with the specified name | ||
call_command('makemigrations', app_label, empty=True, name=f'V{migration_name}') | ||
self.stdout.write(self.style.SUCCESS(f'Successfully created migration for {app_label}')) | ||
except Exception as e: | ||
self.stdout.write(self.style.ERROR(f'Failed to create migration for {app_label}: {str(e)}')) |
This file contains 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