0001_squashed_0007_remove_file_blobs_file_blob.py 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119
  1. # Generated by Django 4.1.3 on 2022-12-10 15:29
  2. from django.db import migrations, models
  3. import django.db.models.deletion
  4. # Functions from the following migrations need manual copying.
  5. # Move them and any dependencies into this file, then update the
  6. # RunPython operations to refer to the local versions:
  7. # files.migrations.0007_remove_file_blobs_file_blob
  8. class Migration(migrations.Migration):
  9. replaces = [
  10. ("files", "0001_initial"),
  11. ("files", "0002_fileblob_organizations"),
  12. ("files", "0003_auto_20210507_1549"),
  13. ("files", "0004_auto_20210509_1658"),
  14. ("files", "0005_file_type_fileblobindex"),
  15. ("files", "0006_alter_file_headers"),
  16. ("files", "0007_remove_file_blobs_file_blob"),
  17. ]
  18. initial = True
  19. dependencies = [
  20. ("organizations_ext", "0001_squashed_0009_organization_scrub_ip_addresses"),
  21. ]
  22. operations = [
  23. migrations.CreateModel(
  24. name="FileBlob",
  25. fields=[
  26. (
  27. "id",
  28. models.BigAutoField(
  29. auto_created=True,
  30. primary_key=True,
  31. serialize=False,
  32. verbose_name="ID",
  33. ),
  34. ),
  35. ("created", models.DateTimeField(auto_now_add=True, db_index=True)),
  36. ("checksum", models.CharField(max_length=40, unique=True)),
  37. ("size", models.PositiveIntegerField(null=True)),
  38. ("blob", models.FileField(default="", upload_to="uploads/file_blobs")),
  39. ],
  40. options={
  41. "abstract": False,
  42. },
  43. ),
  44. migrations.CreateModel(
  45. name="File",
  46. fields=[
  47. (
  48. "id",
  49. models.BigAutoField(
  50. auto_created=True,
  51. primary_key=True,
  52. serialize=False,
  53. verbose_name="ID",
  54. ),
  55. ),
  56. ("created", models.DateTimeField(auto_now_add=True, db_index=True)),
  57. ("name", models.TextField()),
  58. ("headers", models.JSONField(blank=True, null=True)),
  59. ("size", models.PositiveIntegerField(null=True)),
  60. ("checksum", models.CharField(db_index=True, max_length=40, null=True)),
  61. ("blobs", models.ManyToManyField(to="files.fileblob")),
  62. ("type", models.CharField(default="", max_length=64)),
  63. (
  64. "blob",
  65. models.ForeignKey(
  66. null=True,
  67. on_delete=django.db.models.deletion.CASCADE,
  68. to="files.fileblob",
  69. ),
  70. ),
  71. ],
  72. options={
  73. "abstract": False,
  74. },
  75. ),
  76. migrations.CreateModel(
  77. name="FileBlobIndex",
  78. fields=[
  79. (
  80. "id",
  81. models.BigAutoField(
  82. auto_created=True,
  83. primary_key=True,
  84. serialize=False,
  85. verbose_name="ID",
  86. ),
  87. ),
  88. ("offset", models.PositiveIntegerField()),
  89. (
  90. "blob",
  91. models.ForeignKey(
  92. on_delete=django.db.models.deletion.CASCADE, to="files.fileblob"
  93. ),
  94. ),
  95. (
  96. "file",
  97. models.ForeignKey(
  98. on_delete=django.db.models.deletion.CASCADE, to="files.file"
  99. ),
  100. ),
  101. ],
  102. options={
  103. "unique_together": {("file", "blob", "offset")},
  104. },
  105. ),
  106. migrations.RemoveField(
  107. model_name="file",
  108. name="blobs",
  109. ),
  110. ]