diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2019-10-08 00:07:54 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2019-10-08 00:07:54 +0300 |
commit | 8c8b94e7116fa478ad490bd14c09565d23097f57 (patch) | |
tree | 9e4637aa0fe498a5523c86932b87ff691ec72af6 /db | |
parent | eadb77d89f5f7d445bfd326f18873168f4719f12 (diff) |
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'db')
4 files changed, 89 insertions, 0 deletions
diff --git a/db/migrate/20190913174707_add_spdx_id_to_software_licenses.rb b/db/migrate/20190913174707_add_spdx_id_to_software_licenses.rb new file mode 100644 index 00000000000..66cd450895c --- /dev/null +++ b/db/migrate/20190913174707_add_spdx_id_to_software_licenses.rb @@ -0,0 +1,13 @@ +# frozen_string_literal: true + +class AddSpdxIdToSoftwareLicenses < ActiveRecord::Migration[5.2] + DOWNTIME = false + + def up + add_column :software_licenses, :spdx_identifier, :string, limit: 255 + end + + def down + remove_column :software_licenses, :spdx_identifier + end +end diff --git a/db/migrate/20190913175827_add_index_to_software_licenses_on_spdx_id.rb b/db/migrate/20190913175827_add_index_to_software_licenses_on_spdx_id.rb new file mode 100644 index 00000000000..94f8738b0cc --- /dev/null +++ b/db/migrate/20190913175827_add_index_to_software_licenses_on_spdx_id.rb @@ -0,0 +1,17 @@ +# frozen_string_literal: true + +class AddIndexToSoftwareLicensesOnSpdxId < ActiveRecord::Migration[5.2] + include Gitlab::Database::MigrationHelpers + + DOWNTIME = false + + disable_ddl_transaction! + + def up + add_concurrent_index :software_licenses, :spdx_identifier + end + + def down + remove_concurrent_index :software_licenses, :spdx_identifier + end +end diff --git a/db/post_migrate/20190917173107_backfill_software_licenses_spdx_identifiers.rb b/db/post_migrate/20190917173107_backfill_software_licenses_spdx_identifiers.rb new file mode 100644 index 00000000000..09492f5f99e --- /dev/null +++ b/db/post_migrate/20190917173107_backfill_software_licenses_spdx_identifiers.rb @@ -0,0 +1,57 @@ +# frozen_string_literal: true + +class BackfillSoftwareLicensesSpdxIdentifiers < ActiveRecord::Migration[5.2] + include Gitlab::Database::MigrationHelpers + + DOWNTIME = false + CURRENT_LICENSES = { + 'AGPL-1.0' => 'AGPL-1.0', + 'AGPL-3.0' => 'AGPL-3.0', + 'Apache 2.0' => 'Apache-2.0', + 'Artistic-2.0' => 'Artistic-2.0', + 'BSD' => 'BSD-4-Clause', + 'CC0 1.0 Universal' => 'CC0-1.0', + 'CDDL-1.0' => 'CDDL-1.0', + 'CDDL-1.1' => 'CDDL-1.1', + 'EPL-1.0' => 'EPL-1.0', + 'EPL-2.0' => 'EPL-2.0', + 'GPLv2' => 'GPL-2.0', + 'GPLv3' => 'GPL-3.0', + 'ISC' => 'ISC', + 'LGPL' => 'LGPL-3.0-only', + 'LGPL-2.1' => 'LGPL-2.1', + 'MIT' => 'MIT', + 'Mozilla Public License 2.0' => 'MPL-2.0', + 'MS-PL' => 'MS-PL', + 'MS-RL' => 'MS-RL', + 'New BSD' => 'BSD-3-Clause', + 'Python Software Foundation License' => 'Python-2.0', + 'ruby' => 'Ruby', + 'Simplified BSD' => 'BSD-2-Clause', + 'WTFPL' => 'WTFPL', + 'Zlib' => 'Zlib' + }.freeze + + disable_ddl_transaction! + + # 25 records to be updated on GitLab.com + def up + return unless Gitlab.ee? + + say "Expect #{CURRENT_LICENSES.count} updates to the software_licenses table to occur" + CURRENT_LICENSES.each do |name, spdx_identifier| + # The following cop is disabled because of https://gitlab.com/gitlab-org/gitlab/issues/33470 + # For more context see https://gitlab.com/gitlab-org/gitlab/merge_requests/17004#note_226264823 + # rubocop:disable Migration/UpdateColumnInBatches + update_column_in_batches(:software_licenses, :spdx_identifier, spdx_identifier) do |table, query| + query.where(table[:name].eq(name)) + end + end + end + + def down + return unless Gitlab.ee? + + update_column_in_batches(:software_licenses, :spdx_identifier, nil) + end +end diff --git a/db/schema.rb b/db/schema.rb index 6c5c761e774..eaba76f3f1a 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -3350,7 +3350,9 @@ ActiveRecord::Schema.define(version: 2019_09_29_180827) do create_table "software_licenses", id: :serial, force: :cascade do |t| t.string "name", null: false + t.string "spdx_identifier", limit: 255 t.index ["name"], name: "index_software_licenses_on_name" + t.index ["spdx_identifier"], name: "index_software_licenses_on_spdx_identifier" end create_table "spam_logs", id: :serial, force: :cascade do |t| |