You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

12345678910111213141516171819202122232425
  1. from flask_sqlalchemy import SQLAlchemy
  2. from sqlalchemy import MetaData
  3. POSTGRES_INDEXES_NAMING_CONVENTION = {
  4. "ix": "%(column_0_label)s_idx",
  5. "uq": "%(table_name)s_%(column_0_name)s_key",
  6. "ck": "%(table_name)s_%(constraint_name)s_check",
  7. "fk": "%(table_name)s_%(column_0_name)s_fkey",
  8. "pk": "%(table_name)s_pkey",
  9. }
  10. metadata = MetaData(naming_convention=POSTGRES_INDEXES_NAMING_CONVENTION)
  11. # ****** IMPORTANT NOTICE ******
  12. #
  13. # NOTE(QuantumGhost): Avoid directly importing and using `db` in modules outside of the
  14. # `controllers` package.
  15. #
  16. # Instead, import `db` within the `controllers` package and pass it as an argument to
  17. # functions or class constructors.
  18. #
  19. # Directly importing `db` in other modules can make the code more difficult to read, test, and maintain.
  20. #
  21. # Whenever possible, avoid this pattern in new code.
  22. db = SQLAlchemy(metadata=metadata)