diff --git a/scripts/migrations/007_add_submitters_usergroup_to_moderation_request.py b/scripts/migrations/007_add_submitters_usergroup_to_moderation_request.py old mode 100644 new mode 100755 diff --git a/scripts/migrations/008_add_component_type_to_moderation_requests.py b/scripts/migrations/008_add_component_type_to_moderation_requests.py old mode 100644 new mode 100755 diff --git a/scripts/migrations/009_overwrite_release_name_with_component_name.py b/scripts/migrations/009_overwrite_release_name_with_component_name.py old mode 100644 new mode 100755 diff --git a/scripts/migrations/010_repair_missing_vendorId_links_in_releases.py b/scripts/migrations/010_repair_missing_vendorId_links_in_releases.py old mode 100644 new mode 100755 diff --git a/scripts/migrations/012_migrate_todoid_to_title.py b/scripts/migrations/012_migrate_todoid_to_title.py new file mode 100755 index 0000000000..a51d90e2f6 --- /dev/null +++ b/scripts/migrations/012_migrate_todoid_to_title.py @@ -0,0 +1,42 @@ +#!/usr/bin/python + +# ----------------------------------------------------------------------------- +# Copyright Siemens AG, 2019. Part of the SW360 Portal Project. +# +# All rights reserved. This program and the accompanying materials +# are made available under the terms of the Eclipse Public License v1.0 +# which accompanies this distribution, and is available at +# http://www.eclipse.org/legal/epl-v10.html +# +# This is a manual database migration script. It is assumed that a +# dedicated framework for automatic migration will be written in the +# future. When that happens, this script should be refactored to conform +# to the framework's prerequisites to be run by the framework. For +# example, server address and db name should be parametrized, the code +# reorganized into a single class or function, etc. +# ----------------------------------------------------------------------------- + +import couchdb + +COUCHSERVER = "http://localhost:5984/" +DBNAME = 'sw360db' + +couch=couchdb.Server(COUCHSERVER) +db = couch[DBNAME] + +todos_by_id_fun = '''function(doc){ + if (doc.type=="todo"){ + emit(doc._id, doc) + } +}''' + +todos = db.query(todos_by_id_fun) + + +print 'Updating todos and replace todoId with title' +for todo_row in todos: + todo = todo_row.value + todo['title'] = str(todo['todoId']) + del todo['todoId'] + db.save(todo) + diff --git a/scripts/migrations/README.md b/scripts/migrations/README.md index 1870bb5f9a..c06aad2c73 100644 --- a/scripts/migrations/README.md +++ b/scripts/migrations/README.md @@ -28,8 +28,9 @@ To migrate it is recommended to do this in the following order: ### 2.2.0 -> 3.0.0 - `007_add_submitters_usergroup_to_moderation_request.py` - `008_add_component_type_to_moderation_requests.py` -### 3.3.0 -> 3.4.0 +### 3.3.0 -> 4.0.0 - `011_migrate_attachment_usages_license_info.py` +- `012_migrate_todoid_to_title.py` ## Optional usage - `009_overwrite_release_name_with_component_name.py`