-
Notifications
You must be signed in to change notification settings - Fork 101
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(todoMigration): migration script for todos
This commits add a migration script for changing the 'todoId' into the 'title' for todo documents. This is necessary due to the changes in #517. Closes #586 Signed-off-by: Leo von Klenze <[email protected]>
- Loading branch information
Showing
6 changed files
with
44 additions
and
1 deletion.
There are no files selected for viewing
Empty file modified
0
scripts/migrations/007_add_submitters_usergroup_to_moderation_request.py
100644 → 100755
Empty file.
Empty file modified
0
scripts/migrations/008_add_component_type_to_moderation_requests.py
100644 → 100755
Empty file.
Empty file modified
0
scripts/migrations/009_overwrite_release_name_with_component_name.py
100644 → 100755
Empty file.
Empty file modified
0
scripts/migrations/010_repair_missing_vendorId_links_in_releases.py
100644 → 100755
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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) | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters