Add expected guest count on booking
Some checks failed
build-and-deploy / build-deploy (push) Failing after 27s
Some checks failed
build-and-deploy / build-deploy (push) Failing after 27s
This commit is contained in:
@@ -0,0 +1,27 @@
|
||||
package com.android.trisolarisserver.config
|
||||
|
||||
import org.springframework.jdbc.core.JdbcTemplate
|
||||
import org.springframework.stereotype.Component
|
||||
|
||||
@Component
|
||||
class BookingSchemaFix(
|
||||
private val jdbcTemplate: JdbcTemplate
|
||||
) : PostgresSchemaFix(jdbcTemplate) {
|
||||
|
||||
override fun runPostgres(jdbcTemplate: JdbcTemplate) {
|
||||
val hasExpectedGuestCount = jdbcTemplate.queryForObject(
|
||||
"""
|
||||
select count(*)
|
||||
from information_schema.columns
|
||||
where table_name = 'booking'
|
||||
and column_name = 'expected_guest_count'
|
||||
""".trimIndent(),
|
||||
Int::class.java
|
||||
) ?: 0
|
||||
|
||||
if (hasExpectedGuestCount == 0) {
|
||||
logger.info("Adding booking.expected_guest_count column")
|
||||
jdbcTemplate.execute("alter table booking add column expected_guest_count integer")
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user