Refactor models and services in A76 module

- Updated GBultoService to use models.Package instead of models.GBulto.
- Refactored Part model to use SQLAlchemy 2.0 style with Mapped and mapped_column.
- Added timestamps (created_at, updated_at, deleted_at) to various pedimento models.
- Improved relationships and foreign key constraints in pedimento models.
- Updated PermissionRuleOct and Seal models to use Mapped and mapped_column.
- Changed DTO configuration from orm_mode to from_attributes for better compatibility.
- Removed obsolete models (models.py and models_ped.py) from the repository.
This commit is contained in:
2025-11-07 12:17:26 -06:00
parent 2987a6c541
commit ef3924a41d
41 changed files with 565 additions and 331 deletions

View File

@@ -1,11 +1,19 @@
from sqlalchemy import Column, String, Integer, ForeignKey
from sqlalchemy import Integer, String, ForeignKey, PrimaryKeyConstraint, ForeignKeyConstraint, UniqueConstraint
from sqlalchemy.orm import Mapped, mapped_column
from core.database import Base
class FractionRuleOctave(Base):
__tablename__ = "fraction_rule_octave"
__table_args__ = {"schema": "a76"}
permission = Column(String(20), primary_key=True, nullable=False)
line = Column(Integer, nullable=False)
fraction = Column(String(10), nullable=False)
tenant_id = Column(String, ForeignKey("a76.tenants.id"), nullable=False)
__table_args__ = (
PrimaryKeyConstraint('id', name='fraction_rule_octave_pkey'),
UniqueConstraint('permission', 'line', 'fraction', name='uq_fraction_rule_octave_permission_line_fraction'),
ForeignKeyConstraint(['tenant_id'], ['a76.tenants.id'], name='fk_fraction_rule_octave_tenant'),
{"schema": "a76"}
)
id: Mapped[int] = mapped_column(Integer, primary_key=True)
permission: Mapped[str] = mapped_column(String(20))
line: Mapped[int] = mapped_column(Integer)
fraction: Mapped[str] = mapped_column(String(10))
tenant_id: Mapped[int] = mapped_column(Integer, nullable=False, index=True)