obs-portal/api/migrations/utils.py

17 lines
389 B
Python
Raw Normal View History

2022-04-02 10:26:19 +00:00
import sqlalchemy as sa
def dbtype(name):
"""
Create a UserDefinedType for use in migrations as the type of a column,
when the type already exists in the database, but isn't available as a
proper sqlalchemy type.
"""
class TheType(sa.types.UserDefinedType):
def get_col_spec(self):
return name
TheType.__name__ = name
return TheType