...
This commit is contained in:
@@ -27,6 +27,7 @@ object ConfigTable : Table("app_config") {
|
||||
val vtsAccountNo = varchar("vts_account_no", 20).default("")
|
||||
val isSimulation = bool("is_simulation").default(true)
|
||||
val modelPath = varchar("model_path", 512).default("")
|
||||
val embedModelPath = varchar("embed_model_path", 512).default("")
|
||||
val htsId = varchar("hts_id", 50).default("") // HTS ID 컬럼 추가
|
||||
override val primaryKey = PrimaryKey(id)
|
||||
}
|
||||
@@ -61,6 +62,27 @@ object TradeLogTable : Table("trade_logs") {
|
||||
override val primaryKey = PrimaryKey(id)
|
||||
}
|
||||
|
||||
class VectorColumnType(private val dimension: Int) : ColumnType<String>() {
|
||||
// [수정] H2에서 ARRAY는 내부 타입을 명시해야 합니다.
|
||||
// VECTOR 대신 FLOAT8 ARRAY를 사용하면 벡터 연산 함수와 100% 호환됩니다.
|
||||
override fun sqlType(): String = "FLOAT8 ARRAY"
|
||||
|
||||
override fun valueFromDB(value: Any): String = value.toString()
|
||||
|
||||
override fun notNullValueToDB(value: String): Any = value
|
||||
}
|
||||
|
||||
object VectorStoreTable : Table("VECTOR_STORE") {
|
||||
val id = integer("id").autoIncrement()
|
||||
val content = text("content")
|
||||
val metadata = text("metadata")
|
||||
|
||||
// 이제 FLOAT8 ARRAY 타입으로 컬럼이 생성됩니다.
|
||||
val embedding = registerColumn<String>("embedding", VectorColumnType(1024))
|
||||
|
||||
override val primaryKey = PrimaryKey(id)
|
||||
}
|
||||
|
||||
object DatabaseFactory {
|
||||
fun init() {
|
||||
val dbPath = File("db/autotrade_db").absolutePath
|
||||
@@ -71,10 +93,12 @@ object DatabaseFactory {
|
||||
|
||||
transaction {
|
||||
// 테이블 생성 (AutoTradeTable 포함)
|
||||
SchemaUtils.create(ConfigTable, TradeLogTable, AutoTradeTable)
|
||||
SchemaUtils.createMissingTablesAndColumns(ConfigTable, TradeLogTable, AutoTradeTable,VectorStoreTable)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
// --- 자동매매(감시) 관련 함수 ---
|
||||
|
||||
|
||||
@@ -174,7 +198,8 @@ object DatabaseFactory {
|
||||
vtsAccountNo = it[ConfigTable.vtsAccountNo],
|
||||
isSimulation = it[ConfigTable.isSimulation],
|
||||
htsId = it[ConfigTable.htsId], // htsId 로드
|
||||
modelPath = it[ConfigTable.modelPath]
|
||||
modelPath = it[ConfigTable.modelPath],
|
||||
embedModelPath = it[ConfigTable.embedModelPath],
|
||||
)
|
||||
}
|
||||
}
|
||||
@@ -192,6 +217,7 @@ object DatabaseFactory {
|
||||
it[isSimulation] = config.isSimulation
|
||||
it[htsId] = config.htsId
|
||||
it[modelPath] = config.modelPath
|
||||
it[embedModelPath] = config.embedModelPath
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user