@@ -111,145 +111,31 @@ class DatabaseConfig(BaseSettings):
111111 default = "postgresql" ,
112112 )
113113
114- # PostgreSQL configuration
115- POSTGRES_HOST : str = Field (
116- description = "PostgreSQL hostname or IP address." ,
114+ DB_HOST : str = Field (
115+ description = "Hostname or IP address of the database server." ,
117116 default = "localhost" ,
118117 )
119118
120- POSTGRES_PORT : PositiveInt = Field (
121- description = "PostgreSQL port number." ,
119+ DB_PORT : PositiveInt = Field (
120+ description = "Port number for database connection ." ,
122121 default = 5432 ,
123122 )
124123
125- POSTGRES_USER : str = Field (
126- description = "PostgreSQL username ." ,
124+ DB_USERNAME : str = Field (
125+ description = "Username for database authentication ." ,
127126 default = "postgres" ,
128127 )
129128
130- POSTGRES_PASSWORD : str = Field (
131- description = "PostgreSQL password." ,
132- default = "difyai123456" ,
133- )
134-
135- POSTGRES_DATABASE : str = Field (
136- description = "PostgreSQL database name." ,
137- default = "dify" ,
138- )
139-
140- # MySQL configuration
141- MYSQL_HOST : str = Field (
142- description = "MySQL hostname or IP address." ,
143- default = "localhost" ,
144- )
145-
146- MYSQL_PORT : PositiveInt = Field (
147- description = "MySQL port number." ,
148- default = 3306 ,
149- )
150-
151- MYSQL_USER : str = Field (
152- description = "MySQL username." ,
153- default = "root" ,
154- )
155-
156- MYSQL_PASSWORD : str = Field (
157- description = "MySQL password." ,
158- default = "difyai123456" ,
129+ DB_PASSWORD : str = Field (
130+ description = "Password for database authentication." ,
131+ default = "" ,
159132 )
160133
161- MYSQL_DATABASE : str = Field (
162- description = "MySQL database name ." ,
134+ DB_DATABASE : str = Field (
135+ description = "Name of the database to connect to ." ,
163136 default = "dify" ,
164137 )
165138
166- # OceanBase configuration(MySQL-compatible)
167- OCEANBASE_HOST : str = Field (
168- description = "OceanBase hostname or IP address." ,
169- default = "localhost" ,
170- )
171-
172- OCEANBASE_PORT : PositiveInt = Field (
173- description = "OceanBase port number." ,
174- default = 2881 ,
175- )
176-
177- OCEANBASE_USER : str = Field (
178- description = "OceanBase username." ,
179- default = "root@test" ,
180- )
181-
182- OCEANBASE_PASSWORD : str = Field (
183- description = "OceanBase password." ,
184- default = "difyai123456" ,
185- )
186-
187- OCEANBASE_DATABASE : str = Field (
188- description = "OceanBase database name." ,
189- default = "test" ,
190- )
191-
192- # Dynamic properties based on DB_TYPE
193- @computed_field # type: ignore[prop-decorator]
194- @property
195- def DB_HOST (self ) -> str :
196- if self .DB_TYPE == "postgresql" :
197- return self .POSTGRES_HOST
198- elif self .DB_TYPE == "mysql" :
199- return self .MYSQL_HOST
200- elif self .DB_TYPE == "oceanbase" :
201- return self .OCEANBASE_HOST
202- else :
203- raise ValueError (f"Unsupported DB_TYPE: { self .DB_TYPE } " )
204-
205- @computed_field # type: ignore[prop-decorator]
206- @property
207- def DB_PORT (self ) -> int :
208- if self .DB_TYPE == "postgresql" :
209- return self .POSTGRES_PORT
210- elif self .DB_TYPE == "mysql" :
211- return self .MYSQL_PORT
212- elif self .DB_TYPE == "oceanbase" :
213- return self .OCEANBASE_PORT
214- else :
215- raise ValueError (f"Unsupported DB_TYPE: { self .DB_TYPE } " )
216-
217- @computed_field # type: ignore[prop-decorator]
218- @property
219- def DB_USERNAME (self ) -> str :
220- if self .DB_TYPE == "postgresql" :
221- return self .POSTGRES_USER
222- elif self .DB_TYPE == "mysql" :
223- return self .MYSQL_USER
224- elif self .DB_TYPE == "oceanbase" :
225- return self .OCEANBASE_USER
226- else :
227- raise ValueError (f"Unsupported DB_TYPE: { self .DB_TYPE } " )
228-
229- @computed_field # type: ignore[prop-decorator]
230- @property
231- def DB_PASSWORD (self ) -> str :
232- if self .DB_TYPE == "postgresql" :
233- return self .POSTGRES_PASSWORD
234- elif self .DB_TYPE == "mysql" :
235- return self .MYSQL_PASSWORD
236- elif self .DB_TYPE == "oceanbase" :
237- return self .OCEANBASE_PASSWORD
238- else :
239- raise ValueError (f"Unsupported DB_TYPE: { self .DB_TYPE } " )
240-
241- @computed_field # type: ignore[prop-decorator]
242- @property
243- def DB_DATABASE (self ) -> str :
244- if self .DB_TYPE == "postgresql" :
245- return self .POSTGRES_DATABASE
246- elif self .DB_TYPE == "mysql" :
247- return self .MYSQL_DATABASE
248- elif self .DB_TYPE == "oceanbase" :
249- return self .OCEANBASE_DATABASE
250- else :
251- raise ValueError (f"Unsupported DB_TYPE: { self .DB_TYPE } " )
252-
253139 DB_CHARSET : str = Field (
254140 description = "Character set for database connection." ,
255141 default = "" ,
0 commit comments