-
Notifications
You must be signed in to change notification settings - Fork 41
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added a clear command so we can remove views before running a migration
- Loading branch information
Scott Walton
committed
Jul 17, 2014
1 parent
fad4b61
commit 94ed2f7
Showing
4 changed files
with
72 additions
and
1 deletion.
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,28 @@ | ||
from optparse import make_option | ||
import logging | ||
|
||
from django.core.management.base import NoArgsCommand | ||
from django.db import models | ||
|
||
from django_pgviews.view import clear_views | ||
|
||
|
||
log = logging.getLogger('django_pgviews.sync_pgviews') | ||
|
||
|
||
class Command(NoArgsCommand): | ||
help = """Clear Postgres views. Use this before running a migration""" | ||
|
||
def handle_noargs(self, **options): | ||
""" | ||
""" | ||
for module in models.get_apps(): | ||
for status, view_cls, python_name in clear_views(module): | ||
if status == 'DROPPED': | ||
msg = 'dropped' | ||
else: | ||
msg = 'not dropped' | ||
log.info("%(python_name)s (%(view_name)s): %(msg)s" % { | ||
'python_name': python_name, | ||
'view_name': view_cls._meta.db_table, | ||
'msg': msg}) |
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
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
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