<p>I think its just a matter of installing the new version. The database schema is compatible with the previous <code>13.0.*</code> version.</p>

CC BY-SA 4.0
2023-02-03T04:31:41.913Z
Thanks Erik!  I really appreciate the quick response here.  All is back to normal, db-sync is up and running.  I followed the Guild Operators notes, so I had to perform an upgrade of the pre-requisite scripts then add the hash values back into the config.json file.
Nicholas
CC BY-SA 4.0
2023-02-03T01:09:12.897Z
2023-02-03T01:09:12.897Z
Erik de Castro Lopo
<p>While upgrade of dbsync is straightforward (replace binary and schema folder reference), it is important to note that the upgrade will cause you to lose most of your unique indexes (and deletion of foreign key will have performance differences too). There isn't a clear one-to-one mapping documented yet, but recreation of unique indexes (subset) would be as below (only include what you really need):</p>
<pre class="lang-sql prettyprint-override"><code>CREATE UNIQUE INDEX IF NOT EXISTS unique_ada_pots ON public.ada_pots USING btree (block_id);
CREATE UNIQUE INDEX IF NOT EXISTS unique_col_txin ON public.collateral_tx_in USING btree (tx_in_id, tx_out_id, tx_out_index);
CREATE UNIQUE INDEX IF NOT EXISTS unique_col_txout ON public.collateral_tx_out USING btree (tx_id, index);
CREATE UNIQUE INDEX IF NOT EXISTS unique_delegation ON public.delegation USING btree (tx_id, cert_index);
CREATE UNIQUE INDEX IF NOT EXISTS unique_epoch_param ON public.epoch_param USING btree (epoch_no, block_id);
CREATE UNIQUE INDEX IF NOT EXISTS unique_ma_tx_mint ON public.ma_tx_mint USING btree (ident, tx_id);
CREATE UNIQUE INDEX IF NOT EXISTS unique_ma_tx_out ON public.ma_tx_out USING btree (ident, tx_out_id);
CREATE UNIQUE INDEX IF NOT EXISTS unique_param_proposal ON public.param_proposal USING btree (key, registered_tx_id);
CREATE UNIQUE INDEX IF NOT EXISTS unique_pool_owner ON public.pool_owner USING btree (addr_id, pool_update_id);
CREATE UNIQUE INDEX IF NOT EXISTS unique_pool_relay ON public.pool_relay USING btree (update_id, ipv4, ipv6, dns_name);
CREATE UNIQUE INDEX IF NOT EXISTS unique_pool_retiring ON public.pool_retire USING btree (announced_tx_id, cert_index);
CREATE UNIQUE INDEX IF NOT EXISTS unique_ref_tx_in ON reference_tx_in USING btree (tx_in_id, tx_out_id, tx_out_index);
CREATE UNIQUE INDEX IF NOT EXISTS unique_pool_update ON public.pool_update USING btree (registered_tx_id, cert_index);
CREATE UNIQUE INDEX IF NOT EXISTS unique_pot_transfer ON public.pot_transfer USING btree (tx_id, cert_index);
CREATE UNIQUE INDEX IF NOT EXISTS unique_redeemer ON public.redeemer USING btree (tx_id, purpose, index);
CREATE UNIQUE INDEX IF NOT EXISTS unique_reserves ON public.reserve USING btree (addr_id, tx_id, cert_index);
CREATE UNIQUE INDEX IF NOT EXISTS unique_stake_deregistration ON public.stake_deregistration USING btree (tx_id, cert_index);
CREATE UNIQUE INDEX IF NOT EXISTS unique_stake_registration ON public.stake_registration USING btree (tx_id, cert_index);
CREATE UNIQUE INDEX IF NOT EXISTS unique_treasury ON public.treasury USING btree (addr_id, tx_id, cert_index);
CREATE UNIQUE INDEX IF NOT EXISTS unique_txin ON tx_in USING btree (tx_out_id, tx_out_index);
CREATE UNIQUE INDEX IF NOT EXISTS unique_tx_metadata ON public.tx_metadata USING btree (key, tx_id);
CREATE UNIQUE INDEX IF NOT EXISTS unique_withdrawal ON public.withdrawal USING btree (addr_id, tx_id);

CREATE INDEX IF NOT EXISTS idx_ma_tx_out_ident ON ma_tx_out (ident) ;
</code></pre>

CC BY-SA 4.0
2023-02-03T15:13:10.193Z
Diffing the schema, I found two more 

`CREATE UNIQUE INDEX IF NOT EXISTS unique_ref_tx_in ON reference_tx_in USING btree (tx_in_id, tx_out_id, tx_out_index);`

`CREATE UNIQUE INDEX IF NOT EXISTS unique_txin ON tx_in USING btree (tx_out_id, tx_out_index);`


[Related db-sync issue](https://github.com/input-output-hk/cardano-db-sync/issues/1349)
sorki
CC BY-SA 4.0
2023-02-03T23:17:11.823Z
Thanks, updated original comment
RdLrT
CC BY-SA 4.0
2023-02-03T09:06:50.530Z
2023-02-03T22:35:28.847Z
2023-02-03T22:35:28.847Z
RdLrT
<p>I was wondering if anyone knows where I can find the detailed upgrade instructions for db-sync 13.1.  I’m current on the previous release and think the upgrade shouldn’t be too difficult, but I can find any documentation for this.</p>
<p>All help is appreciated!
Nick</p>

<cardano-db-sync>
Detailed upgrade instructions for latest db-sync release 13.1
# Detailed upgrade instructions for latest db-sync release 13.1

(Asked by: username_0 on 2023-02-03)

I was wondering if anyone knows where I can find the detailed upgrade instructions for db-sync 13.1. I’m current on the previous release and think the upgrade shouldn’t be too difficult, but I can find any documentation for this.

All help is appreciated!
Nick

**Tags:** cardano-db-sync

---

## 2 answers

### Answer by username_1 on 2023-02-03. Score: 2 | Accepted answer

I think its just a matter of installing the new version. The database schema is compatible with the previous `13.0.*` version.

> **Comments:**
> **username_0**: Thanks Erik!  I really appreciate the quick response here.  All is back to normal, db-sync is up and running.  I followed the Guild Operators notes, so I had to perform an upgrade of the pre-requisite scripts then add the hash values back into the config.json file.  

---

### Answer by username_2 on 2023-02-03. Score: 2

While upgrade of dbsync is straightforward (replace binary and schema folder reference), it is important to note that the upgrade will cause you to lose most of your unique indexes (and deletion of foreign key will have performance differences too). There isn't a clear one-to-one mapping documented yet, but recreation of unique indexes (subset) would be as below (only include what you really need):
CREATE UNIQUE INDEX IF NOT EXISTS unique_ada_pots ON public.ada_pots USING btree (block_id);
CREATE UNIQUE INDEX IF NOT EXISTS unique_col_txin ON public.collateral_tx_in USING btree (tx_in_id, tx_out_id, tx_out_index);
CREATE UNIQUE INDEX IF NOT EXISTS unique_col_txout ON public.collateral_tx_out USING btree (tx_id, index);
CREATE UNIQUE INDEX IF NOT EXISTS unique_delegation ON public.delegation USING btree (tx_id, cert_index);
CREATE UNIQUE INDEX IF NOT EXISTS unique_epoch_param ON public.epoch_param USING btree (epoch_no, block_id);
CREATE UNIQUE INDEX IF NOT EXISTS unique_ma_tx_mint ON public.ma_tx_mint USING btree (ident, tx_id);
CREATE UNIQUE INDEX IF NOT EXISTS unique_ma_tx_out ON public.ma_tx_out USING btree (ident, tx_out_id);
CREATE UNIQUE INDEX IF NOT EXISTS unique_param_proposal ON public.param_proposal USING btree (key, registered_tx_id);
CREATE UNIQUE INDEX IF NOT EXISTS unique_pool_owner ON public.pool_owner USING btree (addr_id, pool_update_id);
CREATE UNIQUE INDEX IF NOT EXISTS unique_pool_relay ON public.pool_relay USING btree (update_id, ipv4, ipv6, dns_name);
CREATE UNIQUE INDEX IF NOT EXISTS unique_pool_retiring ON public.pool_retire USING btree (announced_tx_id, cert_index);
CREATE UNIQUE INDEX IF NOT EXISTS unique_ref_tx_in ON reference_tx_in USING btree (tx_in_id, tx_out_id, tx_out_index);
CREATE UNIQUE INDEX IF NOT EXISTS unique_pool_update ON public.pool_update USING btree (registered_tx_id, cert_index);
CREATE UNIQUE INDEX IF NOT EXISTS unique_pot_transfer ON public.pot_transfer USING btree (tx_id, cert_index);
CREATE UNIQUE INDEX IF NOT EXISTS unique_redeemer ON public.redeemer USING btree (tx_id, purpose, index);
CREATE UNIQUE INDEX IF NOT EXISTS unique_reserves ON public.reserve USING btree (addr_id, tx_id, cert_index);
CREATE UNIQUE INDEX IF NOT EXISTS unique_stake_deregistration ON public.stake_deregistration USING btree (tx_id, cert_index);
CREATE UNIQUE INDEX IF NOT EXISTS unique_stake_registration ON public.stake_registration USING btree (tx_id, cert_index);
CREATE UNIQUE INDEX IF NOT EXISTS unique_treasury ON public.treasury USING btree (addr_id, tx_id, cert_index);
CREATE UNIQUE INDEX IF NOT EXISTS unique_txin ON tx_in USING btree (tx_out_id, tx_out_index);
CREATE UNIQUE INDEX IF NOT EXISTS unique_tx_metadata ON public.tx_metadata USING btree (key, tx_id);
CREATE UNIQUE INDEX IF NOT EXISTS unique_withdrawal ON public.withdrawal USING btree (addr_id, tx_id);

CREATE INDEX IF NOT EXISTS idx_ma_tx_out_ident ON ma_tx_out (ident) ;

> **Comments:**
> **username_3**: Diffing the schema, I found two more   `CREATE UNIQUE INDEX IF NOT EXISTS unique_ref_tx_in ON reference_tx_in USING btree (tx_in_id, tx_out_id, tx_out_index);`  `CREATE UNIQUE INDEX IF NOT EXISTS unique_txin ON tx_in USING btree (tx_out_id, tx_out_index);`   [Related db-sync issue](https://github.com/input-output-hk/cardano-db-sync/issues/1349)  
> **username_2**: Thanks, updated original comment  

---

