Default MetaData kwarg naming_convention can create issues with certain databases
Author: jvanascoCreated Jul 26, 2019Updated Sep 3, 2026
Labelsdocumentation
- this is a docs ticket; assign to @jvanasco
- reference group discussion: https://groups.google.com/forum/#!topic/sqlalchemy/8xOu-Mlcobo
The alembic docs reference this naming convention: https://alembic.sqlalchemy.org/en/latest/naming.html
convention = {
"ix": "ix_%(column_0_label)s",
"uq": "uq_%(table_name)s_%(column_0_name)s",
"ck": "ck_%(table_name)s_%(constraint_name)s",
"fk": "fk_%(table_name)s_%(column_0_name)s_%(referred_table_name)s",
"pk": "pk_%(table_name)s"
}
metadata = MetaData(naming_convention=convention)a Boolean/Enum column will try to create a constraint on sqlite by default, but constraint_name is not defined. this will cause an error in Engine.create_all(
Tasks:
[ ] have the docs use custom callables to offer an automatic constraint name. [ ] long term: descope into another issue a fallback option for constraint name.
see referenced discussion for details of above.
Source: sqlalchemy/sqlalchemy