Skip to content

armgit / dify

Public Imported from GitHub
0

Build Agentic workflows, RAG pipelines, with rich AI model and tool support on one collaborative workspace. Deploy on cloud, VPC, or self-hosted, so teams move from prototype to production without rebuilding the stack.

chore: update SQLAlchemy configuration with custom naming convention (#6854)

-LAN-feb4576ee71b
diff --git a/api/extensions/ext_database.py b/api/extensions/ext_database.py
index 9121c6ead98..c248e173a25 100644
--- a/api/extensions/ext_database.py
+++ b/api/extensions/ext_database.py
@@ -1,6 +1,16 @@
from flask_sqlalchemy import SQLAlchemy
+from sqlalchemy import MetaData
-db = SQLAlchemy()
+POSTGRES_INDEXES_NAMING_CONVENTION = {
+ 'ix': '%(column_0_label)s_idx',
+ 'uq': '%(table_name)s_%(column_0_name)s_key',
+ 'ck': '%(table_name)s_%(constraint_name)s_check',
+ 'fk': '%(table_name)s_%(column_0_name)s_fkey',
+ 'pk': '%(table_name)s_pkey',
+}
+
+metadata = MetaData(naming_convention=POSTGRES_INDEXES_NAMING_CONVENTION)
+db = SQLAlchemy(metadata=metadata)
def init_app(app):
diff --git a/api/migrations/alembic.ini b/api/migrations/alembic.ini
index ec9d45c26a6..aa21ecabcdd 100644
--- a/api/migrations/alembic.ini
+++ b/api/migrations/alembic.ini
@@ -3,6 +3,7 @@
[alembic]
# template used to generate migration files
# file_template = %%(rev)s_%%(slug)s
+file_template = %%(year)d_%%(month).2d_%%(day).2d_%%(hour).2d%%(minute).2d-%%(rev)s_%%(slug)s
# set to 'true' to run the environment during
# the 'revision' command, regardless of autogenerate