Wednesday, 29 September 2021

Table not found in migration file

Error Message

django.db.utils.OperationalError: no such table: clientauth_tbltokentypes

What I am trying to do

I am trying to migrate data with table generation.

models.py

class tbltokentypes(models.Model):
    token_type_id: AutoField(primary_key=True)
    token_type: CharField(max_length=30)

I ran the command python manage.py makemigrations, which created the file 0001_initial.py.

Then in the migration file, I added managers:

from django.db import migrations, models
from clientauth.models import tbltokentypes

class Migration(migrations.Migration):

    initial = True

    dependencies = [
    ]

    operations = [
        migrations.CreateModel(
            name='tbltokentypes',
            fields=[
                ('token_type_id', models.AutoField(primary_key=True, serialize=False, verbose_name='token_type_id')),
                ('token_type', models.CharField(max_length=30)),
            ],
            managers=[
                tbltokentypes(token_type = "Registration").save()
            ]
        )
    ]

Am I missing anything?



from Table not found in migration file

No comments:

Post a Comment