-
|
pls kindly advise why cannot to add new table from db_models.py as below class UserTenantKB(DataBaseModel): |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 3 replies
-
|
Hi @guiweit! I'm Dosu and I’m helping the ragflow team. The most common reasons a new table isn't created from your model in db_models.py are:
Check your logs for errors during the table creation step, verify your model is present in db_models.py before startup, and confirm your database is healthy and accessible. If you see specific error messages, share them for more targeted help. To reply, just mention @dosu. How did I do? Good | Irrelevant | Incorrect | Verbose | Hallucination | Report 🐛 | Other |
Beta Was this translation helpful? Give feedback.
-
|
Further to above, still unable to create manually @DB.connection_context() |
Beta Was this translation helpful? Give feedback.
When you rename a model's db_table or change its schema, Peewee's create_table(safe=True) will only create the table if it does not already exist—it will not rename or update an existing table. If user_tenant_kb already exists in your database (even with a different schema), create_table will skip creation and log that the table exists. If the schema is outdated, you need to manually migrate (ALTER TABLE) or drop and recreate the table if possible.
Also, make sure your model is imported before init_database_tables runs, or it won't be detected for table creation. Check your logs for any errors during table creation—migration failures or unsynchronized schemas can also block creation, and…