sqlalchemy / alembic

A database migrations tool for SQLAlchemy.
MIT License
2.76k stars 241 forks source link

Programmatically call revision with autogenerate True does not set context.cmd_options.autogenerate to True #1362

Closed ruben-janssens closed 10 months ago

ruben-janssens commented 10 months ago

Describe the bug When attempting to programmatically generate a new revision of a database and placing a process_revision_directives function in the context in env.py does not set context.cmd_options.autogenerate to True. In addition to this it does also not throw any error readable error. The program just gets in a 'stuck'.

Expected behavior Throw an error so we know what the problem is or add more documentation regarding the command module.

To Reproduce Use the command module and call the revision command with autogenerate set to True. In your env.py do something with config.cmd_opts.autogenerate. The application will error and you can catch it with a try except but no readable error is given.

Versions.

zzzeek commented 10 months ago

hi -

cmd_options is only the command line options. if you dont have a command line then nothing there will be set. When calling programmatically, cmd_opts is None, so there will not be anything to read.

to get help debugging your program including this "stuck" state, please open a discussion with more detail how you are calling these commands.