Backfill `project_id` for `dependency_list_exports`

Context: #434994 (comment 1779072112).

We need to define a sharding key for dependency_list_exports. An export can belong to a pipeline, project, group, or organization. Per defining a sharding key, we can have multiple sharding keys but we must have a check constraint ensuring that we have at least one of them.

Implementation plan

  1. Set project_id to pipeline.project_id when creating pipeline dependency list exports
  2. Backfill project_id for all existing exports which have a pipeline_id

Verification

  • Make sure that dependency_list_exports.organization_id is set on rows where pipeline_id is set. The following query shouldn't return any row.

    select * from dependency_list_exports
    where pipeline_id is not null and project_id is null;
Edited by Fabien Catteau