Ticket #775 (new defect)

Opened 3 years ago

Last modified 20 months ago

delete_foreign_key doesn't work on sqlite3

Reported by: victor.van.den.elzen@… Owned by: andrew
Priority: major Milestone:
Component: databaseapi Version: 0.7.3
Keywords: Cc:

Description

django.db.utils.DatabaseError: no such table: information_schema.key_column_usage

For now, to have the same migration for PostgreSQL and SQLite I'm using
if db.backend_name != 'sqlite3': as a workaround. It's not really a useful operation in SQLite anyway because foreign key constraints are disabled by default.

SQLite version: 3.7.6.1

Change History

comment:1 Changed 20 months ago by kitsunde@…

drop_foreign_key has the exact same issue. The workaround by the submitter works great (thanks!) Heres the relevant stack trace:

$ src/mediapop/manage.py test vouchers payments dashboard photo_comps giveaways mpsite video_comps landing_pages --settings=conf.settings_payments_staging
nosetests --verbosity 1 vouchers payments dashboard photo_comps giveaways mpsite video_comps landing_pages --with-coverage --cover-xml --cover-package=mediapop --with-xunit
Creating test database for alias 'default'...
FATAL ERROR - The following SQL query failed: 
                SELECT kc.constraint_name, kc.column_name, c.constraint_type
                FROM information_schema.constraint_column_usage AS kc
                JOIN information_schema.table_constraints AS c ON
                    kc.table_schema = c.table_schema AND
                    kc.table_name = c.table_name AND
                    kc.constraint_name = c.constraint_name
                WHERE
                    kc.table_schema = %s AND
                    kc.table_name = %s
            
The error was: no such table: information_schema.constraint_column_usage
Traceback (most recent call last):
  File "src/mediapop/manage.py", line 9, in <module>
    execute_from_command_line(sys.argv)
  File "/Users/kitsunde/.virtualenvs/media-pop/lib/python2.7/site-packages/django/core/management/__init__.py", line 443, in execute_from_command_line
    utility.execute()
  File "/Users/kitsunde/.virtualenvs/media-pop/lib/python2.7/site-packages/django/core/management/__init__.py", line 382, in execute
    self.fetch_command(subcommand).run_from_argv(self.argv)
  File "/Users/kitsunde/.virtualenvs/media-pop/lib/python2.7/site-packages/django/core/management/commands/test.py", line 49, in run_from_argv
    super(Command, self).run_from_argv(argv)
  File "/Users/kitsunde/.virtualenvs/media-pop/lib/python2.7/site-packages/django/core/management/base.py", line 196, in run_from_argv
    self.execute(*args, **options.__dict__)
  File "/Users/kitsunde/.virtualenvs/media-pop/lib/python2.7/site-packages/django/core/management/base.py", line 232, in execute
    output = self.handle(*args, **options)
  File "/Users/kitsunde/.virtualenvs/media-pop/lib/python2.7/site-packages/south/management/commands/test.py", line 8, in handle
    super(Command, self).handle(*args, **kwargs)
  File "/Users/kitsunde/.virtualenvs/media-pop/lib/python2.7/site-packages/django/core/management/commands/test.py", line 72, in handle
    failures = test_runner.run_tests(test_labels)
  File "/Users/kitsunde/.virtualenvs/media-pop/lib/python2.7/site-packages/django_nose/runner.py", line 155, in run_tests
    result = self.run_suite(nose_argv)
  File "/Users/kitsunde/.virtualenvs/media-pop/lib/python2.7/site-packages/django_nose/runner.py", line 117, in run_suite
    addplugins=plugins_to_add)
  File "/Users/kitsunde/.virtualenvs/media-pop/src/nose/nose/core.py", line 118, in __init__
    **extra_args)
  File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/unittest/main.py", line 95, in __init__
    self.runTests()
  File "/Users/kitsunde/.virtualenvs/media-pop/src/nose/nose/core.py", line 197, in runTests
    result = self.testRunner.run(self.test)
  File "/Users/kitsunde/.virtualenvs/media-pop/src/nose/nose/core.py", line 50, in run
    wrapper = self.config.plugins.prepareTest(test)
  File "/Users/kitsunde/.virtualenvs/media-pop/src/nose/nose/plugins/manager.py", line 99, in __call__
    return self.call(*arg, **kw)
  File "/Users/kitsunde/.virtualenvs/media-pop/src/nose/nose/plugins/manager.py", line 167, in simple
    result = meth(*arg, **kw)
  File "/Users/kitsunde/.virtualenvs/media-pop/lib/python2.7/site-packages/django_nose/plugin.py", line 78, in prepareTest
    self.old_names = self.runner.setup_databases()
  File "/Users/kitsunde/.virtualenvs/media-pop/lib/python2.7/site-packages/django_nose/runner.py", line 323, in setup_databases
    return super(NoseTestSuiteRunner, self).setup_databases()
  File "/Users/kitsunde/.virtualenvs/media-pop/lib/python2.7/site-packages/django/test/simple.py", line 317, in setup_databases
    self.verbosity, autoclobber=not self.interactive)
  File "/Users/kitsunde/.virtualenvs/media-pop/lib/python2.7/site-packages/south/hacks/django_1_0.py", line 100, in wrapper
    f(*args, **kwargs)
  File "/Users/kitsunde/.virtualenvs/media-pop/lib/python2.7/site-packages/django/db/backends/creation.py", line 271, in create_test_db
    load_initial_data=False)
  File "/Users/kitsunde/.virtualenvs/media-pop/lib/python2.7/site-packages/django/core/management/__init__.py", line 150, in call_command
    return klass.execute(*args, **defaults)
  File "/Users/kitsunde/.virtualenvs/media-pop/lib/python2.7/site-packages/django/core/management/base.py", line 232, in execute
    output = self.handle(*args, **options)
  File "/Users/kitsunde/.virtualenvs/media-pop/lib/python2.7/site-packages/django/core/management/base.py", line 371, in handle
    return self.handle_noargs(**options)
  File "/Users/kitsunde/.virtualenvs/media-pop/lib/python2.7/site-packages/south/management/commands/syncdb.py", line 99, in handle_noargs
    management.call_command('migrate', **options)
  File "/Users/kitsunde/.virtualenvs/media-pop/lib/python2.7/site-packages/django/core/management/__init__.py", line 150, in call_command
    return klass.execute(*args, **defaults)
  File "/Users/kitsunde/.virtualenvs/media-pop/lib/python2.7/site-packages/django/core/management/base.py", line 232, in execute
    output = self.handle(*args, **options)
  File "/Users/kitsunde/.virtualenvs/media-pop/lib/python2.7/site-packages/south/management/commands/migrate.py", line 108, in handle
    ignore_ghosts = ignore_ghosts,
  File "/Users/kitsunde/.virtualenvs/media-pop/lib/python2.7/site-packages/south/migration/__init__.py", line 213, in migrate_app
    success = migrator.migrate_many(target, workplan, database)
  File "/Users/kitsunde/.virtualenvs/media-pop/lib/python2.7/site-packages/south/migration/migrators.py", line 235, in migrate_many
    result = migrator.__class__.migrate_many(migrator, target, migrations, database)
  File "/Users/kitsunde/.virtualenvs/media-pop/lib/python2.7/site-packages/south/migration/migrators.py", line 310, in migrate_many
    result = self.migrate(migration, database)
  File "/Users/kitsunde/.virtualenvs/media-pop/lib/python2.7/site-packages/south/migration/migrators.py", line 133, in migrate
    result = self.run(migration)
  File "/Users/kitsunde/.virtualenvs/media-pop/lib/python2.7/site-packages/south/migration/migrators.py", line 107, in run
    return self.run_migration(migration)
  File "/Users/kitsunde/.virtualenvs/media-pop/lib/python2.7/site-packages/south/migration/migrators.py", line 86, in run_migration
    print self.run_migration_error(migration)
  File "/Users/kitsunde/.virtualenvs/media-pop/lib/python2.7/site-packages/south/migration/migrators.py", line 304, in run_migration_error
    (self.format_backwards(migration), extra_info))
  File "/Users/kitsunde/.virtualenvs/media-pop/lib/python2.7/site-packages/south/migration/migrators.py", line 291, in format_backwards
    self.backwards(migration)()
  File "/Users/kitsunde/.virtualenvs/media-pop/lib/python2.7/site-packages/south/migration/migrators.py", line 57, in <lambda>
    return (lambda: direction(orm))
  File "/Users/kitsunde/Development/media-pop/src/mediapop/dashboard/migrations/0002_auto__del_credit__del_unique_credit_name_user__del_subscriptionpackage.py", line 101, in backwards
    raise RuntimeError("Cannot reverse this migration. 'FBClient.package' and its values cannot be restored.")
RuntimeError: Cannot reverse this migration. 'FBClient.package' and its values cannot be restored.
Note: See TracTickets for help on using tickets.