Best location and name for Alembic scripts directory

111 views
Skip to first unread message

Matt McClure

unread,
Jan 26, 2015, 6:07:15 PM1/26/15
to sqlalchem...@googlegroups.com
After reading the tutorial, and searching a little in the documentation and group archives, I'm unclear on the best location and name of the Alembic scripts directory.

The tutorial advises:

yourproject/
    alembic/

And indicates:

yourproject - this is the root of your application’s source code, or some directory within it.

If my project directory structure looks like:

my-project/
    mypackage/
        __init__.py

Then, is it better to make the scripts directory a child or a sibling of mypackage?

Is the intent that the scripts directory be an importable module?

Would it be best to name it something other than "alembic" to avoid import conflicts with Alembic itself?

Best,
Matt

-- 

Michael Bayer

unread,
Jan 26, 2015, 6:50:09 PM1/26/15
to sqlalchem...@googlegroups.com


Matt McClure <ma...@cens.io> wrote:

> After reading the tutorial, and searching a little in the documentation and group archives, I'm unclear on the best location and name of the Alembic scripts directory.
>
> The tutorial advises:
>
> yourproject/
> alembic/
>
> And indicates:
>
> yourproject - this is the root of your application’s source code, or some directory within it.
>
> If my project directory structure looks like:
>
> my-project/
> mypackage/
> __init__.py
>
> Then, is it better to make the scripts directory a child or a sibling of my package?


I tend to go with sibling, it’s not really a “package”.

>
> Is the intent that the scripts directory be an importable module?

it’s not. some people try to treat it that way, putting the migration files at least deep within their package tree, and that is fine also, but Alembic itself doesn’t need it to behave that way.


>
> Would it be best to name it something other than "alembic" to avoid import conflicts with Alembic itself?

you can name it whatever, but it’s not a package so doesn’t have any kind of module name conflicts.




>
> Best,
> Matt
>
> --
> http://matthewlmcclure.com
>
> --
> 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-alem...@googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.

Matt McClure

unread,
Jan 26, 2015, 6:56:08 PM1/26/15
to sqlalchem...@googlegroups.com
Thanks for clarifying!

You received this message because you are subscribed to a topic in the Google Groups "sqlalchemy-alembic" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/sqlalchemy-alembic/pET7mHg59H4/unsubscribe.
To unsubscribe from this group and all its topics, send an email to sqlalchemy-alem...@googlegroups.com.

For more options, visit https://groups.google.com/d/optout.

Tom Lazar

unread,
Jan 27, 2015, 4:36:44 PM1/27/15
to sqlalchem...@googlegroups.com
another aspect you might want to consider (we had to) is that you must make sure that the migration scripts will become part of an eggified version of your package.

once we started to deploy our code from packaged eggs (rather than source checkouts) we found it easiest to simply move the alembic folder *inside* our package.

YMMV,

tom
Reply all
Reply to author
Forward
0 new messages