Fix(PostgresRecordManager): Handle time correctly and ensure schema creation (#4381)
added pgvector check and time handling for postgresql record manager
This commit is contained in:
parent
ac9d732550
commit
e467d0615c
|
|
@ -227,6 +227,8 @@ class PostgresRecordManager implements RecordManagerInterface {
|
|||
const queryRunner = dataSource.createQueryRunner()
|
||||
const tableName = this.sanitizeTableName(this.tableName)
|
||||
|
||||
await queryRunner.query('CREATE EXTENSION IF NOT EXISTS pgcrypto;')
|
||||
|
||||
await queryRunner.manager.query(`
|
||||
CREATE TABLE IF NOT EXISTS "${tableName}" (
|
||||
uuid UUID PRIMARY KEY DEFAULT gen_random_uuid(),
|
||||
|
|
@ -258,9 +260,9 @@ class PostgresRecordManager implements RecordManagerInterface {
|
|||
const dataSource = await this.getDataSource()
|
||||
try {
|
||||
const queryRunner = dataSource.createQueryRunner()
|
||||
const res = await queryRunner.manager.query('SELECT EXTRACT(EPOCH FROM CURRENT_TIMESTAMP)')
|
||||
const res = await queryRunner.manager.query('SELECT EXTRACT(EPOCH FROM CURRENT_TIMESTAMP) AS now')
|
||||
await queryRunner.release()
|
||||
return Number.parseFloat(res[0].extract)
|
||||
return Number.parseFloat(res[0].now)
|
||||
} catch (error) {
|
||||
console.error('Error getting time in PostgresRecordManager:')
|
||||
throw error
|
||||
|
|
|
|||
Loading…
Reference in New Issue