Skip to content

Commit

Permalink
add command to reset database when switching branches (#1730)
Browse files Browse the repository at this point in the history
  • Loading branch information
laura-barluzzi authored and amplifi committed Aug 26, 2017
1 parent 9486648 commit e32e6ee
Showing 1 changed file with 24 additions and 0 deletions.
24 changes: 24 additions & 0 deletions cadasta/core/management/commands/resetdatabase.py
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."))

0 comments on commit e32e6ee

Please sign in to comment.