Refactor `createSchema` method in record managers to streamline data source retrieval and ensure proper cleanup. Updated MySQL, Postgres, and SQLite implementations for consistency and resource management.
This commit is contained in:
parent
84441850a0
commit
b5da98dcb7
|
|
@ -205,7 +205,7 @@ class MySQLRecordManager implements RecordManagerInterface {
|
|||
}
|
||||
|
||||
async createSchema(): Promise<void> {
|
||||
const dataSource = await this.getDataSource('createSchema')
|
||||
const dataSource = await this.getDataSource()
|
||||
try {
|
||||
const queryRunner = dataSource.createQueryRunner()
|
||||
const tableName = this.sanitizeTableName(this.tableName)
|
||||
|
|
|
|||
|
|
@ -222,8 +222,8 @@ class PostgresRecordManager implements RecordManagerInterface {
|
|||
}
|
||||
|
||||
async createSchema(): Promise<void> {
|
||||
try {
|
||||
const dataSource = await this.getDataSource()
|
||||
try {
|
||||
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> {
|
||||
try {
|
||||
const dataSource = await this.getDataSource()
|
||||
try {
|
||||
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