Store PayU payment metadata and attempts
All checks were successful
build-and-deploy / build-deploy (push) Successful in 37s
All checks were successful
build-and-deploy / build-deploy (push) Successful in 37s
This commit is contained in:
@@ -0,0 +1,37 @@
|
||||
package com.android.trisolarisserver.config
|
||||
|
||||
import org.springframework.jdbc.core.JdbcTemplate
|
||||
import org.springframework.stereotype.Component
|
||||
|
||||
@Component
|
||||
class PaymentSchemaFix(
|
||||
private val jdbcTemplate: JdbcTemplate
|
||||
) : PostgresSchemaFix(jdbcTemplate) {
|
||||
|
||||
override fun runPostgres(jdbcTemplate: JdbcTemplate) {
|
||||
ensureColumn("payment", "gateway_payment_id", "varchar")
|
||||
ensureColumn("payment", "gateway_txn_id", "varchar")
|
||||
ensureColumn("payment", "bank_ref_num", "varchar")
|
||||
ensureColumn("payment", "mode", "varchar")
|
||||
ensureColumn("payment", "pg_type", "varchar")
|
||||
ensureColumn("payment", "payer_vpa", "varchar")
|
||||
ensureColumn("payment", "payer_name", "varchar")
|
||||
ensureColumn("payment", "payment_source", "varchar")
|
||||
}
|
||||
|
||||
private fun ensureColumn(table: String, column: String, type: String) {
|
||||
val exists = jdbcTemplate.queryForObject(
|
||||
"""
|
||||
select count(*)
|
||||
from information_schema.columns
|
||||
where table_name = '$table'
|
||||
and column_name = '$column'
|
||||
""".trimIndent(),
|
||||
Int::class.java
|
||||
) ?: 0
|
||||
if (exists == 0) {
|
||||
logger.info("Adding $table.$column column")
|
||||
jdbcTemplate.execute("alter table $table add column $column $type")
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user