Make sure all tables have a primary key
There are a few tables that don't have an explicit primary key set. Instead, there's a unique key that is conceptually equivalent to a primary key.
There are cases where primary keys are required. An example for this is logical replication using pglogical
(see https://gitlab.com/gitlab-com/infrastructure/issues/3446#note_61009547).
Offending tables are: issue_assignees, user_contributed_projects, merge_request_diff_files, merge_request_diff_commits, project_authorizations, push_event_payloads, schema_migrations
This issue is about turning existing unique indexes into primary keys. We need to make sure both MySQL and Postgres support this. Also, primary key definitions need to find their way into db/schema.rb
.
Let's also add (rspec?) tests to make sure we don't create new tables without a primary key.
This issue is about providing a scripted way of adding/removing primary keys for offending tables. This can be used e.g. during a upgrade to PG10 where pglogical requires primary keys for all tables.