Skip to content

Remove association between ChatName and Integration - Step 1: make it optional

This issue is part of the epic &9418 (closed). See that epic for more details.

About

We want to remove the association between a ChatName and an Integration in order to be able to identify users in Slack without a project or integration.

In this issue, we can make the association between ChatName and Integration optional in database modelling.

The next step in #384973 (closed) will be to modify the code to stop associating ChatName and Integration records, and finally, we will drop the database chat_names.integration_id column later in #384974 (closed).

Proposal

  1. Remove the integration_id foreign key from chat_names. Follow our process for removing a foreign key constraint.
  2. Change some of the indexes on the table:
    1. Drop the existing UNIQUE index on (integration_id, team_id, chat_id)
    2. Replace the UNIQUE index on (user_id, integration_id) index with a non-unique index just on user_id. Do this by adding the non-unique index, and then in a second migration drop the other one.
  3. Update the validations in ChatName:
    1. Remove the uniqueness validation on :user_id that is scoped to integration_id.
    2. Change the uniqueness validation on :chat_id so that it is scoped only to :team_id.
Edited by Luke Duncalfe