zoukankan      html  css  js  c++  java
  • django迁移文件出现django.db.utils.InternalError: (1050, "Table 'tb_goods_visit' already exists"),问题解决

    Traceback (most recent call last):
      File "manage.py", line 22, in <module>
        execute_from_command_line(sys.argv)
      File "D:python_learnmeiduo_projectenvlibsite-packagesdjangocoremanagement\__init__.py", line 364, in execute_from_command_line
        utility.execute()
      File "D:python_learnmeiduo_projectenvlibsite-packagesdjangocoremanagement\__init__.py", line 356, in execute
        self.fetch_command(subcommand).run_from_argv(self.argv)
      File "D:python_learnmeiduo_projectenvlibsite-packagesdjangocoremanagementase.py", line 283, in run_from_argv
        self.execute(*args, **cmd_options)
      File "D:python_learnmeiduo_projectenvlibsite-packagesdjangocoremanagementase.py", line 330, in execute
        output = self.handle(*args, **options)
      File "D:python_learnmeiduo_projectenvlibsite-packagesdjangocoremanagementcommandsmigrate.py", line 202, in handle
        post_migrate_state = executor.migrate(
      File "D:python_learnmeiduo_projectenvlibsite-packagesdjangodbmigrationsexecutor.py", line 115, in migrate
        state = self._migrate_all_forwards(state, plan, full_plan, fake=fake, fake_initial=fake_initial)
      File "D:python_learnmeiduo_projectenvlibsite-packagesdjangodbmigrationsexecutor.py", line 145, in _migrate_all_forwards
        state = self.apply_migration(state, migration, fake=fake, fake_initial=fake_initial)
      File "D:python_learnmeiduo_projectenvlibsite-packagesdjangodbmigrationsexecutor.py", line 244, in apply_migration
        state = migration.apply(state, schema_editor)
      File "D:python_learnmeiduo_projectenvlibsite-packagesdjangodbmigrationsmigration.py", line 129, in apply
        operation.database_forwards(self.app_label, schema_editor, old_state, project_state)
      File "D:python_learnmeiduo_projectenvlibsite-packagesdjangodbmigrationsoperationsmodels.py", line 97, in database_forwards
        schema_editor.create_model(model)
      File "D:python_learnmeiduo_projectenvlibsite-packagesdjangodbackendsaseschema.py", line 303, in create_model
        self.execute(sql, params or None)
      File "D:python_learnmeiduo_projectenvlibsite-packagesdjangodbackendsaseschema.py", line 120, in execute
        cursor.execute(sql, params)
      File "D:python_learnmeiduo_projectenvlibsite-packagesdjangodbackendsutils.py", line 79, in execute
        return super(CursorDebugWrapper, self).execute(sql, params)
      File "D:python_learnmeiduo_projectenvlibsite-packagesdjangodbackendsutils.py", line 64, in execute
        return self.cursor.execute(sql, params)
      File "D:python_learnmeiduo_projectenvlibsite-packagesdjangodbutils.py", line 94, in __exit__
        six.reraise(dj_exc_type, dj_exc_value, traceback)
      File "D:python_learnmeiduo_projectenvlibsite-packagesdjangoutilssix.py", line 685, in reraise
        raise value.with_traceback(tb)
      File "D:python_learnmeiduo_projectenvlibsite-packagesdjangodbackendsutils.py", line 62, in execute
        return self.cursor.execute(sql)
      File "D:python_learnmeiduo_projectenvlibsite-packagesdjangodbackendsmysqlase.py", line 101, in execute
        return self.cursor.execute(query, args)
      File "D:python_learnmeiduo_projectenvlibsite-packagespymysqlcursors.py", line 170, in execute
        result = self._query(query)
      File "D:python_learnmeiduo_projectenvlibsite-packagespymysqlcursors.py", line 328, in _query
        conn.query(q)
      File "D:python_learnmeiduo_projectenvlibsite-packagespymysqlconnections.py", line 517, in query
        self._affected_rows = self._read_query_result(unbuffered=unbuffered)
      File "D:python_learnmeiduo_projectenvlibsite-packagespymysqlconnections.py", line 732, in _read_query_result
        result.read()
      File "D:python_learnmeiduo_projectenvlibsite-packagespymysqlconnections.py", line 1075, in read
        first_packet = self.connection._read_packet()
      File "D:python_learnmeiduo_projectenvlibsite-packagespymysqlconnections.py", line 684, in _read_packet
        packet.check_error()
      File "D:python_learnmeiduo_projectenvlibsite-packagespymysqlprotocol.py", line 220, in check_error
        err.raise_mysql_exception(self._data)
      File "D:python_learnmeiduo_projectenvlibsite-packagespymysqlerr.py", line 109, in raise_mysql_exception
        raise errorclass(errno, errval)
    django.db.utils.InternalError: (1050, "Table 'tb_goods_visit' already exists")

    1.使用命令 python manage.py migrate --fake 先进行表结构的同步

    2.完成后删除make_migrations表中最新的迁移数据,在进行迁移即可

  • 相关阅读:
    单点登陆
    【springmvc学习】常用注解总结
    Excel里函数中的万金油,你确定不要点进来看看?
    Maven3在Eclipse上安装插件
    VSCode 云同步扩展设置 Settings Sync 插件
    Ubuntu 18.04 root 使用ssh密钥远程登陆
    [Asp.net] C# 操作Excel的几种方式 优缺点比较
    开源框架Autofac使用入门
    C# .net Ueditor实现图片上传到阿里云OSS 对象存储
    [python]TypeError: string indices must be integers解决方法
  • 原文地址:https://www.cnblogs.com/sewen-H/p/13391207.html
Copyright © 2011-2022 走看看