-
Notifications
You must be signed in to change notification settings - Fork 81
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add command to reset database when switching branches (#1730)
- Loading branch information
1 parent
9486648
commit e32e6ee
Showing
1 changed file
with
24 additions
and
0 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
from django.core.management.base import BaseCommand | ||
from django_extensions.management.commands import reset_db | ||
from subprocess import call | ||
|
||
|
||
class Command(BaseCommand): | ||
help = """Recreates a database using the current local migration files. | ||
It runs loadstatic at the end.""" | ||
|
||
def handle(self, *args, **options): | ||
|
||
print('RESETTING DATABASE\n') | ||
reset_db.Command().handle(router='default') | ||
|
||
print('MAKING MIGRATION FILES\n') | ||
call(args=['./manage.py', 'makemigrations']) | ||
|
||
print('LOADING MIGRATION FILES\n') | ||
call(args=['./manage.py', 'migrate']) | ||
|
||
print('LOADING STATIC:\n') | ||
call(args=['./manage.py', 'loadstatic']) | ||
|
||
self.stdout.write(self.style.SUCCESS("Database reset successfully.")) |