MySQL requires a “type” for a drop constraint, so that the directive knows what 
specific DROP command to emit on MySQL.  Other databases don’t have this 
limitation which is why there’s a “drop_constraint” in the first place, as 
opposed to “drop_foreign_key”, “drop_check_constraint”, etc.

from 
http://alembic.readthedocs.org/en/latest/ops.html#alembic.operations.Operations.drop_constraint:

type_ –
optional, required on MySQL. can be ‘foreignkey’, ‘primary’, ‘unique’, or 
‘check’.





On Dec 30, 2013, at 1:08 AM, Wesley <nisp...@gmail.com> wrote:

> Hi ,
>   I got the following error when do downgrade operation.
> 
> [root@localhost PushServer]# alembic downgrade base
> INFO  [alembic.migration] Context impl MySQLImpl.
> INFO  [alembic.migration] Will assume non-transactional DDL.
> INFO  [alembic.migration] Running downgrade 3cb78fe040f4 -> 4bfc6a00969f, 
> delete name2
> Traceback (most recent call last):
>   File "/usr/bin/alembic", line 9, in <module>
>     load_entry_point('alembic==0.6.2', 'console_scripts', 'alembic')()
>   File "/usr/lib/python2.6/site-packages/alembic/config.py", line 298, in main
>     CommandLine(prog=prog).main(argv=argv)
>   File "/usr/lib/python2.6/site-packages/alembic/config.py", line 293, in main
>     self.run_cmd(cfg, options)
>   File "/usr/lib/python2.6/site-packages/alembic/config.py", line 279, in 
> run_cmd
>     **dict((k, getattr(options, k)) for k in kwarg)
>   File "/usr/lib/python2.6/site-packages/alembic/command.py", line 150, in 
> downgrade
>     script.run_env()
>   File "/usr/lib/python2.6/site-packages/alembic/script.py", line 199, in 
> run_env
>     util.load_python_file(self.dir, 'env.py')
>   File "/usr/lib/python2.6/site-packages/alembic/util.py", line 199, in 
> load_python_file
>     module = load_module(module_id, path)
>   File "/usr/lib/python2.6/site-packages/alembic/compat.py", line 55, in 
> load_module
>     mod = imp.load_source(module_id, path, fp)
>   File "alembic/env.py", line 77, in <module>
>     run_migrations_online()
>   File "alembic/env.py", line 70, in run_migrations_online
>     context.run_migrations()
>   File "<string>", line 7, in run_migrations
>   File "/usr/lib/python2.6/site-packages/alembic/environment.py", line 652, 
> in run_migrations
>     self.get_context().run_migrations(**kw)
>   File "/usr/lib/python2.6/site-packages/alembic/migration.py", line 225, in 
> run_migrations
>     change(**kw)
>   File "alembic/versions/3cb78fe040f4_delete_name2.py", line 29, in downgrade
>     op.drop_constraint(None, 'device')
>   File "<string>", line 7, in drop_constraint
>   File "<string>", line 1, in <lambda>
>   File "/usr/lib/python2.6/site-packages/alembic/util.py", line 294, in go
>     return fn(*arg, **kw)
>   File "/usr/lib/python2.6/site-packages/alembic/operations.py", line 775, in 
> drop_constraint
>     self.impl.drop_constraint(const)
>   File "/usr/lib/python2.6/site-packages/alembic/ddl/impl.py", line 138, in 
> drop_constraint
>     self._exec(schema.DropConstraint(const))
>   File "/usr/lib/python2.6/site-packages/alembic/ddl/impl.py", line 76, in 
> _exec
>     conn.execute(construct, *multiparams, **params)
>   File 
> "/usr/lib/python2.6/site-packages/SQLAlchemy-0.8.3-py2.6-linux-x86_64.egg/sqlalchemy/engine/base.py",
>  line 662, in execute
>     params)
>   File 
> "/usr/lib/python2.6/site-packages/SQLAlchemy-0.8.3-py2.6-linux-x86_64.egg/sqlalchemy/engine/base.py",
>  line 714, in _execute_ddl
>     compiled = ddl.compile(dialect=dialect)
>   File 
> "/usr/lib/python2.6/site-packages/SQLAlchemy-0.8.3-py2.6-linux-x86_64.egg/sqlalchemy/sql/expression.py",
>  line 1920, in compile
>     return self._compiler(dialect, bind=bind, **kw)
>   File 
> "/usr/lib/python2.6/site-packages/SQLAlchemy-0.8.3-py2.6-linux-x86_64.egg/sqlalchemy/schema.py",
>  line 2954, in _compiler
>     return dialect.ddl_compiler(dialect, self, **kw)
>   File 
> "/usr/lib/python2.6/site-packages/SQLAlchemy-0.8.3-py2.6-linux-x86_64.egg/sqlalchemy/engine/interfaces.py",
>  line 787, in __init__
>     self.string = self.process(self.statement, **compile_kwargs)
>   File 
> "/usr/lib/python2.6/site-packages/SQLAlchemy-0.8.3-py2.6-linux-x86_64.egg/sqlalchemy/engine/interfaces.py",
>  line 806, in process
>     return obj._compiler_dispatch(self, **kwargs)
>   File 
> "/usr/lib/python2.6/site-packages/SQLAlchemy-0.8.3-py2.6-linux-x86_64.egg/sqlalchemy/ext/compiler.py",
>  line 410, in <lambda>
>     lambda *arg, **kw: existing(*arg, **kw))
>   File 
> "/usr/lib/python2.6/site-packages/SQLAlchemy-0.8.3-py2.6-linux-x86_64.egg/sqlalchemy/ext/compiler.py",
>  line 448, in __call__
>     return fn(element, compiler, **kw)
>   File "/usr/lib/python2.6/site-packages/alembic/ddl/mysql.py", line 138, in 
> _mysql_drop_constraint
>     "No generic 'DROP CONSTRAINT' in MySQL - "
> NotImplementedError: No generic 'DROP CONSTRAINT' in MySQL - please specify 
> constraint type
> 
> Something related to database settings? how to fix this guy?
> 
> Thanks.
> Wesley
> 
> -- 
> You received this message because you are subscribed to the Google Groups 
> "sqlalchemy-alembic" group.
> To unsubscribe from this group and stop receiving emails from it, send an 
> email to sqlalchemy-alembic+unsubscr...@googlegroups.com.
> For more options, visit https://groups.google.com/groups/opt_out.

Attachment: signature.asc
Description: Message signed with OpenPGP using GPGMail

Reply via email to