|
2 | 2 |
|
3 | 3 | from django.db import migrations |
4 | 4 |
|
5 | | -from dojo.models import Sonarqube_Product, Cobaltio_Product, Product_API_Scan_Configuration, Test |
6 | | - |
7 | 5 |
|
8 | 6 | def migrate_sonarqube(apps, schema_editor): |
9 | | - sq_products = Sonarqube_Product.objects.filter(sonarqube_tool_config__isnull=False) |
| 7 | + |
| 8 | + Sonarqube_Product_model = apps.get_model('dojo', 'Sonarqube_Product') |
| 9 | + Product_API_Scan_Configuration_model = apps.get_model('dojo', 'Product_API_Scan_Configuration') |
| 10 | + Test_model = apps.get_model('dojo', 'Test') |
| 11 | + |
| 12 | + sq_products = Sonarqube_Product_model.objects.filter(sonarqube_tool_config__isnull=False) |
10 | 13 | for sq_product in sq_products: |
11 | | - api_scan_configuration = Product_API_Scan_Configuration() |
| 14 | + api_scan_configuration = Product_API_Scan_Configuration_model() |
12 | 15 | api_scan_configuration.product = sq_product.product |
13 | 16 | api_scan_configuration.tool_configuration = sq_product.sonarqube_tool_config |
14 | 17 | api_scan_configuration.service_key_1 = sq_product.sonarqube_project_key |
15 | 18 | api_scan_configuration.save() |
16 | | - tests = Test.objects.filter(sonarqube_config=sq_product) |
| 19 | + |
| 20 | + tests = Test_model.objects.filter(sonarqube_config=sq_product) |
17 | 21 | for test in tests: |
18 | 22 | test.api_scan_configuration = api_scan_configuration |
19 | 23 | test.sonarqube_config = None |
20 | 24 | test.save() |
| 25 | + |
21 | 26 | sq_product.delete() |
22 | 27 |
|
23 | 28 |
|
24 | 29 | def migrate_cobalt_io(apps, schema_editor): |
25 | | - cobalt_products = Cobaltio_Product.objects.filter(cobaltio_tool_config__isnull=False) |
| 30 | + |
| 31 | + Cobaltio_Product_model = apps.get_model('dojo', 'Cobaltio_Product') |
| 32 | + Product_API_Scan_Configuration_model = apps.get_model('dojo', 'Product_API_Scan_Configuration') |
| 33 | + Test_model = apps.get_model('dojo', 'Test') |
| 34 | + |
| 35 | + cobalt_products = Cobaltio_Product_model.objects.filter(cobaltio_tool_config__isnull=False) |
26 | 36 | for cobalt_product in cobalt_products: |
27 | | - api_scan_configuration = Product_API_Scan_Configuration() |
| 37 | + api_scan_configuration = Product_API_Scan_Configuration_model() |
28 | 38 | api_scan_configuration.product = cobalt_product.product |
29 | 39 | api_scan_configuration.tool_configuration = cobalt_product.cobaltio_tool_config |
30 | 40 | api_scan_configuration.service_key_1 = cobalt_product.cobaltio_asset_id |
31 | 41 | api_scan_configuration.service_key_2 = cobalt_product.cobaltio_asset_name |
32 | 42 | api_scan_configuration.save() |
33 | | - tests = Test.objects.filter(cobaltio_config=cobalt_product) |
| 43 | + |
| 44 | + tests = Test_model.objects.filter(cobaltio_config=cobalt_product) |
34 | 45 | for test in tests: |
35 | 46 | test.api_scan_configuration = api_scan_configuration |
36 | 47 | test.cobaltio_config = None |
37 | 48 | test.save() |
| 49 | + |
38 | 50 | cobalt_product.delete() |
39 | 51 |
|
40 | 52 |
|
|
0 commit comments