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:
nikitas-novatix 2025-05-06 18:27:47 +02:00 committed by GitHub
parent ac9d732550
commit e467d0615c
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with 4 additions and 2 deletions

View File

@ -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