diff --git a/django/contrib/admin/migrations/0001_initial.py b/django/contrib/admin/migrations/0001_initial.py
new file mode 100644
index 0000000..665eb5f
--- /dev/null
+++ b/django/contrib/admin/migrations/0001_initial.py
@@ -0,0 +1,34 @@
+# encoding: utf8
+from django.db import models, migrations
+from django.conf import settings
+
+
+class Migration(migrations.Migration):
+
+    dependencies = [
+        ('contenttypes', '__first__'),
+        migrations.swappable_dependency(settings.AUTH_USER_MODEL),
+    ]
+
+    operations = [
+        migrations.CreateModel(
+            name='LogEntry',
+            fields=[
+                (u'id', models.AutoField(verbose_name=u'ID', serialize=False, auto_created=True, primary_key=True)),
+                ('action_time', models.DateTimeField(auto_now=True, verbose_name=u'action time')),
+                ('user', models.ForeignKey(to=settings.AUTH_USER_MODEL, to_field=u'id')),
+                ('content_type', models.ForeignKey(to_field=u'id', blank=True, to=u'contenttypes.ContentType', null=True)),
+                ('object_id', models.TextField(null=True, verbose_name=u'object id', blank=True)),
+                ('object_repr', models.CharField(max_length=200, verbose_name=u'object repr')),
+                ('action_flag', models.PositiveSmallIntegerField(verbose_name=u'action flag')),
+                ('change_message', models.TextField(verbose_name=u'change message', blank=True)),
+            ],
+            options={
+                u'ordering': (u'-action_time',),
+                u'db_table': u'django_admin_log',
+                u'verbose_name': u'log entry',
+                u'verbose_name_plural': u'log entries',
+            },
+            bases=(models.Model,),
+        ),
+    ]
diff --git a/django/contrib/admin/migrations/__init__.py b/django/contrib/admin/migrations/__init__.py
new file mode 100644
index 0000000..e69de29
diff --git a/django/contrib/auth/migrations/0001_initial.py b/django/contrib/auth/migrations/0001_initial.py
new file mode 100644
index 0000000..085ebd1
--- /dev/null
+++ b/django/contrib/auth/migrations/0001_initial.py
@@ -0,0 +1,68 @@
+# encoding: utf8
+from django.db import models, migrations
+import django.utils.timezone
+import django.core.validators
+
+
+class Migration(migrations.Migration):
+
+    dependencies = [
+        ('contenttypes', '__first__'),
+    ]
+
+    operations = [
+        migrations.CreateModel(
+            name='Permission',
+            fields=[
+                (u'id', models.AutoField(verbose_name=u'ID', serialize=False, auto_created=True, primary_key=True)),
+                ('name', models.CharField(max_length=50, verbose_name=u'name')),
+                ('content_type', models.ForeignKey(to=u'contenttypes.ContentType', to_field=u'id')),
+                ('codename', models.CharField(max_length=100, verbose_name=u'codename')),
+            ],
+            options={
+                u'ordering': (u'content_type__app_label', u'content_type__model', u'codename'),
+                u'unique_together': set([(u'content_type', u'codename')]),
+                u'verbose_name': u'permission',
+                u'verbose_name_plural': u'permissions',
+            },
+            bases=(models.Model,),
+        ),
+        migrations.CreateModel(
+            name='Group',
+            fields=[
+                (u'id', models.AutoField(verbose_name=u'ID', serialize=False, auto_created=True, primary_key=True)),
+                ('name', models.CharField(unique=True, max_length=80, verbose_name=u'name')),
+                ('permissions', models.ManyToManyField(to=u'auth.Permission', verbose_name=u'permissions', blank=True)),
+            ],
+            options={
+                u'verbose_name': u'group',
+                u'verbose_name_plural': u'groups',
+            },
+            bases=(models.Model,),
+        ),
+        migrations.CreateModel(
+            name='User',
+            fields=[
+                (u'id', models.AutoField(verbose_name=u'ID', serialize=False, auto_created=True, primary_key=True)),
+                ('password', models.CharField(max_length=128, verbose_name=u'password')),
+                ('last_login', models.DateTimeField(default=django.utils.timezone.now, verbose_name=u'last login')),
+                ('is_superuser', models.BooleanField(default=False, help_text=u'Designates that this user has all permissions without explicitly assigning them.', verbose_name=u'superuser status')),
+                ('username', models.CharField(help_text=u'Required. 30 characters or fewer. Letters, digits and @/./+/-/_ only.', unique=True, max_length=30, verbose_name=u'username', validators=[django.core.validators.RegexValidator(u'^[\\w.@+-]+$', u'Enter a valid username.', u'invalid')])),
+                ('first_name', models.CharField(max_length=30, verbose_name=u'first name', blank=True)),
+                ('last_name', models.CharField(max_length=30, verbose_name=u'last name', blank=True)),
+                ('email', models.EmailField(max_length=75, verbose_name=u'email address', blank=True)),
+                ('is_staff', models.BooleanField(default=False, help_text=u'Designates whether the user can log into this admin site.', verbose_name=u'staff status')),
+                ('is_active', models.BooleanField(default=True, help_text=u'Designates whether this user should be treated as active. Unselect this instead of deleting accounts.', verbose_name=u'active')),
+                ('date_joined', models.DateTimeField(default=django.utils.timezone.now, verbose_name=u'date joined')),
+                ('groups', models.ManyToManyField(to=u'auth.Group', verbose_name=u'groups', blank=True)),
+                ('user_permissions', models.ManyToManyField(to=u'auth.Permission', verbose_name=u'user permissions', blank=True)),
+            ],
+            options={
+                u'abstract': False,
+                u'verbose_name': u'user',
+                u'swappable': u'AUTH_USER_MODEL',
+                u'verbose_name_plural': u'users',
+            },
+            bases=(models.Model,),
+        ),
+    ]
diff --git a/django/contrib/auth/migrations/__init__.py b/django/contrib/auth/migrations/__init__.py
new file mode 100644
index 0000000..e69de29
diff --git a/django/contrib/comments/migrations/0001_initial.py b/django/contrib/comments/migrations/0001_initial.py
new file mode 100644
index 0000000..1be00bf
--- /dev/null
+++ b/django/contrib/comments/migrations/0001_initial.py
@@ -0,0 +1,58 @@
+# encoding: utf8
+from django.db import models, migrations
+from django.conf import settings
+
+
+class Migration(migrations.Migration):
+
+    dependencies = [
+        ('contenttypes', '__first__'),
+        ('sites', '0001_initial'),
+        migrations.swappable_dependency(settings.AUTH_USER_MODEL),
+    ]
+
+    operations = [
+        migrations.CreateModel(
+            name='Comment',
+            fields=[
+                (u'id', models.AutoField(verbose_name=u'ID', serialize=False, auto_created=True, primary_key=True)),
+                ('content_type', models.ForeignKey(to=u'contenttypes.ContentType', to_field=u'id', verbose_name=u'content type')),
+                ('object_pk', models.TextField(verbose_name=u'object ID')),
+                ('site', models.ForeignKey(to='sites.Site', to_field=u'id')),
+                ('user', models.ForeignKey(verbose_name=u'user', to_field=u'id', blank=True, to=settings.AUTH_USER_MODEL, null=True)),
+                ('user_name', models.CharField(max_length=50, verbose_name=u"user's name", blank=True)),
+                ('user_email', models.EmailField(max_length=75, verbose_name=u"user's email address", blank=True)),
+                ('user_url', models.URLField(verbose_name=u"user's URL", blank=True)),
+                ('comment', models.TextField(max_length=3000, verbose_name=u'comment')),
+                ('submit_date', models.DateTimeField(default=None, verbose_name=u'date/time submitted')),
+                ('ip_address', models.GenericIPAddressField(unpack_ipv4=True, null=True, verbose_name=u'IP address', blank=True)),
+                ('is_public', models.BooleanField(default=True, help_text=u'Uncheck this box to make the comment effectively disappear from the site.', verbose_name=u'is public')),
+                ('is_removed', models.BooleanField(default=False, help_text=u'Check this box if the comment is inappropriate. A "This comment has been removed" message will be displayed instead.', verbose_name=u'is removed')),
+            ],
+            options={
+                u'ordering': ('submit_date',),
+                u'db_table': 'django_comments',
+                u'verbose_name': u'comment',
+                u'verbose_name_plural': u'comments',
+                u'permissions': [('can_moderate', 'Can moderate comments')],
+            },
+            bases=(models.Model,),
+        ),
+        migrations.CreateModel(
+            name='CommentFlag',
+            fields=[
+                (u'id', models.AutoField(verbose_name=u'ID', serialize=False, auto_created=True, primary_key=True)),
+                ('user', models.ForeignKey(to=settings.AUTH_USER_MODEL, to_field=u'id', verbose_name=u'user')),
+                ('comment', models.ForeignKey(to=u'comments.Comment', to_field=u'id', verbose_name=u'comment')),
+                ('flag', models.CharField(max_length=30, verbose_name=u'flag', db_index=True)),
+                ('flag_date', models.DateTimeField(default=None, verbose_name=u'date')),
+            ],
+            options={
+                u'unique_together': set([('user', 'comment', 'flag')]),
+                u'db_table': 'django_comment_flags',
+                u'verbose_name': u'comment flag',
+                u'verbose_name_plural': u'comment flags',
+            },
+            bases=(models.Model,),
+        ),
+    ]
diff --git a/django/contrib/comments/migrations/__init__.py b/django/contrib/comments/migrations/__init__.py
new file mode 100644
index 0000000..e69de29
diff --git a/django/contrib/flatpages/migrations/0001_initial.py b/django/contrib/flatpages/migrations/0001_initial.py
new file mode 100644
index 0000000..e33ccc2
--- /dev/null
+++ b/django/contrib/flatpages/migrations/0001_initial.py
@@ -0,0 +1,32 @@
+# encoding: utf8
+from django.db import models, migrations
+
+
+class Migration(migrations.Migration):
+
+    dependencies = [
+        ('sites', '0001_initial'),
+    ]
+
+    operations = [
+        migrations.CreateModel(
+            name='FlatPage',
+            fields=[
+                (u'id', models.AutoField(verbose_name=u'ID', serialize=False, auto_created=True, primary_key=True)),
+                ('url', models.CharField(max_length=100, verbose_name=u'URL', db_index=True)),
+                ('title', models.CharField(max_length=200, verbose_name=u'title')),
+                ('content', models.TextField(verbose_name=u'content', blank=True)),
+                ('enable_comments', models.BooleanField(default=False, verbose_name=u'enable comments')),
+                ('template_name', models.CharField(help_text=u"Example: 'flatpages/contact_page.html'. If this isn't provided, the system will use 'flatpages/default.html'.", max_length=70, verbose_name=u'template name', blank=True)),
+                ('registration_required', models.BooleanField(default=False, help_text=u'If this is checked, only logged-in users will be able to view the page.', verbose_name=u'registration required')),
+                ('sites', models.ManyToManyField(to='sites.Site')),
+            ],
+            options={
+                u'ordering': (u'url',),
+                u'db_table': u'django_flatpage',
+                u'verbose_name': u'flat page',
+                u'verbose_name_plural': u'flat pages',
+            },
+            bases=(models.Model,),
+        ),
+    ]
diff --git a/django/contrib/flatpages/migrations/__init__.py b/django/contrib/flatpages/migrations/__init__.py
new file mode 100644
index 0000000..e69de29
diff --git a/django/contrib/redirects/migrations/0001_initial.py b/django/contrib/redirects/migrations/0001_initial.py
new file mode 100644
index 0000000..ad1876c
--- /dev/null
+++ b/django/contrib/redirects/migrations/0001_initial.py
@@ -0,0 +1,29 @@
+# encoding: utf8
+from django.db import models, migrations
+
+
+class Migration(migrations.Migration):
+
+    dependencies = [
+        ('sites', '0001_initial'),
+    ]
+
+    operations = [
+        migrations.CreateModel(
+            name='Redirect',
+            fields=[
+                (u'id', models.AutoField(verbose_name=u'ID', serialize=False, auto_created=True, primary_key=True)),
+                ('site', models.ForeignKey(to='sites.Site', to_field=u'id')),
+                ('old_path', models.CharField(help_text=u"This should be an absolute path, excluding the domain name. Example: '/events/search/'.", max_length=200, verbose_name=u'redirect from', db_index=True)),
+                ('new_path', models.CharField(help_text=u"This can be either an absolute path (as above) or a full URL starting with 'http://'.", max_length=200, verbose_name=u'redirect to', blank=True)),
+            ],
+            options={
+                u'ordering': ('old_path',),
+                u'unique_together': set([('site', 'old_path')]),
+                u'db_table': 'django_redirect',
+                u'verbose_name': u'redirect',
+                u'verbose_name_plural': u'redirects',
+            },
+            bases=(models.Model,),
+        ),
+    ]
diff --git a/django/contrib/redirects/migrations/__init__.py b/django/contrib/redirects/migrations/__init__.py
new file mode 100644
index 0000000..e69de29
diff --git a/django/contrib/sessions/migrations/0001_initial.py b/django/contrib/sessions/migrations/0001_initial.py
new file mode 100644
index 0000000..5652692
--- /dev/null
+++ b/django/contrib/sessions/migrations/0001_initial.py
@@ -0,0 +1,25 @@
+# encoding: utf8
+from django.db import models, migrations
+
+
+class Migration(migrations.Migration):
+
+    dependencies = [
+    ]
+
+    operations = [
+        migrations.CreateModel(
+            name='Session',
+            fields=[
+                ('session_key', models.CharField(max_length=40, serialize=False, verbose_name=u'session key', primary_key=True)),
+                ('session_data', models.TextField(verbose_name=u'session data')),
+                ('expire_date', models.DateTimeField(verbose_name=u'expire date', db_index=True)),
+            ],
+            options={
+                u'db_table': 'django_session',
+                u'verbose_name': u'session',
+                u'verbose_name_plural': u'sessions',
+            },
+            bases=(models.Model,),
+        ),
+    ]
diff --git a/django/contrib/sessions/migrations/__init__.py b/django/contrib/sessions/migrations/__init__.py
new file mode 100644
index 0000000..e69de29
diff --git a/django/contrib/sites/migrations/0001_initial.py b/django/contrib/sites/migrations/0001_initial.py
new file mode 100644
index 0000000..3830c1f
--- /dev/null
+++ b/django/contrib/sites/migrations/0001_initial.py
@@ -0,0 +1,27 @@
+# encoding: utf8
+from django.db import models, migrations
+import django.contrib.sites.models
+
+
+class Migration(migrations.Migration):
+
+    dependencies = [
+    ]
+
+    operations = [
+        migrations.CreateModel(
+            name='Site',
+            fields=[
+                (u'id', models.AutoField(verbose_name=u'ID', serialize=False, auto_created=True, primary_key=True)),
+                ('domain', models.CharField(max_length=100, verbose_name=u'domain name', validators=[django.contrib.sites.models._simple_domain_name_validator])),
+                ('name', models.CharField(max_length=50, verbose_name=u'display name')),
+            ],
+            options={
+                u'ordering': (u'domain',),
+                u'db_table': u'django_site',
+                u'verbose_name': u'site',
+                u'verbose_name_plural': u'sites',
+            },
+            bases=(models.Model,),
+        ),
+    ]
diff --git a/django/contrib/sites/migrations/__init__.py b/django/contrib/sites/migrations/__init__.py
new file mode 100644
index 0000000..e69de29
diff --git a/django/db/migrations/recorder.py b/django/db/migrations/recorder.py
index 15a3b49..268d0f6 100644
--- a/django/db/migrations/recorder.py
+++ b/django/db/migrations/recorder.py
@@ -46,21 +46,21 @@ class MigrationRecorder(object):
         Returns a set of (app, name) of applied migrations.
         """
         self.ensure_schema()
-        return set(tuple(x) for x in self.Migration.objects.values_list("app", "name"))
+        return set(tuple(x) for x in self.Migration.objects.using(self.connection.alias).values_list("app", "name"))
 
     def record_applied(self, app, name):
         """
         Records that a migration was applied.
         """
         self.ensure_schema()
-        self.Migration.objects.create(app=app, name=name)
+        self.Migration.objects.using(self.connection.alias).create(app=app, name=name)
 
     def record_unapplied(self, app, name):
         """
         Records that a migration was unapplied.
         """
         self.ensure_schema()
-        self.Migration.objects.filter(app=app, name=name).delete()
+        self.Migration.objects.using(self.connection.alias).filter(app=app, name=name).delete()
 
     @classmethod
     def flush(cls):
diff --git a/tests/migrations/test_executor.py b/tests/migrations/test_executor.py
index e8dcacd..6dcce3a 100644
--- a/tests/migrations/test_executor.py
+++ b/tests/migrations/test_executor.py
@@ -111,13 +111,13 @@ class ExecutorTests(MigrationTestBase):
         # We use 'sessions' here as the second app as it's always present
         # in INSTALLED_APPS, so we can happily assign it test migrations.
         executor = MigrationExecutor(connection)
-        plan = executor.migration_plan([("migrations", "0002_second"), ("sessions", "0001_initial")])
+        plan = executor.migration_plan([("migrations", "0002_second"), ("sessions", "0002_invented")])
         self.assertEqual(
             plan,
             [
                 (executor.loader.graph.nodes["migrations", "0001_initial"], False),
                 (executor.loader.graph.nodes["migrations", "0002_second"], False),
-                (executor.loader.graph.nodes["sessions", "0001_initial"], False),
+                (executor.loader.graph.nodes["sessions", "0002_invented"], False),
             ],
         )
         # Fake-apply all migrations
diff --git a/tests/migrations/test_loader.py b/tests/migrations/test_loader.py
index f661a03..6a09cf2 100644
--- a/tests/migrations/test_loader.py
+++ b/tests/migrations/test_loader.py
@@ -17,18 +17,19 @@ class RecorderTests(TestCase):
         Tests marking migrations as applied/unapplied.
         """
         recorder = MigrationRecorder(connection)
+        already_appled = ["sessions", "redirects", "auth", "admin", "comments", "sites", "flatpages"]
         self.assertEqual(
-            recorder.applied_migrations(),
+            set((x, y) for x, y in recorder.applied_migrations() if x not in already_appled),
             set(),
         )
         recorder.record_applied("myapp", "0432_ponies")
         self.assertEqual(
-            recorder.applied_migrations(),
+            set((x, y) for x, y in recorder.applied_migrations() if x not in already_appled),
             set([("myapp", "0432_ponies")]),
         )
         recorder.record_unapplied("myapp", "0432_ponies")
         self.assertEqual(
-            recorder.applied_migrations(),
+            set((x, y) for x, y in recorder.applied_migrations() if x not in already_appled),
             set(),
         )
 
@@ -39,6 +40,8 @@ class LoaderTests(TestCase):
     in memory.
     """
 
+    available_apps = ["migrations", "django.contrib.auth", "django.contrib.contenttypes"]
+
     @override_settings(MIGRATION_MODULES={"migrations": "migrations.test_migrations"})
     def test_load(self):
         """
@@ -80,7 +83,8 @@ class LoaderTests(TestCase):
         self.assertEqual(
             migration_loader.graph.forwards_plan(("migrations", "0001_initial")),
             [
-                ("auth", "__first__"),
+                ("contenttypes", "__first__"),
+                ("auth", "0001_initial"),
                 ("migrations", "0001_initial"),
             ],
         )
@@ -126,16 +130,17 @@ class LoaderTests(TestCase):
         "Tests loading a squashed migration"
         migration_loader = MigrationLoader(connection)
         recorder = MigrationRecorder(connection)
-        # Loading with nothing applied should just give us the one node
+        # Loading with nothing applied should just give us the one node,
+        # plus 2 from contrib apps
         self.assertEqual(
             len(migration_loader.graph.nodes),
-            1,
+            3,
         )
         # However, fake-apply one migration and it should now use the old two
         recorder.record_applied("migrations", "0001_initial")
         migration_loader.build_graph()
         self.assertEqual(
             len(migration_loader.graph.nodes),
-            2,
+            4,
         )
         recorder.flush()
diff --git a/tests/migrations/test_migrations_2/0002_invented.py b/tests/migrations/test_migrations_2/0002_invented.py
new file mode 100644
index 0000000..81b39d7
--- /dev/null
+++ b/tests/migrations/test_migrations_2/0002_invented.py
@@ -0,0 +1,17 @@
+from django.db import migrations, models
+
+
+class Migration(migrations.Migration):
+
+    dependencies = [("sessions", "0001_initial")]
+
+    operations = [
+
+        migrations.CreateModel(
+            "Huh",
+            [
+                ("id", models.AutoField(primary_key=True)),
+            ],
+        ),
+
+    ]
