61 lines
2.2 KiB
Python
61 lines
2.2 KiB
Python
import django.db.models.deletion
|
|
from django.db import migrations, models
|
|
|
|
|
|
class Migration(migrations.Migration):
|
|
|
|
dependencies = [
|
|
("farms", "0008_cycle_feed_initial_balance"),
|
|
("operations", "0008_manualinput_feed_out_manual"),
|
|
]
|
|
|
|
operations = [
|
|
migrations.CreateModel(
|
|
name="ReportSnapshot",
|
|
fields=[
|
|
(
|
|
"id",
|
|
models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name="ID"),
|
|
),
|
|
(
|
|
"report_type",
|
|
models.CharField(
|
|
choices=[("daily", "Daily"), ("end_cycle", "End Cycle")], max_length=20
|
|
),
|
|
),
|
|
("up_to_day", models.IntegerField(default=0)),
|
|
("payload", models.JSONField(default=dict)),
|
|
("generated_at", models.DateTimeField()),
|
|
("created_at", models.DateTimeField(auto_now_add=True)),
|
|
("updated_at", models.DateTimeField(auto_now=True)),
|
|
(
|
|
"cycle",
|
|
models.ForeignKey(
|
|
on_delete=django.db.models.deletion.CASCADE,
|
|
related_name="report_snapshots",
|
|
to="farms.cycle",
|
|
),
|
|
),
|
|
(
|
|
"kandang",
|
|
models.ForeignKey(
|
|
on_delete=django.db.models.deletion.CASCADE,
|
|
related_name="report_snapshots",
|
|
to="farms.kandang",
|
|
),
|
|
),
|
|
],
|
|
options={
|
|
"verbose_name": "Report Snapshot",
|
|
"verbose_name_plural": "Report Snapshots",
|
|
"db_table": "report_snapshot",
|
|
"ordering": ["-updated_at"],
|
|
"constraints": [
|
|
models.UniqueConstraint(
|
|
fields=("cycle", "kandang", "report_type"),
|
|
name="uniq_report_snapshot_cycle_kandang_type",
|
|
)
|
|
],
|
|
},
|
|
),
|
|
] |