Update room_stay rate_source constraint
All checks were successful
build-and-deploy / build-deploy (push) Successful in 1m34s
All checks were successful
build-and-deploy / build-deploy (push) Successful in 1m34s
This commit is contained in:
@@ -0,0 +1,35 @@
|
|||||||
|
package com.android.trisolarisserver.config
|
||||||
|
|
||||||
|
import org.springframework.jdbc.core.JdbcTemplate
|
||||||
|
import org.springframework.stereotype.Component
|
||||||
|
|
||||||
|
@Component
|
||||||
|
class RoomStaySchemaFix(
|
||||||
|
private val jdbcTemplate: JdbcTemplate
|
||||||
|
) : PostgresSchemaFix(jdbcTemplate) {
|
||||||
|
|
||||||
|
override fun runPostgres(jdbcTemplate: JdbcTemplate) {
|
||||||
|
val exists = jdbcTemplate.queryForObject(
|
||||||
|
"""
|
||||||
|
select count(*)
|
||||||
|
from information_schema.table_constraints
|
||||||
|
where table_name = 'room_stay'
|
||||||
|
and constraint_name = 'room_stay_rate_source_check'
|
||||||
|
""".trimIndent(),
|
||||||
|
Int::class.java
|
||||||
|
) ?: 0
|
||||||
|
|
||||||
|
if (exists > 0) {
|
||||||
|
logger.info("Updating room_stay_rate_source_check constraint")
|
||||||
|
jdbcTemplate.execute("alter table room_stay drop constraint room_stay_rate_source_check")
|
||||||
|
}
|
||||||
|
|
||||||
|
jdbcTemplate.execute(
|
||||||
|
"""
|
||||||
|
alter table room_stay
|
||||||
|
add constraint room_stay_rate_source_check
|
||||||
|
check (rate_source in ('MANUAL','PRESET','RATE_PLAN','NEGOTIATED','OTA'))
|
||||||
|
""".trimIndent()
|
||||||
|
)
|
||||||
|
}
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user