mirror of
https://gitlab.com/gitlab-org/gitlab-foss.git
synced 2025-07-25 16:03:48 +00:00
30 lines
783 B
Ruby
30 lines
783 B
Ruby
# frozen_string_literal: true
|
|
|
|
class AddProjectSnippetsView < Gitlab::Database::Migration[2.2]
|
|
milestone '17.11'
|
|
|
|
def up
|
|
execute <<-SQL
|
|
CREATE VIEW project_snippets_routes_view AS
|
|
SELECT sn.id,
|
|
sh.name AS repository_storage,
|
|
sr.disk_path,
|
|
r.path AS path_with_namespace,
|
|
r.name AS name_with_namespace
|
|
FROM snippets sn
|
|
JOIN snippet_repositories sr
|
|
ON (sn.id=sr.snippet_id AND sn.type='ProjectSnippet')
|
|
JOIN shards sh
|
|
ON (sr.shard_id = sh.id)
|
|
JOIN routes r
|
|
ON (r.source_id = sn.project_id AND source_type = 'Project');
|
|
SQL
|
|
end
|
|
|
|
def down
|
|
execute <<-SQL
|
|
DROP VIEW project_snippets_routes_view;
|
|
SQL
|
|
end
|
|
end
|