djangopypi icon indicating copy to clipboard operation
djangopypi copied to clipboard

Using south fail

Open Natim opened this issue 13 years ago • 3 comments

python manage.py syncdb --migrate
Syncing...
Creating tables ...
Creating table auth_permission
Creating table auth_group_permissions
Creating table auth_group
Creating table auth_user_user_permissions
Creating table auth_user_groups
Creating table auth_user
Creating table django_content_type
Creating table django_session
Creating table django_site
Creating table south_migrationhistory

You just installed Django's auth system, which means you don't have any superusers defined.
Would you like to create one now? (yes/no): no
Installing custom SQL ...
Installing indexes ...
Installed 0 object(s) from 0 fixture(s)
Migrating...
Running migrations for djangopypi:
 - Migrating forwards to 0005_allow_null_distribution_uploader.
 > djangopypi:0001_initial
 > djangopypi:0002_refactoring
~/hg/chishop/apps/local/lib/python2.7/site-packages/django/db/models/fields/__init__.py:808: RuntimeWarning: DateTimeField received a naive datetime (1970-01-01 00:00:00) while time zone support is active.
  RuntimeWarning)
FATAL ERROR - The following SQL query failed: ALTER TABLE `djangopypi_release` ADD COLUMN `package_id` varchar(255) NOT NULL DEFAULT None;
The error was: (1064, "You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'None' at line 1")
 ! 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.

! You *might* be able to recover with:   = CREATE TABLE `djangopypi_project` (`updated` datetime NOT NULL, `description` longtext NOT NULL, `metadata_version` varchar(64) NOT NULL DEFAULT '1.0', `owner_id` integer NOT NULL, `summary` longtext NOT NULL, `name` varchar(255) NOT NULL UNIQUE, `license` longtext NOT NULL, `author` varchar(128) NOT NULL, `home_page` varchar(200) NULL, `download_url` varchar(200) NULL, `id` integer AUTO_INCREMENT NOT NULL PRIMARY KEY, `author_email` varchar(255) NOT NULL); []
   = CREATE TABLE `djangopypi_project_classifiers` (`id` integer AUTO_INCREMENT NOT NULL PRIMARY KEY, `project_id` integer NOT NULL, `classifier_id` integer NOT NULL); []
   = ALTER TABLE `djangopypi_project_classifiers` ADD CONSTRAINT `djangopypi_project_classifiers_project_id_cff2b4571a6cca1_uniq` UNIQUE (`project_id`, `classifier_id`) []
   = DROP TABLE `djangopypi_distribution` CASCADE; []
   = DROP TABLE `djangopypi_review` CASCADE; []
   = DROP TABLE `djangopypi_package` CASCADE; []
   = DROP TABLE `djangopypi_package_owners` CASCADE; []
   = DROP TABLE `djangopypi_package_maintainers` CASCADE; []
   - no dry run output for alter_column() due to dynamic DDL, sorry
   = ALTER TABLE `djangopypi_release` ADD COLUMN `md5_digest` varchar(255) NOT NULL DEFAULT ''; []
   - no dry run output for alter_column() due to dynamic DDL, sorry
   = ALTER TABLE `djangopypi_release` ADD COLUMN `filetype` varchar(255) NOT NULL DEFAULT ''; []
   - no dry run output for alter_column() due to dynamic DDL, sorry
   = ALTER TABLE `djangopypi_release` ADD COLUMN `upload_time` datetime NOT NULL DEFAULT '1969-12-31 23:00:00'; []
   - no dry run output for alter_column() due to dynamic DDL, sorry
   = ALTER TABLE `djangopypi_release` ADD COLUMN `pyversion` varchar(255) NOT NULL DEFAULT ''; []
   - no dry run output for alter_column() due to dynamic DDL, sorry
   = ALTER TABLE `djangopypi_release` ADD COLUMN `project_id` integer NOT NULL DEFAULT None; []
   - no dry run output for alter_column() due to dynamic DDL, sorry
   = ALTER TABLE `djangopypi_release` ADD COLUMN `platform` varchar(255) NOT NULL DEFAULT ''; []
   - no dry run output for alter_column() due to dynamic DDL, sorry
   = ALTER TABLE `djangopypi_release` ADD COLUMN `signature` varchar(128) NOT NULL DEFAULT ''; []
   - no dry run output for alter_column() due to dynamic DDL, sorry
   = ALTER TABLE `djangopypi_release` ADD COLUMN `distribution` varchar(100) NOT NULL DEFAULT ''; []
   - no dry run output for alter_column() due to dynamic DDL, sorry
   - no dry run output for delete_foreign_key() due to dynamic DDL, sorry
   = ALTER TABLE `djangopypi_release` DROP COLUMN `package_id` CASCADE; []
   - no dry run output for delete_foreign_key() due to dynamic DDL, sorry
   = ALTER TABLE `djangopypi_release` DROP COLUMN `metadata_version` CASCADE; []
   - no dry run output for delete_foreign_key() due to dynamic DDL, sorry
   = ALTER TABLE `djangopypi_release` DROP COLUMN `package_info` CASCADE; []
   - no dry run output for delete_foreign_key() due to dynamic DDL, sorry
   = ALTER TABLE `djangopypi_release` DROP COLUMN `hidden` CASCADE; []
   - no dry run output for delete_foreign_key() due to dynamic DDL, sorry
   = ALTER TABLE `djangopypi_release` DROP COLUMN `created` CASCADE; []
   = ALTER TABLE `djangopypi_release` ADD CONSTRAINT `djangopypi_release_project_id_3b8fc244160e211b_uniq` UNIQUE (`project_id`, `platform`, `distribution`, `version`, `pyversion`) []
   - no dry run output for delete_unique_column() due to dynamic DDL, sorry

 ! 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: djangopypi:0002_refactoring
Traceback (most recent call last):
  File "manage.py", line 10, in <module>
    execute_from_command_line(sys.argv)
  File "~/hg/chishop/apps/local/lib/python2.7/site-packages/django/core/management/__init__.py", line 443, in execute_from_command_line
    utility.execute()
  File "~/hg/chishop/apps/local/lib/python2.7/site-packages/django/core/management/__init__.py", line 382, in execute
    self.fetch_command(subcommand).run_from_argv(self.argv)
  File "~/hg/chishop/apps/local/lib/python2.7/site-packages/django/core/management/base.py", line 196, in run_from_argv
    self.execute(*args, **options.__dict__)
  File "~/hg/chishop/apps/local/lib/python2.7/site-packages/django/core/management/base.py", line 232, in execute
    output = self.handle(*args, **options)
  File "~/hg/chishop/apps/local/lib/python2.7/site-packages/django/core/management/base.py", line 371, in handle
    return self.handle_noargs(**options)
  File "~/hg/chishop/apps/local/lib/python2.7/site-packages/south/management/commands/syncdb.py", line 99, in handle_noargs
    management.call_command('migrate', **options)
  File "~/hg/chishop/apps/local/lib/python2.7/site-packages/django/core/management/__init__.py", line 150, in call_command
    return klass.execute(*args, **defaults)
  File "~/hg/chishop/apps/local/lib/python2.7/site-packages/django/core/management/base.py", line 232, in execute
    output = self.handle(*args, **options)
  File "~/hg/chishop/apps/local/lib/python2.7/site-packages/south/management/commands/migrate.py", line 107, in handle
    ignore_ghosts = ignore_ghosts,
  File "~/hg/chishop/apps/local/lib/python2.7/site-packages/south/migration/__init__.py", line 219, in migrate_app
    success = migrator.migrate_many(target, workplan, database)
  File "~/hg/chishop/apps/local/lib/python2.7/site-packages/south/migration/migrators.py", line 235, in migrate_many
    result = migrator.__class__.migrate_many(migrator, target, migrations, database)
  File "~/hg/chishop/apps/local/lib/python2.7/site-packages/south/migration/migrators.py", line 310, in migrate_many
    result = self.migrate(migration, database)
  File "~/hg/chishop/apps/local/lib/python2.7/site-packages/south/migration/migrators.py", line 133, in migrate
    result = self.run(migration)
  File "~/hg/chishop/apps/local/lib/python2.7/site-packages/south/migration/migrators.py", line 107, in run
    return self.run_migration(migration)
  File "~/hg/chishop/apps/local/lib/python2.7/site-packages/south/migration/migrators.py", line 81, in run_migration
    migration_function()
  File "~/hg/chishop/apps/local/lib/python2.7/site-packages/south/migration/migrators.py", line 57, in <lambda>
    return (lambda: direction(orm))
  File "~/hg/chishop/apps/local/lib/python2.7/site-packages/djangopypi/migrations/0002_refactoring.py", line 96, in forwards
    db.add_column('djangopypi_release', 'package', self.gf('django.db.models.fields.related.ForeignKey')(default='', related_name='releases', to=orm['djangopypi.Package']), keep_default=False)
  File "~/hg/chishop/apps/local/lib/python2.7/site-packages/south/db/generic.py", line 46, in _cache_clear
    return func(self, table, *args, **opts)
  File "~/hg/chishop/apps/local/lib/python2.7/site-packages/south/db/generic.py", line 408, in add_column
    self.execute(sql)
  File "~/hg/chishop/apps/local/lib/python2.7/site-packages/south/db/generic.py", line 264, in execute
    cursor.execute(sql, params)
  File "~/hg/chishop/apps/local/lib/python2.7/site-packages/django/db/backends/util.py", line 40, in execute
    return self.cursor.execute(sql, params)
  File "~/hg/chishop/apps/local/lib/python2.7/site-packages/django/db/backends/mysql/base.py", line 114, in execute
    return self.cursor.execute(query, args)
  File "~/hg/chishop/apps/local/lib/python2.7/site-packages/MySQLdb/cursors.py", line 174, in execute
    self.errorhandler(self, exc, value)
  File "~/hg/chishop/apps/local/lib/python2.7/site-packages/MySQLdb/connections.py", line 36, in defaulterrorhandler
    raise errorclass, errorvalue
django.db.utils.DatabaseError: (1064, "You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'None' at line 1")

Natim avatar May 03 '12 06:05 Natim

I got something very similar using postgresql:

Running migrations for djangopypi:

  • Migrating forwards to 0005_allow_null_distribution_uploader.

    djangopypi:0001_initial djangopypi:0002_refactoring FATAL ERROR - The following SQL query failed: ALTER TABLE "djangopypi_release" ADD COLUMN "package_id" varchar(255) NOT NULL DEFAULT None; The error was: column "none" does not exist

Error in migration: djangopypi:0002_refactoring Traceback (most recent call last): File "/var/www/django/kavipypi/manage.py", line 14, in execute_manager(settings) File "/usr/lib/python2.6/site-packages/django/core/management/init.py", line 438, in execute_manager utility.execute() File "/usr/lib/python2.6/site-packages/django/core/management/init.py", line 379, in execute self.fetch_command(subcommand).run_from_argv(self.argv) File "/usr/lib/python2.6/site-packages/django/core/management/base.py", line 191, in run_from_argv self.execute(_args, *_options.dict) File "/usr/lib/python2.6/site-packages/django/core/management/base.py", line 220, in execute output = self.handle(_args, *_options) File "/usr/lib/python2.6/site-packages/south/management/commands/migrate.py", line 107, in handle ignore_ghosts = ignore_ghosts, File "/usr/lib/python2.6/site-packages/south/migration/init.py", line 219, in migrate_app success = migrator.migrate_many(target, workplan, database) File "/usr/lib/python2.6/site-packages/south/migration/migrators.py", line 235, in migrate_many result = migrator.class.migrate_many(migrator, target, migrations, database) File "/usr/lib/python2.6/site-packages/south/migration/migrators.py", line 310, in migrate_many result = self.migrate(migration, database) File "/usr/lib/python2.6/site-packages/south/migration/migrators.py", line 133, in migrate result = self.run(migration) File "/usr/lib/python2.6/site-packages/south/migration/migrators.py", line 107, in run return self.run_migration(migration) File "/usr/lib/python2.6/site-packages/south/migration/migrators.py", line 81, in run_migration migration_function() File "/usr/lib/python2.6/site-packages/south/migration/migrators.py", line 57, in return (lambda: direction(orm)) File "/usr/lib/python2.6/site-packages/djangopypi-0.4.4-py2.6.egg/djangopypi/migrations/0002_refactoring.py", line 96, in forwards db.add_column('djangopypi_release', 'package', self.gf('django.db.models.fields.related.ForeignKey')(default='', related_name='releases', to=orm['djangopypi.Package']), keep_default=False) File "/usr/lib/python2.6/site-packages/south/db/generic.py", line 44, in _cache_clear return func(self, table, _args, *_opts) File "/usr/lib/python2.6/site-packages/south/db/generic.py", line 405, in add_column self.execute(sql) File "/usr/lib/python2.6/site-packages/south/db/generic.py", line 273, in execute cursor.execute(sql, params) File "/usr/lib/python2.6/site-packages/django/db/backends/postgresql_psycopg2/base.py", line 44, in execute return self.cursor.execute(query, args) django.db.utils.DatabaseError: column "none" does not exist

spkane avatar Sep 07 '12 18:09 spkane

ALTER TABLE djangopypi_release ADD COLUMN package_id varchar(255) NOT NULL;

seems to work whereas:

ALTER TABLE "djangopypi_release" ADD COLUMN "package_id" varchar(255) NOT NULL DEFAULT None;

does not

spkane avatar Sep 07 '12 18:09 spkane

I too encountered the similar error with south

a1Gupta avatar Jan 05 '15 07:01 a1Gupta