Ensure proper cleanup of the database connection in `createSchema` (#5315)
* Ensure proper cleanup of the database connection in `createSchema` method in `MySQLRecordManager`. * Update MySQLrecordManager.ts * Refactor createSchema to optimize dataSource usage Refactor createSchema method to avoid duplicate dataSource retrieval. * Refactor createSchema method for efficiency Refactor createSchema to avoid redundant dataSource retrieval. --------- Co-authored-by: Henry Heng <henryheng@flowiseai.com>
This commit is contained in:
parent
ac565b8981
commit
9554b1a8e3
|
|
@ -205,8 +205,8 @@ class MySQLRecordManager implements RecordManagerInterface {
|
|||
}
|
||||
|
||||
async createSchema(): Promise<void> {
|
||||
const dataSource = await this.getDataSource()
|
||||
try {
|
||||
const dataSource = await this.getDataSource()
|
||||
const queryRunner = dataSource.createQueryRunner()
|
||||
const tableName = this.sanitizeTableName(this.tableName)
|
||||
|
||||
|
|
@ -241,6 +241,8 @@ class MySQLRecordManager implements RecordManagerInterface {
|
|||
return
|
||||
}
|
||||
throw e
|
||||
} finally {
|
||||
await dataSource.destroy()
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -222,8 +222,8 @@ class PostgresRecordManager implements RecordManagerInterface {
|
|||
}
|
||||
|
||||
async createSchema(): Promise<void> {
|
||||
const dataSource = await this.getDataSource()
|
||||
try {
|
||||
const dataSource = await this.getDataSource()
|
||||
const queryRunner = dataSource.createQueryRunner()
|
||||
const tableName = this.sanitizeTableName(this.tableName)
|
||||
|
||||
|
|
@ -251,6 +251,8 @@ class PostgresRecordManager implements RecordManagerInterface {
|
|||
return
|
||||
}
|
||||
throw e
|
||||
} finally {
|
||||
await dataSource.destroy()
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -179,8 +179,8 @@ class SQLiteRecordManager implements RecordManagerInterface {
|
|||
}
|
||||
|
||||
async createSchema(): Promise<void> {
|
||||
const dataSource = await this.getDataSource()
|
||||
try {
|
||||
const dataSource = await this.getDataSource()
|
||||
const queryRunner = dataSource.createQueryRunner()
|
||||
const tableName = this.sanitizeTableName(this.tableName)
|
||||
|
||||
|
|
@ -208,6 +208,8 @@ CREATE INDEX IF NOT EXISTS group_id_index ON "${tableName}" (group_id);`)
|
|||
return
|
||||
}
|
||||
throw e
|
||||
} finally {
|
||||
await dataSource.destroy()
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue