21 lines
627 B
Python
21 lines
627 B
Python
|
from mamweb.settings import INSTALLED_APPS
|
||
|
from django.core.management.base import BaseCommand, CommandError
|
||
|
from django.core.management import call_command
|
||
|
|
||
|
class Command(BaseCommand):
|
||
|
help = "Odmigruje všechny moduly (i.e. smaže všechny tabulky, ale databázi nechá)"
|
||
|
|
||
|
def add_arguments(self, parser):
|
||
|
# TODO: --force (makat a neblábolit)
|
||
|
pass
|
||
|
def handle(self, *args, **options):
|
||
|
# TODO: zeptat se
|
||
|
for app in INSTALLED_APPS:
|
||
|
app = app.split('.')[-1]
|
||
|
try:
|
||
|
call_command('migrate', app, 'zero')
|
||
|
except CommandError:
|
||
|
# app nemá migrace (aspoň typicky)
|
||
|
pass
|
||
|
call_command('showmigrations')
|