Files
plantillas-proyectos/backend/api/v1/modules/a76/country_rule_oct/models.py
acazares ef3924a41d 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.
2025-11-07 12:17:26 -06:00

26 lines
1.2 KiB
Python

from sqlalchemy import Integer, String, ForeignKey, PrimaryKeyConstraint, ForeignKeyConstraint, UniqueConstraint
from sqlalchemy.orm import Mapped, mapped_column
from core.database import Base
class CountryRuleOct(Base):
__tablename__ = "country_rule_oct"
__table_args__ = (
PrimaryKeyConstraint('id', name='country_rule_oct_pkey'),
UniqueConstraint('permission', 'line', 'fraction', 'country_code', name='uq_country_rule_oct_permission_line_fraction_country'),
ForeignKeyConstraint(
['permission', 'line', 'fraction'],
['a76.fraction_rule_octave.permission', 'a76.fraction_rule_octave.line', 'a76.fraction_rule_octave.fraction'],
ondelete="CASCADE",
name='fk_country_rule_oct_frac_octava'
),
ForeignKeyConstraint(['tenant_id'], ['a76.tenants.id'], name='fk_country_rule_oct_tenant'),
{"schema": "a76"}
)
id: Mapped[int] = mapped_column(Integer, primary_key=True)
permission: Mapped[str] = mapped_column(String(20))
line: Mapped[int] = mapped_column()
fraction: Mapped[str] = mapped_column(String(10))
country_code: Mapped[str] = mapped_column(String(3))
tenant_id: Mapped[int] = mapped_column(Integer, nullable=False, index=True)