Files
TrisolarisServer/src/main/kotlin/com/android/trisolarisserver/config/RoomImageSchemaFix.kt
androidlover5842 9b64b34ab9
All checks were successful
build-and-deploy / build-deploy (push) Successful in 33s
Deduplicate logic across controllers, auth, and schema fixes
2026-01-28 23:03:48 +05:30

28 lines
839 B
Kotlin

package com.android.trisolarisserver.config
import org.springframework.jdbc.core.JdbcTemplate
import org.springframework.stereotype.Component
@Component
class RoomImageSchemaFix(
private val jdbcTemplate: JdbcTemplate
) : PostgresSchemaFix(jdbcTemplate) {
override fun runPostgres(jdbcTemplate: JdbcTemplate) {
val hasContentHash = jdbcTemplate.queryForObject(
"""
select count(*)
from information_schema.columns
where table_name = 'room_image'
and column_name = 'content_hash'
""".trimIndent(),
Int::class.java
) ?: 0
if (hasContentHash == 0) {
logger.info("Adding room_image.content_hash column")
jdbcTemplate.execute("alter table room_image add column content_hash text")
}
}
}