Scaffold SQLAlchemy models, routers, and Alembic migrations
- app/models/: Printer, Filament, PrintJob, Todo, PricingConfig with full SQLAlchemy 2.x mapped columns and relationships - app/routers/: list + get-by-id endpoints for all five resources - app/db.py: SQLAlchemy engine + SessionLocal + get_db dependency - alembic/: env.py reads MYSQL_* env vars; 0001_initial_schema mirrors db.sql - alembic.ini: script_location configured, URL injected at runtime Since db.sql already created the tables, stamp the DB before running future migrations: alembic stamp head Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
20
app/models/pricing.py
Normal file
20
app/models/pricing.py
Normal file
@@ -0,0 +1,20 @@
|
||||
from datetime import date, datetime
|
||||
from decimal import Decimal
|
||||
|
||||
from sqlalchemy import Date, DateTime, Numeric, String, func
|
||||
from sqlalchemy.orm import Mapped, mapped_column
|
||||
|
||||
from app.models.base import Base
|
||||
|
||||
|
||||
class PricingConfig(Base):
|
||||
__tablename__ = "pricing_config"
|
||||
|
||||
id: Mapped[int] = mapped_column(primary_key=True)
|
||||
name: Mapped[str] = mapped_column(String(100), default="default")
|
||||
electricity_kwh_eur: Mapped[Decimal] = mapped_column(Numeric(6, 4), default=Decimal("0.30"))
|
||||
printer_watt: Mapped[Decimal] = mapped_column(Numeric(8, 2), default=Decimal("200.00"))
|
||||
hourly_rate_eur: Mapped[Decimal] = mapped_column(Numeric(8, 2), default=Decimal("0.00"))
|
||||
markup_percent: Mapped[Decimal] = mapped_column(Numeric(5, 2), default=Decimal("20.00"))
|
||||
valid_from: Mapped[date] = mapped_column(Date, server_default=func.current_date())
|
||||
created_at: Mapped[datetime] = mapped_column(DateTime, server_default=func.now())
|
||||
Reference in New Issue
Block a user