fix: update VARCHAR lengths to prevent truncation errors in audit_log and discharges
This commit is contained in:
@@ -0,0 +1,104 @@
|
|||||||
|
"""Fix VARCHAR(20) truncation errors in audit_log and discharges
|
||||||
|
|
||||||
|
Revision ID: i7j8k9l0m1n2
|
||||||
|
Revises: h1a2b3c4d5e6
|
||||||
|
Create Date: 2026-04-30 13:00:00.000000
|
||||||
|
|
||||||
|
Issues fixed:
|
||||||
|
- audit_log.system: String(20) → String(50)
|
||||||
|
- audit_log.operation_type: String(20) → String(50)
|
||||||
|
- discharges.cancelled_by: String(20) → String(100)
|
||||||
|
- octave_balance.octave_permit: String(20) → String(100)
|
||||||
|
"""
|
||||||
|
from alembic import op
|
||||||
|
import sqlalchemy as sa
|
||||||
|
|
||||||
|
# revision identifiers, used by Alembic.
|
||||||
|
revision = 'i7j8k9l0m1n2'
|
||||||
|
down_revision = 'h1a2b3c4d5e6'
|
||||||
|
branch_labels = None
|
||||||
|
depends_on = None
|
||||||
|
|
||||||
|
|
||||||
|
def upgrade() -> None:
|
||||||
|
# Fix audit_log.system
|
||||||
|
op.alter_column(
|
||||||
|
'audit_logs',
|
||||||
|
'system',
|
||||||
|
existing_type=sa.String(length=20),
|
||||||
|
type_=sa.String(length=50),
|
||||||
|
existing_nullable=False,
|
||||||
|
schema='a76',
|
||||||
|
)
|
||||||
|
|
||||||
|
# Fix audit_log.operation_type
|
||||||
|
op.alter_column(
|
||||||
|
'audit_logs',
|
||||||
|
'operation_type',
|
||||||
|
existing_type=sa.String(length=20),
|
||||||
|
type_=sa.String(length=50),
|
||||||
|
existing_nullable=True,
|
||||||
|
schema='a76',
|
||||||
|
)
|
||||||
|
|
||||||
|
# Fix discharges.cancelled_by
|
||||||
|
op.alter_column(
|
||||||
|
'discharge_header',
|
||||||
|
'cancelled_by',
|
||||||
|
existing_type=sa.String(length=20),
|
||||||
|
type_=sa.String(length=100),
|
||||||
|
existing_nullable=True,
|
||||||
|
schema='a24',
|
||||||
|
)
|
||||||
|
|
||||||
|
# Fix octave_balance.octave_permit
|
||||||
|
op.alter_column(
|
||||||
|
'octave_balance',
|
||||||
|
'octave_permit',
|
||||||
|
existing_type=sa.String(length=20),
|
||||||
|
type_=sa.String(length=100),
|
||||||
|
existing_nullable=False,
|
||||||
|
schema='a76',
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
|
def downgrade() -> None:
|
||||||
|
# Revert octave_balance.octave_permit
|
||||||
|
op.alter_column(
|
||||||
|
'octave_balance',
|
||||||
|
'octave_permit',
|
||||||
|
existing_type=sa.String(length=100),
|
||||||
|
type_=sa.String(length=20),
|
||||||
|
existing_nullable=False,
|
||||||
|
schema='a76',
|
||||||
|
)
|
||||||
|
|
||||||
|
# Revert discharges.cancelled_by
|
||||||
|
op.alter_column(
|
||||||
|
'discharge_header',
|
||||||
|
'cancelled_by',
|
||||||
|
existing_type=sa.String(length=100),
|
||||||
|
type_=sa.String(length=20),
|
||||||
|
existing_nullable=True,
|
||||||
|
schema='a24',
|
||||||
|
)
|
||||||
|
|
||||||
|
# Revert audit_log.operation_type
|
||||||
|
op.alter_column(
|
||||||
|
'audit_logs',
|
||||||
|
'operation_type',
|
||||||
|
existing_type=sa.String(length=50),
|
||||||
|
type_=sa.String(length=20),
|
||||||
|
existing_nullable=True,
|
||||||
|
schema='a76',
|
||||||
|
)
|
||||||
|
|
||||||
|
# Revert audit_log.system
|
||||||
|
op.alter_column(
|
||||||
|
'audit_logs',
|
||||||
|
'system',
|
||||||
|
existing_type=sa.String(length=50),
|
||||||
|
type_=sa.String(length=20),
|
||||||
|
existing_nullable=False,
|
||||||
|
schema='a76',
|
||||||
|
)
|
||||||
@@ -132,7 +132,7 @@ class DischargeHeader(Base, TenantScopedMixin, TimestampMixin):
|
|||||||
)
|
)
|
||||||
|
|
||||||
# ── Cancellation trail ────────────────────────────────────────────────
|
# ── Cancellation trail ────────────────────────────────────────────────
|
||||||
cancelled_by: Mapped[Optional[str]] = mapped_column(String(20))
|
cancelled_by: Mapped[Optional[str]] = mapped_column(String(100))
|
||||||
cancellation_reason: Mapped[Optional[str]] = mapped_column(String(300))
|
cancellation_reason: Mapped[Optional[str]] = mapped_column(String(300))
|
||||||
|
|
||||||
# ── Relationships ─────────────────────────────────────────────────────
|
# ── Relationships ─────────────────────────────────────────────────────
|
||||||
|
|||||||
@@ -30,12 +30,12 @@ class AuditLog(Base, TenantScopedMixin, TimestampMixin):
|
|||||||
|
|
||||||
# Technical Columns
|
# Technical Columns
|
||||||
timestamp = Column(DateTime(timezone=True), nullable=False, index=True) # Combined for queries
|
timestamp = Column(DateTime(timezone=True), nullable=False, index=True) # Combined for queries
|
||||||
system = Column(String(20), nullable=False, index=True, default="fixed_asset")
|
system = Column(String(50), nullable=False, index=True, default="fixed_asset")
|
||||||
|
|
||||||
# Traceability
|
# Traceability
|
||||||
table_name = Column(String(100), nullable=True, index=True)
|
table_name = Column(String(100), nullable=True, index=True)
|
||||||
record_id = Column(String(255), nullable=True, index=True)
|
record_id = Column(String(255), nullable=True, index=True)
|
||||||
operation_type = Column(String(20), nullable=True, index=True) # CREATE, UPDATE, DELETE, LOGIN
|
operation_type = Column(String(50), nullable=True, index=True) # CREATE, UPDATE, DELETE, LOGIN
|
||||||
|
|
||||||
# Data Changes
|
# Data Changes
|
||||||
old_values = Column(JSONB, nullable=True)
|
old_values = Column(JSONB, nullable=True)
|
||||||
|
|||||||
@@ -42,7 +42,7 @@ class OctaveBalance(Base, TenantScopedMixin, TimestampMixin):
|
|||||||
origin_country: Mapped[str] = mapped_column(String(3)) # PAISORIGEN
|
origin_country: Mapped[str] = mapped_column(String(3)) # PAISORIGEN
|
||||||
fraction_type: Mapped[str] = mapped_column(String(7)) # TIPOFRACIMPO
|
fraction_type: Mapped[str] = mapped_column(String(7)) # TIPOFRACIMPO
|
||||||
sector: Mapped[str] = mapped_column(String(8)) # SECTOR
|
sector: Mapped[str] = mapped_column(String(8)) # SECTOR
|
||||||
octave_permit: Mapped[str] = mapped_column(String(20)) # PERMISOROCTAVA
|
octave_permit: Mapped[str] = mapped_column(String(100)) # PERMISOROCTAVA
|
||||||
origin: Mapped[str] = mapped_column(String(3)) # PROCEDENCIA ('TEM')
|
origin: Mapped[str] = mapped_column(String(3)) # PROCEDENCIA ('TEM')
|
||||||
system: Mapped[str] = mapped_column(String(5)) # SISTEMA ('fixed_asset | inventory')
|
system: Mapped[str] = mapped_column(String(5)) # SISTEMA ('fixed_asset | inventory')
|
||||||
line: Mapped[int] = mapped_column(Integer) # LINEA
|
line: Mapped[int] = mapped_column(Integer) # LINEA
|
||||||
|
|||||||
@@ -310,5 +310,5 @@ networks:
|
|||||||
driver: bridge
|
driver: bridge
|
||||||
|
|
||||||
hub-net:
|
hub-net:
|
||||||
external: false
|
external: true
|
||||||
name: aduanasoft-hub_default
|
name: aduanasoft-hub_default
|
||||||
|
|||||||
Reference in New Issue
Block a user