Why django migrate command don't insert to django_migrations table

Viewed 84

There was a change in the DB and the Model was modified. After running Makemigrations, I ran migrate.

The DB has been changed normally, but the history is not added to the django_migrations Table.

Because of this problem, a warning to continue to migrate appears even after migrating. And when I try to migrate again, the history is not added to the django_migrations table, so I try to change the DB as before, and this is of course an error.

This is migrations file.

class Migration(migrations.Migration):

    dependencies = [
        ('common_py', '0001_initial'),
    ]

    operations = [
        migrations.AddField(
            model_name='customer_company',
            name='del_date',
            field=models.DateTimeField(default=None, null=True, verbose_name='삭제일'),
        ),
    ]

Run command "python manage.py migrate"

Result

(venv) PS D:\Projects\AFF\AFF> python manage.py migrate
Operations to perform:
  Apply all migrations: auth, common_py, contenttypes, sessions
Running migrations:
  Applying common_py.0002_customer_company_del_date... OK

Change Table Success

enter image description here

But didn't add history to "django_migrations" Table

enter image description here

Have you any idea? I Couldn't find any information about this. Thank you.

1 Answers

I turned off autocommit of mariadb. To use transaction in my Django program.

This is the reason of problem. I guess that the "python manage.py migration" command is not using transaction commit.

Solution.(Os windows)

open mariadb config file.

C:\Program Files\MariaDB 10.5\data\my.ini

Then add(or change) this line in [mysqld] autocommit=1

Restart pc or mariadb.

Complete.

Related