Update Alembic migration scripts for configuration changes and observations in pedimentos
This commit is contained in:
@@ -1,28 +0,0 @@
|
||||
"""increase_port_description_length
|
||||
|
||||
Revision ID: 3a012dff0274
|
||||
Revises: 7937209f9718
|
||||
Create Date: 2025-12-24 10:24:49.927020
|
||||
|
||||
"""
|
||||
from typing import Sequence, Union
|
||||
|
||||
from alembic import op
|
||||
import sqlalchemy as sa
|
||||
|
||||
|
||||
# revision identifiers, used by Alembic.
|
||||
revision: str = '3a012dff0274'
|
||||
down_revision: Union[str, Sequence[str], None] = '7937209f9718'
|
||||
branch_labels: Union[str, Sequence[str], None] = None
|
||||
depends_on: Union[str, Sequence[str], None] = None
|
||||
|
||||
|
||||
def upgrade() -> None:
|
||||
"""Upgrade schema."""
|
||||
pass
|
||||
|
||||
|
||||
def downgrade() -> None:
|
||||
"""Downgrade schema."""
|
||||
pass
|
||||
@@ -1,118 +0,0 @@
|
||||
"""change_config_parameters_to_boolean
|
||||
|
||||
Revision ID: 7c4a2cee214d
|
||||
Revises: 8de9bb2a4c1b
|
||||
Create Date: 2025-12-26 23:15:47.125136
|
||||
|
||||
"""
|
||||
from typing import Sequence, Union
|
||||
|
||||
from alembic import op
|
||||
import sqlalchemy as sa
|
||||
|
||||
|
||||
# revision identifiers, used by Alembic.
|
||||
revision: str = '7c4a2cee214d'
|
||||
down_revision: Union[str, Sequence[str], None] = '8de9bb2a4c1b'
|
||||
branch_labels: Union[str, Sequence[str], None] = None
|
||||
depends_on: Union[str, Sequence[str], None] = None
|
||||
|
||||
|
||||
def upgrade() -> None:
|
||||
"""Upgrade schema."""
|
||||
# Change SmallInteger columns to Boolean with default False
|
||||
op.alter_column('pedimento_config_parameters', 'is_embassy',
|
||||
type_=sa.Boolean(),
|
||||
server_default='false',
|
||||
schema='a76')
|
||||
op.alter_column('pedimento_config_parameters', 'rule_3121_section_ii',
|
||||
type_=sa.Boolean(),
|
||||
server_default='false',
|
||||
schema='a76')
|
||||
op.alter_column('pedimento_config_parameters', 'use_previous_tariff',
|
||||
type_=sa.Boolean(),
|
||||
server_default='false',
|
||||
schema='a76')
|
||||
op.alter_column('pedimento_config_parameters', 'use_payment_date_fi',
|
||||
type_=sa.Boolean(),
|
||||
server_default='false',
|
||||
schema='a76')
|
||||
op.alter_column('pedimento_config_parameters', 'add_state_supplier_record_505',
|
||||
type_=sa.Boolean(),
|
||||
server_default='false',
|
||||
schema='a76')
|
||||
op.alter_column('pedimento_config_parameters', 'customs_value_calculation',
|
||||
type_=sa.Boolean(),
|
||||
server_default='false',
|
||||
schema='a76')
|
||||
op.alter_column('pedimento_config_parameters', 'two_decimals_unit_value',
|
||||
type_=sa.Boolean(),
|
||||
server_default='false',
|
||||
schema='a76')
|
||||
op.alter_column('pedimento_config_parameters', 'customs_value_per_item',
|
||||
type_=sa.Boolean(),
|
||||
server_default='false',
|
||||
schema='a76')
|
||||
op.alter_column('pedimento_config_parameters', 'is_national_supplier',
|
||||
type_=sa.Boolean(),
|
||||
server_default='false',
|
||||
schema='a76')
|
||||
op.alter_column('pedimento_config_parameters', 'is_consolidated',
|
||||
type_=sa.Boolean(),
|
||||
server_default='false',
|
||||
schema='a76')
|
||||
|
||||
# Change embassy_dta to have default value
|
||||
op.alter_column('pedimento_config_parameters', 'embassy_dta',
|
||||
server_default='0.00',
|
||||
schema='a76')
|
||||
|
||||
|
||||
def downgrade() -> None:
|
||||
"""Downgrade schema."""
|
||||
# Revert to SmallInteger
|
||||
op.alter_column('pedimento_config_parameters', 'is_embassy',
|
||||
type_=sa.SmallInteger(),
|
||||
server_default=None,
|
||||
schema='a76')
|
||||
op.alter_column('pedimento_config_parameters', 'rule_3121_section_ii',
|
||||
type_=sa.SmallInteger(),
|
||||
server_default=None,
|
||||
schema='a76')
|
||||
op.alter_column('pedimento_config_parameters', 'use_previous_tariff',
|
||||
type_=sa.SmallInteger(),
|
||||
server_default=None,
|
||||
schema='a76')
|
||||
op.alter_column('pedimento_config_parameters', 'use_payment_date_fi',
|
||||
type_=sa.SmallInteger(),
|
||||
server_default=None,
|
||||
schema='a76')
|
||||
op.alter_column('pedimento_config_parameters', 'add_state_supplier_record_505',
|
||||
type_=sa.SmallInteger(),
|
||||
server_default=None,
|
||||
schema='a76')
|
||||
op.alter_column('pedimento_config_parameters', 'customs_value_calculation',
|
||||
type_=sa.SmallInteger(),
|
||||
server_default=None,
|
||||
schema='a76')
|
||||
op.alter_column('pedimento_config_parameters', 'two_decimals_unit_value',
|
||||
type_=sa.SmallInteger(),
|
||||
server_default=None,
|
||||
schema='a76')
|
||||
op.alter_column('pedimento_config_parameters', 'customs_value_per_item',
|
||||
type_=sa.SmallInteger(),
|
||||
server_default=None,
|
||||
schema='a76')
|
||||
op.alter_column('pedimento_config_parameters', 'is_national_supplier',
|
||||
type_=sa.SmallInteger(),
|
||||
server_default=None,
|
||||
schema='a76')
|
||||
op.alter_column('pedimento_config_parameters', 'is_consolidated',
|
||||
type_=sa.SmallInteger(),
|
||||
server_default=None,
|
||||
schema='a76')
|
||||
|
||||
# Remove default from embassy_dta
|
||||
op.alter_column('pedimento_config_parameters', 'embassy_dta',
|
||||
server_default=None,
|
||||
schema='a76')
|
||||
@@ -1,34 +0,0 @@
|
||||
"""make_status_nullable
|
||||
|
||||
Revision ID: 8de9bb2a4c1b
|
||||
Revises: e34fc441c57f
|
||||
Create Date: 2025-12-26 22:48:03.475946
|
||||
|
||||
"""
|
||||
from typing import Sequence, Union
|
||||
|
||||
from alembic import op
|
||||
import sqlalchemy as sa
|
||||
|
||||
|
||||
# revision identifiers, used by Alembic.
|
||||
revision: str = '8de9bb2a4c1b'
|
||||
down_revision: Union[str, Sequence[str], None] = 'e34fc441c57f'
|
||||
branch_labels: Union[str, Sequence[str], None] = None
|
||||
depends_on: Union[str, Sequence[str], None] = None
|
||||
|
||||
|
||||
def upgrade() -> None:
|
||||
"""Upgrade schema."""
|
||||
op.alter_column('pedimentos', 'status',
|
||||
existing_type=sa.String(30),
|
||||
nullable=True,
|
||||
schema='a76')
|
||||
|
||||
|
||||
def downgrade() -> None:
|
||||
"""Downgrade schema."""
|
||||
op.alter_column('pedimentos', 'status',
|
||||
existing_type=sa.String(30),
|
||||
nullable=False,
|
||||
schema='a76')
|
||||
@@ -1,113 +0,0 @@
|
||||
"""update_config_calculations_types
|
||||
|
||||
Revision ID: b83a80ad1cb8
|
||||
Revises: 7c4a2cee214d
|
||||
Create Date: 2025-12-26 23:52:00.464690
|
||||
|
||||
"""
|
||||
from typing import Sequence, Union
|
||||
|
||||
from alembic import op
|
||||
import sqlalchemy as sa
|
||||
|
||||
|
||||
# revision identifiers, used by Alembic.
|
||||
revision: str = 'b83a80ad1cb8'
|
||||
down_revision: Union[str, Sequence[str], None] = '7c4a2cee214d'
|
||||
branch_labels: Union[str, Sequence[str], None] = None
|
||||
depends_on: Union[str, Sequence[str], None] = None
|
||||
|
||||
|
||||
def upgrade() -> None:
|
||||
"""Upgrade schema."""
|
||||
# Make dta_type nullable
|
||||
op.execute('ALTER TABLE a76.pedimento_config_calculations ALTER COLUMN dta_type DROP NOT NULL')
|
||||
|
||||
# Change SmallInteger to Boolean with defaults using USING clause
|
||||
op.execute('''
|
||||
ALTER TABLE a76.pedimento_config_calculations
|
||||
ALTER COLUMN dta_operation TYPE boolean USING (dta_operation::boolean),
|
||||
ALTER COLUMN dta_operation SET DEFAULT false
|
||||
''')
|
||||
|
||||
op.execute('ALTER TABLE a76.pedimento_config_calculations ALTER COLUMN dta_vehicle_count SET DEFAULT 0')
|
||||
|
||||
op.execute('''
|
||||
ALTER TABLE a76.pedimento_config_calculations
|
||||
ALTER COLUMN dta_mixed_rate_8permil TYPE boolean USING (dta_mixed_rate_8permil::boolean),
|
||||
ALTER COLUMN dta_mixed_rate_8permil SET DEFAULT false
|
||||
''')
|
||||
|
||||
op.execute('''
|
||||
ALTER TABLE a76.pedimento_config_calculations
|
||||
ALTER COLUMN pays_vat TYPE boolean USING (pays_vat::boolean),
|
||||
ALTER COLUMN pays_vat SET DEFAULT false
|
||||
''')
|
||||
|
||||
op.execute('''
|
||||
ALTER TABLE a76.pedimento_config_calculations
|
||||
ALTER COLUMN pays_prevalidation TYPE boolean USING (pays_prevalidation::boolean),
|
||||
ALTER COLUMN pays_prevalidation SET DEFAULT false
|
||||
''')
|
||||
|
||||
op.execute('''
|
||||
ALTER TABLE a76.pedimento_config_calculations
|
||||
ALTER COLUMN include_sagar_certificate_fee TYPE boolean USING (include_sagar_certificate_fee::boolean),
|
||||
ALTER COLUMN include_sagar_certificate_fee SET DEFAULT false
|
||||
''')
|
||||
|
||||
op.execute('''
|
||||
ALTER TABLE a76.pedimento_config_calculations
|
||||
ALTER COLUMN fixed_vehicle_dta_fee TYPE boolean USING (fixed_vehicle_dta_fee::boolean),
|
||||
ALTER COLUMN fixed_vehicle_dta_fee SET DEFAULT false
|
||||
''')
|
||||
|
||||
op.execute('ALTER TABLE a76.pedimento_config_calculations ALTER COLUMN additional_fixed_fee SET DEFAULT 0')
|
||||
op.execute('ALTER TABLE a76.pedimento_config_calculations ALTER COLUMN additional_fixed_fee_payment_method DROP NOT NULL')
|
||||
|
||||
|
||||
def downgrade() -> None:
|
||||
"""Downgrade schema."""
|
||||
# Revert changes
|
||||
op.execute('ALTER TABLE a76.pedimento_config_calculations ALTER COLUMN dta_type SET NOT NULL')
|
||||
|
||||
op.execute('''
|
||||
ALTER TABLE a76.pedimento_config_calculations
|
||||
ALTER COLUMN dta_operation TYPE smallint USING (dta_operation::int::smallint),
|
||||
ALTER COLUMN dta_operation DROP DEFAULT
|
||||
''')
|
||||
|
||||
op.execute('ALTER TABLE a76.pedimento_config_calculations ALTER COLUMN dta_vehicle_count DROP DEFAULT')
|
||||
|
||||
op.execute('''
|
||||
ALTER TABLE a76.pedimento_config_calculations
|
||||
ALTER COLUMN dta_mixed_rate_8permil TYPE smallint USING (dta_mixed_rate_8permil::int::smallint),
|
||||
ALTER COLUMN dta_mixed_rate_8permil DROP DEFAULT
|
||||
''')
|
||||
|
||||
op.execute('''
|
||||
ALTER TABLE a76.pedimento_config_calculations
|
||||
ALTER COLUMN pays_vat TYPE smallint USING (pays_vat::int::smallint),
|
||||
ALTER COLUMN pays_vat DROP DEFAULT
|
||||
''')
|
||||
|
||||
op.execute('''
|
||||
ALTER TABLE a76.pedimento_config_calculations
|
||||
ALTER COLUMN pays_prevalidation TYPE smallint USING (pays_prevalidation::int::smallint),
|
||||
ALTER COLUMN pays_prevalidation DROP DEFAULT
|
||||
''')
|
||||
|
||||
op.execute('''
|
||||
ALTER TABLE a76.pedimento_config_calculations
|
||||
ALTER COLUMN include_sagar_certificate_fee TYPE smallint USING (include_sagar_certificate_fee::int::smallint),
|
||||
ALTER COLUMN include_sagar_certificate_fee DROP DEFAULT
|
||||
''')
|
||||
|
||||
op.execute('''
|
||||
ALTER TABLE a76.pedimento_config_calculations
|
||||
ALTER COLUMN fixed_vehicle_dta_fee TYPE smallint USING (fixed_vehicle_dta_fee::int::smallint),
|
||||
ALTER COLUMN fixed_vehicle_dta_fee DROP DEFAULT
|
||||
''')
|
||||
|
||||
op.execute('ALTER TABLE a76.pedimento_config_calculations ALTER COLUMN additional_fixed_fee DROP DEFAULT')
|
||||
op.execute('ALTER TABLE a76.pedimento_config_calculations ALTER COLUMN additional_fixed_fee_payment_method SET NOT NULL')
|
||||
@@ -1,31 +0,0 @@
|
||||
"""add_observations_to_pedimentos
|
||||
|
||||
Revision ID: e34fc441c57f
|
||||
Revises: 3a012dff0274
|
||||
Create Date: 2025-12-26 20:26:46.308358
|
||||
|
||||
"""
|
||||
from typing import Sequence, Union
|
||||
|
||||
from alembic import op
|
||||
import sqlalchemy as sa
|
||||
|
||||
|
||||
# revision identifiers, used by Alembic.
|
||||
revision: str = 'e34fc441c57f'
|
||||
down_revision: Union[str, Sequence[str], None] = '3a012dff0274'
|
||||
branch_labels: Union[str, Sequence[str], None] = None
|
||||
depends_on: Union[str, Sequence[str], None] = None
|
||||
|
||||
|
||||
def upgrade() -> None:
|
||||
"""Upgrade schema."""
|
||||
op.add_column('pedimentos',
|
||||
sa.Column('observations', sa.Text(), nullable=True),
|
||||
schema='a76'
|
||||
)
|
||||
|
||||
|
||||
def downgrade() -> None:
|
||||
"""Downgrade schema."""
|
||||
op.drop_column('pedimentos', 'observations', schema='a76')
|
||||
Reference in New Issue
Block a user