0

I'm trying to write a pyramid app that uses the cd34/apex project for authentication. In it, the models for auth are already part of the apex project, which are imported in at runtime. Alembic seems to ignore those models, even if I import them in the env.py.

I tried extending the classes from apex in my own models:

from apex.models import (
    AuthUser,
    AuthUserLog,
    AuthGroup,
    AuthID
)


class EAuthUser(AuthUser):
    pass


class EAuthUserLog(AuthUserLog):
    pass


class EAuthGroup(AuthGroup):
    pass


class EAuthID(AuthID):
    pass

but alembic still drops the tables when I use --autogenerate:

op.drop_table('auth_user_log')
op.drop_table('auth_users')
op.drop_table('auth_groups')
op.drop_table('auth_id')
op.drop_table('auth_auth_groups')

Is there some magic I can do to make alembic ignore particular table names, or better yet, have it track and follow the model definitions in another project?

Peter Grace
  • 569
  • 5
  • 20

1 Answers1

2

make sure your env.py refers to the MetaData used by these models as well as that when env.py runs, it imports everything needed to ensure that these modules all get invoked and imported.

zzzeek
  • 72,307
  • 23
  • 193
  • 185
  • 1
    I didn't realize that the metadata was the secret sauce; all this time I assumed that the system scanned for classes derived from Base and worked from there. by iterating a list of metadatas, I was able to get everything working. As always, you rock! Thanks so much. – Peter Grace Oct 08 '15 at 12:12