Files
Bambu-Run/bambu_run/migrations/0003_cloud_task.py

178 lines
6.3 KiB
Python

# Generated by Django 6.0.2 on 2026-03-29 11:38
import django.db.models.deletion
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
("bambu_run", "0002_filament_is_transparent"),
]
operations = [
migrations.AddField(
model_name="printjob",
name="cloud_task_id_raw",
field=models.BigIntegerField(
blank=True,
db_index=True,
help_text="MQTT task_id — captured at job start, used to link cloud task",
null=True,
),
),
migrations.CreateModel(
name="BambuCloudTask",
fields=[
(
"id",
models.BigAutoField(
auto_created=True,
primary_key=True,
serialize=False,
verbose_name="ID",
),
),
(
"task_id",
models.BigIntegerField(
db_index=True,
help_text="Bambu Cloud task ID (matches MQTT task_id)",
unique=True,
),
),
(
"design_id",
models.IntegerField(
blank=True, help_text="Makerworld design ID", null=True
),
),
(
"design_title",
models.CharField(
blank=True,
help_text="Human project name from Makerworld (designTitle)",
max_length=500,
),
),
(
"plate_title",
models.CharField(
blank=True,
help_text="Plate/variant name (matches MQTT subtask_name)",
max_length=500,
),
),
("model_id", models.CharField(blank=True, max_length=100)),
(
"profile_id",
models.BigIntegerField(
blank=True, help_text="Bambu Cloud profile ID", null=True
),
),
("plate_index", models.SmallIntegerField(blank=True, null=True)),
(
"device_serial",
models.CharField(
blank=True,
help_text="Printer serial number from cloud",
max_length=100,
),
),
(
"cover_url",
models.URLField(
blank=True,
help_text="Plate preview image URL from S3",
max_length=1000,
),
),
(
"weight_grams",
models.DecimalField(
blank=True,
decimal_places=2,
help_text="Actual filament weight reported by cloud",
max_digits=8,
null=True,
),
),
(
"length_mm",
models.IntegerField(
blank=True, help_text="Filament length in mm", null=True
),
),
(
"cost_time_seconds",
models.IntegerField(
blank=True,
help_text="Cloud-measured print duration in seconds",
null=True,
),
),
(
"cloud_status",
models.SmallIntegerField(
blank=True, help_text="2=finish, 3=failed", null=True
),
),
("bed_type", models.CharField(blank=True, max_length=50)),
("use_ams", models.BooleanField(default=True)),
(
"print_mode",
models.CharField(
blank=True, help_text="cloud_file, local, etc.", max_length=50
),
),
(
"ams_detail_mapping",
models.JSONField(
default=list,
help_text="Per-slot filament weight breakdown from cloud",
),
),
("cloud_start_time", models.DateTimeField(blank=True, null=True)),
("cloud_end_time", models.DateTimeField(blank=True, null=True)),
(
"raw_data",
models.JSONField(
default=dict,
help_text="Full task response — preserved for future use",
),
),
("synced_at", models.DateTimeField(auto_now=True)),
],
options={
"verbose_name": "Bambu Cloud Task",
"verbose_name_plural": "Bambu Cloud Tasks",
"db_table": "infrastructure_cloud_task",
"ordering": ["-cloud_start_time"],
"indexes": [
models.Index(
fields=["task_id"], name="infrastruct_task_id_95b5ab_idx"
),
models.Index(
fields=["design_id"], name="infrastruct_design__88bdc0_idx"
),
models.Index(
fields=["-cloud_start_time"],
name="infrastruct_cloud_s_4078b0_idx",
),
],
},
),
migrations.AddField(
model_name="printjob",
name="cloud_task",
field=models.ForeignKey(
blank=True,
help_text="Linked Bambu Cloud task record (set by bambu_sync_cloud or collector)",
null=True,
on_delete=django.db.models.deletion.SET_NULL,
related_name="print_jobs",
to="bambu_run.bambucloudtask",
),
),
]