﻿id	summary	reporter	owner	description	type	status	component	version	severity	resolution	keywords	cc	stage	has_patch	needs_docs	needs_tests	needs_better_patch	easy	ui_ux
25913	--fake-initial not working with apps with other table names	James Lin	nobody	"I have the following migration step in ""clients"" app, notice the table name is ""auth_client"":

{{{
migrations.CreateModel(
            name='Client',
            fields=[
                ('id', models.AutoField(verbose_name='ID', serialize=False, auto_created=True, primary_key=True)),
                ('created_at', models.DateTimeField(auto_now_add=True, verbose_name='date created', db_index=True)),
                ('updated_at', models.DateTimeField(auto_now=True, verbose_name='date modified', db_index=True)),
                ('logo', models.FileField(null=True, upload_to=goconnect_client.clients.models.logo_path, blank=True)),
                ('name', models.CharField(max_length=255, blank=True)),
                ('client_id', models.CharField(default=goconnect_client.clients.generators.generate_client_id, unique=True, max_length=100, db_index=True)),
                ('client_secret', models.CharField(default=goconnect_client.clients.generators.generate_client_secret, max_length=255, db_index=True, blank=True)),
                ('client_type', models.CharField(max_length=32, choices=[('confidential', 'Confidential'), ('public', 'Public')])),
                ('authorization_grant_type', models.CharField(max_length=32, choices=[('authorization-code', 'Authorization code'), ('implicit', 'Implicit'), ('password', 'Resource owner password-based'), ('client-credentials', 'Client credentials')])),
                ('skip_authorization', models.BooleanField(default=False)),
                ('redirect_uris', models.TextField(blank=True, validators=[goconnect_client.clients.validators.validate_uris])),
                ('cors', models.TextField(null=True, blank=True)),
                ('user', models.ForeignKey(related_name='clients_client', to=settings.AUTH_USER_MODEL)),
            ],
            options={
                'abstract': False,
                'db_table': 'auth_client',
                'swappable': 'AUTH_CLIENT_MODEL',
            },
            bases=(grabone_models.misc.timestampedmixin.TimeStampedMixin, models.Model),
        ),
}}}

When I run:

{{{
./manage migrate clients --fake-initial
}}}

it complains about 'auth_client' table already exists.

""When migrate is run with the --fake-initial option, these initial migrations are treated specially. For an initial migration that creates one or more tables (CreateModel operation), Django checks that all of those tables already exist in the database and fake-applies the migration if so. Similarly, for an initial migration that adds one or more fields (AddField operation), Django checks that all of the respective columns already exist in the database and fake-applies the migration if so. Without --fake-initial, initial migrations are treated no differently from any other migration.""

I am '''speculating''' that when determining the existence of the table it's using the default 'app_table' convention, and surely 'clients_client' table doesn't exist, but when running actual migration it uses 'auth_client' as table name and encounter the error."	Bug	closed	Migrations	1.8	Normal	needsinfo			Unreviewed	0	0	0	0	0	0
