storj/satellite/satellitedb/dbx
Jessica Grebenschikov aeab599d21 satellitedb: removed unused id on storagenode_storage_tallies table, add index on node_id
The goal of this change is to improve the storagenode_storage_tallies table by removing the unneeded id column that is not being used but only taking up space, and also to add an index on a different column that needs it. Removing and adding a column seems simple, but ended up being more complicated because of some cockroachdb limitations.

The cockroachdb limitation when trying to remove a column from a table and create a new primary key are:
1. only allows primary key creation at table creation time (docs: https://www.cockroachlabs.com/docs/stable/primary-key.html)
2. table drop or rename is performed async and cannot be done in a transaction (issue: https://github.com/cockroachdb/cockroach/issues/12123, https://github.com/cockroachdb/cockroach/issues/22868)

To address these differences between cockroachdb  and Postgres, this PR performs different migrations for the two database. The Postgres migration is straight forward and what you would expect, but the cockroach migration has two main changes:
1. To change a primary key, use the recommended process from the cockroachdb docs to create a new table with the new primary key you want and then migrate the data.
2. In order to do 1, we needed to do the new table renaming in a separate transaction from the data migration.

Ref: SM-65

Change-Id: Idc9aee3ab57aa4d5570e3d2980afea853cd966bf
2020-03-20 14:39:44 -07:00
..
templates satellite/satellitedb/dbx: monitor the database calls 2019-12-18 21:57:36 +00:00
gen.go all: use monkit v3 2020-02-05 23:53:17 +00:00
gen.sh satellite/satellitedb/dbx: Remove bashism from gen.sh 2020-01-23 17:09:07 -05:00
satellitedb.dbx satellitedb: removed unused id on storagenode_storage_tallies table, add index on node_id 2020-03-20 14:39:44 -07:00
satellitedb.dbx.cockroach.sql satellitedb: removed unused id on storagenode_storage_tallies table, add index on node_id 2020-03-20 14:39:44 -07:00
satellitedb.dbx.go satellitedb: removed unused id on storagenode_storage_tallies table, add index on node_id 2020-03-20 14:39:44 -07:00
satellitedb.dbx.postgres.sql satellitedb: removed unused id on storagenode_storage_tallies table, add index on node_id 2020-03-20 14:39:44 -07:00