-
Task
-
Resolution: Done
-
Major
-
None
-
None
-
5
-
False
-
-
True
-
-
PostgreSQL logical replication doesn't allow UPDATE or DELETE operations on tables that don't have a primary key. Most of our tables have primary keys by necessity, but our join tables and the Liquibase tables do not. We need to add primary keys to those tables.
Using this query:
- contract_metrics
- databasechangelog
- databasechangelog_swatch_contracts
- sku_child_sku
- sku_oid
- sku_product_tag
PostgreSQL logical replication doesn't allow UPDATE or DELETE operations on tables that don't have a primary key. Most of our tables have primary keys by necessity, but our join tables and the Liquibase tables do not. We need to add primary keys to those tables.
The databasechangelog table doesn't have a primary key, but according to the Liquibase developer "You can always manually add a primary key if you like; Liquibase will not care"
Steps:
- Write liquibase migrations to add primary keys to tables that are missing them
- Ideally, use a UUID. id uuid PRIMARY KEY DEFAULT uuid_generate_v4() but that will require the uuid-ossp package in Postgres 12. RDS in theory supports this: https://docs.aws.amazon.com/AmazonRDS/latest/PostgreSQLReleaseNotes/postgresql-extensions.html#postgresql-extensions-12x See here
- Otherwise, use a sequence, not a serial. We don't have to map these keys in Hibernate, but if we ever do, a sequence will avoid some issues
Done Criteria
- Stage is not broken when this is implemented on Postgres 12
- Ephemeral is not broken when this is implemented on Postgres 12