meta.py 857B

1234567891011121314151617181920
  1. # -*- coding: utf-8 -*-
  2. from sqlalchemy.ext.declarative import declarative_base
  3. from sqlalchemy.schema import MetaData
  4. # Recommended naming convention used by Alembic, as various different database
  5. # providers will autogenerate vastly different names making migrations more
  6. # difficult. See: http://alembic.zzzcomputing.com/en/latest/naming.html
  7. NAMING_CONVENTION = {
  8. "ix": "ix_%(column_0_label)s",
  9. "uq": "uq__%(table_name)s__%(column_0_name)s", # Unique constrains
  10. # TODO - G.M - 28-03-2018 - [Database] Convert database to allow naming convention
  11. # for ck contraint.
  12. # "ck": "ck_%(table_name)s_%(constraint_name)s",
  13. "fk": "fk_%(table_name)s_%(column_0_name)s_%(referred_table_name)s",
  14. "pk": "pk_%(table_name)s"
  15. }
  16. metadata = MetaData(naming_convention=NAMING_CONVENTION)
  17. DeclarativeBase = declarative_base(metadata=metadata)