Reputation: 459
I recently had a database issue so I decided to nuke it since I had no important data. I deleted my migrations folder in my app directory and dropped the database. However now when I go to recreate everything with manage.py migrate
I get the following error:
File "../manage.py", line 21, in <module>
main()
File "../manage.py", line 17, in main
execute_from_command_line(sys.argv)
File "/usr/local/lib/python3.6/dist-packages/django/core/management/__init__.py", line 381, in execute_from_command_line
utility.execute()
File "/usr/local/lib/python3.6/dist-packages/django/core/management/__init__.py", line 375, in execute
self.fetch_command(subcommand).run_from_argv(self.argv)
File "/usr/local/lib/python3.6/dist-packages/django/core/management/base.py", line 323, in run_from_argv
self.execute(*args, **cmd_options)
File "/usr/local/lib/python3.6/dist-packages/django/core/management/base.py", line 364, in execute
output = self.handle(*args, **options)
File "/usr/local/lib/python3.6/dist-packages/django/core/management/base.py", line 83, in wrapped
res = handle_func(*args, **kwargs)
File "/usr/local/lib/python3.6/dist-packages/django/core/management/commands/migrate.py", line 234, in handle
fake_initial=fake_initial,
File "/usr/local/lib/python3.6/dist-packages/django/db/migrations/executor.py", line 91, in migrate
self.recorder.ensure_schema()
File "/usr/local/lib/python3.6/dist-packages/django/db/migrations/recorder.py", line 69, in ensure_schema
raise MigrationSchemaMissing("Unable to create the django_migrations table (%s)" % exc)
django.db.migrations.exceptions.MigrationSchemaMissing: Unable to create the django_migrations table ((1050, "Table 'django_migrations' already exists"))
I have tried running this after deleting the database, and after recreating the empty database. I can be 100% sure there are no tables there right now. So I have no idea why it thinks that table is there.
Upvotes: 2
Views: 1441
Reputation: 11
Removed migrations and created the project directory and startapp directory again. Then makemigration and migrate. Worked on mySQL.
Upvotes: 0
Reputation: 459
Figured out my issue. MariaDB had my tables open in the cache. I ran two statements: FLUSH QUERY CACHE;
and FLUSH TABLES;
. I'm not sure which one did the trick but I was then able to run migrations and everything works again now!
Upvotes: 5