Skip to content
This repository has been archived by the owner on Sep 16, 2022. It is now read-only.

Commit

Permalink
Merge pull request #739 from CSCfi/stable
Browse files Browse the repository at this point in the history
Merge Stable to Master
  • Loading branch information
katrite authored Jan 10, 2021
2 parents 78d67ea + 284bcbf commit 046fa6a
Show file tree
Hide file tree
Showing 3 changed files with 154 additions and 0 deletions.
83 changes: 83 additions & 0 deletions src/metax_api/migrations/0030_auto_20201103_1233.py
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(),
),
]
13 changes: 13 additions & 0 deletions src/metax_api/migrations/0031_merge_20201207_1117.py
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 = [
]
58 changes: 58 additions & 0 deletions src/metax_api/migrations/0032_auto_20201222_1321.py
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),
]

0 comments on commit 046fa6a

Please sign in to comment.