Add migration fixing wrong team reference for assets in repository snapshots [SCI-9929] (#6880)

This commit is contained in:
Alex Kriuchykhin 2024-01-05 14:44:35 +01:00 committed by GitHub
parent e9d42beec4
commit 00cb69c4e2
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -0,0 +1,16 @@
# frozen_string_literal: true
class FixTeamIdForClonedRepositoryAssets < ActiveRecord::Migration[7.0]
def up
execute(
'UPDATE "assets" ' \
'SET "team_id" = "repositories"."team_id" ' \
'FROM "repositories" ' \
'INNER JOIN "repository_columns" ON "repository_columns"."repository_id" = "repositories"."id" ' \
'INNER JOIN "repository_cells" ON "repository_cells"."repository_column_id" = "repository_columns"."id" ' \
'INNER JOIN "repository_asset_values" ON "repository_asset_values"."id" = "repository_cells"."value_id" ' \
'AND "repository_cells"."value_type" = \'RepositoryAssetValue\' ' \
'WHERE "assets"."team_id" != "repositories"."team_id"'
)
end
end