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")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -110,6 +110,7 @@ class BookingFlow(
|
|||||||
maleCount = request.maleCount,
|
maleCount = request.maleCount,
|
||||||
femaleCount = request.femaleCount,
|
femaleCount = request.femaleCount,
|
||||||
totalGuestCount = totalGuestCount,
|
totalGuestCount = totalGuestCount,
|
||||||
|
expectedGuestCount = request.expectedGuestCount,
|
||||||
notes = request.notes,
|
notes = request.notes,
|
||||||
createdBy = actor,
|
createdBy = actor,
|
||||||
updatedAt = now
|
updatedAt = now
|
||||||
|
|||||||
@@ -22,6 +22,7 @@ data class BookingCreateRequest(
|
|||||||
val childCount: Int? = null,
|
val childCount: Int? = null,
|
||||||
val maleCount: Int? = null,
|
val maleCount: Int? = null,
|
||||||
val femaleCount: Int? = null,
|
val femaleCount: Int? = null,
|
||||||
|
val expectedGuestCount: Int? = null,
|
||||||
val notes: String? = null
|
val notes: String? = null
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|||||||
@@ -71,6 +71,9 @@ class Booking(
|
|||||||
@Column(name = "total_guest_count")
|
@Column(name = "total_guest_count")
|
||||||
var totalGuestCount: Int? = null,
|
var totalGuestCount: Int? = null,
|
||||||
|
|
||||||
|
@Column(name = "expected_guest_count")
|
||||||
|
var expectedGuestCount: Int? = null,
|
||||||
|
|
||||||
var notes: String? = null,
|
var notes: String? = null,
|
||||||
|
|
||||||
@ManyToOne(fetch = FetchType.LAZY)
|
@ManyToOne(fetch = FetchType.LAZY)
|
||||||
|
|||||||
Reference in New Issue
Block a user