From a50d71bbfe77b11d3bfa68385632a03c33099083 Mon Sep 17 00:00:00 2001 From: metalicn20 Date: Tue, 24 Aug 2021 11:51:14 +0430 Subject: [PATCH 1/5] Fix application class name --- .../main/kotlin/co/nilin/opex/bcgateway/app/BCGatewayApp.kt | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/BlockchainGateway/bc-gateway-app/src/main/kotlin/co/nilin/opex/bcgateway/app/BCGatewayApp.kt b/BlockchainGateway/bc-gateway-app/src/main/kotlin/co/nilin/opex/bcgateway/app/BCGatewayApp.kt index 3a906cb3a..3762d89a6 100644 --- a/BlockchainGateway/bc-gateway-app/src/main/kotlin/co/nilin/opex/bcgateway/app/BCGatewayApp.kt +++ b/BlockchainGateway/bc-gateway-app/src/main/kotlin/co/nilin/opex/bcgateway/app/BCGatewayApp.kt @@ -5,9 +5,9 @@ import org.springframework.boot.runApplication import org.springframework.context.annotation.ComponentScan @SpringBootApplication -@ComponentScan("co.nilin.mixchange") -class WalletApp +@ComponentScan("co.nilin.opex") +class BCGatewayApp fun main(args: Array) { - runApplication(*args) + runApplication(*args) } From 6171e726497c6647c413b238348c4fe34db63499 Mon Sep 17 00:00:00 2001 From: metalicn20 Date: Tue, 24 Aug 2021 11:51:48 +0430 Subject: [PATCH 2/5] Fix and improve db models --- .../postgres/model/AddressTypeModel.kt | 8 ++++---- .../postgres/model/CachedAddressModel.kt | 5 ++--- .../bcgateway/postgres/model/ChainModel.kt | 19 ++++++++++--------- .../bcgateway/postgres/model/SyncModel.kt | 14 ++++++++------ 4 files changed, 24 insertions(+), 22 deletions(-) diff --git a/BlockchainGateway/bc-gateway-ports/bc-persister-postgres/src/main/kotlin/co/nilin/opex/port/bcgateway/postgres/model/AddressTypeModel.kt b/BlockchainGateway/bc-gateway-ports/bc-persister-postgres/src/main/kotlin/co/nilin/opex/port/bcgateway/postgres/model/AddressTypeModel.kt index d2e0c5aa0..fc1995fe5 100644 --- a/BlockchainGateway/bc-gateway-ports/bc-persister-postgres/src/main/kotlin/co/nilin/opex/port/bcgateway/postgres/model/AddressTypeModel.kt +++ b/BlockchainGateway/bc-gateway-ports/bc-persister-postgres/src/main/kotlin/co/nilin/opex/port/bcgateway/postgres/model/AddressTypeModel.kt @@ -5,8 +5,8 @@ import org.springframework.data.relational.core.mapping.Table @Table("address_types") data class AddressTypeModel( - val id: Long? - , @Column("address_type") val type: String - , @Column("address_regex") val addressRegex: String - , @Column("memo_regex") val memoRegex: String + val id: Long?, + @Column("address_type") val type: String, + @Column("address_regex") val addressRegex: String, + @Column("memo_regex") val memoRegex: String ) \ No newline at end of file diff --git a/BlockchainGateway/bc-gateway-ports/bc-persister-postgres/src/main/kotlin/co/nilin/opex/port/bcgateway/postgres/model/CachedAddressModel.kt b/BlockchainGateway/bc-gateway-ports/bc-persister-postgres/src/main/kotlin/co/nilin/opex/port/bcgateway/postgres/model/CachedAddressModel.kt index 8f207c68d..fbb698b1b 100644 --- a/BlockchainGateway/bc-gateway-ports/bc-persister-postgres/src/main/kotlin/co/nilin/opex/port/bcgateway/postgres/model/CachedAddressModel.kt +++ b/BlockchainGateway/bc-gateway-ports/bc-persister-postgres/src/main/kotlin/co/nilin/opex/port/bcgateway/postgres/model/CachedAddressModel.kt @@ -4,7 +4,6 @@ import org.springframework.data.relational.core.mapping.Column import org.springframework.data.relational.core.mapping.Table @Table("cached_addresses") -data class CachedAddressModel(val address: String - , val memo: String? - , @Column("address_type") val type: Long +data class CachedAddressModel( + val id: Long?, val address: String, val memo: String?, @Column("address_type") val type: Long ) \ No newline at end of file diff --git a/BlockchainGateway/bc-gateway-ports/bc-persister-postgres/src/main/kotlin/co/nilin/opex/port/bcgateway/postgres/model/ChainModel.kt b/BlockchainGateway/bc-gateway-ports/bc-persister-postgres/src/main/kotlin/co/nilin/opex/port/bcgateway/postgres/model/ChainModel.kt index 5204e8d15..11c79f3e0 100644 --- a/BlockchainGateway/bc-gateway-ports/bc-persister-postgres/src/main/kotlin/co/nilin/opex/port/bcgateway/postgres/model/ChainModel.kt +++ b/BlockchainGateway/bc-gateway-ports/bc-persister-postgres/src/main/kotlin/co/nilin/opex/port/bcgateway/postgres/model/ChainModel.kt @@ -8,14 +8,15 @@ import org.springframework.data.relational.core.mapping.Table data class ChainModel(@Id val name: String) @Table("chain_address_types") -data class ChainAddressTypeModel(@Id val id: Long? -, @Column("chain_name") val chainName: String -, @Column("addr_type_id") val addressTypeId: Long) +data class ChainAddressTypeModel( + @Id val id: Long?, @Column("chain_name") val chainName: String, @Column("addr_type_id") val addressTypeId: Long +) @Table("chain_endpoints") -data class ChainEndpointModel(@Id val id: Long? - , @Column("chain_name") val chainName: String - , @Column("endpoint_url") val url: String - , @Column("endpoint_user") val user: String - , @Column("endpoint_password") val password: String - ) \ No newline at end of file +data class ChainEndpointModel( + @Id val id: Long?, + @Column("chain_name") val chainName: String, + @Column("endpoint_url") val url: String, + @Column("endpoint_user") val user: String, + @Column("endpoint_password") val password: String +) \ No newline at end of file diff --git a/BlockchainGateway/bc-gateway-ports/bc-persister-postgres/src/main/kotlin/co/nilin/opex/port/bcgateway/postgres/model/SyncModel.kt b/BlockchainGateway/bc-gateway-ports/bc-persister-postgres/src/main/kotlin/co/nilin/opex/port/bcgateway/postgres/model/SyncModel.kt index 3a4d53ec0..a131264ce 100644 --- a/BlockchainGateway/bc-gateway-ports/bc-persister-postgres/src/main/kotlin/co/nilin/opex/port/bcgateway/postgres/model/SyncModel.kt +++ b/BlockchainGateway/bc-gateway-ports/bc-persister-postgres/src/main/kotlin/co/nilin/opex/port/bcgateway/postgres/model/SyncModel.kt @@ -11,11 +11,13 @@ data class SyncScheduleModel( ) @Table("chain_sync_record") -data class SyncRecord(@Id @Column("chain") val chain: String -, val time: LocalDateTime -, @Column("endpoint_url") val endpointUrl: String -, @Column("latest_block") val latestBlock: Long? -, val success: Boolean -, val error: String?) +data class SyncRecord( + @Id @Column("chain") val chain: String, + val time: LocalDateTime, + @Column("endpoint_url") val endpointUrl: String, + @Column("latest_block") val latestBlock: Long?, + val success: Boolean, + val error: String? +) From 53195cb30ddf988f970075daf6203e1d6884caa3 Mon Sep 17 00:00:00 2001 From: metalicn20 Date: Tue, 24 Aug 2021 11:52:14 +0430 Subject: [PATCH 3/5] Add table scripts --- .../postgres/config/PostgresConfig.kt | 62 +++++++++++++++++-- 1 file changed, 56 insertions(+), 6 deletions(-) diff --git a/BlockchainGateway/bc-gateway-ports/bc-persister-postgres/src/main/kotlin/co/nilin/opex/port/bcgateway/postgres/config/PostgresConfig.kt b/BlockchainGateway/bc-gateway-ports/bc-persister-postgres/src/main/kotlin/co/nilin/opex/port/bcgateway/postgres/config/PostgresConfig.kt index 66357545d..f2d9e24c0 100644 --- a/BlockchainGateway/bc-gateway-ports/bc-persister-postgres/src/main/kotlin/co/nilin/opex/port/bcgateway/postgres/config/PostgresConfig.kt +++ b/BlockchainGateway/bc-gateway-ports/bc-persister-postgres/src/main/kotlin/co/nilin/opex/port/bcgateway/postgres/config/PostgresConfig.kt @@ -1,22 +1,72 @@ -package co.nilin.mixchange.port.order.kafka.config - +package co.nilin.opex.port.bcgateway.postgres.config import org.springframework.context.annotation.Configuration import org.springframework.data.r2dbc.repository.config.EnableR2dbcRepositories import org.springframework.r2dbc.core.DatabaseClient - @Configuration -@EnableR2dbcRepositories(basePackages = ["co.nilin.mixchange"]) +@EnableR2dbcRepositories(basePackages = ["co.nilin.opex"]) class PostgresConfig(db: DatabaseClient) { init { val initDb = db.sql { """ + CREATE TABLE IF NOT EXISTS address_types ( + id SERIAL PRIMARY KEY, + address_type VARCHAR(72), + address_regex VARCHAR(72), + memo_regex VARCHAR(72) + ); + CREATE TABLE IF NOT EXISTS assigned_addresses ( + id SERIAL PRIMARY KEY, + uuid VARCHAR(72), + address VARCHAR(72), + memo VARCHAR(72), + addr_type_id numeric + ); + CREATE TABLE IF NOT EXISTS assigned_address_chains ( + id SERIAL PRIMARY KEY, + assigned_address_id numeric, + chain VARCHAR(72) + ); + CREATE TABLE IF NOT EXISTS cached_addresses ( + id SERIAL PRIMARY KEY, + address VARCHAR(72), + memo VARCHAR(72), + address_type VARCHAR(72) + ); + CREATE TABLE IF NOT EXISTS chain ( + name VARCHAR(72) PRIMARY KEY + ); + CREATE TABLE IF NOT EXISTS chain_address_types ( + id SERIAL PRIMARY KEY, + chain_name VARCHAR(72), + addr_type_id numeric + ); + CREATE TABLE IF NOT EXISTS chain_endpoints ( + id SERIAL PRIMARY KEY, + chain_name VARCHAR(72), + endpoint_url VARCHAR(72), + endpoint_user VARCHAR(72), + endpoint_password VARCHAR(72) + ); + CREATE TABLE IF NOT EXISTS chain_sync_schedule ( + chain VARCHAR(72) PRIMARY KEY, + retry_time TIMESTAMP, + delay numeric + ); + CREATE TABLE IF NOT EXISTS chain_sync_record ( + chain VARCHAR(72) PRIMARY KEY, + time TIMESTAMP, + endpoint_url VARCHAR(72), + latest_block numeric, + success BOOLEAN, + error VARCHAR(100) + ); """ } initDb // initialize the database - .then() - .subscribe() // execute + .then() + .subscribe() // execute } } From db3726f14dc6eedf56e07190bcaadc077fd7f5ba Mon Sep 17 00:00:00 2001 From: metalicn20 Date: Tue, 24 Aug 2021 15:32:12 +0430 Subject: [PATCH 4/5] Add remained repository classes --- .../bcgateway/postgres/dao/AddressTypeRepository.kt | 2 +- .../postgres/dao/AssignedAddressChainRepository.kt | 2 +- .../postgres/dao/AssignedAddressRepository.kt | 7 ++++--- .../postgres/dao/CachedAddressRepository.kt | 13 +++++++++++++ .../postgres/dao/ChainAddressTypeRepository.kt | 8 ++++++++ .../postgres/dao/ChainEndpointRepository.kt | 8 ++++++++ .../port/bcgateway/postgres/dao/ChainRepository.kt | 2 +- .../postgres/dao/ChainSyncRecordRepository.kt | 13 +++++++++++++ .../postgres/dao/ChainSyncScheduleRepository.kt | 13 +++++++++++++ 9 files changed, 62 insertions(+), 6 deletions(-) create mode 100644 BlockchainGateway/bc-gateway-ports/bc-persister-postgres/src/main/kotlin/co/nilin/opex/port/bcgateway/postgres/dao/CachedAddressRepository.kt create mode 100644 BlockchainGateway/bc-gateway-ports/bc-persister-postgres/src/main/kotlin/co/nilin/opex/port/bcgateway/postgres/dao/ChainAddressTypeRepository.kt create mode 100644 BlockchainGateway/bc-gateway-ports/bc-persister-postgres/src/main/kotlin/co/nilin/opex/port/bcgateway/postgres/dao/ChainEndpointRepository.kt create mode 100644 BlockchainGateway/bc-gateway-ports/bc-persister-postgres/src/main/kotlin/co/nilin/opex/port/bcgateway/postgres/dao/ChainSyncRecordRepository.kt create mode 100644 BlockchainGateway/bc-gateway-ports/bc-persister-postgres/src/main/kotlin/co/nilin/opex/port/bcgateway/postgres/dao/ChainSyncScheduleRepository.kt diff --git a/BlockchainGateway/bc-gateway-ports/bc-persister-postgres/src/main/kotlin/co/nilin/opex/port/bcgateway/postgres/dao/AddressTypeRepository.kt b/BlockchainGateway/bc-gateway-ports/bc-persister-postgres/src/main/kotlin/co/nilin/opex/port/bcgateway/postgres/dao/AddressTypeRepository.kt index 7c1f67d0a..657a2caf4 100644 --- a/BlockchainGateway/bc-gateway-ports/bc-persister-postgres/src/main/kotlin/co/nilin/opex/port/bcgateway/postgres/dao/AddressTypeRepository.kt +++ b/BlockchainGateway/bc-gateway-ports/bc-persister-postgres/src/main/kotlin/co/nilin/opex/port/bcgateway/postgres/dao/AddressTypeRepository.kt @@ -5,4 +5,4 @@ import org.springframework.data.repository.reactive.ReactiveCrudRepository import org.springframework.stereotype.Repository @Repository -interface AddressTypeRepository: ReactiveCrudRepository \ No newline at end of file +interface AddressTypeRepository : ReactiveCrudRepository \ No newline at end of file diff --git a/BlockchainGateway/bc-gateway-ports/bc-persister-postgres/src/main/kotlin/co/nilin/opex/port/bcgateway/postgres/dao/AssignedAddressChainRepository.kt b/BlockchainGateway/bc-gateway-ports/bc-persister-postgres/src/main/kotlin/co/nilin/opex/port/bcgateway/postgres/dao/AssignedAddressChainRepository.kt index 65c973242..47b7d7524 100644 --- a/BlockchainGateway/bc-gateway-ports/bc-persister-postgres/src/main/kotlin/co/nilin/opex/port/bcgateway/postgres/dao/AssignedAddressChainRepository.kt +++ b/BlockchainGateway/bc-gateway-ports/bc-persister-postgres/src/main/kotlin/co/nilin/opex/port/bcgateway/postgres/dao/AssignedAddressChainRepository.kt @@ -9,7 +9,7 @@ import org.springframework.data.repository.reactive.ReactiveCrudRepository import org.springframework.stereotype.Repository @Repository -interface AssignedAddressChainRepository: ReactiveCrudRepository { +interface AssignedAddressChainRepository : ReactiveCrudRepository { @Query("select * from assigned_address_chains where assigned_address_id = :assignedAddress") fun findByAssignedAddress(@Param("assignedAddress") type: Long): Flow } \ No newline at end of file diff --git a/BlockchainGateway/bc-gateway-ports/bc-persister-postgres/src/main/kotlin/co/nilin/opex/port/bcgateway/postgres/dao/AssignedAddressRepository.kt b/BlockchainGateway/bc-gateway-ports/bc-persister-postgres/src/main/kotlin/co/nilin/opex/port/bcgateway/postgres/dao/AssignedAddressRepository.kt index 1c0c1ba2e..96ca13fbf 100644 --- a/BlockchainGateway/bc-gateway-ports/bc-persister-postgres/src/main/kotlin/co/nilin/opex/port/bcgateway/postgres/dao/AssignedAddressRepository.kt +++ b/BlockchainGateway/bc-gateway-ports/bc-persister-postgres/src/main/kotlin/co/nilin/opex/port/bcgateway/postgres/dao/AssignedAddressRepository.kt @@ -8,8 +8,9 @@ import org.springframework.data.repository.reactive.ReactiveCrudRepository import org.springframework.stereotype.Repository @Repository -interface AssignedAddressRepository: ReactiveCrudRepository { +interface AssignedAddressRepository : ReactiveCrudRepository { @Query("select * from assigned_addresses where uuid = :uuid and addr_type_id in (:addressTypes)") - fun findByUuidAndAddressType(@Param("uuid") uuid: String - , @Param("addressTypes") types: List): Flow + fun findByUuidAndAddressType( + @Param("uuid") uuid: String, @Param("addressTypes") types: List + ): Flow } \ No newline at end of file diff --git a/BlockchainGateway/bc-gateway-ports/bc-persister-postgres/src/main/kotlin/co/nilin/opex/port/bcgateway/postgres/dao/CachedAddressRepository.kt b/BlockchainGateway/bc-gateway-ports/bc-persister-postgres/src/main/kotlin/co/nilin/opex/port/bcgateway/postgres/dao/CachedAddressRepository.kt new file mode 100644 index 000000000..f3a30bdeb --- /dev/null +++ b/BlockchainGateway/bc-gateway-ports/bc-persister-postgres/src/main/kotlin/co/nilin/opex/port/bcgateway/postgres/dao/CachedAddressRepository.kt @@ -0,0 +1,13 @@ +package co.nilin.opex.port.bcgateway.postgres.dao + +import co.nilin.opex.port.bcgateway.postgres.model.AssignedAddressChainModel +import co.nilin.opex.port.bcgateway.postgres.model.CachedAddressModel +import co.nilin.opex.port.bcgateway.postgres.model.ChainModel +import kotlinx.coroutines.flow.Flow +import org.springframework.data.r2dbc.repository.Query +import org.springframework.data.repository.query.Param +import org.springframework.data.repository.reactive.ReactiveCrudRepository + +interface CachedAddressRepository : ReactiveCrudRepository { + +} \ No newline at end of file diff --git a/BlockchainGateway/bc-gateway-ports/bc-persister-postgres/src/main/kotlin/co/nilin/opex/port/bcgateway/postgres/dao/ChainAddressTypeRepository.kt b/BlockchainGateway/bc-gateway-ports/bc-persister-postgres/src/main/kotlin/co/nilin/opex/port/bcgateway/postgres/dao/ChainAddressTypeRepository.kt new file mode 100644 index 000000000..5708cb225 --- /dev/null +++ b/BlockchainGateway/bc-gateway-ports/bc-persister-postgres/src/main/kotlin/co/nilin/opex/port/bcgateway/postgres/dao/ChainAddressTypeRepository.kt @@ -0,0 +1,8 @@ +package co.nilin.opex.port.bcgateway.postgres.dao + +import co.nilin.opex.port.bcgateway.postgres.model.ChainAddressTypeModel +import org.springframework.data.repository.reactive.ReactiveCrudRepository + +interface ChainAddressTypeRepository : ReactiveCrudRepository { + +} \ No newline at end of file diff --git a/BlockchainGateway/bc-gateway-ports/bc-persister-postgres/src/main/kotlin/co/nilin/opex/port/bcgateway/postgres/dao/ChainEndpointRepository.kt b/BlockchainGateway/bc-gateway-ports/bc-persister-postgres/src/main/kotlin/co/nilin/opex/port/bcgateway/postgres/dao/ChainEndpointRepository.kt new file mode 100644 index 000000000..9c43fe56c --- /dev/null +++ b/BlockchainGateway/bc-gateway-ports/bc-persister-postgres/src/main/kotlin/co/nilin/opex/port/bcgateway/postgres/dao/ChainEndpointRepository.kt @@ -0,0 +1,8 @@ +package co.nilin.opex.port.bcgateway.postgres.dao + +import co.nilin.opex.port.bcgateway.postgres.model.ChainEndpointModel +import org.springframework.data.repository.reactive.ReactiveCrudRepository + +interface ChainEndpointRepository : ReactiveCrudRepository { + +} \ No newline at end of file diff --git a/BlockchainGateway/bc-gateway-ports/bc-persister-postgres/src/main/kotlin/co/nilin/opex/port/bcgateway/postgres/dao/ChainRepository.kt b/BlockchainGateway/bc-gateway-ports/bc-persister-postgres/src/main/kotlin/co/nilin/opex/port/bcgateway/postgres/dao/ChainRepository.kt index cafa5bbf4..35de62148 100644 --- a/BlockchainGateway/bc-gateway-ports/bc-persister-postgres/src/main/kotlin/co/nilin/opex/port/bcgateway/postgres/dao/ChainRepository.kt +++ b/BlockchainGateway/bc-gateway-ports/bc-persister-postgres/src/main/kotlin/co/nilin/opex/port/bcgateway/postgres/dao/ChainRepository.kt @@ -7,6 +7,6 @@ import org.springframework.data.r2dbc.repository.Query import org.springframework.data.repository.query.Param import org.springframework.data.repository.reactive.ReactiveCrudRepository -interface ChainRepository: ReactiveCrudRepository { +interface ChainRepository : ReactiveCrudRepository { } \ No newline at end of file diff --git a/BlockchainGateway/bc-gateway-ports/bc-persister-postgres/src/main/kotlin/co/nilin/opex/port/bcgateway/postgres/dao/ChainSyncRecordRepository.kt b/BlockchainGateway/bc-gateway-ports/bc-persister-postgres/src/main/kotlin/co/nilin/opex/port/bcgateway/postgres/dao/ChainSyncRecordRepository.kt new file mode 100644 index 000000000..94cb26e68 --- /dev/null +++ b/BlockchainGateway/bc-gateway-ports/bc-persister-postgres/src/main/kotlin/co/nilin/opex/port/bcgateway/postgres/dao/ChainSyncRecordRepository.kt @@ -0,0 +1,13 @@ +package co.nilin.opex.port.bcgateway.postgres.dao + +import co.nilin.opex.port.bcgateway.postgres.model.AssignedAddressChainModel +import co.nilin.opex.port.bcgateway.postgres.model.ChainModel +import co.nilin.opex.port.bcgateway.postgres.model.SyncRecord +import kotlinx.coroutines.flow.Flow +import org.springframework.data.r2dbc.repository.Query +import org.springframework.data.repository.query.Param +import org.springframework.data.repository.reactive.ReactiveCrudRepository + +interface ChainSyncRecordRepository : ReactiveCrudRepository { + +} \ No newline at end of file diff --git a/BlockchainGateway/bc-gateway-ports/bc-persister-postgres/src/main/kotlin/co/nilin/opex/port/bcgateway/postgres/dao/ChainSyncScheduleRepository.kt b/BlockchainGateway/bc-gateway-ports/bc-persister-postgres/src/main/kotlin/co/nilin/opex/port/bcgateway/postgres/dao/ChainSyncScheduleRepository.kt new file mode 100644 index 000000000..7455e08bd --- /dev/null +++ b/BlockchainGateway/bc-gateway-ports/bc-persister-postgres/src/main/kotlin/co/nilin/opex/port/bcgateway/postgres/dao/ChainSyncScheduleRepository.kt @@ -0,0 +1,13 @@ +package co.nilin.opex.port.bcgateway.postgres.dao + +import co.nilin.opex.port.bcgateway.postgres.model.AssignedAddressChainModel +import co.nilin.opex.port.bcgateway.postgres.model.ChainModel +import co.nilin.opex.port.bcgateway.postgres.model.SyncScheduleModel +import kotlinx.coroutines.flow.Flow +import org.springframework.data.r2dbc.repository.Query +import org.springframework.data.repository.query.Param +import org.springframework.data.repository.reactive.ReactiveCrudRepository + +interface ChainSyncScheduleRepository : ReactiveCrudRepository { + +} \ No newline at end of file From f70a93f19f5adc0a01120d280bdca6b6846b19ed Mon Sep 17 00:00:00 2001 From: metalicn20 Date: Sun, 29 Aug 2021 13:06:13 +0430 Subject: [PATCH 5/5] Add uuid and (address, memo) UNIQUE constraint --- .../opex/port/bcgateway/postgres/config/PostgresConfig.kt | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/BlockchainGateway/bc-gateway-ports/bc-persister-postgres/src/main/kotlin/co/nilin/opex/port/bcgateway/postgres/config/PostgresConfig.kt b/BlockchainGateway/bc-gateway-ports/bc-persister-postgres/src/main/kotlin/co/nilin/opex/port/bcgateway/postgres/config/PostgresConfig.kt index f2d9e24c0..07ca7afa5 100644 --- a/BlockchainGateway/bc-gateway-ports/bc-persister-postgres/src/main/kotlin/co/nilin/opex/port/bcgateway/postgres/config/PostgresConfig.kt +++ b/BlockchainGateway/bc-gateway-ports/bc-persister-postgres/src/main/kotlin/co/nilin/opex/port/bcgateway/postgres/config/PostgresConfig.kt @@ -19,10 +19,11 @@ class PostgresConfig(db: DatabaseClient) { ); CREATE TABLE IF NOT EXISTS assigned_addresses ( id SERIAL PRIMARY KEY, - uuid VARCHAR(72), + uuid VARCHAR(72) UNIQUE, address VARCHAR(72), memo VARCHAR(72), - addr_type_id numeric + addr_type_id numeric, + UNIQUE (address, memo) ); CREATE TABLE IF NOT EXISTS assigned_address_chains ( id SERIAL PRIMARY KEY,