0

I have a Flask project with multiple apps and using Sqlalchemy+Alembic for database, how would I handle the case where the apps have models with same name (for example all of the apps will have User model)? In Django the tables are prefixed with app name so there's no conflicts. Is there some way to do the same here?

4

1 回答 1

2

在每个模型中使用__tablename__为每个表显式分配名称:

class User1(db.Model):
    __tablename__ = 'app1_users'
    id = db.Column(...)
    # ...

class User2(db.Model):
    __tablename__ = 'app2_users'
    id = db.Column(...)
    # ...
于 2013-09-09T01:57:10.303 回答