0

我正在将我的更改从开发人员交付到生产人员的过程中。

一切都在开发中运行良好。

我正在使用 Django 1.4

我面临的问题是 South 没有接受并且没有为我正在使用的 manytomanyfield 创建一个表。

在 dev 上,我看到有 21 个 MySql 表,而 prod 上缺少 1 个表。

我真的不知道如何解决这个问题。

这是 South 第一次被添加到我的开发和产品中。

任何想法如何创建丢失的表?

这就是我所做的以及我收到的错误:

./manage.py schemamigration companies --auto --update
 + Added M2M table for companyjobs on companies.Company
Migration to be updated, 0003_auto, is already applied, rolling it back now...
previous_migration: 0002_auto (applied: 2013-05-04 06:19:38+00:00)
Running migrations for companies:
 - Migrating backwards to just after 0002_auto.
 < companies:0003_auto
FATAL ERROR - The following SQL query failed: DROP TABLE `companies_company_companyjobs` CASCADE;
The error was: (1051, "Unknown table 'companies_company_companyjobs'")
 ! Error found during real run of migration! Aborting.

 ! Since you have a database that does not support running
 ! schema-altering statements in transactions, we have had 
 ! to leave it in an interim state between migrations.

 ! The South developers regret this has happened, and would
 ! like to gently persuade you to consider a slightly
 ! easier-to-deal-with DBMS (one that supports DDL transactions)
 ! NOTE: The error which caused the migration to fail is further up.
Error in migration: companies:0003_auto
Traceback (most recent call last):
  File "./manage.py", line 10, in <module>
    execute_from_command_line(sys.argv)
  File "/usr/local/lib/python2.7/dist-packages/django/core/management/__init__.py", line 443, in execute_from_command_line
    utility.execute()
  File "/usr/local/lib/python2.7/dist-packages/django/core/management/__init__.py", line 382, in execute
    self.fetch_command(subcommand).run_from_argv(self.argv)
  File "/usr/local/lib/python2.7/dist-packages/django/core/management/base.py", line 196, in run_from_argv
    self.execute(*args, **options.__dict__)
  File "/usr/local/lib/python2.7/dist-packages/django/core/management/base.py", line 232, in execute
    output = self.handle(*args, **options)
  File "/usr/local/lib/python2.7/dist-packages/South-0.7.6-py2.7.egg/south/management/commands/schemamigration.py", line 173, in handle
    migrate_app(migrations, 'current-1', verbosity=verbosity)
  File "/usr/local/lib/python2.7/dist-packages/South-0.7.6-py2.7.egg/south/migration/__init__.py", line 213, in migrate_app
    success = migrator.migrate_many(target, workplan, database)
  File "/usr/local/lib/python2.7/dist-packages/South-0.7.6-py2.7.egg/south/migration/migrators.py", line 356, in migrate_many
    self.migrate(migration, database)
  File "/usr/local/lib/python2.7/dist-packages/South-0.7.6-py2.7.egg/south/migration/migrators.py", line 133, in migrate
    result = self.run(migration)
  File "/usr/local/lib/python2.7/dist-packages/South-0.7.6-py2.7.egg/south/migration/migrators.py", line 107, in run
    return self.run_migration(migration)
  File "/usr/local/lib/python2.7/dist-packages/South-0.7.6-py2.7.egg/south/migration/migrators.py", line 81, in run_migration
    migration_function()
  File "/usr/local/lib/python2.7/dist-packages/South-0.7.6-py2.7.egg/south/migration/migrators.py", line 57, in <lambda>
    return (lambda: direction(orm))
  File "/srv/app/companies/migrations/0003_auto.py", line 22, in backwards
    db.delete_table('companies_company_companyjobs')
  File "/usr/local/lib/python2.7/dist-packages/South-0.7.6-py2.7.egg/south/db/mysql.py", line 78, in _cache_clear
    return func(self, table, *args, **opts)
  File "/usr/local/lib/python2.7/dist-packages/South-0.7.6-py2.7.egg/south/db/mysql.py", line 226, in delete_table
    super(DatabaseOperations, self).delete_table(table_name)
  File "/usr/local/lib/python2.7/dist-packages/South-0.7.6-py2.7.egg/south/db/generic.py", line 44, in _cache_clear
    return func(self, table, *args, **opts)
  File "/usr/local/lib/python2.7/dist-packages/South-0.7.6-py2.7.egg/south/db/generic.py", line 377, in delete_table
    self.execute('DROP TABLE %s CASCADE;' % params)
  File "/usr/local/lib/python2.7/dist-packages/South-0.7.6-py2.7.egg/south/db/generic.py", line 273, in execute
    cursor.execute(sql, params)
  File "/usr/local/lib/python2.7/dist-packages/django/db/backends/mysql/base.py", line 114, in execute
    return self.cursor.execute(query, args)
  File "/usr/lib/python2.7/dist-packages/MySQLdb/cursors.py", line 174, in execute
    self.errorhandler(self, exc, value)
  File "/usr/lib/python2.7/dist-packages/MySQLdb/connections.py", line 36, in defaulterrorhandler
    raise errorclass, errorvalue
django.db.utils.DatabaseError: (1051, "Unknown table 'companies_company_companyjobs'")
4

0 回答 0