Skip to content

Commit

Permalink
Merge pull request #141 from c3g/regenerate-migrations
Browse files Browse the repository at this point in the history
Delete all migrations and regenerate new migrations
  • Loading branch information
zxenia committed Jul 7, 2020
2 parents ba85db6 + cb65376 commit 7706526
Show file tree
Hide file tree
Showing 67 changed files with 628 additions and 3,374 deletions.
14 changes: 14 additions & 0 deletions chord_metadata_service/chord/ingest.py
Original file line number Diff line number Diff line change
Expand Up @@ -259,6 +259,7 @@ def ingest_phenopacket(phenopacket_data, table_id) -> pm.Phenopacket:
biosamples = phenopacket_data.get("biosamples", [])
genes = phenopacket_data.get("genes", [])
diseases = phenopacket_data.get("diseases", [])
hts_files = phenopacket_data.get("hts_files", [])
meta_data = phenopacket_data["meta_data"]

if subject:
Expand Down Expand Up @@ -321,6 +322,18 @@ def ingest_phenopacket(phenopacket_data, table_id) -> pm.Phenopacket:
)
diseases_db.append(d_obj.id)

hts_files_db = []
for htsfile in hts_files:
htsf_obj, _ = pm.HtsFile.objects.get_or_create(
uri=htsfile["uri"],
description=htsfile.get("description", None),
hts_format=htsfile["hts_format"],
genome_assembly=htsfile["genome_assembly"],
individual_to_sample_identifiers=htsfile.get("individual_to_sample_identifiers", None),
extra_properties=htsfile.get("extra_properties", None)
)
hts_files_db.append(htsf_obj)

resources_db = [ingest_resource(rs) for rs in meta_data.get("resources", [])]

meta_data_obj = pm.MetaData(
Expand All @@ -346,6 +359,7 @@ def ingest_phenopacket(phenopacket_data, table_id) -> pm.Phenopacket:
new_phenopacket.biosamples.set(biosamples_db)
new_phenopacket.genes.set(genes_db)
new_phenopacket.diseases.set(diseases_db)
new_phenopacket.hts_files.set(hts_files_db)

return new_phenopacket

Expand Down
70 changes: 0 additions & 70 deletions chord_metadata_service/chord/migrations/0001_initial.py

This file was deleted.

90 changes: 90 additions & 0 deletions chord_metadata_service/chord/migrations/0001_v1_0_0.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,90 @@
# Generated by Django 2.2.13 on 2020-07-06 14:55

import chord_metadata_service.chord.models
import django.contrib.postgres.fields.jsonb
from django.db import migrations, models
import django.db.models.deletion
import uuid


class Migration(migrations.Migration):

initial = True

dependencies = [
('resources', '0001_v1_0_0'),
]

operations = [
migrations.CreateModel(
name='Dataset',
fields=[
('identifier', models.UUIDField(default=uuid.uuid4, editable=False, primary_key=True, serialize=False)),
('title', models.CharField(max_length=200, unique=True)),
('description', models.TextField(blank=True)),
('contact_info', models.TextField(blank=True)),
('data_use', django.contrib.postgres.fields.jsonb.JSONField()),
('linked_field_sets', django.contrib.postgres.fields.jsonb.JSONField(blank=True, default=list, help_text='Data type fields which are linked together.')),
('alternate_identifiers', django.contrib.postgres.fields.jsonb.JSONField(blank=True, default=list, help_text='Alternate identifiers for the dataset.')),
('related_identifiers', django.contrib.postgres.fields.jsonb.JSONField(blank=True, default=list, help_text='Related identifiers for the dataset.')),
('dates', django.contrib.postgres.fields.jsonb.JSONField(blank=True, default=list, help_text='Relevant dates for the datasets, a date must be added, e.g. creation date or last modification date should be added.')),
('stored_in', django.contrib.postgres.fields.jsonb.JSONField(blank=True, help_text='The data repository hosting the dataset.', null=True)),
('spatial_coverage', django.contrib.postgres.fields.jsonb.JSONField(blank=True, default=list, help_text='The geographical extension and span covered by the dataset and its measured dimensions/variables.')),
('types', django.contrib.postgres.fields.jsonb.JSONField(blank=True, default=list, help_text='A term, ideally from a controlled terminology, identifying the dataset type or nature of the data, placing it in a typology.')),
('availability', models.CharField(blank=True, help_text='A qualifier indicating the different types of availability for a dataset (available, unavailable, embargoed, available with restriction, information not available).', max_length=200)),
('refinement', models.CharField(blank=True, help_text='A qualifier to describe the level of data processing of the dataset and its distributions.', max_length=200)),
('aggregation', models.CharField(blank=True, help_text="A qualifier indicating if the entity represents an 'instance of dataset' or a 'collection of datasets'.", max_length=200)),
('privacy', models.CharField(blank=True, help_text='A qualifier to describe the data protection applied to the dataset. This is relevant for clinical data.', max_length=200)),
('distributions', django.contrib.postgres.fields.jsonb.JSONField(blank=True, default=list, help_text='The distribution(s) by which datasets are made available (for example: mySQL dump).')),
('dimensions', django.contrib.postgres.fields.jsonb.JSONField(blank=True, default=list, help_text='The different dimensions (granular components) making up a dataset.')),
('primary_publications', django.contrib.postgres.fields.jsonb.JSONField(blank=True, default=list, help_text='The primary publication(s) associated with the dataset, usually describing how the dataset was produced.')),
('citations', django.contrib.postgres.fields.jsonb.JSONField(blank=True, default=list, help_text='The publication(s) that cite this dataset.')),
('citation_count', models.IntegerField(blank=True, help_text='The number of publications that cite this dataset (enumerated in the citations property).', null=True)),
('produced_by', django.contrib.postgres.fields.jsonb.JSONField(blank=True, help_text='A study process which generated a given dataset, if any.', null=True)),
('creators', django.contrib.postgres.fields.jsonb.JSONField(blank=True, default=list, help_text='The person(s) or organization(s) which contributed to the creation of the dataset.')),
('licenses', django.contrib.postgres.fields.jsonb.JSONField(blank=True, default=list, help_text='The terms of use of the dataset.')),
('acknowledges', django.contrib.postgres.fields.jsonb.JSONField(blank=True, default=list, help_text='The grant(s) which funded and supported the work reported by the dataset.')),
('keywords', django.contrib.postgres.fields.jsonb.JSONField(blank=True, default=list, help_text='Tags associated with the dataset, which will help in its discovery.')),
('version', models.CharField(blank=True, default=chord_metadata_service.chord.models.version_default, help_text='A release point for the dataset when applicable.', max_length=200)),
('extra_properties', django.contrib.postgres.fields.jsonb.JSONField(blank=True, help_text='Extra properties that do not fit in the previous specified attributes.', null=True)),
('created', models.DateTimeField(auto_now_add=True)),
('updated', models.DateTimeField(auto_now=True)),
('additional_resources', models.ManyToManyField(blank=True, help_text="Any resource objects linked to this dataset that aren't specified by a phenopacket in the dataset.", to='resources.Resource')),
('has_part', models.ManyToManyField(blank=True, help_text="A Dataset that is a subset of this Dataset; Datasets declaring the 'hasPart' relationship are considered a collection of Datasets, the aggregation criteria could be included in the 'description' field.", related_name='_dataset_has_part_+', to='chord.Dataset')),
],
),
migrations.CreateModel(
name='Project',
fields=[
('identifier', models.UUIDField(default=uuid.uuid4, editable=False, primary_key=True, serialize=False)),
('title', models.CharField(max_length=200, unique=True)),
('description', models.TextField(blank=True)),
('created', models.DateTimeField(auto_now_add=True)),
('updated', models.DateTimeField(auto_now=True)),
],
),
migrations.CreateModel(
name='TableOwnership',
fields=[
('table_id', models.CharField(max_length=200, primary_key=True, serialize=False)),
('service_id', models.CharField(max_length=200)),
('service_artifact', models.CharField(default='', max_length=200)),
('dataset', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='table_ownership', to='chord.Dataset')),
],
),
migrations.CreateModel(
name='Table',
fields=[
('ownership_record', models.OneToOneField(on_delete=django.db.models.deletion.CASCADE, primary_key=True, serialize=False, to='chord.TableOwnership')),
('name', models.CharField(max_length=200, unique=True)),
('data_type', models.CharField(choices=[('experiment', 'experiment'), ('phenopacket', 'phenopacket')], max_length=30)),
('created', models.DateTimeField(auto_now_add=True)),
('updated', models.DateTimeField(auto_now=True)),
],
),
migrations.AddField(
model_name='dataset',
name='project',
field=models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='datasets', to='chord.Project'),
),
]
32 changes: 0 additions & 32 deletions chord_metadata_service/chord/migrations/0002_auto_20191210_2104.py

This file was deleted.

This file was deleted.

18 changes: 0 additions & 18 deletions chord_metadata_service/chord/migrations/0004_auto_20200123_2126.py

This file was deleted.

18 changes: 0 additions & 18 deletions chord_metadata_service/chord/migrations/0005_auto_20200123_2144.py

This file was deleted.

This file was deleted.

0 comments on commit 7706526

Please sign in to comment.