Support different database flavors in the SQL scripts
This uses a new database table and some psql conditionals to introduce three different flavors for the swh.storage Postgres database:
- the 'default' flavor has all the deduplication features, foreign keys and read indexes
- the 'mirror' flavor has all the deduplication features and read indexes; it drops some foreign keys to allow for out of order addition of some object types
- the 'read_replica' flavor has the minimal set of indexes to support read queries, and replication using the PostgreSQL logical replication feature
We still need to introduce a way to initialize the "flavor" of the database in
swh db-init
, between playing 00-swh-flavor.sql and 60-swh-indexes.sql.
Related to #2604 (closed).
(To support this feature, a preceding commit replaces our use of psycopg2 with psql for initialization of the test databases)
Test Plan
For now, only tested with tox (using the default, full-fat database flavor).
Migrated from D3981 (view on Phabricator)