Enforce unique outpoints for SpendingInfoDb (#1673)

This commit is contained in:
Ben Carman 2020-07-15 14:09:44 -05:00 committed by GitHub
parent 88eb145a37
commit 2ef3f48313
4 changed files with 4 additions and 2 deletions

View file

@ -58,7 +58,7 @@ class DbManagementTest extends BitcoinSAsyncTest with EmbeddedPg {
dbConfig(ProjectType.Wallet))
val walletDbManagement = createWalletDbManagement(walletAppConfig)
val result = walletDbManagement.migrate()
val expected = if (walletAppConfig.driverName == "postgresql") 2 else 5
val expected = if (walletAppConfig.driverName == "postgresql") 3 else 6
assert(result == expected)
}

View file

@ -0,0 +1 @@
CREATE UNIQUE INDEX utxo_outpoints ON txo_spending_info (tx_outpoint);

View file

@ -0,0 +1 @@
CREATE UNIQUE INDEX "utxo_outpoints" ON "txo_spending_info" ("tx_outpoint");

View file

@ -203,7 +203,7 @@ case class SpendingInfoDAO()(implicit
extends TableAutoInc[SpendingInfoDb](tag, "txo_spending_info") {
def outPoint: Rep[TransactionOutPoint] =
column("tx_outpoint")
column("tx_outpoint", O.Unique)
def txid: Rep[DoubleSha256DigestBE] = column("txid")