This repository has been archived by the owner on Sep 16, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #739 from CSCfi/stable
Merge Stable to Master
- Loading branch information
Showing
3 changed files
with
154 additions
and
0 deletions.
There are no files selected for viewing
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,83 @@ | ||
# Generated by Django 3.1.2 on 2020-11-03 10:33 | ||
from django.db import migrations, models | ||
import django.db.models.deletion | ||
|
||
|
||
class Migration(migrations.Migration): | ||
|
||
dependencies = [ | ||
('metax_api', '0029_auto_20201028_1602'), | ||
] | ||
|
||
operations = [ | ||
migrations.AlterField( | ||
model_name='catalogrecord', | ||
name='_directory_data', | ||
field=models.JSONField(help_text='Stores directory data related to browsing files and directories', null=True), | ||
), | ||
migrations.AlterField( | ||
model_name='catalogrecord', | ||
name='access_granter', | ||
field=models.JSONField(default=None, help_text='Stores data of REMS user who is currently granting access to this dataset', null=True), | ||
), | ||
migrations.AlterField( | ||
model_name='catalogrecord', | ||
name='api_meta', | ||
field=models.JSONField(default=dict, help_text='Saves api related info about the dataset. E.g. api version', null=True), | ||
), | ||
migrations.AlterField( | ||
model_name='catalogrecord', | ||
name='dataset_version_set', | ||
field=models.ForeignKey(help_text='Records which are different dataset versions of each other.', null=True, on_delete=django.db.models.deletion.DO_NOTHING, related_name='records', to='metax_api.datasetversionset'), | ||
), | ||
migrations.AlterField( | ||
model_name='catalogrecord', | ||
name='editor', | ||
field=models.JSONField(help_text='Editor specific fields, such as owner_id, modified, record_identifier', null=True), | ||
), | ||
migrations.AlterField( | ||
model_name='catalogrecord', | ||
name='next_draft', | ||
field=models.OneToOneField(help_text='A draft of the next changes to be published on this dataset, in order to be able to save progress, and continue later. Is created from a published dataset. When the draft is published, changes are saved on top of the original dataset, and the draft record is destroyed.', null=True, on_delete=django.db.models.deletion.SET_NULL, related_name='draft_of', to='metax_api.catalogrecord'), | ||
), | ||
migrations.AlterField( | ||
model_name='catalogrecord', | ||
name='research_dataset', | ||
field=models.JSONField(), | ||
), | ||
migrations.AlterField( | ||
model_name='contract', | ||
name='contract_json', | ||
field=models.JSONField(blank=True, null=True), | ||
), | ||
migrations.AlterField( | ||
model_name='datacatalog', | ||
name='catalog_json', | ||
field=models.JSONField(), | ||
), | ||
migrations.AlterField( | ||
model_name='file', | ||
name='file_characteristics', | ||
field=models.JSONField(blank=True, null=True), | ||
), | ||
migrations.AlterField( | ||
model_name='file', | ||
name='file_characteristics_extension', | ||
field=models.JSONField(blank=True, null=True), | ||
), | ||
migrations.AlterField( | ||
model_name='filestorage', | ||
name='file_storage_json', | ||
field=models.JSONField(blank=True, null=True), | ||
), | ||
migrations.AlterField( | ||
model_name='metaxuser', | ||
name='first_name', | ||
field=models.CharField(blank=True, max_length=150, verbose_name='first name'), | ||
), | ||
migrations.AlterField( | ||
model_name='researchdatasetversion', | ||
name='research_dataset', | ||
field=models.JSONField(), | ||
), | ||
] |
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,13 @@ | ||
# Generated by Django 3.1.2 on 2020-12-07 09:17 | ||
from django.db import migrations | ||
|
||
|
||
class Migration(migrations.Migration): | ||
|
||
dependencies = [ | ||
('metax_api', '0030_auto_20201103_1233'), | ||
('metax_api', '0030_kotus_datasets'), | ||
] | ||
|
||
operations = [ | ||
] |
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,58 @@ | ||
# Generated by Django 3.1.2 on 2020-12-22 11:21 | ||
|
||
from django.db import migrations | ||
import logging | ||
import json | ||
_logger = logging.getLogger(__name__) | ||
|
||
datasets = [ | ||
'3884f2e1-e73f-4c7b-8cab-b71ccc80c4d6', # Testdata | ||
'a0651f93-1826-4264-8fe4-df39f1ee72ac', # OKM dataset | ||
'234568cc-a5cb-45cc-8b51-c7828ceb3a46', # Kotus | ||
'3746a761-b492-4b33-aa87-5a5a364fe877', # Kotus | ||
'e69340f2-6f55-4097-8299-5e7c3f8344b0', # Kotus | ||
'b1014ce6-6b8b-4343-b95b-478d30c184c4', # Kotus | ||
] | ||
|
||
def add_version_set_field_to_rd(apps, schema_editor): | ||
CatalogRecord = apps.get_model('metax_api', 'CatalogRecord') | ||
DataCatalog = apps.get_model('metax_api', 'DataCatalog') | ||
DatasetVersionSet = apps.get_model('metax_api', 'DatasetVersionSet') | ||
|
||
for cr in CatalogRecord.objects.filter(identifier__in=datasets): | ||
|
||
ida = 'urn:nbn:fi:att:data-catalog-ida' | ||
dc = DataCatalog.objects.get(catalog_json__identifier = ida) | ||
cr.data_catalog_id = dc.id | ||
|
||
dvs = DatasetVersionSet() | ||
dvs.save() | ||
dvs.records.add(cr) | ||
|
||
cr.save() | ||
_logger.info(f'successfully migrated cr {cr.identifier}') | ||
|
||
def revert(apps, schema_editor): | ||
CatalogRecord = apps.get_model('metax_api', 'CatalogRecord') | ||
DataCatalog = apps.get_model('metax_api', 'DataCatalog') | ||
|
||
for cr in CatalogRecord.objects.filter(identifier__in=datasets): | ||
|
||
att = 'urn:nbn:fi:att:data-catalog-att' | ||
dc = DataCatalog.objects.get(catalog_json__identifier = att) | ||
cr.data_catalog_id = dc.id | ||
|
||
cr.dataset_version_set_id = None | ||
|
||
cr.save() | ||
_logger.info(f'successfully reverted migration of cr {cr.identifier}') | ||
|
||
|
||
class Migration(migrations.Migration): | ||
dependencies = [ | ||
('metax_api', '0031_merge_20201207_1117'), | ||
] | ||
|
||
operations = [ | ||
migrations.RunPython(add_version_set_field_to_rd, revert), | ||
] |