diff --git a/django/db/migrations/recorder.py b/django/db/migrations/recorder.py
index 15a3b49..a0c0404 100644
a
|
b
|
|
1 | 1 | from django.apps.registry import Apps |
2 | 2 | from django.db import models |
| 3 | from django.utils.encoding import python_2_unicode_compatible |
3 | 4 | from django.utils.timezone import now |
4 | 5 | |
5 | 6 | |
… |
… |
class MigrationRecorder(object):
|
16 | 17 | a row in the table always means a migration is applied. |
17 | 18 | """ |
18 | 19 | |
| 20 | @python_2_unicode_compatible |
19 | 21 | class Migration(models.Model): |
20 | 22 | app = models.CharField(max_length=255) |
21 | 23 | name = models.CharField(max_length=255) |
… |
… |
class MigrationRecorder(object):
|
26 | 28 | app_label = "migrations" |
27 | 29 | db_table = "django_migrations" |
28 | 30 | |
| 31 | def __str__(self): |
| 32 | return "Migration %s for %s" % (self.name, self.app) |
| 33 | |
29 | 34 | def __init__(self, connection): |
30 | 35 | self.connection = connection |
31 | 36 | |
… |
… |
class MigrationRecorder(object):
|
46 | 51 | Returns a set of (app, name) of applied migrations. |
47 | 52 | """ |
48 | 53 | self.ensure_schema() |
49 | | return set(tuple(x) for x in self.Migration.objects.values_list("app", "name")) |
| 54 | return set(tuple(x) for x in self.Migration.objects.using(self.connection.alias).values_list("app", "name")) |
50 | 55 | |
51 | 56 | def record_applied(self, app, name): |
52 | 57 | """ |
53 | 58 | Records that a migration was applied. |
54 | 59 | """ |
55 | 60 | self.ensure_schema() |
56 | | self.Migration.objects.create(app=app, name=name) |
| 61 | self.Migration.objects.using(self.connection.alias).create(app=app, name=name) |
57 | 62 | |
58 | 63 | def record_unapplied(self, app, name): |
59 | 64 | """ |
60 | 65 | Records that a migration was unapplied. |
61 | 66 | """ |
62 | 67 | self.ensure_schema() |
63 | | self.Migration.objects.filter(app=app, name=name).delete() |
| 68 | self.Migration.objects.using(self.connection.alias).filter(app=app, name=name).delete() |
64 | 69 | |
65 | 70 | @classmethod |
66 | 71 | def flush(cls): |
67 | 72 | """ |
68 | 73 | Deletes all migration records. Useful if you're testing migrations. |
69 | 74 | """ |
70 | | cls.Migration.objects.all().delete() |
| 75 | cls.Migration.objects.using(self.connection.alias).all().delete() |