Skip to content

Commit 886159f

Browse files
committed
feat: Remove collection_file_item
1 parent 225a272 commit 886159f

File tree

3 files changed

+69
-4534
lines changed

3 files changed

+69
-4534
lines changed
Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
# Generated by Django 4.2.16 on 2024-11-02 05:03
2+
3+
import django.db.models.deletion
4+
from django.db import migrations, models
5+
6+
7+
class Migration(migrations.Migration):
8+
dependencies = [
9+
("process", "0043_compiledrelease_collection_file_and_more"),
10+
]
11+
12+
operations = [
13+
migrations.RemoveField(
14+
model_name="collectionfileitem",
15+
name="collection_file",
16+
),
17+
migrations.RemoveIndex(
18+
model_name="compiledrelease",
19+
name="compiled_release_collection_file_item_id_idx",
20+
),
21+
migrations.RemoveIndex(
22+
model_name="record",
23+
name="record_collection_file_item_id_idx",
24+
),
25+
migrations.RemoveIndex(
26+
model_name="release",
27+
name="release_collection_file_item_id_idx",
28+
),
29+
migrations.RemoveField(
30+
model_name="compiledrelease",
31+
name="collection_file_item",
32+
),
33+
migrations.RemoveField(
34+
model_name="record",
35+
name="collection_file_item",
36+
),
37+
migrations.RemoveField(
38+
model_name="release",
39+
name="collection_file_item",
40+
),
41+
migrations.AlterField(
42+
model_name="compiledrelease",
43+
name="collection_file",
44+
field=models.ForeignKey(
45+
db_index=False, on_delete=django.db.models.deletion.CASCADE, to="process.collectionfile"
46+
),
47+
),
48+
migrations.AlterField(
49+
model_name="record",
50+
name="collection_file",
51+
field=models.ForeignKey(
52+
db_index=False, on_delete=django.db.models.deletion.CASCADE, to="process.collectionfile"
53+
),
54+
),
55+
migrations.AlterField(
56+
model_name="release",
57+
name="collection_file",
58+
field=models.ForeignKey(
59+
db_index=False, on_delete=django.db.models.deletion.CASCADE, to="process.collectionfile"
60+
),
61+
),
62+
migrations.DeleteModel(
63+
name="CollectionFileItem",
64+
),
65+
]

process/models.py

Lines changed: 3 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -251,31 +251,6 @@ def __str__(self):
251251
)
252252

253253

254-
class CollectionFileItem(models.Model):
255-
"""An item within a file in the collection."""
256-
257-
collection_file = models.ForeignKey(CollectionFile, on_delete=models.CASCADE, db_index=False)
258-
259-
number = models.IntegerField(blank=True)
260-
261-
class Meta:
262-
db_table = "collection_file_item"
263-
indexes = [
264-
# ForeignKey with db_index=False.
265-
models.Index(name="collection_file_item_collection_file_id_idx", fields=["collection_file"]),
266-
]
267-
constraints = [
268-
models.UniqueConstraint(
269-
name="unique_collection_file_item_identifiers", fields=["collection_file", "number"]
270-
),
271-
]
272-
273-
def __str__(self):
274-
return "{collection_file_id}:{number} (id: {id})".format_map(
275-
Default(number=self.number, collection_file_id=self.collection_file_id, id=self.pk)
276-
)
277-
278-
279254
class Data(models.Model):
280255
"""The contents of a release, record or compiled release."""
281256

@@ -314,8 +289,7 @@ class Release(models.Model):
314289
"""A release."""
315290

316291
collection = models.ForeignKey(Collection, on_delete=models.CASCADE, db_index=False)
317-
collection_file = models.ForeignKey(CollectionFile, on_delete=models.CASCADE, db_index=False, null=True)
318-
collection_file_item = models.ForeignKey(CollectionFileItem, on_delete=models.CASCADE, db_index=False, null=True)
292+
collection_file = models.ForeignKey(CollectionFile, on_delete=models.CASCADE, db_index=False)
319293

320294
ocid = models.TextField(blank=True)
321295
release_id = models.TextField(blank=True)
@@ -332,7 +306,6 @@ class Meta:
332306
# ForeignKey with db_index=False.
333307
models.Index(name="release_collection_id_idx", fields=["collection"]),
334308
models.Index(name="release_collection_file_id_idx", fields=["collection_file"]),
335-
models.Index(name="release_collection_file_item_id_idx", fields=["collection_file_item"]),
336309
models.Index(name="release_data_id_idx", fields=["data"]),
337310
models.Index(name="release_package_data_id_idx", fields=["package_data"]),
338311
]
@@ -349,8 +322,7 @@ class Record(models.Model):
349322
"""A record."""
350323

351324
collection = models.ForeignKey(Collection, on_delete=models.CASCADE, db_index=False)
352-
collection_file = models.ForeignKey(CollectionFile, on_delete=models.CASCADE, db_index=False, null=True)
353-
collection_file_item = models.ForeignKey(CollectionFileItem, on_delete=models.CASCADE, db_index=False, null=True)
325+
collection_file = models.ForeignKey(CollectionFile, on_delete=models.CASCADE, db_index=False)
354326

355327
ocid = models.TextField(blank=True)
356328

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

382353
collection = models.ForeignKey(Collection, on_delete=models.CASCADE, db_index=False)
383-
collection_file = models.ForeignKey(CollectionFile, on_delete=models.CASCADE, db_index=False, null=True)
384-
collection_file_item = models.ForeignKey(CollectionFileItem, on_delete=models.CASCADE, db_index=False, null=True)
354+
collection_file = models.ForeignKey(CollectionFile, on_delete=models.CASCADE, db_index=False)
385355

386356
ocid = models.TextField(blank=True)
387357
release_date = models.TextField(blank=True)
@@ -396,7 +366,6 @@ class Meta:
396366
# ForeignKey with db_index=False.
397367
models.Index(name="compiled_release_collection_id_idx", fields=["collection"]),
398368
models.Index(name="compiled_release_collection_file_id_idx", fields=["collection_file"]),
399-
models.Index(name="compiled_release_collection_file_item_id_idx", fields=["collection_file_item"]),
400369
models.Index(name="compiled_release_data_id_idx", fields=["data"]),
401370
]
402371

0 commit comments

Comments
 (0)