feat(database): add deleted_at column to units of measure tables and update DTO field lengths
This commit is contained in:
@@ -178,6 +178,7 @@ def upgrade() -> None:
|
||||
sa.Column('description', sa.String(length=49), nullable=True),
|
||||
sa.Column('created_at', sa.DateTime(), server_default=sa.text('now()'), nullable=False),
|
||||
sa.Column('updated_at', sa.DateTime(), server_default=sa.text('now()'), nullable=False),
|
||||
sa.Column('deleted_at', sa.DateTime(), nullable=True),
|
||||
sa.PrimaryKeyConstraint('id'),
|
||||
sa.UniqueConstraint('code', name='uq_uom_ace_code'),
|
||||
schema='a76'
|
||||
@@ -191,6 +192,7 @@ def upgrade() -> None:
|
||||
sa.Column('description', sa.String(length=200), nullable=True),
|
||||
sa.Column('created_at', sa.DateTime(), server_default=sa.text('now()'), nullable=False),
|
||||
sa.Column('updated_at', sa.DateTime(), server_default=sa.text('now()'), nullable=False),
|
||||
sa.Column('deleted_at', sa.DateTime(), nullable=True),
|
||||
sa.PrimaryKeyConstraint('id'),
|
||||
sa.UniqueConstraint('code', name='uq_uom_oma_code'),
|
||||
schema='a76'
|
||||
@@ -204,6 +206,7 @@ def upgrade() -> None:
|
||||
sa.Column('description', sa.String(length=40), nullable=True),
|
||||
sa.Column('created_at', sa.DateTime(), server_default=sa.text('now()'), nullable=False),
|
||||
sa.Column('updated_at', sa.DateTime(), server_default=sa.text('now()'), nullable=False),
|
||||
sa.Column('deleted_at', sa.DateTime(), nullable=True),
|
||||
sa.PrimaryKeyConstraint('id'),
|
||||
sa.UniqueConstraint('code', name='uq_uom_american_code'),
|
||||
schema='a76'
|
||||
@@ -218,6 +221,7 @@ def upgrade() -> None:
|
||||
sa.Column('scaii_unit_code', sa.String(length=5), nullable=True),
|
||||
sa.Column('created_at', sa.DateTime(), server_default=sa.text('now()'), nullable=False),
|
||||
sa.Column('updated_at', sa.DateTime(), server_default=sa.text('now()'), nullable=False),
|
||||
sa.Column('deleted_at', sa.DateTime(), nullable=True),
|
||||
sa.PrimaryKeyConstraint('id'),
|
||||
sa.UniqueConstraint('code', name='uq_uom_customs_code'),
|
||||
schema='a76'
|
||||
@@ -238,6 +242,7 @@ def upgrade() -> None:
|
||||
sa.Column('company_id', sa.Integer(), nullable=False),
|
||||
sa.Column('created_at', sa.DateTime(), server_default=sa.text('now()'), nullable=False),
|
||||
sa.Column('updated_at', sa.DateTime(), server_default=sa.text('now()'), nullable=False),
|
||||
sa.Column('deleted_at', sa.DateTime(), nullable=True),
|
||||
sa.ForeignKeyConstraint(
|
||||
['customs_code'],
|
||||
['a76.unit_of_measure_customs.code'],
|
||||
|
||||
@@ -79,6 +79,10 @@ def upgrade() -> None:
|
||||
op.execute("ALTER TABLE a76.units_of_measure ALTER COLUMN american_code TYPE VARCHAR(20);")
|
||||
op.execute("ALTER TABLE a76.units_of_measure ALTER COLUMN ace_code TYPE VARCHAR(20);")
|
||||
op.execute("ALTER TABLE a76.units_of_measure ALTER COLUMN oma_code TYPE VARCHAR(20);")
|
||||
|
||||
# --- AGREGAR COLUMNAS deleted_at ---
|
||||
op.execute("ALTER TABLE a76.units_of_measure ADD COLUMN IF NOT EXISTS deleted_at TIMESTAMP;")
|
||||
op.execute("ALTER TABLE a76.units_of_measure_general ADD COLUMN IF NOT EXISTS deleted_at TIMESTAMP;")
|
||||
|
||||
# --- UTILIDAD DE FORMATEO ---
|
||||
def format_value(val):
|
||||
|
||||
@@ -21,29 +21,29 @@ class UnitOfMeasureAmericanBase(BaseModel):
|
||||
|
||||
|
||||
class UnitOfMeasureCustomsBase(BaseModel):
|
||||
code: str = Field(..., max_length=2, description="Customs Code")
|
||||
description: Optional[str] = Field(None, max_length=20)
|
||||
code: str = Field(..., max_length=10, description="Customs Code")
|
||||
description: Optional[str] = Field(None, max_length=50)
|
||||
scaii_unit_code: Optional[str] = Field(None, max_length=5)
|
||||
|
||||
|
||||
class UnitOfMeasureBase(BaseModel):
|
||||
code: str = Field(..., max_length=5, description="Unit Code")
|
||||
code: str = Field(..., max_length=20, description="Unit Code")
|
||||
description: Optional[str] = Field(None, max_length=100)
|
||||
description_en: Optional[str] = Field(None, max_length=100)
|
||||
customs_code: Optional[str] = Field(None, max_length=2)
|
||||
american_code: Optional[str] = Field(None, max_length=3)
|
||||
ace_code: Optional[str] = Field(None, max_length=4)
|
||||
oma_code: Optional[str] = Field(None, max_length=10)
|
||||
customs_code: Optional[str] = Field(None, max_length=20)
|
||||
american_code: Optional[str] = Field(None, max_length=20)
|
||||
ace_code: Optional[str] = Field(None, max_length=20)
|
||||
oma_code: Optional[str] = Field(None, max_length=20)
|
||||
|
||||
|
||||
class UnitOfMeasureGeneralBase(BaseModel):
|
||||
code: str = Field(..., max_length=5, description="Unit Code")
|
||||
code: str = Field(..., max_length=20, description="Unit Code")
|
||||
description: Optional[str] = Field(None, max_length=100)
|
||||
conversion_factor: Optional[Decimal] = None
|
||||
mexico_unit: Optional[str] = Field(None, max_length=5)
|
||||
american_unit_code: Optional[str] = Field(None, max_length=5)
|
||||
customs_code: Optional[str] = Field(None, max_length=2)
|
||||
ace_code: Optional[str] = Field(None, max_length=4)
|
||||
mexico_unit: Optional[str] = Field(None, max_length=20)
|
||||
american_unit_code: Optional[str] = Field(None, max_length=20)
|
||||
customs_code: Optional[str] = Field(None, max_length=20)
|
||||
ace_code: Optional[str] = Field(None, max_length=20)
|
||||
|
||||
# --- Create DTOs ---
|
||||
|
||||
@@ -90,29 +90,29 @@ class UnitOfMeasureAmericanUpdate(BaseModel):
|
||||
|
||||
|
||||
class UnitOfMeasureCustomsUpdate(BaseModel):
|
||||
code: Optional[str] = Field(None, max_length=2)
|
||||
description: Optional[str] = Field(None, max_length=20)
|
||||
code: Optional[str] = Field(None, max_length=10)
|
||||
description: Optional[str] = Field(None, max_length=50)
|
||||
scaii_unit_code: Optional[str] = Field(None, max_length=5)
|
||||
|
||||
|
||||
class UnitOfMeasureUpdate(BaseModel):
|
||||
code: Optional[str] = Field(None, max_length=5)
|
||||
code: Optional[str] = Field(None, max_length=20)
|
||||
description: Optional[str] = Field(None, max_length=100)
|
||||
description_en: Optional[str] = Field(None, max_length=100)
|
||||
customs_code: Optional[str] = Field(None, max_length=2)
|
||||
american_code: Optional[str] = Field(None, max_length=3)
|
||||
ace_code: Optional[str] = Field(None, max_length=4)
|
||||
oma_code: Optional[str] = Field(None, max_length=10)
|
||||
customs_code: Optional[str] = Field(None, max_length=20)
|
||||
american_code: Optional[str] = Field(None, max_length=20)
|
||||
ace_code: Optional[str] = Field(None, max_length=20)
|
||||
oma_code: Optional[str] = Field(None, max_length=20)
|
||||
|
||||
|
||||
class UnitOfMeasureGeneralUpdate(BaseModel):
|
||||
code: Optional[str] = Field(None, max_length=5)
|
||||
code: Optional[str] = Field(None, max_length=20)
|
||||
description: Optional[str] = Field(None, max_length=100)
|
||||
conversion_factor: Optional[Decimal] = None
|
||||
mexico_unit: Optional[str] = Field(None, max_length=5)
|
||||
american_unit_code: Optional[str] = Field(None, max_length=5)
|
||||
customs_code: Optional[str] = Field(None, max_length=2)
|
||||
ace_code: Optional[str] = Field(None, max_length=4)
|
||||
mexico_unit: Optional[str] = Field(None, max_length=20)
|
||||
american_unit_code: Optional[str] = Field(None, max_length=20)
|
||||
customs_code: Optional[str] = Field(None, max_length=20)
|
||||
ace_code: Optional[str] = Field(None, max_length=20)
|
||||
|
||||
# --- Response DTOs ---
|
||||
|
||||
|
||||
Reference in New Issue
Block a user