it's possible to change the table name for user/role/permission tables?
ZeeD opened this issue · 2 comments
By default the models/tables defined in flask_appbuilder/security/sqla/models.py have the ab_
prefix
I am trying to extend the data model (adding some columns) with a subclass - as suggested in Extending the User Model - but I also would like to change the table names, so ab_user
will became users
.
It's possible? if I naively set
class MyUser(User):
__tablename__ = 'users'
...
I end with sqlalchemy.exc.ArgumentError: Can't place __table_args__ on an inherited class with no table.
during the import of the module
What are you trying to accomplish?
Do you want the entire user table to have a different name, or are you trying to store only your custom columns in a different table?
If you want to change the table name of the User
class you would have to change it in the source code and rebuild from scratch. as the User
class is used internally. I think theoraticly you could make an edit to the class that allows polymorphism (like here). But im not quite sure how it works and seems like a lot of trouble.
If you want to create a new table that only holds your custom columns, I would suggest creating your own class and making a 1-to-1 mapping to the User
class.
However im still not really understanding why you would want to change the table name....
I want the entire user table to have a different name, while keeping the logic already there.
AND I also want to extend the table adding some columns, but that's another thing.
But I really don't want to vendor the project, so I think I would try to change the class dynamically