|
1 from django.core.management.base import NoArgsCommand |
|
2 from django.db import connection |
|
3 from django.core.management import call_command |
|
4 from django.contrib.contenttypes.models import ContentType |
|
5 |
|
6 class Command(NoArgsCommand): |
|
7 help = "Migrate existing database to Django 1.8" |
|
8 |
|
9 def handle_noargs(self, **options): |
|
10 # delete tables |
|
11 cursor = connection.cursor() |
|
12 for tname in [ "jogging_log", "auth_message", |
|
13 "django_openid_consumer_association", |
|
14 "django_openid_consumer_nonce", |
|
15 "piston_consumer", "piston_nonce", |
|
16 "piston_resource", "piston_token", |
|
17 "south_migrationhistory", "social_auth_nonce", |
|
18 "social_auth_association", "social_auth_usersocialauth"]: |
|
19 cursor.execute("DROP TABLE IF EXISTS \"%s\" CASCADE;" % tname) |
|
20 |
|
21 call_command('migrate', 'contenttypes', fake_initial=True, interactive=False) |
|
22 call_command('migrate', 'auth', fake_initial=True, interactive=False) |
|
23 call_command('migrate', 'user', fake_initial=True, interactive=False) |
|
24 call_command('migrate', 'default', interactive=False) |
|
25 call_command('migrate', 'oauth_provider', fake=True, interactive=False) |
|
26 call_command('migrate', fake_initial=True, interactive=False) |
|
27 |
|
28 |
|
29 ContentType.objects.filter(app_label="auth", model="user").delete() |
|
30 ContentType.objects.filter(app_label="user", model="userprofile").delete() |
|
31 ContentType.objects.filter(app_label="user", model="ldt").delete() |