Some checks failed
CI / style (push) Has been cancelled
CI / build-client (push) Has been cancelled
CI / build-amd64 (push) Has been cancelled
CI / build-tester (push) Has been cancelled
CI / test (cockroachdb) (push) Has been cancelled
CI / test (mariadb) (push) Has been cancelled
CI / test (postgres) (push) Has been cancelled
CI / test (sqlite) (push) Has been cancelled
CI / build-arm64 (push) Has been cancelled
CI / build-armv7 (push) Has been cancelled
CI / publish-images (push) Has been cancelled
CI / publish-release (push) Has been cancelled
Store extruder and bed temperatures as min/max ranges instead of single values for more accurate filament specifications. Backend changes: - Add 4 new columns: settings_extruder_temp_min/max, settings_bed_temp_min/max - Keep old columns for backward compatibility (marked deprecated) - Alembic migration copies existing values to both min and max - Update Pydantic models and API endpoints Frontend changes: - Filament model updated with new fields - Create form uses min/max input pairs with Space.Compact - Import from external DB populates both min and max with same value - Label template updated to show ranges: "ET: 190-220 °C" - Template help includes new tags Labels now display temperature ranges like "190-220°C" which is more useful for printing than a single recommended value. Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
57 lines
1.9 KiB
Python
57 lines
1.9 KiB
Python
"""add_temperature_ranges.
|
|
|
|
Revision ID: a1b2c3d4e5f6
|
|
Revises: 415a8f855e14
|
|
Create Date: 2025-01-15 02:00:00.000000
|
|
"""
|
|
|
|
import sqlalchemy as sa
|
|
from alembic import op
|
|
|
|
# revision identifiers, used by Alembic.
|
|
revision = "a1b2c3d4e5f6"
|
|
down_revision = "415a8f855e14"
|
|
branch_labels = None
|
|
depends_on = None
|
|
|
|
|
|
def upgrade() -> None:
|
|
"""Add temperature range columns and migrate existing data."""
|
|
# Add new columns for temperature ranges
|
|
op.add_column("filament", sa.Column("settings_extruder_temp_min", sa.Integer(), nullable=True))
|
|
op.add_column("filament", sa.Column("settings_extruder_temp_max", sa.Integer(), nullable=True))
|
|
op.add_column("filament", sa.Column("settings_bed_temp_min", sa.Integer(), nullable=True))
|
|
op.add_column("filament", sa.Column("settings_bed_temp_max", sa.Integer(), nullable=True))
|
|
|
|
# Migrate existing single temp values to both min and max
|
|
# This preserves the existing data while enabling the new range functionality
|
|
connection = op.get_bind()
|
|
connection.execute(
|
|
sa.text(
|
|
"""
|
|
UPDATE filament
|
|
SET settings_extruder_temp_min = settings_extruder_temp,
|
|
settings_extruder_temp_max = settings_extruder_temp
|
|
WHERE settings_extruder_temp IS NOT NULL
|
|
"""
|
|
)
|
|
)
|
|
connection.execute(
|
|
sa.text(
|
|
"""
|
|
UPDATE filament
|
|
SET settings_bed_temp_min = settings_bed_temp,
|
|
settings_bed_temp_max = settings_bed_temp
|
|
WHERE settings_bed_temp IS NOT NULL
|
|
"""
|
|
)
|
|
)
|
|
|
|
|
|
def downgrade() -> None:
|
|
"""Remove temperature range columns."""
|
|
op.drop_column("filament", "settings_bed_temp_max")
|
|
op.drop_column("filament", "settings_bed_temp_min")
|
|
op.drop_column("filament", "settings_extruder_temp_max")
|
|
op.drop_column("filament", "settings_extruder_temp_min")
|