Add temporary room cards with 7 minute expiry
Some checks failed
build-and-deploy / build-deploy (push) Failing after 28s
Some checks failed
build-and-deploy / build-deploy (push) Failing after 28s
This commit is contained in:
@@ -0,0 +1,38 @@
|
||||
package com.android.trisolarisserver.config
|
||||
|
||||
import org.slf4j.LoggerFactory
|
||||
import org.springframework.boot.ApplicationArguments
|
||||
import org.springframework.boot.ApplicationRunner
|
||||
import org.springframework.jdbc.core.JdbcTemplate
|
||||
import org.springframework.stereotype.Component
|
||||
|
||||
@Component
|
||||
class IssuedCardSchemaFix(
|
||||
private val jdbcTemplate: JdbcTemplate
|
||||
) : ApplicationRunner {
|
||||
|
||||
private val logger = LoggerFactory.getLogger(IssuedCardSchemaFix::class.java)
|
||||
|
||||
override fun run(args: ApplicationArguments) {
|
||||
val version = jdbcTemplate.queryForObject("select version()", String::class.java) ?: return
|
||||
if (!version.contains("PostgreSQL", ignoreCase = true)) {
|
||||
return
|
||||
}
|
||||
|
||||
val isNullable = jdbcTemplate.queryForObject(
|
||||
"""
|
||||
select count(*)
|
||||
from information_schema.columns
|
||||
where table_name = 'issued_card'
|
||||
and column_name = 'room_stay_id'
|
||||
and is_nullable = 'YES'
|
||||
""".trimIndent(),
|
||||
Int::class.java
|
||||
) ?: 0
|
||||
|
||||
if (isNullable == 0) {
|
||||
logger.info("Dropping NOT NULL on issued_card.room_stay_id")
|
||||
jdbcTemplate.execute("alter table issued_card alter column room_stay_id drop not null")
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user