28 lines
839 B
Kotlin
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")
|
|
}
|
|
}
|
|
}
|