Skip to content

Commit

Permalink
feat: Remove collection_file_item
Browse files Browse the repository at this point in the history
  • Loading branch information
jpmckinney committed Nov 2, 2024
1 parent 225a272 commit 886159f
Show file tree
Hide file tree
Showing 3 changed files with 69 additions and 4,534 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
# Generated by Django 4.2.16 on 2024-11-02 05:03

import django.db.models.deletion
from django.db import migrations, models


class Migration(migrations.Migration):
dependencies = [
("process", "0043_compiledrelease_collection_file_and_more"),
]

operations = [
migrations.RemoveField(
model_name="collectionfileitem",
name="collection_file",
),
migrations.RemoveIndex(
model_name="compiledrelease",
name="compiled_release_collection_file_item_id_idx",
),
migrations.RemoveIndex(
model_name="record",
name="record_collection_file_item_id_idx",
),
migrations.RemoveIndex(
model_name="release",
name="release_collection_file_item_id_idx",
),
migrations.RemoveField(
model_name="compiledrelease",
name="collection_file_item",
),
migrations.RemoveField(
model_name="record",
name="collection_file_item",
),
migrations.RemoveField(
model_name="release",
name="collection_file_item",
),
migrations.AlterField(
model_name="compiledrelease",
name="collection_file",
field=models.ForeignKey(
db_index=False, on_delete=django.db.models.deletion.CASCADE, to="process.collectionfile"
),
),
migrations.AlterField(
model_name="record",
name="collection_file",
field=models.ForeignKey(
db_index=False, on_delete=django.db.models.deletion.CASCADE, to="process.collectionfile"
),
),
migrations.AlterField(
model_name="release",
name="collection_file",
field=models.ForeignKey(
db_index=False, on_delete=django.db.models.deletion.CASCADE, to="process.collectionfile"
),
),
migrations.DeleteModel(
name="CollectionFileItem",
),
]
37 changes: 3 additions & 34 deletions process/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -251,31 +251,6 @@ def __str__(self):
)


class CollectionFileItem(models.Model):
"""An item within a file in the collection."""

collection_file = models.ForeignKey(CollectionFile, on_delete=models.CASCADE, db_index=False)

number = models.IntegerField(blank=True)

class Meta:
db_table = "collection_file_item"
indexes = [
# ForeignKey with db_index=False.
models.Index(name="collection_file_item_collection_file_id_idx", fields=["collection_file"]),
]
constraints = [
models.UniqueConstraint(
name="unique_collection_file_item_identifiers", fields=["collection_file", "number"]
),
]

def __str__(self):
return "{collection_file_id}:{number} (id: {id})".format_map(
Default(number=self.number, collection_file_id=self.collection_file_id, id=self.pk)
)


class Data(models.Model):
"""The contents of a release, record or compiled release."""

Expand Down Expand Up @@ -314,8 +289,7 @@ class Release(models.Model):
"""A release."""

collection = models.ForeignKey(Collection, on_delete=models.CASCADE, db_index=False)
collection_file = models.ForeignKey(CollectionFile, on_delete=models.CASCADE, db_index=False, null=True)
collection_file_item = models.ForeignKey(CollectionFileItem, on_delete=models.CASCADE, db_index=False, null=True)
collection_file = models.ForeignKey(CollectionFile, on_delete=models.CASCADE, db_index=False)

ocid = models.TextField(blank=True)
release_id = models.TextField(blank=True)
Expand All @@ -332,7 +306,6 @@ class Meta:
# ForeignKey with db_index=False.
models.Index(name="release_collection_id_idx", fields=["collection"]),
models.Index(name="release_collection_file_id_idx", fields=["collection_file"]),
models.Index(name="release_collection_file_item_id_idx", fields=["collection_file_item"]),
models.Index(name="release_data_id_idx", fields=["data"]),
models.Index(name="release_package_data_id_idx", fields=["package_data"]),
]
Expand All @@ -349,8 +322,7 @@ class Record(models.Model):
"""A record."""

collection = models.ForeignKey(Collection, on_delete=models.CASCADE, db_index=False)
collection_file = models.ForeignKey(CollectionFile, on_delete=models.CASCADE, db_index=False, null=True)
collection_file_item = models.ForeignKey(CollectionFileItem, on_delete=models.CASCADE, db_index=False, null=True)
collection_file = models.ForeignKey(CollectionFile, on_delete=models.CASCADE, db_index=False)

ocid = models.TextField(blank=True)

Expand All @@ -365,7 +337,6 @@ class Meta:
# ForeignKey with db_index=False.
models.Index(name="record_collection_id_idx", fields=["collection"]),
models.Index(name="record_collection_file_id_idx", fields=["collection_file"]),
models.Index(name="record_collection_file_item_id_idx", fields=["collection_file_item"]),
models.Index(name="record_data_id_idx", fields=["data"]),
models.Index(name="record_package_data_id_idx", fields=["package_data"]),
]
Expand All @@ -380,8 +351,7 @@ class CompiledRelease(models.Model):
"""A compiled release."""

collection = models.ForeignKey(Collection, on_delete=models.CASCADE, db_index=False)
collection_file = models.ForeignKey(CollectionFile, on_delete=models.CASCADE, db_index=False, null=True)
collection_file_item = models.ForeignKey(CollectionFileItem, on_delete=models.CASCADE, db_index=False, null=True)
collection_file = models.ForeignKey(CollectionFile, on_delete=models.CASCADE, db_index=False)

ocid = models.TextField(blank=True)
release_date = models.TextField(blank=True)
Expand All @@ -396,7 +366,6 @@ class Meta:
# ForeignKey with db_index=False.
models.Index(name="compiled_release_collection_id_idx", fields=["collection"]),
models.Index(name="compiled_release_collection_file_id_idx", fields=["collection_file"]),
models.Index(name="compiled_release_collection_file_item_id_idx", fields=["collection_file_item"]),
models.Index(name="compiled_release_data_id_idx", fields=["data"]),
]

Expand Down
Loading

0 comments on commit 886159f

Please sign in to comment.