Ticket #570 (reopened defect)
Syntax Error!!!
| Reported by: | anonymous | Owned by: | andrew |
|---|---|---|---|
| Priority: | major | Milestone: | 1.0 |
| Component: | commands | Version: | unknown |
| Keywords: | Cc: |
Description (last modified by andrew) (diff)
Creating test database 'default'...
Skipping creation of NoticeTypes as notification app not found
Skipping creation of NoticeTypes as notification app not found
Traceback (most recent call last):
File "./myproject/manage.py", line 11, in <module>
execute_manager(settings)
File "/usr/local/lib/python2.6/dist-packages/django/core/management/__init__.py", line 438, in execute_manager
utility.execute()
File "/usr/local/lib/python2.6/dist-packages/django/core/management/__init__.py", line 379, in execute
self.fetch_command(subcommand).run_from_argv(self.argv)
File "/usr/local/lib/python2.6/dist-packages/django/core/management/base.py", line 191, in run_from_argv
self.execute(*args, **options.__dict__)
File "/usr/local/lib/python2.6/dist-packages/django/core/management/base.py", line 220, in execute
output = self.handle(*args, **options)
File "/home/satels/south-read-only/south/management/commands/test.py", line 8, in handle
super(Command, self).handle(*args, **kwargs)
File "/usr/local/lib/python2.6/dist-packages/django/core/management/commands/test.py", line 37, in handle
failures = test_runner.run_tests(test_labels)
File "/usr/local/lib/python2.6/dist-packages/django/test/simple.py", line 313, in run_tests
old_config = self.setup_databases()
File "/usr/local/lib/python2.6/dist-packages/django/test/simple.py", line 270, in setup_databases
connection.creation.create_test_db(self.verbosity, autoclobber=not self.interactive)
File "/usr/local/lib/python2.6/dist-packages/django/db/backends/creation.py", line 356, in create_test_db
call_command('syncdb', verbosity=max(verbosity - 1, 0), interactive=False, database=self.connection.alias)
File "/usr/local/lib/python2.6/dist-packages/django/core/management/__init__.py", line 166, in call_command
return klass.execute(*args, **defaults)
File "/usr/local/lib/python2.6/dist-packages/django/core/management/base.py", line 220, in execute
output = self.handle(*args, **options)
File "/usr/local/lib/python2.6/dist-packages/django/core/management/base.py", line 351, in handle
return self.handle_noargs(**options)
File "/home/satels/south-read-only/south/management/commands/syncdb.py", line 99, in handle_noargs
management.call_command('migrate', **options)
File "/usr/local/lib/python2.6/dist-packages/django/core/management/__init__.py", line 166, in call_command
return klass.execute(*args, **defaults)
File "/usr/local/lib/python2.6/dist-packages/django/core/management/base.py", line 220, in execute
output = self.handle(*args, **options)
File "/home/satels/south-read-only/south/management/commands/migrate.py", line 105, in handle
ignore_ghosts = ignore_ghosts,
File "/home/satels/south-read-only/south/migration/__init__.py", line 191, in migrate_app
success = migrator.migrate_many(target, workplan, database)
File "/home/satels/south-read-only/south/migration/migrators.py", line 221, in migrate_many
result = migrator.__class__.migrate_many(migrator, target, migrations, database)
File "/home/satels/south-read-only/south/migration/migrators.py", line 292, in migrate_many
result = self.migrate(migration, database)
File "/home/satels/south-read-only/south/migration/migrators.py", line 125, in migrate
result = self.run(migration)
File "/home/satels/south-read-only/south/migration/migrators.py", line 99, in run
return self.run_migration(migration)
File "/home/satels/south-read-only/south/migration/migrators.py", line 81, in run_migration
migration_function()
File "/home/satels/south-read-only/south/migration/migrators.py", line 57, in <lambda>
return (lambda: direction(orm))
File "/home/satels/workspace/myproject/myproject/projects/migrations/0001_add_user_section.py", line 12, in forwards
db.add_column('projects_project', 'author', self.gf('django.db.models.fields.related.ForeignKey')(default=1, to=orm['auth.User']), keep_default=False)
File "/home/satels/south-read-only/south/db/sqlite3.py", line 33, in add_column
field.column: self._column_sql_for_create(table_name, name, field, False),
File "/home/satels/south-read-only/south/db/sqlite3.py", line 79, in _remake_table
self._copy_data(table_name, temp_name, renames)
File "/home/satels/south-read-only/south/db/sqlite3.py", line 105, in _copy_data
self.quote_name(src),
File "/home/satels/south-read-only/south/db/generic.py", line 137, in execute
cursor.execute(sql, params)
File "/usr/local/lib/python2.6/dist-packages/django/db/backends/sqlite3/base.py", line 200, in execute
return Database.Cursor.execute(self, query, params)
django.db.utils.DatabaseError: near ")": syntax error
Attachments
Change History
comment:2 Changed 3 years ago by wediddoit+south@…
I'm having the same problem with a project that I've already deployed and migrated several times before on other machines without issue.
comment:3 Changed 3 years ago by andrew
- Status changed from new to infoneeded
- Description modified (diff)
- Milestone set to 0.7.3
Could either of you please run it again with "--verbosity=2" and paste the output? That way, I can see what the failing statement is.
comment:4 Changed 3 years ago by wediddoit+south@…
- Status changed from infoneeded to assigned
Here's the output:
http://dpaste.com/235796/
comment:5 Changed 3 years ago by wediddoit+south@…
I believe I discovered the problem. Bazaar was versioning the .pyc files for the migrations (I don't know why because it automatically ignores all my other .pyc's). Deleting the .pyc files and then migrating my app worked fine. I don't have the ability to attempt to replicate the problem right now, but this worked for me.
comment:6 Changed 3 years ago by andrew
- Status changed from assigned to closed
- Resolution set to invalid
Alright - since that worked, and the paste has unfortunately expired, I'll close this as invalid for now. Feel free to re-open if you can replicate it.
Changed 2 years ago by desired.mta@…
failing migration
comment:7 Changed 2 years ago by desired.mta@…
2011-03-09 19:46:09,843 DEBUG: /home/motiejus/code/liveopenly_geras/env/lib/python2.6/site-packages/django/db/backends/util.py:44 (0.003) SELECT "south_migrationhistory"."id", "south_migrationhistory"."app_name", "south_migrationhistory"."migration", "south_migrationhistory"."applied" FROM "south_migrationhistory" WHERE "south_migrationhistory"."applied" IS NOT NULL; args=()
2011-03-09 19:46:09,843 DEBUG: /home/motiejus/code/liveopenly_geras/env/lib/python2.6/site-packages/django/db/backends/util.py:44 (0.003) SELECT "south_migrationhistory"."id", "south_migrationhistory"."app_name", "south_migrationhistory"."migration", "south_migrationhistory"."applied" FROM "south_migrationhistory" WHERE "south_migrationhistory"."applied" IS NOT NULL; args=()
2011-03-09 19:46:09,872 DEBUG: /home/motiejus/code/liveopenly_geras/env/lib/python2.6/site-packages/django/db/backends/util.py:44 (0.000) PRAGMA table_info("merchants_merchant"); args=()
2011-03-09 19:46:09,872 DEBUG: /home/motiejus/code/liveopenly_geras/env/lib/python2.6/site-packages/django/db/backends/util.py:44 (0.000) PRAGMA table_info("merchants_merchant"); args=()
2011-03-09 19:46:09,872 DEBUG: /home/motiejus/code/liveopenly_geras/env/lib/python2.6/site-packages/django/db/backends/util.py:44 (0.000) PRAGMA index_list("merchants_merchant"); args=()
2011-03-09 19:46:09,872 DEBUG: /home/motiejus/code/liveopenly_geras/env/lib/python2.6/site-packages/django/db/backends/util.py:44 (0.000) PRAGMA index_list("merchants_merchant"); args=()
2011-03-09 19:46:09,873 DEBUG: /home/motiejus/code/liveopenly_geras/env/lib/python2.6/site-packages/django/db/backends/util.py:44 (0.000) PRAGMA index_list("merchants_merchant"); args=()
2011-03-09 19:46:09,873 DEBUG: /home/motiejus/code/liveopenly_geras/env/lib/python2.6/site-packages/django/db/backends/util.py:44 (0.000) PRAGMA index_list("merchants_merchant"); args=()
2011-03-09 19:46:09,873 DEBUG: /home/motiejus/code/liveopenly_geras/env/lib/python2.6/site-packages/django/db/backends/util.py:44 (0.000) PRAGMA table_info("merchants_merchant"); args=()
2011-03-09 19:46:09,873 DEBUG: /home/motiejus/code/liveopenly_geras/env/lib/python2.6/site-packages/django/db/backends/util.py:44 (0.000) PRAGMA table_info("merchants_merchant"); args=()
2011-03-09 19:46:09,873 DEBUG: /home/motiejus/code/liveopenly_geras/env/lib/python2.6/site-packages/south/db/generic.py:145 south execute "CREATE TABLE "_south_new_merchants_merchant" ()" with params "[]"
2011-03-09 19:46:09,873 DEBUG: /home/motiejus/code/liveopenly_geras/env/lib/python2.6/site-packages/south/db/generic.py:145 south execute "CREATE TABLE "_south_new_merchants_merchant" ()" with params "[]"
2011-03-09 19:46:09,874 DEBUG: /home/motiejus/code/liveopenly_geras/env/lib/python2.6/site-packages/django/db/backends/util.py:44 (0.000) CREATE TABLE "_south_new_merchants_merchant" (); args=[]
2011-03-09 19:46:09,874 DEBUG: /home/motiejus/code/liveopenly_geras/env/lib/python2.6/site-packages/django/db/backends/util.py:44 (0.000) CREATE TABLE "_south_new_merchants_merchant" (); args=[]
Creating NoticeTypes
Running migrations for merchants:
- Migrating forwards to 0004_auto__del_field_merchant_address__add_field_merchant_category__add_fie.
> merchants:0004_auto__del_field_merchant_address__add_field_merchant_category__add_fie
= CREATE TABLE "_south_new_merchants_merchant" () []
Traceback (most recent call last):
File "./manage.py", line 11, in <module>
execute_manager(settings)
File "/home/motiejus/code/liveopenly_geras/env/lib/python2.6/site-packages/django/core/management/__init__.py", line 438, in execute_manager
utility.execute()
File "/home/motiejus/code/liveopenly_geras/env/lib/python2.6/site-packages/django/core/management/__init__.py", line 379, in execute
self.fetch_command(subcommand).run_from_argv(self.argv)
File "/home/motiejus/code/liveopenly_geras/env/lib/python2.6/site-packages/django/core/management/base.py", line 191, in run_from_argv
self.execute(*args, **options.__dict__)
File "/home/motiejus/code/liveopenly_geras/env/lib/python2.6/site-packages/django/core/management/base.py", line 220, in execute
output = self.handle(*args, **options)
File "/home/motiejus/code/liveopenly_geras/env/lib/python2.6/site-packages/south/management/commands/migrate.py", line 105, in handle
ignore_ghosts = ignore_ghosts,
File "/home/motiejus/code/liveopenly_geras/env/lib/python2.6/site-packages/south/migration/__init__.py", line 191, in migrate_app
success = migrator.migrate_many(target, workplan, database)
File "/home/motiejus/code/liveopenly_geras/env/lib/python2.6/site-packages/south/migration/migrators.py", line 221, in migrate_many
result = migrator.__class__.migrate_many(migrator, target, migrations, database)
File "/home/motiejus/code/liveopenly_geras/env/lib/python2.6/site-packages/south/migration/migrators.py", line 292, in migrate_many
result = self.migrate(migration, database)
File "/home/motiejus/code/liveopenly_geras/env/lib/python2.6/site-packages/south/migration/migrators.py", line 125, in migrate
result = self.run(migration)
File "/home/motiejus/code/liveopenly_geras/env/lib/python2.6/site-packages/south/migration/migrators.py", line 99, in run
return self.run_migration(migration)
File "/home/motiejus/code/liveopenly_geras/env/lib/python2.6/site-packages/south/migration/migrators.py", line 81, in run_migration
migration_function()
File "/home/motiejus/code/liveopenly_geras/env/lib/python2.6/site-packages/south/migration/migrators.py", line 57, in <lambda>
return (lambda: direction(orm))
File "/home/motiejus/code/liveopenly_geras/application/apps/merchants/migrations/0004_auto__del_field_merchant_address__add_field_merchant_category__add_fie.py", line 12, in forwards
db.delete_column('merchants_merchant', 'address')
File "/home/motiejus/code/liveopenly_geras/env/lib/python2.6/site-packages/south/db/sqlite3.py", line 187, in delete_column
self._remake_table(table_name, deleted=[column_name])
File "/home/motiejus/code/liveopenly_geras/env/lib/python2.6/site-packages/south/db/sqlite3.py", line 80, in _remake_table
", ".join(["%s %s" % (self.quote_name(cname), ctype) for cname, ctype in definitions.items()]),
File "/home/motiejus/code/liveopenly_geras/env/lib/python2.6/site-packages/south/db/generic.py", line 150, in execute
cursor.execute(sql, params)
File "/home/motiejus/code/liveopenly_geras/env/lib/python2.6/site-packages/django/db/backends/util.py", line 34, in execute
return self.cursor.execute(sql, params)
File "/home/motiejus/code/liveopenly_geras/env/lib/python2.6/site-packages/django/db/backends/sqlite3/base.py", line 234, in execute
return Database.Cursor.execute(self, query, params)
django.db.utils.DatabaseError: near ")": syntax error
comment:9 Changed 2 years ago by andrew
- Status changed from closed to reopened
- Resolution invalid deleted
- Milestone changed from 0.7.3 to 1.0
comment:10 Changed 2 years ago by desired.mta@…
Hello,
I managed to figure out what was wrong. The migration 0001 was changed by accident to 0004, therefore it was creating a "migrated" database already, and complaining on 0004 with this rather unhelpful error message.
If necessary, I can attach migrations 0001-0003 to improve the help text for programmer mistakes. :)
Thanks for a great tool!
comment:11 follow-up: ↓ 12 Changed 2 years ago by andrew
Hang on, so you moved migration 0001 to 0004, and that caused the error? It's worth attaching them, just in case I get the time to review them.
comment:12 in reply to: ↑ 11 Changed 2 years ago by jivan
I'm getting the same error, but don't see any evidence that a migration number was moved forward. The error only appears when one app is migrated before another. If the order is reversed, the migrations go smoothly. I'll include the output of the failing migration; if there's anything else I can do to help find the problem, please let me know.
- Migrating forwards to 0002_auto__add_field_modulepairfitnesscutoff_version__add_field_coherencecu.
> data_analysis:0002_auto__add_field_modulepairfitnesscutoff_version__add_field_coherencecu
= CREATE TABLE "_south_new_data_analysis_modulepairfitnesscutoff" ("version" varchar(8) NOT NULL DEFAULT '1.0') []
= INSERT INTO "_south_new_data_analysis_modulepairfitnesscutoff" () SELECT FROM "data_analysis_modulepairfitnesscutoff"; []
Traceback (most recent call last):
File "manage.py", line 11, in <module>
execute_manager(settings)
File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/django/core/management/__init__.py", line 438, in execute_manager
utility.execute()
-- snip --
File "/Users/jivan/projects/lanternscs/data_analysis/migrations/0002_auto__add_field_modulepairfitnesscutoff_version__add_field_coherencecu.py", line 12, in forwards
db.add_column('data_analysis_modulepairfitnesscutoff', 'version', self.gf('django.db.models.fields.CharField')(default='1.0', max_length='8'), keep_default=False)
File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/south/db/sqlite3.py", line 35, in add_column
field.column: self._column_sql_for_create(table_name, name, field, False),
File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/south/db/sqlite3.py", line 83, in _remake_table
self._copy_data(table_name, temp_name, renames)
File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/south/db/sqlite3.py", line 114, in _copy_data
self.quote_name(src),
File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/south/db/generic.py", line 150, in execute
cursor.execute(sql, params)
File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/django/db/backends/util.py", line 15, in execute
return self.cursor.execute(sql, params)
File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/django/db/backends/sqlite3/base.py", line 200, in execute
return Database.Cursor.execute(self, query, params)
django.db.utils.DatabaseError: near ")": syntax error
comment:13 Changed 19 months ago by alej0varas@…
I had the same problem recently and is south that is generating a bad query, this because I renamed some migrations and south was migrating a table that was dropped by a previous migration. So putting my migrations in order fixed the problem.
comment:14 Changed 7 weeks ago by fredley
I get this error when trying to migrate an auto-generated schema-migration:
FATAL ERROR - The following SQL query failed: INSERT INTO "_south_new_skan_doctoraccess" () SELECT FROM "skan_doctoraccess"; The error was: near ")": syntax error ! 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: ! 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: skan:0018_auto__chg_field_doctoraccess_patient__chg_field_doctoraccess_doctor__c DatabaseError: near ")": syntax error
comment:15 Changed 7 weeks ago by lewis
Hi fredley,
I had the same problem when I was doing a migration with Sqlite3. For me, South was trying to perform the query:
INSERT INTO "_south_new_auth_user" () SELECT FROM "auth_user";
That's clearly an invalid query. South is trying to create a new table and copy the contents of the old into the new. After some digging, I found that South is introspecting the table to find out which columns to copy into the new table. The short answer is the old table, auth_user, didn't exist.
Try running your migrations against MySQL - it gives you a much more helpful error message! :)
Make sure there is a command in a previous migration that creates the table skan_doctoraccess. One thing to try is migrating to 0017, then go into Sqlite3 and ensure that the table is there. I'll bet you a beer it isn't.
Hope this helps

Version: 0.7.2