On Thu, Mar 5, 2020, at 8:08 AM, Daniel Cardin wrote:
> I am attempting to write a library which invokes alembic commands, while 
> referencing the migrations of a separate package which has installed said 
> library.
> 
> The intent here, is for the library to invoke the alembic commands with an 
> env.py defined in that package. This seems to work through 
> config.get("script_location", "package_name:foldername")
> but then obviously expects the actual migrations to be colocated at the same 
> location.
> 
> My guess would be, if this is possible at all, that there'd be something I 
> could put in the env.py which would reconfigure it to execute the 
> `context.run_migrations()` migration context (and therefore search path, back 
> at the original call site.
> 
> I realize that this won't always work, given that env.py is often likely 
> customized enough such that a generic one wouldn't be able to execute them, 
> but per your cookbook suggestions about programmatic invocation of commands, 
> this sort of thing requires the user to opt into changing their env.py to use
> connectable = context.config.attributes.get("connection", None)
> in order to make use of a connection handed to it.

I'm not following all the moving pieces here, like when you say "commands", i 
assume you mean the commands in alembic.command, , like 
alembic.command.upgrade(). when you say "an env.py defined in that package", I 
guess you mean in the separate package that is using your library. 

this doesn't seem different from what Alembic itself does, "that package" would 
have a directory where the env.py and its migration files are present? So... 
I'm not really sure what you're trying to do beyond call an Alembic command 
that is against a particular directory.

if OTOH by "commands" you mean migration operations, like you want to call 
op.create_table() yourself, OK, but I don't really understand enough to 
formulate an answer for you.




> 

> --
>  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.
>  To view this discussion on the web visit 
> https://groups.google.com/d/msgid/sqlalchemy-alembic/5612f1d1-9e93-46ed-9be7-0db362b815a8%40googlegroups.com
>  
> <https://groups.google.com/d/msgid/sqlalchemy-alembic/5612f1d1-9e93-46ed-9be7-0db362b815a8%40googlegroups.com?utm_medium=email&utm_source=footer>.

-- 
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.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/sqlalchemy-alembic/68640cf0-9297-4a55-9c26-7c54d7edae62%40www.fastmail.com.

Reply via email to