Files
plantillas-proyectos/backend/alembic/versions/9db46c604463_initial_schema.py
Kevin_Ramirez bdd089954b
Some checks failed
Build Producción & Push a Harbor / test (push) Failing after 3s
Build Producción & Push a Harbor / build (push) Has been skipped
Aduanasoft/plantillas-proyectos/pipeline/head There was a failure building this commit
feat: plantilla base workspace SaaS
2026-07-21 13:59:00 -05:00

5092 lines
348 KiB
Python

"""initial_schema
Revision ID: 9db46c604463
Revises:
Create Date: 2026-05-01 22:01:23.130310
"""
from typing import Sequence, Union
from alembic import op
import sqlalchemy as sa
from sqlalchemy.dialects import postgresql
# revision identifiers, used by Alembic.
revision: str = '9db46c604463'
down_revision: Union[str, Sequence[str], None] = None
branch_labels: Union[str, Sequence[str], None] = None
depends_on: Union[str, Sequence[str], None] = None
_TABLES_TENANT_ONLY: list[tuple[str, str]] = [
("a76", "company"),
("core", "license_usage"),
("core", "licenses"),
]
_TABLES_TENANT_AND_COMPANY: list[tuple[str, str]] = [
("a24", "balance_movement"),
("a24", "discharge_detail"),
("a24", "discharge_header"),
("a24", "discharge_scrap"),
("a24", "fa_classes"),
("a24", "fa_item_lines"),
("a24", "fa_partes"),
("a24", "inv_aphis_characteristic"),
("a24", "inv_aphis_containers"),
("a24", "inv_aphis_entities"),
("a24", "inv_aphis_general"),
("a24", "inv_aphis_lpcos"),
("a24", "inv_aphis_routing"),
("a24", "inv_aphis_stype_pitems"),
("a24", "inv_bom"),
("a24", "inv_classes"),
("a24", "inv_parte_paises"),
("a24", "inv_partes"),
("a76", "app_settings"),
("a76", "audit_logs"),
("a76", "canadian_tariff_fractions"),
("a76", "classes"),
("a76", "classification_concepts"),
("a76", "clients_and_providers"),
("a76", "clients_and_providers_address"),
("a76", "clients_and_providers_programs"),
("a76", "concept_manifestations"),
("a76", "concepts"),
("a76", "country_rule_oct"),
("a76", "ctm_receipts"),
("a76", "customs_broker_concepts"),
("a76", "customs_brokers"),
("a76", "customs_brokers_personnel"),
("a76", "customs_brokers_vu"),
("a76", "depreciation_catalog"),
("a76", "document_types_digitization"),
("a76", "doda"),
("a76", "doda_alta_log"),
("a76", "doda_american_pedimentos"),
("a76", "doda_container_seals"),
("a76", "doda_containers"),
("a76", "doda_pedimentos"),
("a76", "driver"),
("a76", "electronic_notices"),
("a76", "equivalencies"),
("a76", "equivalency_items"),
("a76", "error_catalogs"),
("a76", "error_classifications"),
("a76", "exchange_rate"),
("a76", "fa_location_ext"),
("a76", "fda_affirmation_codes"),
("a76", "fda_catalog"),
("a76", "fda_constituent_elements"),
("a76", "fda_lot_production"),
("a76", "fda_specifications"),
("a76", "fraction_rule_octave"),
("a76", "historical_tariff_fractions"),
("a76", "identifier_details"),
("a76", "identifiers"),
("a76", "inpc"),
("a76", "invoice_collections"),
("a76", "invoice_compliance_mx"),
("a76", "invoice_financials"),
("a76", "invoice_header"),
("a76", "invoice_logistics"),
("a76", "invoice_sales_details"),
("a76", "invoice_settings"),
("a76", "item_line_series"),
("a76", "item_lines"),
("a76", "item_presets"),
("a76", "legends"),
("a76", "location"),
("a76", "manifest_anexos"),
("a76", "manifest_drivers"),
("a76", "manifests"),
("a76", "multi_currency_types"),
("a76", "octave_balance"),
("a76", "packages"),
("a76", "packing_lists"),
("a76", "parts"),
("a76", "pedimento_config_additional"),
("a76", "pedimento_config_calculations"),
("a76", "pedimento_config_parameters"),
("a76", "pedimento_config_surcharges"),
("a76", "pedimento_config_update_rectification"),
("a76", "pedimento_config_updates"),
("a76", "pedimento_containers"),
("a76", "pedimento_contributions"),
("a76", "pedimento_customs_offices"),
("a76", "pedimento_dates"),
("a76", "pedimento_decrementables"),
("a76", "pedimento_guides"),
("a76", "pedimento_incrementables"),
("a76", "pedimento_indexes"),
("a76", "pedimento_packages"),
("a76", "pedimento_payments"),
("a76", "pedimento_rectification_destination"),
("a76", "pedimento_rectification_origin"),
("a76", "pedimento_seals"),
("a76", "pedimento_transport_carriers"),
("a76", "pedimento_transport_means"),
("a76", "pedimento_validation"),
("a76", "pedimentos"),
("a76", "permission_rule_oct"),
("a76", "permission_rule_octave"),
("a76", "ports"),
("a76", "prevalidators"),
("a76", "previous_fractions"),
("a76", "seal"),
("a76", "sectors"),
("a76", "signatures"),
("a76", "subassembly_entries"),
("a76", "trailer"),
("a76", "transporter"),
("a76", "unit_conversions"),
("a76", "units_of_measure"),
("a76", "units_of_measure_general"),
("a76", "us_tariff_fractions"),
("a76", "value_manifestations"),
("a76", "vehicle"),
("core", "company_roles"),
("core", "role_permissions"),
("core", "user_company_permissions"),
("core", "user_company_roles"),
("public", "warning_fractions"),
]
_TABLES_COMPANY_ONLY: list[tuple[str, str]] = [
("a24", "inv_aphis_catalog"),
("a76", "company_address"),
("a76", "company_certification"),
("a76", "company_cfdi"),
("a76", "company_digital_certificate"),
("a76", "company_electronic_agent"),
("a76", "company_prevalidator"),
]
_POLICY_TENANT_ONLY = "tenant_isolation"
_POLICY_TENANT_COMPANY = "tenant_company_isolation"
_POLICY_COMPANY_ONLY = "company_isolation"
def _enable_rls_tenant_company() -> None:
op.execute("CREATE SCHEMA IF NOT EXISTS app")
op.execute(
"""
CREATE OR REPLACE FUNCTION app.current_tenant_id() RETURNS INTEGER
LANGUAGE sql STABLE AS $$
SELECT NULLIF(current_setting('app.tenant_id', true), '')::INTEGER
$$
"""
)
op.execute(
"""
CREATE OR REPLACE FUNCTION app.current_company_id() RETURNS INTEGER
LANGUAGE sql STABLE AS $$
SELECT NULLIF(current_setting('app.company_id', true), '')::INTEGER
$$
"""
)
for schema, table in _TABLES_TENANT_ONLY:
op.execute(f'ALTER TABLE "{schema}"."{table}" ENABLE ROW LEVEL SECURITY')
op.execute(f'ALTER TABLE "{schema}"."{table}" FORCE ROW LEVEL SECURITY')
op.execute(
f"""
CREATE POLICY {_POLICY_TENANT_ONLY} ON "{schema}"."{table}"
USING (tenant_id = app.current_tenant_id())
WITH CHECK (tenant_id = app.current_tenant_id())
"""
)
for schema, table in _TABLES_TENANT_AND_COMPANY:
op.execute(f'ALTER TABLE "{schema}"."{table}" ENABLE ROW LEVEL SECURITY')
op.execute(f'ALTER TABLE "{schema}"."{table}" FORCE ROW LEVEL SECURITY')
op.execute(
f"""
CREATE POLICY {_POLICY_TENANT_COMPANY} ON "{schema}"."{table}"
USING (
tenant_id = app.current_tenant_id()
AND (
app.current_company_id() IS NULL
OR company_id = app.current_company_id()
)
)
WITH CHECK (
tenant_id = app.current_tenant_id()
AND (
app.current_company_id() IS NULL
OR company_id = app.current_company_id()
)
)
"""
)
for schema, table in _TABLES_COMPANY_ONLY:
op.execute(f'ALTER TABLE "{schema}"."{table}" ENABLE ROW LEVEL SECURITY')
op.execute(f'ALTER TABLE "{schema}"."{table}" FORCE ROW LEVEL SECURITY')
op.execute(
f"""
CREATE POLICY {_POLICY_COMPANY_ONLY} ON "{schema}"."{table}"
USING (
EXISTS (
SELECT 1 FROM a76.company c
WHERE c.id = "{schema}"."{table}".company_id
AND c.tenant_id = app.current_tenant_id()
)
AND (
app.current_company_id() IS NULL
OR company_id = app.current_company_id()
)
)
WITH CHECK (
EXISTS (
SELECT 1 FROM a76.company c
WHERE c.id = "{schema}"."{table}".company_id
AND c.tenant_id = app.current_tenant_id()
)
AND (
app.current_company_id() IS NULL
OR company_id = app.current_company_id()
)
)
"""
)
def _disable_rls_tenant_company() -> None:
for schema, table in _TABLES_COMPANY_ONLY:
op.execute(
f'DROP POLICY IF EXISTS {_POLICY_COMPANY_ONLY} ON "{schema}"."{table}"'
)
op.execute(f'ALTER TABLE "{schema}"."{table}" NO FORCE ROW LEVEL SECURITY')
op.execute(f'ALTER TABLE "{schema}"."{table}" DISABLE ROW LEVEL SECURITY')
for schema, table in _TABLES_TENANT_AND_COMPANY:
op.execute(
f'DROP POLICY IF EXISTS {_POLICY_TENANT_COMPANY} ON "{schema}"."{table}"'
)
op.execute(f'ALTER TABLE "{schema}"."{table}" NO FORCE ROW LEVEL SECURITY')
op.execute(f'ALTER TABLE "{schema}"."{table}" DISABLE ROW LEVEL SECURITY')
for schema, table in _TABLES_TENANT_ONLY:
op.execute(
f'DROP POLICY IF EXISTS {_POLICY_TENANT_ONLY} ON "{schema}"."{table}"'
)
op.execute(f'ALTER TABLE "{schema}"."{table}" NO FORCE ROW LEVEL SECURITY')
op.execute(f'ALTER TABLE "{schema}"."{table}" DISABLE ROW LEVEL SECURITY')
op.execute("DROP FUNCTION IF EXISTS app.current_company_id()")
op.execute("DROP FUNCTION IF EXISTS app.current_tenant_id()")
op.execute("DROP SCHEMA IF EXISTS app")
def upgrade() -> None:
"""Upgrade schema."""
op.execute("CREATE SCHEMA IF NOT EXISTS a24")
op.execute("CREATE SCHEMA IF NOT EXISTS a76")
op.execute("CREATE SCHEMA IF NOT EXISTS core")
# ### commands auto generated by Alembic - please adjust! ###
op.create_table('inv_aphis_catalog',
sa.Column('id', sa.Integer(), autoincrement=True, nullable=False),
sa.Column('company_id', sa.Integer(), nullable=False),
sa.Column('program_code', sa.String(length=10), nullable=True),
sa.Column('processing_code', sa.String(length=10), nullable=True),
sa.Column('aphis_type', sa.String(length=10), nullable=True),
sa.Column('disclaimer', sa.String(length=10), nullable=True),
sa.Column('electronic_image', sa.String(length=50), nullable=True),
sa.Column('confidential', sa.String(length=1), nullable=True),
sa.Column('global_product_id', sa.String(length=100), nullable=True),
sa.Column('intended_use_code', sa.String(length=10), nullable=True),
sa.Column('intended_use_description', sa.String(length=200), nullable=True),
sa.Column('item_type', sa.String(length=20), nullable=True),
sa.Column('product_code', sa.String(length=20), nullable=True),
sa.Column('product_code_2', sa.String(length=20), nullable=True),
sa.Column('product_code_3', sa.String(length=20), nullable=True),
sa.Column('scientific_genus_name', sa.String(length=100), nullable=True),
sa.Column('scientific_species_name', sa.String(length=100), nullable=True),
sa.Column('scientific_sub_species_name', sa.String(length=100), nullable=True),
sa.Column('common_name_specific', sa.String(length=200), nullable=True),
sa.Column('common_name_general', sa.String(length=200), nullable=True),
sa.Column('signed_doc', sa.String(length=100), nullable=True),
sa.Column('signed_doc_date', sa.Date(), nullable=True),
sa.Column('signed_doc_id', sa.String(length=50), nullable=True),
sa.Column('invoice_number', sa.String(length=50), nullable=True),
sa.Column('quantity_1', sa.String(length=50), nullable=True),
sa.Column('quantity_2', sa.String(length=50), nullable=True),
sa.Column('quantity_3', sa.String(length=50), nullable=True),
sa.Column('inspection', sa.String(length=200), nullable=True),
sa.Column('inspection_date', sa.Date(), nullable=True),
sa.Column('inspection_loc_date', sa.Date(), nullable=True),
sa.Column('inspection_location', sa.String(length=200), nullable=True),
sa.Column('country_production', sa.String(length=3), nullable=True),
sa.Column('country_source', sa.String(length=3), nullable=True),
sa.Column('characteristics', sa.JSON(), nullable=True),
sa.Column('pitems', sa.JSON(), nullable=True),
sa.Column('lpcos', sa.JSON(), nullable=True),
sa.Column('entities', sa.JSON(), nullable=True),
sa.Column('containers', sa.JSON(), nullable=True),
sa.Column('routing', sa.JSON(), nullable=True),
sa.PrimaryKeyConstraint('id', name='inv_aphis_catalog_pkey'),
schema='a24'
)
op.create_index(op.f('ix_a24_inv_aphis_catalog_company_id'), 'inv_aphis_catalog', ['company_id'], unique=False, schema='a24')
op.create_table('tariff_fractions',
sa.Column('id', sa.Integer(), autoincrement=True, nullable=False),
sa.Column('code', sa.String(length=10), nullable=False),
sa.Column('fraction', sa.String(length=15), nullable=False),
sa.Column('description', sa.String(length=1000), nullable=True),
sa.Column('nico', sa.String(length=10), nullable=True),
sa.Column('umt', sa.String(length=10), nullable=True),
sa.Column('adv_impo', sa.String(length=20), nullable=True),
sa.Column('adv_expo', sa.String(length=20), nullable=True),
sa.PrimaryKeyConstraint('id', name='tariff_fractions_pkey'),
schema='a76'
)
op.create_index(op.f('ix_a76_tariff_fractions_code'), 'tariff_fractions', ['code'], unique=True, schema='a76')
op.create_index(op.f('ix_a76_tariff_fractions_fraction'), 'tariff_fractions', ['fraction'], unique=False, schema='a76')
op.create_table('unit_of_measure_ace',
sa.Column('id', sa.Integer(), autoincrement=True, nullable=False),
sa.Column('code', sa.String(length=4), nullable=False),
sa.Column('description', sa.String(length=49), nullable=True),
sa.Column('deleted_at', sa.DateTime(), 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.PrimaryKeyConstraint('id'),
sa.UniqueConstraint('code', name='uq_uom_ace_code'),
schema='a76'
)
op.create_table('unit_of_measure_american',
sa.Column('id', sa.Integer(), autoincrement=True, nullable=False),
sa.Column('code', sa.String(length=3), nullable=False),
sa.Column('description', sa.String(length=40), nullable=True),
sa.Column('deleted_at', sa.DateTime(), 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.PrimaryKeyConstraint('id'),
sa.UniqueConstraint('code', name='uq_uom_american_code'),
schema='a76'
)
op.create_table('unit_of_measure_customs',
sa.Column('id', sa.Integer(), autoincrement=True, nullable=False),
sa.Column('code', sa.String(length=10), nullable=False),
sa.Column('description', sa.String(length=20), nullable=True),
sa.Column('a76_unit_code', sa.String(length=5), nullable=True),
sa.Column('deleted_at', sa.DateTime(), 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.PrimaryKeyConstraint('id'),
sa.UniqueConstraint('code', name='uq_uom_customs_code'),
schema='a76'
)
op.create_table('unit_of_measure_oma',
sa.Column('id', sa.Integer(), autoincrement=True, nullable=False),
sa.Column('code', sa.String(length=10), nullable=False),
sa.Column('description', sa.String(length=200), nullable=True),
sa.Column('deleted_at', sa.DateTime(), 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.PrimaryKeyConstraint('id'),
sa.UniqueConstraint('code', name='uq_uom_oma_code'),
schema='a76'
)
op.create_table('containers',
sa.Column('key', sa.String(length=3), nullable=False),
sa.Column('description', sa.String(length=500), nullable=False),
sa.PrimaryKeyConstraint('key', name='containers_pkey')
)
op.create_table('permissions',
sa.Column('id', sa.Integer(), nullable=False),
sa.Column('code', sa.String(length=100), nullable=False),
sa.Column('description', sa.String(length=255), nullable=True),
sa.Column('module', sa.String(length=50), nullable=False),
sa.Column('action', sa.String(length=50), nullable=False),
sa.Column('is_active', sa.Boolean(), server_default='true', nullable=False),
sa.Column('deleted_at', sa.DateTime(), 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.PrimaryKeyConstraint('id'),
schema='core'
)
op.create_index(op.f('ix_core_permissions_code'), 'permissions', ['code'], unique=True, schema='core')
op.create_index(op.f('ix_core_permissions_id'), 'permissions', ['id'], unique=False, schema='core')
op.create_index(op.f('ix_core_permissions_module'), 'permissions', ['module'], unique=False, schema='core')
op.create_table('tenants',
sa.Column('id', sa.Integer(), nullable=False),
sa.Column('name', sa.String(length=255), nullable=False),
sa.Column('slug', sa.String(length=100), nullable=False),
sa.Column('type', sa.Enum('SHARED', 'DEDICATED', name='tenanttype'), server_default='SHARED', nullable=False),
sa.Column('keycloak_realm', sa.String(length=255), nullable=False),
sa.Column('db_config', sa.Text(), nullable=True),
sa.Column('contact_name', sa.String(length=255), nullable=True),
sa.Column('contact_email', sa.String(length=255), nullable=True),
sa.Column('contact_phone', sa.String(length=50), nullable=True),
sa.Column('is_active', sa.Boolean(), server_default='true', nullable=False),
sa.Column('deleted_at', sa.DateTime(), 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.PrimaryKeyConstraint('id'),
schema='core'
)
op.create_index(op.f('ix_core_tenants_id'), 'tenants', ['id'], unique=False, schema='core')
op.create_index(op.f('ix_core_tenants_name'), 'tenants', ['name'], unique=False, schema='core')
op.create_index(op.f('ix_core_tenants_slug'), 'tenants', ['slug'], unique=True, schema='core')
op.create_table('help_articles',
sa.Column('uuid', sa.UUID(), nullable=False),
sa.Column('slug', sa.String(length=255), nullable=False),
sa.Column('title', sa.String(length=255), nullable=False),
sa.Column('content', sa.Text(), nullable=False),
sa.Column('updated_at', sa.DateTime(timezone=True), nullable=False),
sa.Column('last_editor', sa.String(length=255), nullable=False),
sa.Column('category', sa.String(length=255), nullable=True),
sa.Column('order', sa.Integer(), nullable=True),
sa.PrimaryKeyConstraint('uuid')
)
op.create_index(op.f('ix_help_articles_slug'), 'help_articles', ['slug'], unique=True)
op.create_index(op.f('ix_help_articles_uuid'), 'help_articles', ['uuid'], unique=False)
op.create_table('agency_tariff_codes',
sa.Column('id', sa.Integer(), nullable=False),
sa.Column('tariff_flag_code', sa.String(length=10), nullable=False),
sa.Column('agency_code', sa.String(length=10), nullable=False),
sa.Column('requirement_level', sa.String(length=1), nullable=False),
sa.Column('program_code', sa.String(length=10), nullable=False),
sa.Column('definition', sa.String(length=500), nullable=False),
sa.PrimaryKeyConstraint('id', name='agency_tariff_codes_pkey'),
schema='public'
)
op.create_index(op.f('ix_public_agency_tariff_codes_agency_code'), 'agency_tariff_codes', ['agency_code'], unique=False, schema='public')
op.create_index(op.f('ix_public_agency_tariff_codes_program_code'), 'agency_tariff_codes', ['program_code'], unique=False, schema='public')
op.create_index(op.f('ix_public_agency_tariff_codes_tariff_flag_code'), 'agency_tariff_codes', ['tariff_flag_code'], unique=False, schema='public')
op.create_table('carta_porte_codes',
sa.Column('id', sa.Integer(), nullable=False),
sa.Column('code', sa.String(length=20), nullable=False),
sa.Column('description', sa.String(length=2000), nullable=False),
sa.Column('similar_words', sa.String(length=2000), nullable=True),
sa.Column('is_hazardous', sa.Integer(), nullable=False),
sa.Column('start_date', sa.String(length=20), nullable=True),
sa.Column('end_date', sa.String(length=20), nullable=True),
sa.PrimaryKeyConstraint('id'),
schema='public'
)
op.create_index(op.f('ix_public_carta_porte_codes_code'), 'carta_porte_codes', ['code'], unique=False, schema='public')
op.create_table('countries',
sa.Column('m3_key', sa.String(length=3), nullable=False),
sa.Column('mex_key', sa.String(length=2), nullable=False),
sa.Column('ame_key', sa.String(length=2), nullable=False),
sa.Column('description_es', sa.String(length=50), nullable=False),
sa.Column('description_en', sa.String(length=50), nullable=False),
sa.PrimaryKeyConstraint('m3_key', name='countries_pkey'),
schema='public'
)
op.create_index('ak_country_ame', 'countries', ['ame_key'], unique=True, schema='public')
op.create_table('currency_types',
sa.Column('code', sa.String(length=3), nullable=False),
sa.Column('currency_name', sa.String(length=15), nullable=False),
sa.Column('country_description', sa.String(length=50), nullable=False),
sa.PrimaryKeyConstraint('code', name='currency_types_pkey'),
schema='public'
)
op.create_table('customs_sections',
sa.Column('customs_code', sa.String(length=3), nullable=False),
sa.Column('section_name', sa.String(length=255), nullable=False),
sa.PrimaryKeyConstraint('customs_code', name='customs_code_pkey'),
schema='public'
)
op.create_table('customs_warehouses',
sa.Column('key', sa.String(length=3), nullable=False),
sa.Column('customs', sa.String(length=100), nullable=False),
sa.Column('fiscalized_warehouse', sa.String(length=1000), nullable=False),
sa.PrimaryKeyConstraint('key', 'customs', name='pk_customs_warehouse'),
schema='public'
)
op.create_table('identifiers',
sa.Column('key', sa.String(length=10), nullable=False),
sa.Column('description', sa.String(length=2000), nullable=False),
sa.Column('level', sa.String(length=1), nullable=False),
sa.Column('complement', sa.String(length=5000), nullable=False),
sa.PrimaryKeyConstraint('key', name='identifiers_pkey'),
schema='public'
)
op.create_table('incoterms',
sa.Column('code', sa.String(length=5), nullable=False),
sa.Column('description_es', sa.String(length=256), nullable=False),
sa.Column('description_en', sa.String(length=256), nullable=False),
sa.PrimaryKeyConstraint('code', name='incoterms_pkey'),
schema='public'
)
op.create_table('invoice_types',
sa.Column('key', sa.String(length=5), nullable=False),
sa.Column('description', sa.String(length=50), nullable=False),
sa.Column('note', sa.String(length=500), nullable=False),
sa.Column('type', sa.String(length=15), nullable=False),
sa.Column('operation', sa.String(length=5), nullable=False),
sa.PrimaryKeyConstraint('key', name='invoice_types_pkey'),
schema='public'
)
op.create_table('license_exceptions',
sa.Column('key', sa.String(length=10), nullable=False),
sa.Column('description', sa.String(length=500), nullable=False),
sa.PrimaryKeyConstraint('key', name='license_exceptions_pkey'),
schema='public'
)
op.create_table('material_types',
sa.Column('key', sa.String(length=10), nullable=False),
sa.Column('type', sa.String(length=15), nullable=False),
sa.Column('description', sa.String(length=256), nullable=False),
sa.PrimaryKeyConstraint('key', name='material_types_pkey'),
schema='public'
)
op.create_table('payment_methods',
sa.Column('key', sa.String(length=2), nullable=False),
sa.Column('description', sa.String(length=100), nullable=False),
sa.PrimaryKeyConstraint('key', name='payment_methods_pkey'),
schema='public'
)
op.create_table('pedimento_codes',
sa.Column('code', sa.String(length=3), nullable=False),
sa.Column('description', sa.String(length=250), nullable=False),
sa.PrimaryKeyConstraint('code', name='pedimento_codes_pkey'),
schema='public'
)
op.create_table('pedimento_regimens',
sa.Column('code', sa.String(length=3), nullable=False),
sa.Column('description', sa.String(length=100), nullable=False),
sa.PrimaryKeyConstraint('code', name='pedimento_regimens_pkey'),
schema='public'
)
op.create_table('pedimento_transport_catalog',
sa.Column('code', sa.String(length=3), nullable=False),
sa.Column('transport_en', sa.String(length=80), nullable=False),
sa.Column('transport_es', sa.String(length=120), nullable=False),
sa.Column('payment_date_code', sa.String(length=1), nullable=False),
sa.CheckConstraint("payment_date_code IN ('E', 'P')", name='pedimento_transport_catalog_payment_date_code_chk'),
sa.PrimaryKeyConstraint('code', name='pedimento_transport_catalog_pkey'),
schema='public'
)
op.create_table('trailer_type',
sa.Column('trailer_type_key', sa.String(length=2), nullable=False),
sa.Column('description', sa.String(length=100), nullable=True),
sa.Column('deleted_at', sa.DateTime(), 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.PrimaryKeyConstraint('trailer_type_key'),
schema='public'
)
op.create_table('transport_modes',
sa.Column('key', sa.String(length=3), nullable=False),
sa.Column('name', sa.String(length=30), nullable=False),
sa.PrimaryKeyConstraint('key', name='transport_modes_pkey'),
schema='public'
)
op.create_table('transport_types',
sa.Column('transport_code', sa.String(length=2), nullable=False),
sa.Column('description', sa.String(length=100), nullable=False),
sa.PrimaryKeyConstraint('transport_code', name='transport_types_pkey'),
schema='public'
)
op.create_table('valuation_methods',
sa.Column('key', sa.String(length=2), nullable=False),
sa.Column('description', sa.String(length=200), nullable=False),
sa.PrimaryKeyConstraint('key', name='valuation_methods_pkey'),
schema='public'
)
op.create_table('company',
sa.Column('id', sa.Integer(), nullable=False),
sa.Column('tenant_id', sa.Integer(), nullable=False),
sa.Column('name', sa.String(length=256), nullable=True),
sa.Column('rfc', sa.String(length=30), nullable=True),
sa.Column('curp', sa.String(length=19), nullable=True),
sa.Column('main_activity', sa.String(length=80), nullable=True),
sa.Column('program', sa.String(length=7), nullable=True),
sa.Column('program_number', sa.String(length=40), nullable=True),
sa.Column('prosec', sa.Boolean(), server_default='false', nullable=False),
sa.Column('prosec_authorization', sa.String(length=20), nullable=True),
sa.Column('sector1', sa.String(length=150), nullable=True),
sa.Column('sector2', sa.String(length=150), nullable=True),
sa.Column('sector3', sa.String(length=5), nullable=True),
sa.Column('manufacturer_id', sa.String(length=25), nullable=True),
sa.Column('broker_company', sa.String(length=6), nullable=True),
sa.Column('responsible', sa.String(length=80), nullable=True),
sa.Column('responsible_name', sa.String(length=20), nullable=True),
sa.Column('responsible_last_name', sa.String(length=20), nullable=True),
sa.Column('responsible_mother_last_name', sa.String(length=20), nullable=True),
sa.Column('responsible_rfc', sa.String(length=30), nullable=True),
sa.Column('position', sa.String(length=30), nullable=True),
sa.Column('logo', sa.String(length=512), nullable=True),
sa.Column('fiscal_deposit', sa.Boolean(), server_default='false', nullable=True),
sa.Column('generate_barcodes_with_fiel', sa.Boolean(), server_default='false', nullable=True),
sa.Column('order_format_type', sa.String(length=19), nullable=True),
sa.Column('is_service_company', sa.Boolean(), server_default='false', nullable=True),
sa.Column('client_name', sa.String(length=300), nullable=True),
sa.Column('subassembly_mode', sa.String(length=7), nullable=True),
sa.Column('previous_code', sa.SmallInteger(), nullable=True),
sa.Column('active_labels', sa.SmallInteger(), nullable=True),
sa.Column('active_fractions', sa.SmallInteger(), nullable=True),
sa.Column('activate_caat', sa.SmallInteger(), nullable=True),
sa.Column('trans_interface', sa.SmallInteger(), nullable=True),
sa.Column('american_costs', sa.SmallInteger(), nullable=True),
sa.Column('scaf_readonly', sa.SmallInteger(), nullable=True),
sa.Column('parts_replacement', sa.SmallInteger(), nullable=True),
sa.Column('activate_facmexame', sa.SmallInteger(), nullable=True),
sa.Column('part_reference', sa.SmallInteger(), nullable=True),
sa.Column('international_firm', sa.SmallInteger(), nullable=True),
sa.Column('seventh_amendment', sa.Boolean(), nullable=True),
sa.Column('ftp_key', sa.String(length=10), nullable=True),
sa.Column('sifra_path', sa.String(length=255), nullable=True),
sa.Column('version_type', sa.String(length=20), nullable=True),
sa.Column('sql_language', sa.String(length=19), nullable=True),
sa.Column('balance_operation_mode', sa.String(length=50), nullable=True),
sa.Column('inter_db_name', sa.String(length=100), nullable=True),
sa.Column('deleted_at', sa.DateTime(), 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.ForeignKeyConstraint(['tenant_id'], ['core.tenants.id'], ),
sa.PrimaryKeyConstraint('id'),
schema='a76'
)
op.create_index(op.f('ix_a76_company_tenant_id'), 'company', ['tenant_id'], unique=False, schema='a76')
op.create_table('customs_broker_concepts',
sa.Column('id', sa.Integer(), autoincrement=True, nullable=False),
sa.Column('company_id', sa.Integer(), nullable=False),
sa.Column('broker_key', sa.String(length=5), nullable=False),
sa.Column('concept', sa.String(length=15), nullable=False),
sa.Column('amount', sa.Numeric(precision=11, scale=2), nullable=True),
sa.Column('priority', sa.Integer(), nullable=True),
sa.Column('tenant_id', sa.Integer(), nullable=False),
sa.Column('deleted_at', sa.DateTime(), 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.ForeignKeyConstraint(['tenant_id'], ['core.tenants.id'], ),
sa.PrimaryKeyConstraint('id'),
sa.UniqueConstraint('broker_key', 'concept', 'company_id', name='uq_broker_concept'),
schema='a76'
)
op.create_index(op.f('ix_a76_customs_broker_concepts_tenant_id'), 'customs_broker_concepts', ['tenant_id'], unique=False, schema='a76')
op.create_table('license_usage',
sa.Column('id', sa.Integer(), nullable=False),
sa.Column('tenant_id', sa.Integer(), nullable=False),
sa.Column('period_start', sa.DateTime(timezone=True), nullable=False),
sa.Column('period_end', sa.DateTime(timezone=True), nullable=False),
sa.Column('active_users', sa.Integer(), server_default='0', nullable=True),
sa.Column('storage_used_gb', sa.Integer(), server_default='0', nullable=True),
sa.Column('operations_count', sa.Integer(), server_default='0', nullable=True),
sa.Column('api_calls_count', sa.Integer(), server_default='0', nullable=True),
sa.Column('deleted_at', sa.DateTime(), 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.ForeignKeyConstraint(['tenant_id'], ['core.tenants.id'], ),
sa.PrimaryKeyConstraint('id'),
schema='core'
)
op.create_index(op.f('ix_core_license_usage_id'), 'license_usage', ['id'], unique=False, schema='core')
op.create_index(op.f('ix_core_license_usage_tenant_id'), 'license_usage', ['tenant_id'], unique=False, schema='core')
op.create_table('licenses',
sa.Column('id', sa.Integer(), nullable=False),
sa.Column('tenant_id', sa.Integer(), nullable=False),
sa.Column('plan', sa.Enum('FREE', 'BASIC', 'PROFESSIONAL', 'ENTERPRISE', name='licenseplan'), server_default='FREE', nullable=False),
sa.Column('status', sa.Enum('ACTIVE', 'EXPIRED', 'SUSPENDED', 'PENDING', 'CANCELLED', name='licensestatus'), server_default='PENDING', nullable=False),
sa.Column('max_users', sa.Integer(), server_default='5', nullable=False),
sa.Column('max_storage_gb', sa.Integer(), server_default='10', nullable=False),
sa.Column('max_monthly_operations', sa.Integer(), server_default='1000', nullable=False),
sa.Column('feature_api_access', sa.Boolean(), server_default='true', nullable=True),
sa.Column('feature_advanced_reports', sa.Boolean(), server_default='false', nullable=True),
sa.Column('feature_integrations', sa.Boolean(), server_default='false', nullable=True),
sa.Column('feature_dedicated_support', sa.Boolean(), server_default='false', nullable=True),
sa.Column('starts_at', sa.DateTime(timezone=True), nullable=False),
sa.Column('expires_at', sa.DateTime(timezone=True), nullable=False),
sa.Column('deleted_at', sa.DateTime(), 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.ForeignKeyConstraint(['tenant_id'], ['core.tenants.id'], ),
sa.PrimaryKeyConstraint('id'),
schema='core'
)
op.create_index(op.f('ix_core_licenses_id'), 'licenses', ['id'], unique=False, schema='core')
op.create_index(op.f('ix_core_licenses_tenant_id'), 'licenses', ['tenant_id'], unique=True, schema='core')
op.create_table('code_pedimento_regimens',
sa.Column('id', sa.Integer(), nullable=False),
sa.Column('pedimento_code', sa.String(length=3), nullable=False),
sa.Column('regimen_code', sa.String(length=3), nullable=False),
sa.Column('type_code', sa.String(length=1), nullable=True),
sa.ForeignKeyConstraint(['pedimento_code'], ['public.pedimento_codes.code'], name='fk_codeped'),
sa.ForeignKeyConstraint(['regimen_code'], ['public.pedimento_regimens.code'], name='fk_regimenped'),
sa.PrimaryKeyConstraint('id', name='clave_pedimento_regimens_pkey'),
schema='public'
)
op.create_table('states',
sa.Column('m3_key', sa.String(length=3), nullable=False),
sa.Column('description', sa.String(length=50), nullable=False),
sa.Column('mex_key', sa.String(length=3), nullable=True),
sa.ForeignKeyConstraint(['m3_key'], ['public.countries.m3_key'], ),
sa.PrimaryKeyConstraint('m3_key', 'description', name='states_pkey'),
schema='public'
)
op.create_table('CompanyVU',
sa.Column('id', sa.Integer(), nullable=False),
sa.Column('company_id', sa.Integer(), nullable=False),
sa.Column('webservice_user', sa.String(length=100), nullable=True),
sa.Column('webservice_password', sa.String(length=100), nullable=True),
sa.Column('email', sa.String(length=800), nullable=True),
sa.Column('figure_type', sa.String(length=29), nullable=True),
sa.Column('central_path', sa.String(length=1499), nullable=True),
sa.Column('xml_files_path', sa.String(length=1499), nullable=True),
sa.Column('query_rfc', sa.String(length=30), nullable=True),
sa.Column('validation_rfc', sa.String(length=30), nullable=True),
sa.Column('configuration_source', sa.String(length=30), nullable=True),
sa.Column('measurement_units', sa.String(length=3), nullable=True),
sa.Column('deleted_at', sa.DateTime(), 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.ForeignKeyConstraint(['company_id'], ['a76.company.id'], ondelete='CASCADE'),
sa.PrimaryKeyConstraint('id'),
schema='a76'
)
op.create_index(op.f('ix_a76_CompanyVU_company_id'), 'CompanyVU', ['company_id'], unique=True, schema='a76')
op.create_table('app_settings',
sa.Column('id', sa.Integer(), autoincrement=True, nullable=False),
sa.Column('tenant_id', sa.Integer(), nullable=True),
sa.Column('company_id', sa.Integer(), nullable=True),
sa.Column('settings', postgresql.JSONB(astext_type=sa.Text()), 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.ForeignKeyConstraint(['company_id'], ['a76.company.id'], ),
sa.ForeignKeyConstraint(['tenant_id'], ['core.tenants.id'], ),
sa.PrimaryKeyConstraint('id'),
sa.UniqueConstraint('tenant_id', 'company_id', name='uq_app_settings_tenant_company'),
schema='a76'
)
op.create_index(op.f('ix_a76_app_settings_company_id'), 'app_settings', ['company_id'], unique=False, schema='a76')
op.create_index(op.f('ix_a76_app_settings_tenant_id'), 'app_settings', ['tenant_id'], unique=False, schema='a76')
op.create_table('audit_logs',
sa.Column('spec_id', sa.Integer(), autoincrement=True, nullable=False),
sa.Column('reference', sa.String(length=100), nullable=False),
sa.Column('procedure', sa.String(length=100), nullable=False),
sa.Column('movement', sa.String(length=255), nullable=False),
sa.Column('username', sa.String(length=100), nullable=False),
sa.Column('date', sa.Date(), nullable=False),
sa.Column('time', sa.Time(), nullable=False),
sa.Column('timestamp', sa.DateTime(timezone=True), nullable=False),
sa.Column('system', sa.String(length=50), nullable=False),
sa.Column('table_name', sa.String(length=100), nullable=True),
sa.Column('record_id', sa.String(length=255), nullable=True),
sa.Column('operation_type', sa.String(length=50), nullable=True),
sa.Column('old_values', postgresql.JSONB(astext_type=sa.Text()), nullable=True),
sa.Column('new_values', postgresql.JSONB(astext_type=sa.Text()), nullable=True),
sa.Column('changed_fields', postgresql.ARRAY(sa.String()), nullable=True),
sa.Column('ip_address', sa.String(length=45), nullable=True),
sa.Column('user_agent', sa.Text(), nullable=True),
sa.Column('endpoint', sa.String(length=500), nullable=True),
sa.Column('request_method', sa.String(length=10), nullable=True),
sa.Column('session_id', sa.String(length=50), nullable=True),
sa.Column('execution_time_ms', sa.Integer(), nullable=True),
sa.Column('tenant_id', sa.Integer(), nullable=False),
sa.Column('company_id', sa.Integer(), nullable=False),
sa.Column('deleted_at', sa.DateTime(), 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.ForeignKeyConstraint(['company_id'], ['a76.company.id'], ),
sa.ForeignKeyConstraint(['tenant_id'], ['core.tenants.id'], ),
sa.PrimaryKeyConstraint('spec_id'),
schema='a76'
)
op.create_index('idx_audit_procedure_date', 'audit_logs', ['procedure', 'date'], unique=False, schema='a76')
op.create_index('idx_audit_system_timestamp', 'audit_logs', ['system', 'timestamp'], unique=False, schema='a76')
op.create_index('idx_audit_table_record', 'audit_logs', ['table_name', 'record_id'], unique=False, schema='a76')
op.create_index('idx_audit_username_date', 'audit_logs', ['username', 'date'], unique=False, schema='a76')
op.create_index(op.f('ix_a76_audit_logs_company_id'), 'audit_logs', ['company_id'], unique=False, schema='a76')
op.create_index(op.f('ix_a76_audit_logs_date'), 'audit_logs', ['date'], unique=False, schema='a76')
op.create_index(op.f('ix_a76_audit_logs_operation_type'), 'audit_logs', ['operation_type'], unique=False, schema='a76')
op.create_index(op.f('ix_a76_audit_logs_procedure'), 'audit_logs', ['procedure'], unique=False, schema='a76')
op.create_index(op.f('ix_a76_audit_logs_record_id'), 'audit_logs', ['record_id'], unique=False, schema='a76')
op.create_index(op.f('ix_a76_audit_logs_reference'), 'audit_logs', ['reference'], unique=False, schema='a76')
op.create_index(op.f('ix_a76_audit_logs_session_id'), 'audit_logs', ['session_id'], unique=False, schema='a76')
op.create_index(op.f('ix_a76_audit_logs_system'), 'audit_logs', ['system'], unique=False, schema='a76')
op.create_index(op.f('ix_a76_audit_logs_table_name'), 'audit_logs', ['table_name'], unique=False, schema='a76')
op.create_index(op.f('ix_a76_audit_logs_tenant_id'), 'audit_logs', ['tenant_id'], unique=False, schema='a76')
op.create_index(op.f('ix_a76_audit_logs_timestamp'), 'audit_logs', ['timestamp'], unique=False, schema='a76')
op.create_index(op.f('ix_a76_audit_logs_username'), 'audit_logs', ['username'], unique=False, schema='a76')
op.create_table('canadian_tariff_fractions',
sa.Column('id', sa.Integer(), nullable=False),
sa.Column('fraction', sa.String(length=13), nullable=False),
sa.Column('ad_valorem', sa.Numeric(precision=5, scale=2), nullable=True),
sa.Column('unit_of_measure', sa.String(length=5), nullable=True),
sa.Column('country_code', sa.String(length=3), nullable=False),
sa.Column('description', sa.String(length=1000), nullable=True),
sa.Column('tenant_id', sa.Integer(), nullable=False),
sa.Column('company_id', sa.Integer(), nullable=False),
sa.Column('deleted_at', sa.DateTime(), 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.ForeignKeyConstraint(['company_id'], ['a76.company.id'], ),
sa.ForeignKeyConstraint(['tenant_id'], ['core.tenants.id'], ),
sa.PrimaryKeyConstraint('id'),
sa.UniqueConstraint('fraction', 'country_code', 'company_id', name='uq_canadian_fraction_country_company'),
schema='a76'
)
op.create_index(op.f('ix_a76_canadian_tariff_fractions_company_id'), 'canadian_tariff_fractions', ['company_id'], unique=False, schema='a76')
op.create_index(op.f('ix_a76_canadian_tariff_fractions_country_code'), 'canadian_tariff_fractions', ['country_code'], unique=False, schema='a76')
op.create_index(op.f('ix_a76_canadian_tariff_fractions_fraction'), 'canadian_tariff_fractions', ['fraction'], unique=False, schema='a76')
op.create_index(op.f('ix_a76_canadian_tariff_fractions_id'), 'canadian_tariff_fractions', ['id'], unique=False, schema='a76')
op.create_index(op.f('ix_a76_canadian_tariff_fractions_tenant_id'), 'canadian_tariff_fractions', ['tenant_id'], unique=False, schema='a76')
op.create_table('classification_concepts',
sa.Column('id', sa.Integer(), autoincrement=True, nullable=False),
sa.Column('classification', sa.String(length=30), nullable=False),
sa.Column('description', sa.String(length=255), nullable=True),
sa.Column('tenant_id', sa.Integer(), nullable=False),
sa.Column('company_id', sa.Integer(), nullable=False),
sa.Column('deleted_at', sa.DateTime(), 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.ForeignKeyConstraint(['company_id'], ['a76.company.id'], ),
sa.ForeignKeyConstraint(['tenant_id'], ['core.tenants.id'], ),
sa.PrimaryKeyConstraint('id'),
sa.UniqueConstraint('classification', name='uq_classification_concept'),
schema='a76'
)
op.create_index(op.f('ix_a76_classification_concepts_company_id'), 'classification_concepts', ['company_id'], unique=False, schema='a76')
op.create_index(op.f('ix_a76_classification_concepts_tenant_id'), 'classification_concepts', ['tenant_id'], unique=False, schema='a76')
op.create_table('clients_and_providers',
sa.Column('id', sa.Integer(), nullable=False),
sa.Column('type_nat_foreign', sa.String(length=1), nullable=True),
sa.Column('name', sa.String(length=256), nullable=True),
sa.Column('short_name', sa.String(length=10), nullable=True),
sa.Column('rfc', sa.String(length=30), nullable=True),
sa.Column('curp', sa.String(length=19), nullable=True),
sa.Column('client_or_provider', sa.Enum('CLIENT', 'PROVIDER', 'BOTH', name='entity_client_or_provider'), nullable=False),
sa.Column('linking', sa.String(length=1), nullable=True),
sa.Column('transform_subassembly', sa.String(length=1), nullable=True),
sa.Column('extra_information', sa.String(length=399), nullable=True),
sa.Column('web_key', sa.String(length=40), nullable=True),
sa.Column('responsible', sa.String(length=80), nullable=True),
sa.Column('position', sa.String(length=30), nullable=True),
sa.Column('incoterm', sa.String(length=19), nullable=True),
sa.Column('is_active', sa.Boolean(), nullable=True),
sa.Column('tenant_id', sa.Integer(), nullable=False),
sa.Column('company_id', sa.Integer(), nullable=False),
sa.Column('deleted_at', sa.DateTime(), 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.ForeignKeyConstraint(['company_id'], ['a76.company.id'], ),
sa.ForeignKeyConstraint(['tenant_id'], ['core.tenants.id'], ),
sa.PrimaryKeyConstraint('id', name='clients_and_providers_pkey'),
schema='a76'
)
op.create_index(op.f('ix_a76_clients_and_providers_company_id'), 'clients_and_providers', ['company_id'], unique=False, schema='a76')
op.create_index(op.f('ix_a76_clients_and_providers_tenant_id'), 'clients_and_providers', ['tenant_id'], unique=False, schema='a76')
op.create_table('company_address',
sa.Column('id', sa.Integer(), nullable=False),
sa.Column('company_id', sa.Integer(), nullable=False),
sa.Column('address_type', sa.String(length=20), nullable=False),
sa.Column('street', sa.String(length=100), nullable=True),
sa.Column('exterior_number', sa.String(length=20), nullable=True),
sa.Column('interior_number', sa.String(length=20), nullable=True),
sa.Column('postal_code', sa.String(length=15), nullable=True),
sa.Column('neighborhood', sa.String(length=40), nullable=True),
sa.Column('city', sa.String(length=40), nullable=True),
sa.Column('municipality', sa.String(length=50), nullable=True),
sa.Column('state', sa.String(length=30), nullable=True),
sa.Column('country', sa.String(length=4), nullable=True),
sa.Column('phone', sa.String(length=30), nullable=True),
sa.Column('fax', sa.String(length=30), nullable=True),
sa.Column('email', sa.String(length=100), nullable=True),
sa.Column('deleted_at', sa.DateTime(), 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.ForeignKeyConstraint(['company_id'], ['a76.company.id'], ondelete='CASCADE'),
sa.PrimaryKeyConstraint('id'),
schema='a76'
)
op.create_index(op.f('ix_a76_company_address_company_id'), 'company_address', ['company_id'], unique=False, schema='a76')
op.create_table('company_certification',
sa.Column('id', sa.Integer(), nullable=False),
sa.Column('company_id', sa.Integer(), nullable=False),
sa.Column('is_certified_company', sa.Boolean(), nullable=True),
sa.Column('certified_company_registration', sa.String(length=40), nullable=True),
sa.Column('certified_company_start_date', sa.Date(), nullable=True),
sa.Column('certified_company_end_date', sa.Date(), nullable=True),
sa.Column('annex30_certification_date', sa.Date(), nullable=True),
sa.Column('annex30_certification_number', sa.String(length=50), nullable=True),
sa.Column('annex30_modality', sa.String(length=3), nullable=True),
sa.Column('annex30_company_type', sa.String(length=50), nullable=True),
sa.Column('annex30_renewal_date', sa.Date(), nullable=True),
sa.Column('annex30_final_certification_date', sa.Date(), nullable=True),
sa.Column('is_seciit_company', sa.Boolean(), nullable=True),
sa.Column('is_oea_company', sa.Boolean(), nullable=True),
sa.Column('ctpat_svi', sa.String(length=100), nullable=True),
sa.Column('trusted_exporter_number', sa.String(length=50), nullable=True),
sa.Column('neec_company', sa.Boolean(), nullable=True),
sa.Column('deleted_at', sa.DateTime(), 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.ForeignKeyConstraint(['company_id'], ['a76.company.id'], ondelete='CASCADE'),
sa.PrimaryKeyConstraint('id'),
schema='a76'
)
op.create_index(op.f('ix_a76_company_certification_company_id'), 'company_certification', ['company_id'], unique=True, schema='a76')
op.create_table('company_cfdi',
sa.Column('id', sa.Integer(), nullable=False),
sa.Column('company_id', sa.Integer(), nullable=False),
sa.Column('xml_save_path', sa.String(length=5000), nullable=True),
sa.Column('cfdi_app_path', sa.String(length=5000), nullable=True),
sa.Column('pac_app_path', sa.String(length=5000), nullable=True),
sa.Column('deleted_at', sa.DateTime(), 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.ForeignKeyConstraint(['company_id'], ['a76.company.id'], ondelete='CASCADE'),
sa.PrimaryKeyConstraint('id'),
schema='a76'
)
op.create_index(op.f('ix_a76_company_cfdi_company_id'), 'company_cfdi', ['company_id'], unique=True, schema='a76')
op.create_table('company_digital_certificate',
sa.Column('id', sa.Integer(), nullable=False),
sa.Column('company_id', sa.Integer(), nullable=False),
sa.Column('certificate_type', sa.String(length=20), nullable=False),
sa.Column('cer_file_path', sa.String(length=5000), nullable=True),
sa.Column('key_file_path', sa.String(length=5000), nullable=True),
sa.Column('password', sa.String(length=200), nullable=True),
sa.Column('access_key', sa.String(length=50), nullable=True),
sa.Column('cer_expiration_date', sa.Integer(), nullable=True),
sa.Column('key_expiration_date', sa.Integer(), nullable=True),
sa.Column('deleted_at', sa.DateTime(), 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.ForeignKeyConstraint(['company_id'], ['a76.company.id'], ondelete='CASCADE'),
sa.PrimaryKeyConstraint('id'),
schema='a76'
)
op.create_index(op.f('ix_a76_company_digital_certificate_company_id'), 'company_digital_certificate', ['company_id'], unique=False, schema='a76')
op.create_table('company_electronic_agent',
sa.Column('id', sa.Integer(), nullable=False),
sa.Column('company_id', sa.Integer(), nullable=False),
sa.Column('input_folder', sa.String(length=1000), nullable=True),
sa.Column('output_folder', sa.String(length=1000), nullable=True),
sa.Column('send_mask', sa.String(length=20), nullable=True),
sa.Column('response_mask', sa.String(length=20), nullable=True),
sa.Column('response_extension', sa.String(length=20), nullable=True),
sa.Column('counter_start', sa.Integer(), nullable=True),
sa.Column('counter_end', sa.Integer(), nullable=True),
sa.Column('counter_next', sa.Integer(), nullable=True),
sa.Column('deleted_at', sa.DateTime(), 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.ForeignKeyConstraint(['company_id'], ['a76.company.id'], ondelete='CASCADE'),
sa.PrimaryKeyConstraint('id'),
schema='a76'
)
op.create_index(op.f('ix_a76_company_electronic_agent_company_id'), 'company_electronic_agent', ['company_id'], unique=True, schema='a76')
op.create_table('company_prevalidator',
sa.Column('id', sa.Integer(), nullable=False),
sa.Column('company_id', sa.Integer(), nullable=False),
sa.Column('customs', sa.String(length=20), nullable=True),
sa.Column('key', sa.String(length=20), nullable=True),
sa.Column('patent', sa.String(length=4), nullable=True),
sa.Column('description', sa.String(length=100), nullable=True),
sa.Column('deleted_at', sa.DateTime(), 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.ForeignKeyConstraint(['company_id'], ['a76.company.id'], ondelete='CASCADE'),
sa.PrimaryKeyConstraint('id'),
schema='a76'
)
op.create_index(op.f('ix_a76_company_prevalidator_company_id'), 'company_prevalidator', ['company_id'], unique=True, schema='a76')
op.create_table('customs_brokers',
sa.Column('id', sa.Integer(), nullable=False),
sa.Column('type', sa.String(length=9), nullable=True),
sa.Column('broker_key', sa.String(length=5), nullable=False),
sa.Column('name', sa.String(length=80), nullable=True),
sa.Column('address', sa.String(length=1500), nullable=True),
sa.Column('postal_code', sa.String(length=15), nullable=True),
sa.Column('city', sa.String(length=30), nullable=True),
sa.Column('state', sa.String(length=30), nullable=True),
sa.Column('phone', sa.String(length=30), nullable=True),
sa.Column('fax', sa.String(length=30), nullable=True),
sa.Column('email', sa.String(length=100), nullable=True),
sa.Column('country', sa.String(length=3), nullable=True),
sa.Column('tax_id', sa.String(length=30), nullable=True),
sa.Column('personal_id', sa.String(length=20), nullable=True),
sa.Column('position', sa.String(length=30), nullable=True),
sa.Column('license', sa.String(length=4), nullable=True),
sa.Column('company', sa.String(length=200), nullable=True),
sa.Column('contact', sa.String(length=80), nullable=True),
sa.Column('tenant_id', sa.Integer(), nullable=False),
sa.Column('company_id', sa.Integer(), nullable=False),
sa.Column('deleted_at', sa.DateTime(), 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.ForeignKeyConstraint(['company_id'], ['a76.company.id'], ),
sa.ForeignKeyConstraint(['tenant_id'], ['core.tenants.id'], ),
sa.PrimaryKeyConstraint('id', name='customs_brokers_pkey'),
sa.UniqueConstraint('broker_key', 'tenant_id', 'company_id', name='uq_broker_key_tenant_company'),
schema='a76'
)
op.create_index(op.f('ix_a76_customs_brokers_company_id'), 'customs_brokers', ['company_id'], unique=False, schema='a76')
op.create_index(op.f('ix_a76_customs_brokers_tenant_id'), 'customs_brokers', ['tenant_id'], unique=False, schema='a76')
op.create_table('depreciation_catalog',
sa.Column('id', sa.Integer(), nullable=False),
sa.Column('fraction', sa.String(length=10), nullable=False),
sa.Column('description', sa.String(length=500), nullable=False),
sa.Column('depreciation_rate', sa.Numeric(precision=5, scale=2), nullable=False),
sa.Column('tenant_id', sa.Integer(), nullable=False),
sa.Column('company_id', sa.Integer(), nullable=False),
sa.Column('deleted_at', sa.DateTime(), 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.ForeignKeyConstraint(['company_id'], ['a76.company.id'], ),
sa.ForeignKeyConstraint(['tenant_id'], ['core.tenants.id'], ),
sa.PrimaryKeyConstraint('id', name='depreciation_catalog_pkey'),
schema='a76'
)
op.create_index(op.f('ix_a76_depreciation_catalog_company_id'), 'depreciation_catalog', ['company_id'], unique=False, schema='a76')
op.create_index(op.f('ix_a76_depreciation_catalog_description'), 'depreciation_catalog', ['description'], unique=False, schema='a76')
op.create_index(op.f('ix_a76_depreciation_catalog_fraction'), 'depreciation_catalog', ['fraction'], unique=False, schema='a76')
op.create_index(op.f('ix_a76_depreciation_catalog_tenant_id'), 'depreciation_catalog', ['tenant_id'], unique=False, schema='a76')
op.create_table('document_types_digitization',
sa.Column('id', sa.Integer(), nullable=False),
sa.Column('code', sa.String(length=10), nullable=False),
sa.Column('description', sa.Text(), nullable=False),
sa.Column('active', sa.Boolean(), server_default='true', nullable=False),
sa.Column('tenant_id', sa.Integer(), nullable=False),
sa.Column('company_id', sa.Integer(), nullable=False),
sa.Column('deleted_at', sa.DateTime(), 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.ForeignKeyConstraint(['company_id'], ['a76.company.id'], ),
sa.ForeignKeyConstraint(['tenant_id'], ['core.tenants.id'], ),
sa.PrimaryKeyConstraint('id', name='document_types_digitization_pkey'),
sa.UniqueConstraint('tenant_id', 'company_id', 'code', name='document_types_digitization_code_key'),
schema='a76'
)
op.create_index(op.f('ix_a76_document_types_digitization_code'), 'document_types_digitization', ['code'], unique=False, schema='a76')
op.create_index(op.f('ix_a76_document_types_digitization_company_id'), 'document_types_digitization', ['company_id'], unique=False, schema='a76')
op.create_index(op.f('ix_a76_document_types_digitization_tenant_id'), 'document_types_digitization', ['tenant_id'], unique=False, schema='a76')
op.create_table('doda',
sa.Column('id', sa.Integer(), autoincrement=True, nullable=False),
sa.Column('integration_number', sa.String(length=30), nullable=True),
sa.Column('doda_date', sa.Integer(), nullable=True),
sa.Column('doda_time', sa.Integer(), nullable=True),
sa.Column('dispatch_customs', sa.String(length=3), nullable=True),
sa.Column('customs_sections', sa.String(length=3), nullable=True),
sa.Column('patent', sa.String(length=4), nullable=True),
sa.Column('pedimentos', sa.String(length=80), nullable=True),
sa.Column('caat', sa.String(length=10), nullable=True),
sa.Column('transport_identification', sa.String(length=20), nullable=True),
sa.Column('fast_id', sa.String(length=20), nullable=True),
sa.Column('operation_type', sa.String(length=1), nullable=True),
sa.Column('selected', sa.Boolean(), nullable=True),
sa.Column('user_selected', sa.String(length=30), nullable=True),
sa.Column('last_user', sa.String(length=30), nullable=True),
sa.Column('responsible', sa.String(length=14), nullable=True),
sa.Column('carrier', sa.String(length=8), nullable=True),
sa.Column('shipments', sa.String(length=80), nullable=True),
sa.Column('pedimento_type', sa.String(length=30), nullable=True),
sa.Column('original_chain', sa.String(length=5000), nullable=True),
sa.Column('serial_number', sa.String(length=21), nullable=True),
sa.Column('electronic_signature', sa.String(length=2000), nullable=True),
sa.Column('transaction_number', sa.String(length=30), nullable=True),
sa.Column('status', sa.String(length=30), nullable=True),
sa.Column('linq_sat_qr', sa.String(length=1000), nullable=True),
sa.Column('sat_certificate', sa.String(length=2001), nullable=True),
sa.Column('sat_digital_seal', sa.Text(), nullable=True),
sa.Column('xml_doda_sent_path', sa.String(length=1000), nullable=True),
sa.Column('xml_doda_response_path', sa.String(length=1000), nullable=True),
sa.Column('doda_report_pdf_path', sa.String(length=1000), nullable=True),
sa.Column('doda_report_pdf_generated_at', sa.DateTime(), nullable=True),
sa.Column('doda_report_source_fingerprint', sa.String(length=64), nullable=True),
sa.Column('sat_original_chain', sa.Text(), nullable=True),
sa.Column('customs_clearance', sa.Integer(), nullable=True),
sa.Column('unique_badge_number', sa.String(length=250), nullable=True),
sa.Column('tenant_id', sa.Integer(), nullable=False),
sa.Column('company_id', sa.Integer(), nullable=False),
sa.Column('deleted_at', sa.DateTime(), 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.ForeignKeyConstraint(['company_id'], ['a76.company.id'], ),
sa.ForeignKeyConstraint(['tenant_id'], ['core.tenants.id'], ),
sa.PrimaryKeyConstraint('id', name='doda_pkey'),
schema='a76'
)
op.create_index(op.f('ix_a76_doda_company_id'), 'doda', ['company_id'], unique=False, schema='a76')
op.create_index(op.f('ix_a76_doda_tenant_id'), 'doda', ['tenant_id'], unique=False, schema='a76')
op.create_table(
"doda_alta_log",
sa.Column("id", sa.Integer(), autoincrement=True, nullable=False),
sa.Column("doda_id", sa.Integer(), nullable=True),
sa.Column("variant", sa.String(length=10), nullable=True),
sa.Column("action", sa.String(length=20), nullable=True),
sa.Column("responsible", sa.String(length=20), nullable=True),
sa.Column("patent", sa.String(length=10), nullable=True),
sa.Column("dispatch_customs", sa.String(length=10), nullable=True),
sa.Column("operation_type", sa.String(length=5), nullable=True),
sa.Column("integration_number", sa.String(length=50), nullable=True),
sa.Column("task_id", sa.String(length=255), nullable=True),
sa.Column("status", sa.String(length=30), nullable=True),
sa.Column("message", sa.String(length=2000), nullable=True),
sa.Column("result_json", sa.Text(), nullable=True),
sa.Column("tenant_id", sa.Integer(), nullable=False),
sa.Column("company_id", sa.Integer(), nullable=False),
sa.Column("deleted_at", sa.DateTime(), 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.ForeignKeyConstraint(["company_id"], ["a76.company.id"]),
sa.ForeignKeyConstraint(["tenant_id"], ["core.tenants.id"]),
sa.PrimaryKeyConstraint("id", name="doda_alta_log_pkey"),
schema="a76",
)
op.create_index(
op.f("ix_a76_doda_alta_log_company_id"),
"doda_alta_log",
["company_id"],
unique=False,
schema="a76",
)
op.create_index(
op.f("ix_a76_doda_alta_log_tenant_id"),
"doda_alta_log",
["tenant_id"],
unique=False,
schema="a76",
)
op.create_index(
op.f("ix_a76_doda_alta_log_doda_id"),
"doda_alta_log",
["doda_id"],
unique=False,
schema="a76",
)
op.create_index(
op.f("ix_a76_doda_alta_log_task_id"),
"doda_alta_log",
["task_id"],
unique=False,
schema="a76",
)
op.create_table('electronic_notices',
sa.Column('id', sa.Integer(), nullable=False),
sa.Column('notice_number', sa.String(length=500), nullable=True),
sa.Column('year', sa.String(length=20), nullable=True),
sa.Column('patent', sa.String(length=4), nullable=True),
sa.Column('pedimento', sa.String(length=15), nullable=True),
sa.Column('file_sent', sa.String(length=1000), nullable=True),
sa.Column('file_response', sa.String(length=1000), nullable=True),
sa.Column('status', sa.String(length=100), nullable=True),
sa.Column('invoice', sa.String(length=50), nullable=True),
sa.Column('validation_acknowledgment', sa.String(length=20), nullable=True),
sa.Column('fea', sa.String(length=1000), nullable=True),
sa.Column('certificate_number', sa.String(length=50), nullable=True),
sa.Column('tenant_id', sa.Integer(), nullable=False),
sa.Column('company_id', sa.Integer(), nullable=False),
sa.Column('deleted_at', sa.DateTime(), 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.ForeignKeyConstraint(['company_id'], ['a76.company.id'], ),
sa.ForeignKeyConstraint(['tenant_id'], ['core.tenants.id'], ),
sa.PrimaryKeyConstraint('id', name='electronic_notices_pkey'),
schema='a76'
)
op.create_index(op.f('ix_a76_electronic_notices_company_id'), 'electronic_notices', ['company_id'], unique=False, schema='a76')
op.create_index(op.f('ix_a76_electronic_notices_tenant_id'), 'electronic_notices', ['tenant_id'], unique=False, schema='a76')
op.create_table('equivalency_items',
sa.Column('id', sa.Integer(), autoincrement=True, nullable=False),
sa.Column('original_field', sa.String(length=100), nullable=False),
sa.Column('external_field', sa.String(length=100), nullable=False),
sa.Column('conversion_factor', sa.Numeric(precision=13, scale=6), nullable=True),
sa.Column('tenant_id', sa.Integer(), nullable=False),
sa.Column('company_id', sa.Integer(), nullable=False),
sa.Column('deleted_at', sa.DateTime(), 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.ForeignKeyConstraint(['company_id'], ['a76.company.id'], ),
sa.ForeignKeyConstraint(['tenant_id'], ['core.tenants.id'], ),
sa.PrimaryKeyConstraint('id'),
sa.UniqueConstraint('original_field', 'external_field', 'tenant_id', 'company_id', name='uq_equivalency_item_fields'),
schema='a76'
)
op.create_index(op.f('ix_a76_equivalency_items_company_id'), 'equivalency_items', ['company_id'], unique=False, schema='a76')
op.create_index(op.f('ix_a76_equivalency_items_tenant_id'), 'equivalency_items', ['tenant_id'], unique=False, schema='a76')
op.create_table('error_classifications',
sa.Column('id', sa.Integer(), autoincrement=True, nullable=False),
sa.Column('code', sa.String(length=100), nullable=False),
sa.Column('level', sa.String(length=3), nullable=True),
sa.Column('tenant_id', sa.Integer(), nullable=False),
sa.Column('company_id', sa.Integer(), nullable=False),
sa.Column('deleted_at', sa.DateTime(), 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.ForeignKeyConstraint(['company_id'], ['a76.company.id'], ),
sa.ForeignKeyConstraint(['tenant_id'], ['core.tenants.id'], ),
sa.PrimaryKeyConstraint('id', name='error_classifications_pkey'),
sa.UniqueConstraint('code'),
sa.UniqueConstraint('code', name='error_classifications_code_unique'),
schema='a76'
)
op.create_index(op.f('ix_a76_error_classifications_company_id'), 'error_classifications', ['company_id'], unique=False, schema='a76')
op.create_index(op.f('ix_a76_error_classifications_tenant_id'), 'error_classifications', ['tenant_id'], unique=False, schema='a76')
op.create_table('exchange_rate',
sa.Column('id', sa.Integer(), nullable=False),
sa.Column('date', sa.DateTime(), nullable=False),
sa.Column('value', sa.DECIMAL(precision=13, scale=6), nullable=True),
sa.Column('local_currency', sa.String(length=7), nullable=True),
sa.Column('foreign_currency', sa.String(length=7), nullable=True),
sa.Column('tenant_id', sa.Integer(), nullable=False),
sa.Column('company_id', sa.Integer(), nullable=False),
sa.Column('deleted_at', sa.DateTime(), 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.ForeignKeyConstraint(['company_id'], ['a76.company.id'], ),
sa.ForeignKeyConstraint(['tenant_id'], ['core.tenants.id'], ),
sa.PrimaryKeyConstraint('id', name='exchange_rate_pkey'),
sa.UniqueConstraint('tenant_id', 'company_id', 'date', name='uq_exchange_rate_date_tenant'),
schema='a76'
)
op.create_index(op.f('ix_a76_exchange_rate_company_id'), 'exchange_rate', ['company_id'], unique=False, schema='a76')
op.create_index(op.f('ix_a76_exchange_rate_tenant_id'), 'exchange_rate', ['tenant_id'], unique=False, schema='a76')
op.create_table('expediente_archivo',
sa.Column('id', sa.Integer(), autoincrement=True, nullable=False),
sa.Column('e_document', sa.String(length=50), nullable=True),
sa.Column('num_operacion', sa.String(length=50), nullable=True),
sa.Column('tipo_documento', sa.String(length=10), nullable=True),
sa.Column('archivo_digitalizado_en', sa.String(length=500), nullable=True),
sa.Column('fecha_digitalizacion', sa.Date(), nullable=True),
sa.Column('agente_aduanal', sa.String(length=50), nullable=True),
sa.Column('pedimento', sa.String(length=21), nullable=True),
sa.Column('rfc_consulta', sa.String(length=13), nullable=True),
sa.Column('nombre_archivo', sa.String(length=255), nullable=True),
sa.Column('status', sa.String(length=20), nullable=True),
sa.Column('task_id', sa.String(length=255), nullable=True),
sa.Column('external_task_id', sa.String(length=255), nullable=True),
sa.Column('acuse_pdf_path', sa.String(length=500), nullable=True),
sa.Column('envio_xml_path', sa.String(length=500), nullable=True),
sa.Column('respuesta_xml_path', sa.String(length=500), nullable=True),
sa.Column('consulta_envio_xml_path', sa.String(length=500), nullable=True),
sa.Column('consulta_respuesta_xml_path', sa.String(length=500), nullable=True),
sa.Column('tenant_id', sa.Integer(), nullable=False),
sa.Column('company_id', sa.Integer(), nullable=False),
sa.Column('deleted_at', sa.DateTime(), 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.ForeignKeyConstraint(['company_id'], ['a76.company.id'], ),
sa.ForeignKeyConstraint(['tenant_id'], ['core.tenants.id'], ),
sa.PrimaryKeyConstraint('id'),
schema='a76'
)
op.create_index(op.f('ix_a76_expediente_archivo_company_id'), 'expediente_archivo', ['company_id'], unique=False, schema='a76')
op.create_index(op.f('ix_a76_expediente_archivo_external_task_id'), 'expediente_archivo', ['external_task_id'], unique=False, schema='a76')
op.create_index(op.f('ix_a76_expediente_archivo_task_id'), 'expediente_archivo', ['task_id'], unique=False, schema='a76')
op.create_index(op.f('ix_a76_expediente_archivo_tenant_id'), 'expediente_archivo', ['tenant_id'], unique=False, schema='a76')
op.create_table('fda_catalog',
sa.Column('id', sa.Integer(), nullable=False),
sa.Column('fda_key', sa.String(length=20), nullable=False),
sa.Column('description', sa.String(length=500), nullable=False),
sa.Column('fda_code', sa.String(length=50), nullable=True),
sa.Column('requirements', sa.String(length=500), nullable=True),
sa.Column('manufacturer_number', sa.String(length=50), nullable=True),
sa.Column('country_of_production', sa.String(length=100), nullable=True),
sa.Column('storage_status', sa.String(length=100), nullable=True),
sa.Column('warehouse_code', sa.String(length=20), nullable=True),
sa.Column('call_atl', sa.String(length=20), nullable=True),
sa.Column('tenant_id', sa.Integer(), nullable=False),
sa.Column('company_id', sa.Integer(), nullable=False),
sa.Column('deleted_at', sa.DateTime(), 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.ForeignKeyConstraint(['company_id'], ['a76.company.id'], ),
sa.ForeignKeyConstraint(['tenant_id'], ['core.tenants.id'], ),
sa.PrimaryKeyConstraint('id', name='fda_catalog_pkey'),
sa.UniqueConstraint('tenant_id', 'company_id', 'fda_key', name='idx_fda_catalog_unique'),
schema='a76'
)
op.create_index(op.f('ix_a76_fda_catalog_company_id'), 'fda_catalog', ['company_id'], unique=False, schema='a76')
op.create_index(op.f('ix_a76_fda_catalog_description'), 'fda_catalog', ['description'], unique=False, schema='a76')
op.create_index(op.f('ix_a76_fda_catalog_fda_key'), 'fda_catalog', ['fda_key'], unique=False, schema='a76')
op.create_index(op.f('ix_a76_fda_catalog_tenant_id'), 'fda_catalog', ['tenant_id'], unique=False, schema='a76')
op.create_table('fraction_rule_octave',
sa.Column('id', sa.Integer(), autoincrement=True, nullable=False),
sa.Column('permission', sa.String(length=20), nullable=False),
sa.Column('line', sa.Integer(), nullable=False),
sa.Column('fraction', sa.String(length=10), nullable=False),
sa.Column('quota_quantity', sa.Numeric(precision=19, scale=8), nullable=True),
sa.Column('quantity_used', sa.Numeric(precision=23, scale=8), nullable=True),
sa.Column('quota_value', sa.Numeric(precision=23, scale=8), nullable=True),
sa.Column('value_used', sa.Numeric(precision=23, scale=8), nullable=True),
sa.Column('unit_cost_me', sa.Numeric(precision=23, scale=8), nullable=True),
sa.Column('unit_of_measure', sa.String(length=5), nullable=True),
sa.Column('tenant_id', sa.Integer(), nullable=False),
sa.Column('company_id', sa.Integer(), nullable=False),
sa.Column('deleted_at', sa.DateTime(), 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.ForeignKeyConstraint(['company_id'], ['a76.company.id'], ),
sa.ForeignKeyConstraint(['tenant_id'], ['core.tenants.id'], ),
sa.PrimaryKeyConstraint('id'),
sa.UniqueConstraint('tenant_id', 'company_id', 'permission', 'line', 'fraction', name='uq_fraction_rule_octave_permission_line_fraction'),
schema='a76'
)
op.create_index(op.f('ix_a76_fraction_rule_octave_company_id'), 'fraction_rule_octave', ['company_id'], unique=False, schema='a76')
op.create_index(op.f('ix_a76_fraction_rule_octave_tenant_id'), 'fraction_rule_octave', ['tenant_id'], unique=False, schema='a76')
op.create_table('historical_tariff_fractions',
sa.Column('id', sa.Integer(), nullable=False),
sa.Column('historical_fraction', sa.String(length=8), nullable=True),
sa.Column('nico', sa.String(length=2), nullable=True),
sa.Column('unit_of_measure_code', sa.String(length=10), nullable=True),
sa.Column('country', sa.String(length=3), nullable=True),
sa.Column('fraction_type', sa.String(length=7), nullable=True),
sa.Column('sector', sa.String(length=5), nullable=True),
sa.Column('import_tax_rate', sa.Numeric(precision=7, scale=2), nullable=True),
sa.Column('export_tax_rate', sa.Numeric(precision=7, scale=2), nullable=True),
sa.Column('publication_date', sa.DateTime(), nullable=True),
sa.Column('is_immex', sa.Boolean(), nullable=True),
sa.Column('normal_temporality', sa.Boolean(), nullable=True),
sa.Column('services_temporality', sa.Boolean(), nullable=True),
sa.Column('certified_temporality', sa.Boolean(), nullable=True),
sa.Column('by_log', sa.Boolean(), nullable=True),
sa.Column('end_date', sa.DateTime(), nullable=True),
sa.Column('tenant_id', sa.Integer(), nullable=False),
sa.Column('company_id', sa.Integer(), nullable=False),
sa.Column('deleted_at', sa.DateTime(), 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.ForeignKeyConstraint(['company_id'], ['a76.company.id'], ),
sa.ForeignKeyConstraint(['country'], ['public.countries.m3_key'], ),
sa.ForeignKeyConstraint(['tenant_id'], ['core.tenants.id'], ),
sa.ForeignKeyConstraint(['unit_of_measure_code'], ['a76.unit_of_measure_customs.code'], ),
sa.PrimaryKeyConstraint('id'),
schema='a76'
)
op.create_index(op.f('ix_a76_historical_tariff_fractions_company_id'), 'historical_tariff_fractions', ['company_id'], unique=False, schema='a76')
op.create_index(op.f('ix_a76_historical_tariff_fractions_tenant_id'), 'historical_tariff_fractions', ['tenant_id'], unique=False, schema='a76')
op.create_table('identifiers',
sa.Column('id', sa.Integer(), autoincrement=True, nullable=False),
sa.Column('code', sa.String(length=2), nullable=False),
sa.Column('description', sa.String(length=1000), nullable=True),
sa.Column('level', sa.String(length=1), nullable=True),
sa.Column('complement', sa.String(length=5000), nullable=True),
sa.Column('tenant_id', sa.Integer(), nullable=False),
sa.Column('company_id', sa.Integer(), nullable=False),
sa.Column('deleted_at', sa.DateTime(), 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.ForeignKeyConstraint(['company_id'], ['a76.company.id'], ),
sa.ForeignKeyConstraint(['tenant_id'], ['core.tenants.id'], ),
sa.PrimaryKeyConstraint('id'),
sa.UniqueConstraint('code', name='uq_identifier_code'),
schema='a76'
)
op.create_index(op.f('ix_a76_identifiers_company_id'), 'identifiers', ['company_id'], unique=False, schema='a76')
op.create_index(op.f('ix_a76_identifiers_tenant_id'), 'identifiers', ['tenant_id'], unique=False, schema='a76')
op.create_table('inpc',
sa.Column('id', sa.Integer(), autoincrement=True, nullable=False),
sa.Column('year', sa.String(length=4), nullable=False),
sa.Column('month', sa.String(length=2), nullable=False),
sa.Column('value', sa.Numeric(precision=19, scale=8), nullable=True),
sa.Column('tenant_id', sa.Integer(), nullable=False),
sa.Column('company_id', sa.Integer(), nullable=False),
sa.Column('deleted_at', sa.DateTime(), 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.ForeignKeyConstraint(['company_id'], ['a76.company.id'], ),
sa.ForeignKeyConstraint(['tenant_id'], ['core.tenants.id'], ),
sa.PrimaryKeyConstraint('id'),
sa.UniqueConstraint('year', 'month', 'tenant_id', 'company_id', name='uq_inpc_year_month'),
schema='a76'
)
op.create_index(op.f('ix_a76_inpc_company_id'), 'inpc', ['company_id'], unique=False, schema='a76')
op.create_index(op.f('ix_a76_inpc_tenant_id'), 'inpc', ['tenant_id'], unique=False, schema='a76')
op.create_table('invoice_header',
sa.Column('id', sa.BigInteger(), autoincrement=True, nullable=False),
sa.Column('system', sa.String(length=12), nullable=False),
sa.Column('operation_type', sa.String(length=11), nullable=False),
sa.Column('invoice_type', sa.String(length=5), nullable=False),
sa.Column('document_type', sa.String(length=3), nullable=True),
sa.Column('invoice_number', sa.String(length=100), nullable=False),
sa.Column('project_number', sa.String(length=14), nullable=True),
sa.Column('purchase_order', sa.String(length=50), nullable=True),
sa.Column('related_doc_id', sa.Integer(), nullable=True),
sa.Column('alternate_invoice', sa.String(length=99), nullable=True),
sa.Column('invoice_ref', sa.String(length=19), nullable=True),
sa.Column('proforma_number', sa.String(length=20), nullable=True),
sa.Column('invoice_date', sa.Date(), nullable=False),
sa.Column('capture_date', sa.TIMESTAMP(), server_default=sa.text('now()'), nullable=False),
sa.Column('emission_date', sa.Date(), nullable=True),
sa.Column('status', sa.String(length=10), nullable=False),
sa.Column('status_rec', sa.String(length=10), nullable=True),
sa.Column('status_rep', sa.String(length=10), nullable=True),
sa.Column('processed_date', sa.TIMESTAMP(), nullable=True),
sa.Column('who_processed', sa.String(length=100), nullable=True),
sa.Column('capture_user', sa.String(length=100), nullable=True),
sa.Column('traffic_light_status', sa.String(length=50), nullable=True),
sa.Column('process_log', sa.String(length=300), nullable=True),
sa.Column('observation_es', sa.Text(), nullable=True),
sa.Column('observation_en', sa.Text(), nullable=True),
sa.Column('comments_status', sa.Text(), nullable=True),
sa.Column('vu_observations', sa.String(length=500), nullable=True),
sa.Column('cfdi_uuid', sa.String(length=100), nullable=True),
sa.Column('path_pdf', sa.String(length=500), nullable=True),
sa.Column('path_xml', sa.String(length=500), nullable=True),
sa.Column('subcompany', sa.String(length=5), nullable=True),
sa.Column('party_count', sa.Integer(), nullable=True),
sa.Column('generate_id', sa.Boolean(), server_default='false', nullable=True),
sa.Column('generate_desc_parties', sa.String(length=12), nullable=True),
sa.Column('apply_manual_discount', sa.Boolean(), server_default='false', nullable=True),
sa.Column('is_bulk', sa.Boolean(), nullable=True),
sa.Column('download_substance', sa.Boolean(), nullable=True),
sa.Column('download_class', sa.Boolean(), nullable=True),
sa.Column('download_def', sa.Boolean(), nullable=True),
sa.Column('payment_terms', sa.String(length=200), nullable=True),
sa.Column('handling_fees', sa.Numeric(precision=19, scale=8), nullable=True),
sa.Column('option_iv18', sa.String(length=50), nullable=True),
sa.Column('enajenation_goods', sa.Boolean(), nullable=True),
sa.Column('tenant_id', sa.Integer(), nullable=False),
sa.Column('company_id', sa.Integer(), nullable=False),
sa.Column('deleted_at', sa.DateTime(), 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.ForeignKeyConstraint(['company_id'], ['a76.company.id'], ),
sa.ForeignKeyConstraint(['document_type'], ['public.pedimento_regimens.code'], ),
sa.ForeignKeyConstraint(['invoice_type'], ['public.invoice_types.key'], ),
sa.ForeignKeyConstraint(['tenant_id'], ['core.tenants.id'], ),
sa.PrimaryKeyConstraint('id'),
schema='a76'
)
op.create_index(op.f('ix_a76_invoice_header_company_id'), 'invoice_header', ['company_id'], unique=False, schema='a76')
op.create_index(op.f('ix_a76_invoice_header_tenant_id'), 'invoice_header', ['tenant_id'], unique=False, schema='a76')
op.create_table('invoice_settings',
sa.Column('id', sa.BigInteger(), autoincrement=True, nullable=False),
sa.Column('invoice_type', sa.String(length=5), nullable=False),
sa.Column('operation_type', sa.String(length=11), nullable=False),
sa.Column('settings', postgresql.JSONB(astext_type=sa.Text()), nullable=False),
sa.Column('tenant_id', sa.Integer(), nullable=False),
sa.Column('company_id', sa.Integer(), nullable=False),
sa.Column('deleted_at', sa.DateTime(), 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.ForeignKeyConstraint(['company_id'], ['a76.company.id'], ),
sa.ForeignKeyConstraint(['invoice_type'], ['public.invoice_types.key'], ),
sa.ForeignKeyConstraint(['tenant_id'], ['core.tenants.id'], ),
sa.PrimaryKeyConstraint('id'),
sa.UniqueConstraint('tenant_id', 'company_id', 'invoice_type', 'operation_type', name='uq_invoice_settings_tenant_company_type_op'),
schema='a76'
)
op.create_index(op.f('ix_a76_invoice_settings_company_id'), 'invoice_settings', ['company_id'], unique=False, schema='a76')
op.create_index(op.f('ix_a76_invoice_settings_tenant_id'), 'invoice_settings', ['tenant_id'], unique=False, schema='a76')
op.create_table('item_presets',
sa.Column('id', sa.Integer(), autoincrement=True, nullable=False),
sa.Column('name', sa.String(length=100), nullable=False),
sa.Column('description', sa.String(length=500), nullable=True),
sa.Column('items', sa.JSON(), nullable=False),
sa.Column('tenant_id', sa.Integer(), nullable=False),
sa.Column('company_id', sa.Integer(), nullable=False),
sa.Column('deleted_at', sa.DateTime(), 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.ForeignKeyConstraint(['company_id'], ['a76.company.id'], ),
sa.ForeignKeyConstraint(['tenant_id'], ['core.tenants.id'], ),
sa.PrimaryKeyConstraint('id'),
schema='a76'
)
op.create_index(op.f('ix_a76_item_presets_company_id'), 'item_presets', ['company_id'], unique=False, schema='a76')
op.create_index(op.f('ix_a76_item_presets_tenant_id'), 'item_presets', ['tenant_id'], unique=False, schema='a76')
op.create_table('legends',
sa.Column('id', sa.Integer(), autoincrement=True, nullable=False),
sa.Column('code', sa.Integer(), nullable=False),
sa.Column('description', sa.String(length=2000), nullable=True),
sa.Column('tenant_id', sa.Integer(), nullable=False),
sa.Column('company_id', sa.Integer(), nullable=False),
sa.Column('deleted_at', sa.DateTime(), 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.ForeignKeyConstraint(['company_id'], ['a76.company.id'], ),
sa.ForeignKeyConstraint(['tenant_id'], ['core.tenants.id'], ),
sa.PrimaryKeyConstraint('id'),
sa.UniqueConstraint('code', 'tenant_id', 'company_id', name='uq_legend_code'),
schema='a76'
)
op.create_index(op.f('ix_a76_legends_company_id'), 'legends', ['company_id'], unique=False, schema='a76')
op.create_index(op.f('ix_a76_legends_tenant_id'), 'legends', ['tenant_id'], unique=False, schema='a76')
op.create_table('location',
sa.Column('id', sa.Integer(), autoincrement=True, nullable=False),
sa.Column('clave_localizacion', sa.String(length=20), nullable=False),
sa.Column('localizacion', sa.String(length=200), nullable=True),
sa.Column('system', sa.String(length=20), nullable=False),
sa.Column('tenant_id', sa.Integer(), nullable=False),
sa.Column('company_id', sa.Integer(), nullable=False),
sa.Column('deleted_at', sa.DateTime(), 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.ForeignKeyConstraint(['company_id'], ['a76.company.id'], ),
sa.ForeignKeyConstraint(['tenant_id'], ['core.tenants.id'], ),
sa.PrimaryKeyConstraint('id'),
sa.UniqueConstraint('clave_localizacion', 'tenant_id', 'company_id', 'system', name='uq_location_clave_tenant_company_system'),
schema='a76'
)
op.create_index(op.f('ix_a76_location_company_id'), 'location', ['company_id'], unique=False, schema='a76')
op.create_index(op.f('ix_a76_location_tenant_id'), 'location', ['tenant_id'], unique=False, schema='a76')
op.create_table('manifest_anexos',
sa.Column('consecutive', sa.Integer(), nullable=False),
sa.Column('line_number', sa.Integer(), nullable=False),
sa.Column('attachment_type', sa.String(length=10), nullable=True),
sa.Column('number', sa.String(length=10), nullable=True),
sa.Column('attached_doc', sa.String(length=200), nullable=True),
sa.Column('tenant_id', sa.Integer(), nullable=False),
sa.Column('company_id', sa.Integer(), nullable=False),
sa.Column('deleted_at', sa.DateTime(), 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.ForeignKeyConstraint(['company_id'], ['a76.company.id'], ),
sa.ForeignKeyConstraint(['tenant_id'], ['core.tenants.id'], ),
sa.PrimaryKeyConstraint('consecutive', 'line_number', name='manifest_anexos_pkey'),
schema='a76'
)
op.create_index('idx_manifest_anexos_consecutive', 'manifest_anexos', ['consecutive'], unique=False, schema='a76')
op.create_index(op.f('ix_a76_manifest_anexos_company_id'), 'manifest_anexos', ['company_id'], unique=False, schema='a76')
op.create_index(op.f('ix_a76_manifest_anexos_tenant_id'), 'manifest_anexos', ['tenant_id'], unique=False, schema='a76')
op.create_table('manifest_drivers',
sa.Column('manifest_number', sa.String(length=15), nullable=False),
sa.Column('driver_name', sa.String(length=80), nullable=False),
sa.Column('driver_type', sa.String(length=1), nullable=True),
sa.Column('address_1', sa.String(length=100), nullable=True),
sa.Column('address_2', sa.String(length=100), nullable=True),
sa.Column('city', sa.String(length=30), nullable=True),
sa.Column('state', sa.String(length=30), nullable=True),
sa.Column('postal_code', sa.String(length=15), nullable=True),
sa.Column('country', sa.String(length=3), nullable=True),
sa.Column('tenant_id', sa.Integer(), nullable=False),
sa.Column('company_id', sa.Integer(), nullable=False),
sa.Column('deleted_at', sa.DateTime(), 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.ForeignKeyConstraint(['company_id'], ['a76.company.id'], ),
sa.ForeignKeyConstraint(['tenant_id'], ['core.tenants.id'], ),
sa.PrimaryKeyConstraint('manifest_number', 'driver_name', name='manifest_drivers_pkey'),
schema='a76'
)
op.create_index('idx_manifest_drivers_manifest_number', 'manifest_drivers', ['manifest_number'], unique=False, schema='a76')
op.create_index(op.f('ix_a76_manifest_drivers_company_id'), 'manifest_drivers', ['company_id'], unique=False, schema='a76')
op.create_index(op.f('ix_a76_manifest_drivers_tenant_id'), 'manifest_drivers', ['tenant_id'], unique=False, schema='a76')
op.create_table('manifests',
sa.Column('id', sa.Integer(), autoincrement=True, nullable=False),
sa.Column('manifest_number', sa.String(length=15), nullable=True),
sa.Column('importer_details', sa.String(length=60), nullable=True),
sa.Column('person_in_charge', sa.String(length=60), nullable=True),
sa.Column('consigned_to', sa.String(length=8), nullable=True),
sa.Column('sent_by', sa.String(length=8), nullable=True),
sa.Column('foreign_exit_port', sa.String(length=6), nullable=True),
sa.Column('foreign_exit_port_loc', sa.String(length=4), nullable=True),
sa.Column('destination_port', sa.String(length=6), nullable=True),
sa.Column('destination_port_loc', sa.String(length=4), nullable=True),
sa.Column('entry_port', sa.String(length=6), nullable=True),
sa.Column('entry_port_loc', sa.String(length=4), nullable=True),
sa.Column('entry_date', sa.Integer(), nullable=True),
sa.Column('net_weight', sa.Numeric(precision=19, scale=8), nullable=True),
sa.Column('gross_weight', sa.Numeric(precision=19, scale=8), nullable=True),
sa.Column('total_value', sa.Numeric(precision=19, scale=8), nullable=True),
sa.Column('description', sa.String(length=2500), nullable=True),
sa.Column('broker_code', sa.String(length=5), nullable=True),
sa.Column('carrier_code', sa.String(length=5), nullable=True),
sa.Column('payment_invoice_number', sa.String(length=5), nullable=True),
sa.Column('seal_number', sa.String(length=30), nullable=True),
sa.Column('entry_hour', sa.Integer(), nullable=True),
sa.Column('hazardous_material', sa.String(length=2), nullable=True),
sa.Column('transport_mode', sa.String(length=2), nullable=True),
sa.Column('transport_code', sa.String(length=14), nullable=True),
sa.Column('trailer_number', sa.String(length=20), nullable=True),
sa.Column('status', sa.String(length=14), nullable=True),
sa.Column('status_description', sa.String(length=1000), nullable=True),
sa.Column('manifest_type', sa.String(length=3), nullable=True),
sa.Column('tenant_id', sa.Integer(), nullable=False),
sa.Column('company_id', sa.Integer(), nullable=False),
sa.Column('deleted_at', sa.DateTime(), 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.ForeignKeyConstraint(['company_id'], ['a76.company.id'], ),
sa.ForeignKeyConstraint(['tenant_id'], ['core.tenants.id'], ),
sa.PrimaryKeyConstraint('id'),
schema='a76'
)
op.create_index('idx_manifests_manifest_number', 'manifests', ['manifest_number'], unique=False, schema='a76')
op.create_index(op.f('ix_a76_manifests_company_id'), 'manifests', ['company_id'], unique=False, schema='a76')
op.create_index(op.f('ix_a76_manifests_tenant_id'), 'manifests', ['tenant_id'], unique=False, schema='a76')
op.create_table('multi_currency_types',
sa.Column('id', sa.Integer(), autoincrement=True, nullable=False),
sa.Column('currency_type_code', sa.String(length=3), nullable=False),
sa.Column('country_key', sa.String(length=3), nullable=True),
sa.Column('conversion_factor', sa.Numeric(precision=13, scale=6), nullable=True),
sa.Column('publication_date', sa.Integer(), nullable=False),
sa.Column('tenant_id', sa.Integer(), nullable=False),
sa.Column('company_id', sa.Integer(), nullable=False),
sa.Column('deleted_at', sa.DateTime(), 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.ForeignKeyConstraint(['company_id'], ['a76.company.id'], ),
sa.ForeignKeyConstraint(['country_key'], ['public.countries.m3_key'], ),
sa.ForeignKeyConstraint(['currency_type_code'], ['public.currency_types.code'], ),
sa.ForeignKeyConstraint(['tenant_id'], ['core.tenants.id'], ),
sa.PrimaryKeyConstraint('id'),
sa.UniqueConstraint('currency_type_code', 'publication_date', 'tenant_id', 'company_id', name='uq_multi_currency_type_code_date'),
schema='a76'
)
op.create_index(op.f('ix_a76_multi_currency_types_company_id'), 'multi_currency_types', ['company_id'], unique=False, schema='a76')
op.create_index(op.f('ix_a76_multi_currency_types_tenant_id'), 'multi_currency_types', ['tenant_id'], unique=False, schema='a76')
op.create_table('octave_balance',
sa.Column('invoice_import', sa.String(length=15), nullable=False),
sa.Column('part_number', sa.String(length=70), nullable=False),
sa.Column('origin_country', sa.String(length=3), nullable=False),
sa.Column('fraction_type', sa.String(length=7), nullable=False),
sa.Column('sector', sa.String(length=8), nullable=False),
sa.Column('octave_permit', sa.String(length=100), nullable=False),
sa.Column('origin', sa.String(length=3), nullable=False),
sa.Column('system', sa.String(length=5), nullable=False),
sa.Column('line', sa.Integer(), nullable=False),
sa.Column('quantity_stock', sa.Numeric(precision=19, scale=8), nullable=True),
sa.Column('unit_of_measure', sa.String(length=5), nullable=True),
sa.Column('class_code', sa.String(length=8), nullable=True),
sa.Column('import_fraction', sa.String(length=10), nullable=True),
sa.Column('ro_fraction', sa.String(length=10), nullable=True),
sa.Column('value_me', sa.Numeric(precision=23, scale=8), nullable=True),
sa.Column('tenant_id', sa.Integer(), nullable=False),
sa.Column('company_id', sa.Integer(), nullable=False),
sa.Column('deleted_at', sa.DateTime(), 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.ForeignKeyConstraint(['company_id'], ['a76.company.id'], ),
sa.ForeignKeyConstraint(['tenant_id'], ['core.tenants.id'], ),
sa.PrimaryKeyConstraint('tenant_id', 'company_id', 'invoice_import', 'part_number', 'origin_country', 'fraction_type', 'sector', 'octave_permit', 'origin', 'system', 'line', name='pk_octave_balance'),
schema='a76'
)
op.create_index(op.f('ix_a76_octave_balance_company_id'), 'octave_balance', ['company_id'], unique=False, schema='a76')
op.create_index(op.f('ix_a76_octave_balance_tenant_id'), 'octave_balance', ['tenant_id'], unique=False, schema='a76')
op.create_table('packages',
sa.Column('id', sa.Integer(), nullable=False),
sa.Column('key', sa.String(length=5), nullable=False),
sa.Column('description_es', sa.String(length=40), nullable=True),
sa.Column('description_en', sa.String(length=40), nullable=True),
sa.Column('weight_unit', sa.DECIMAL(precision=19, scale=8), nullable=True),
sa.Column('plurals', sa.String(length=4), nullable=True),
sa.Column('plural_in', sa.String(length=4), nullable=True),
sa.Column('code_ace', sa.String(length=4), nullable=True),
sa.Column('code_aamex', sa.String(length=9), nullable=True),
sa.Column('tenant_id', sa.Integer(), nullable=False),
sa.Column('company_id', sa.Integer(), nullable=False),
sa.Column('deleted_at', sa.DateTime(), 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.ForeignKeyConstraint(['company_id'], ['a76.company.id'], ),
sa.ForeignKeyConstraint(['tenant_id'], ['core.tenants.id'], ),
sa.PrimaryKeyConstraint('id', name='packages_pkey'),
sa.UniqueConstraint('tenant_id', 'company_id', 'key', name='packages_key_ukey'),
schema='a76'
)
op.create_index(op.f('ix_a76_packages_company_id'), 'packages', ['company_id'], unique=False, schema='a76')
op.create_index(op.f('ix_a76_packages_tenant_id'), 'packages', ['tenant_id'], unique=False, schema='a76')
op.create_table('packing_lists',
sa.Column('id', sa.Integer(), autoincrement=True, nullable=False),
sa.Column('item_line_id', sa.Integer(), nullable=False),
sa.Column('packing_list_number', sa.String(length=100), nullable=True),
sa.Column('tenant_id', sa.Integer(), nullable=False),
sa.Column('company_id', sa.Integer(), nullable=False),
sa.Column('deleted_at', sa.DateTime(), 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.ForeignKeyConstraint(['company_id'], ['a76.company.id'], ),
sa.ForeignKeyConstraint(['tenant_id'], ['core.tenants.id'], ),
sa.PrimaryKeyConstraint('id'),
schema='a76'
)
op.create_index(op.f('ix_a76_packing_lists_company_id'), 'packing_lists', ['company_id'], unique=False, schema='a76')
op.create_index(op.f('ix_a76_packing_lists_tenant_id'), 'packing_lists', ['tenant_id'], unique=False, schema='a76')
op.create_table('permission_rule_oct',
sa.Column('id', sa.Integer(), nullable=False),
sa.Column('permission', sa.String(length=20), nullable=False),
sa.Column('start_date', sa.Integer(), nullable=True),
sa.Column('end_date', sa.Integer(), nullable=True),
sa.Column('sector', sa.String(length=8), nullable=True),
sa.Column('system', sa.String(length=5), nullable=True),
sa.Column('tenant_id', sa.Integer(), nullable=False),
sa.Column('company_id', sa.Integer(), nullable=False),
sa.Column('deleted_at', sa.DateTime(), 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.ForeignKeyConstraint(['company_id'], ['a76.company.id'], ),
sa.ForeignKeyConstraint(['tenant_id'], ['core.tenants.id'], ),
sa.PrimaryKeyConstraint('id', name='permission_rule_oct_pkey'),
sa.UniqueConstraint('tenant_id', 'company_id', 'permission', name='permission_rule_oct_permission_tenant_ukey'),
schema='a76'
)
op.create_index(op.f('ix_a76_permission_rule_oct_company_id'), 'permission_rule_oct', ['company_id'], unique=False, schema='a76')
op.create_index(op.f('ix_a76_permission_rule_oct_tenant_id'), 'permission_rule_oct', ['tenant_id'], unique=False, schema='a76')
op.create_table('permission_rule_octave',
sa.Column('id', sa.Integer(), autoincrement=True, nullable=False),
sa.Column('permission', sa.String(length=20), nullable=False),
sa.Column('start_date', sa.DateTime(), nullable=True),
sa.Column('end_date', sa.DateTime(), nullable=True),
sa.Column('sector', sa.String(length=8), nullable=True),
sa.Column('system', sa.String(length=5), nullable=True),
sa.Column('tenant_id', sa.Integer(), nullable=False),
sa.Column('company_id', sa.Integer(), nullable=False),
sa.Column('deleted_at', sa.DateTime(), 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.ForeignKeyConstraint(['company_id'], ['a76.company.id'], ),
sa.ForeignKeyConstraint(['tenant_id'], ['core.tenants.id'], ),
sa.PrimaryKeyConstraint('id'),
sa.UniqueConstraint('tenant_id', 'company_id', 'permission', name='uq_permissions_rule_octave_permission'),
schema='a76'
)
op.create_index(op.f('ix_a76_permission_rule_octave_company_id'), 'permission_rule_octave', ['company_id'], unique=False, schema='a76')
op.create_index(op.f('ix_a76_permission_rule_octave_tenant_id'), 'permission_rule_octave', ['tenant_id'], unique=False, schema='a76')
op.create_table('ports',
sa.Column('id', sa.Integer(), autoincrement=True, nullable=False),
sa.Column('port_code', sa.String(length=6), nullable=False),
sa.Column('description', sa.String(length=20), nullable=True),
sa.Column('location_code', sa.String(length=4), nullable=False),
sa.Column('location_description', sa.String(length=20), nullable=True),
sa.Column('port_type', sa.String(length=15), server_default='ENTRY', nullable=False),
sa.Column('tenant_id', sa.Integer(), nullable=False),
sa.Column('company_id', sa.Integer(), nullable=False),
sa.Column('deleted_at', sa.DateTime(), 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.ForeignKeyConstraint(['company_id'], ['a76.company.id'], ),
sa.ForeignKeyConstraint(['tenant_id'], ['core.tenants.id'], ),
sa.PrimaryKeyConstraint('id'),
sa.UniqueConstraint('port_code', 'location_code', 'tenant_id', 'company_id', name='uq_port_location'),
schema='a76'
)
op.create_index(op.f('ix_a76_ports_company_id'), 'ports', ['company_id'], unique=False, schema='a76')
op.create_index(op.f('ix_a76_ports_tenant_id'), 'ports', ['tenant_id'], unique=False, schema='a76')
op.create_table('prevalidators',
sa.Column('id', sa.Integer(), nullable=False),
sa.Column('code', sa.String(length=20), nullable=False),
sa.Column('customs_prevalidator', sa.String(length=20), nullable=True),
sa.Column('patent_prevalidator', sa.String(length=20), nullable=True),
sa.Column('description', sa.String(length=50), nullable=True),
sa.Column('tenant_id', sa.Integer(), nullable=False),
sa.Column('company_id', sa.Integer(), nullable=False),
sa.Column('deleted_at', sa.DateTime(), 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.ForeignKeyConstraint(['company_id'], ['a76.company.id'], ),
sa.ForeignKeyConstraint(['tenant_id'], ['core.tenants.id'], ),
sa.PrimaryKeyConstraint('id', name='prevalidators_pkey'),
sa.UniqueConstraint('code', 'tenant_id', 'company_id', name='prevalidators_code_unique'),
schema='a76'
)
op.create_index(op.f('ix_a76_prevalidators_company_id'), 'prevalidators', ['company_id'], unique=False, schema='a76')
op.create_index(op.f('ix_a76_prevalidators_tenant_id'), 'prevalidators', ['tenant_id'], unique=False, schema='a76')
op.create_table('previous_fractions',
sa.Column('id', sa.Integer(), autoincrement=True, nullable=False),
sa.Column('current_fraction', sa.String(length=50), nullable=True),
sa.Column('previous_fraction', sa.String(length=50), nullable=True),
sa.Column('tenant_id', sa.Integer(), nullable=False),
sa.Column('company_id', sa.Integer(), nullable=False),
sa.Column('deleted_at', sa.DateTime(), 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.ForeignKeyConstraint(['company_id'], ['a76.company.id'], ),
sa.ForeignKeyConstraint(['tenant_id'], ['core.tenants.id'], ),
sa.PrimaryKeyConstraint('id'),
schema='a76'
)
op.create_index(op.f('ix_a76_previous_fractions_company_id'), 'previous_fractions', ['company_id'], unique=False, schema='a76')
op.create_index(op.f('ix_a76_previous_fractions_tenant_id'), 'previous_fractions', ['tenant_id'], unique=False, schema='a76')
op.create_table('seal',
sa.Column('id', sa.Integer(), nullable=False),
sa.Column('seal', sa.String(length=15), nullable=False),
sa.Column('tenant_id', sa.Integer(), nullable=False),
sa.Column('company_id', sa.Integer(), nullable=False),
sa.Column('deleted_at', sa.DateTime(), 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.ForeignKeyConstraint(['company_id'], ['a76.company.id'], ),
sa.ForeignKeyConstraint(['tenant_id'], ['core.tenants.id'], ),
sa.PrimaryKeyConstraint('id', name='seal_pkey'),
sa.UniqueConstraint('tenant_id', 'company_id', 'seal', name='seal_ukey'),
schema='a76'
)
op.create_index(op.f('ix_a76_seal_company_id'), 'seal', ['company_id'], unique=False, schema='a76')
op.create_index(op.f('ix_a76_seal_tenant_id'), 'seal', ['tenant_id'], unique=False, schema='a76')
op.create_table('sectors',
sa.Column('id', sa.Integer(), nullable=False),
sa.Column('key', sa.String(length=8), nullable=False),
sa.Column('description', sa.String(length=150), nullable=False),
sa.Column('authorized', sa.Boolean(), server_default='false', nullable=True),
sa.Column('tenant_id', sa.Integer(), nullable=False),
sa.Column('company_id', sa.Integer(), nullable=False),
sa.Column('deleted_at', sa.DateTime(), 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.ForeignKeyConstraint(['company_id'], ['a76.company.id'], ),
sa.ForeignKeyConstraint(['tenant_id'], ['core.tenants.id'], ),
sa.PrimaryKeyConstraint('id', name='sectors_pkey'),
sa.UniqueConstraint('tenant_id', 'company_id', 'key', name='sectors_key_ukey'),
schema='a76'
)
op.create_index(op.f('ix_a76_sectors_company_id'), 'sectors', ['company_id'], unique=False, schema='a76')
op.create_index(op.f('ix_a76_sectors_tenant_id'), 'sectors', ['tenant_id'], unique=False, schema='a76')
op.create_table('signatures',
sa.Column('id', sa.Integer(), autoincrement=True, nullable=False),
sa.Column('code', sa.String(length=10), nullable=False),
sa.Column('signature', sa.String(length=1000), nullable=True),
sa.Column('photo_path', sa.String(length=1000), nullable=True),
sa.Column('tenant_id', sa.Integer(), nullable=False),
sa.Column('company_id', sa.Integer(), nullable=False),
sa.Column('deleted_at', sa.DateTime(), 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.ForeignKeyConstraint(['company_id'], ['a76.company.id'], ),
sa.ForeignKeyConstraint(['tenant_id'], ['core.tenants.id'], ),
sa.PrimaryKeyConstraint('id', name='signatures_pkey'),
sa.UniqueConstraint('code', 'tenant_id', 'company_id', name='signatures_code_unique'),
schema='a76'
)
op.create_index(op.f('ix_a76_signatures_company_id'), 'signatures', ['company_id'], unique=False, schema='a76')
op.create_index(op.f('ix_a76_signatures_tenant_id'), 'signatures', ['tenant_id'], unique=False, schema='a76')
op.create_table('subassembly_entries',
sa.Column('id', sa.Integer(), autoincrement=True, nullable=False),
sa.Column('remission_line', sa.Integer(), nullable=False),
sa.Column('exit_invoice', sa.String(length=15), nullable=True),
sa.Column('exit_line', sa.Integer(), nullable=True),
sa.Column('tenant_id', sa.Integer(), nullable=False),
sa.Column('company_id', sa.Integer(), nullable=False),
sa.Column('deleted_at', sa.DateTime(), 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.ForeignKeyConstraint(['company_id'], ['a76.company.id'], ),
sa.ForeignKeyConstraint(['tenant_id'], ['core.tenants.id'], ),
sa.PrimaryKeyConstraint('id'),
schema='a76'
)
op.create_index(op.f('ix_a76_subassembly_entries_company_id'), 'subassembly_entries', ['company_id'], unique=False, schema='a76')
op.create_index(op.f('ix_a76_subassembly_entries_tenant_id'), 'subassembly_entries', ['tenant_id'], unique=False, schema='a76')
op.create_table('trailer',
sa.Column('trailer_number', sa.String(length=20), nullable=False),
sa.Column('trailer_id', sa.BigInteger(), nullable=False),
sa.Column('ace_trailer_number', sa.String(length=10), nullable=True),
sa.Column('trailer_type_key', sa.String(length=2), nullable=True),
sa.Column('seal', sa.String(length=15), nullable=True),
sa.Column('entity_code', sa.String(length=1), nullable=True),
sa.Column('plate_number', sa.String(length=17), nullable=True),
sa.Column('state', sa.String(length=30), nullable=True),
sa.Column('country', sa.String(length=3), nullable=True),
sa.Column('container_key', sa.String(length=3), nullable=True),
sa.Column('tenant_id', sa.Integer(), nullable=False),
sa.Column('company_id', sa.Integer(), nullable=False),
sa.Column('deleted_at', sa.DateTime(), 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.ForeignKeyConstraint(['company_id'], ['a76.company.id'], ),
sa.ForeignKeyConstraint(['tenant_id'], ['core.tenants.id'], ),
sa.ForeignKeyConstraint(['trailer_type_key'], ['public.trailer_type.trailer_type_key'], ),
sa.PrimaryKeyConstraint('trailer_number'),
schema='a76'
)
op.create_index(op.f('ix_a76_trailer_company_id'), 'trailer', ['company_id'], unique=False, schema='a76')
op.create_index(op.f('ix_a76_trailer_tenant_id'), 'trailer', ['tenant_id'], unique=False, schema='a76')
op.create_index(op.f('ix_a76_trailer_trailer_id'), 'trailer', ['trailer_id'], unique=True, schema='a76')
op.create_table('transporter',
sa.Column('transporter_key', sa.String(length=23), nullable=False),
sa.Column('transporter_id', sa.BigInteger(), nullable=False),
sa.Column('name', sa.String(length=256), nullable=True),
sa.Column('short_name', sa.String(length=10), nullable=True),
sa.Column('responsible', sa.String(length=100), nullable=True),
sa.Column('rfc', sa.String(length=30), nullable=True),
sa.Column('streets', sa.String(length=100), nullable=True),
sa.Column('postal_code', sa.String(length=15), nullable=True),
sa.Column('city', sa.String(length=30), nullable=True),
sa.Column('state', sa.String(length=30), nullable=True),
sa.Column('country', sa.String(length=3), nullable=True),
sa.Column('loader_code', sa.String(length=9), nullable=True),
sa.Column('caat_code', sa.String(length=49), nullable=True),
sa.Column('transport_code', sa.String(length=8), nullable=True),
sa.Column('transport_interface_type', sa.String(length=20), nullable=True),
sa.Column('ftp_server', sa.String(length=200), nullable=True),
sa.Column('ftp_user', sa.String(length=200), nullable=True),
sa.Column('ftp_password', sa.String(length=100), nullable=True),
sa.Column('ftp_directory', sa.String(length=1000), nullable=True),
sa.Column('filler_code', sa.String(length=20), nullable=True),
sa.Column('has_express_line', sa.Boolean(), server_default='false', nullable=False),
sa.Column('tenant_id', sa.Integer(), nullable=False),
sa.Column('company_id', sa.Integer(), nullable=False),
sa.Column('deleted_at', sa.DateTime(), 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.ForeignKeyConstraint(['company_id'], ['a76.company.id'], ),
sa.ForeignKeyConstraint(['tenant_id'], ['core.tenants.id'], ),
sa.PrimaryKeyConstraint('transporter_key'),
schema='a76'
)
op.create_index(op.f('ix_a76_transporter_company_id'), 'transporter', ['company_id'], unique=False, schema='a76')
op.create_index(op.f('ix_a76_transporter_tenant_id'), 'transporter', ['tenant_id'], unique=False, schema='a76')
op.create_index(op.f('ix_a76_transporter_transporter_id'), 'transporter', ['transporter_id'], unique=True, schema='a76')
op.create_table('units_of_measure',
sa.Column('id', sa.Integer(), autoincrement=True, nullable=False),
sa.Column('code', sa.String(length=5), nullable=False),
sa.Column('description', sa.String(length=100), nullable=True),
sa.Column('description_en', sa.String(length=100), nullable=True),
sa.Column('customs_code', sa.String(length=10), nullable=True),
sa.Column('american_code', sa.String(length=3), nullable=True),
sa.Column('ace_code', sa.String(length=4), nullable=True),
sa.Column('oma_code', sa.String(length=10), nullable=True),
sa.Column('tenant_id', sa.Integer(), nullable=False),
sa.Column('company_id', sa.Integer(), nullable=False),
sa.Column('deleted_at', sa.DateTime(), 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.ForeignKeyConstraint(['ace_code'], ['a76.unit_of_measure_ace.code'], ),
sa.ForeignKeyConstraint(['american_code'], ['a76.unit_of_measure_american.code'], ),
sa.ForeignKeyConstraint(['company_id'], ['a76.company.id'], ),
sa.ForeignKeyConstraint(['customs_code'], ['a76.unit_of_measure_customs.code'], ),
sa.ForeignKeyConstraint(['oma_code'], ['a76.unit_of_measure_oma.code'], ),
sa.ForeignKeyConstraint(['tenant_id'], ['core.tenants.id'], ),
sa.PrimaryKeyConstraint('id'),
sa.UniqueConstraint('code', 'tenant_id', 'company_id', name='uq_uom_code'),
schema='a76'
)
op.create_index(op.f('ix_a76_units_of_measure_company_id'), 'units_of_measure', ['company_id'], unique=False, schema='a76')
op.create_index(op.f('ix_a76_units_of_measure_tenant_id'), 'units_of_measure', ['tenant_id'], unique=False, schema='a76')
op.create_table('units_of_measure_general',
sa.Column('id', sa.Integer(), autoincrement=True, nullable=False),
sa.Column('code', sa.String(length=5), nullable=False),
sa.Column('description', sa.String(length=100), nullable=True),
sa.Column('conversion_factor', sa.Numeric(precision=13, scale=6), nullable=True),
sa.Column('mexico_unit', sa.String(length=5), nullable=True),
sa.Column('american_unit_code', sa.String(length=3), nullable=True),
sa.Column('customs_code', sa.String(length=10), nullable=True),
sa.Column('ace_code', sa.String(length=4), nullable=True),
sa.Column('tenant_id', sa.Integer(), nullable=False),
sa.Column('company_id', sa.Integer(), nullable=False),
sa.Column('deleted_at', sa.DateTime(), 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.ForeignKeyConstraint(['ace_code'], ['a76.unit_of_measure_ace.code'], ),
sa.ForeignKeyConstraint(['ace_code'], ['a76.unit_of_measure_ace.code'], name='fk_uom_general_ace', use_alter=True),
sa.ForeignKeyConstraint(['american_unit_code'], ['a76.unit_of_measure_american.code'], ),
sa.ForeignKeyConstraint(['company_id'], ['a76.company.id'], ),
sa.ForeignKeyConstraint(['customs_code'], ['a76.unit_of_measure_customs.code'], ),
sa.ForeignKeyConstraint(['customs_code'], ['a76.unit_of_measure_customs.code'], name='fk_uom_general_customs', use_alter=True),
sa.ForeignKeyConstraint(['tenant_id'], ['core.tenants.id'], ),
sa.PrimaryKeyConstraint('id'),
sa.UniqueConstraint('code', 'tenant_id', 'company_id', name='uq_uom_general_code'),
schema='a76'
)
op.create_index(op.f('ix_a76_units_of_measure_general_company_id'), 'units_of_measure_general', ['company_id'], unique=False, schema='a76')
op.create_index(op.f('ix_a76_units_of_measure_general_tenant_id'), 'units_of_measure_general', ['tenant_id'], unique=False, schema='a76')
op.create_table('us_tariff_fractions',
sa.Column('id', sa.Integer(), nullable=False),
sa.Column('code', sa.String(length=16), nullable=False, comment='Código de fracción americana'),
sa.Column('prefix', sa.String(length=10), nullable=True, comment='Prefijo de clasificación'),
sa.Column('type_code', sa.String(length=10), nullable=True, comment='Código de tipo'),
sa.Column('ad_valorem', sa.Numeric(precision=10, scale=2), nullable=True, comment='Porcentaje ad valorem'),
sa.Column('fixed_cost', sa.Numeric(precision=15, scale=8), nullable=True, comment='Tasa fija'),
sa.Column('unit_of_measure', sa.String(length=10), nullable=True, comment='Unidad de medida'),
sa.Column('description', sa.String(), nullable=True, comment='Descripción de la fracción'),
sa.Column('tenant_id', sa.Integer(), nullable=False),
sa.Column('company_id', sa.Integer(), nullable=False),
sa.Column('deleted_at', sa.DateTime(), 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.ForeignKeyConstraint(['company_id'], ['a76.company.id'], ),
sa.ForeignKeyConstraint(['tenant_id'], ['core.tenants.id'], ),
sa.PrimaryKeyConstraint('id'),
schema='a76'
)
op.create_index(op.f('ix_a76_us_tariff_fractions_company_id'), 'us_tariff_fractions', ['company_id'], unique=False, schema='a76')
op.create_index(op.f('ix_a76_us_tariff_fractions_id'), 'us_tariff_fractions', ['id'], unique=False, schema='a76')
op.create_index(op.f('ix_a76_us_tariff_fractions_tenant_id'), 'us_tariff_fractions', ['tenant_id'], unique=False, schema='a76')
op.create_table('value_manifestations',
sa.Column('id', sa.Integer(), autoincrement=True, nullable=False),
sa.Column('manifestation_number', sa.String(length=100), nullable=True),
sa.Column('pedimento', sa.String(length=15), nullable=True),
sa.Column('periodicity', sa.String(length=10), nullable=True),
sa.Column('semester', sa.SmallInteger(), nullable=True),
sa.Column('year', sa.String(length=4), nullable=True),
sa.Column('pedimento_type', sa.String(length=3), nullable=True),
sa.Column('aa_code', sa.String(length=5), nullable=True),
sa.Column('patent', sa.String(length=4), nullable=True),
sa.Column('first_name', sa.String(length=80), nullable=True),
sa.Column('last_name_paternal', sa.String(length=80), nullable=True),
sa.Column('last_name_maternal', sa.String(length=80), nullable=True),
sa.Column('methods_count', sa.Integer(), nullable=True),
sa.Column('merchandise_value_method', sa.String(length=10), nullable=True),
sa.Column('transaction_value', sa.SmallInteger(), nullable=True),
sa.Column('identical_merchandise_value', sa.SmallInteger(), nullable=True),
sa.Column('similar_merchandise_value', sa.SmallInteger(), nullable=True),
sa.Column('unit_sale_price_value', sa.SmallInteger(), nullable=True),
sa.Column('reconstructed_value', sa.SmallInteger(), nullable=True),
sa.Column('article_78_value', sa.SmallInteger(), nullable=True),
sa.Column('provisional_value_declaration', sa.Integer(), nullable=True),
sa.Column('has_attachments', sa.SmallInteger(), nullable=True),
sa.Column('attachment_pages_number', sa.String(length=100), nullable=True),
sa.Column('transaction_value_paid_price', sa.Numeric(precision=19, scale=8), nullable=True),
sa.Column('price_pre_invoice', sa.SmallInteger(), nullable=True),
sa.Column('price_other_docs', sa.SmallInteger(), nullable=True),
sa.Column('concept_article_66', sa.SmallInteger(), nullable=True),
sa.Column('concept_article_66_breakdown', sa.SmallInteger(), nullable=True),
sa.Column('attachment_article_66', sa.String(length=2), nullable=True),
sa.Column('prepaid_merchandise_article_65', sa.String(length=2), nullable=True),
sa.Column('attachment_article_65', sa.String(length=2), nullable=True),
sa.Column('tax_base_no_sale', sa.String(length=2), nullable=True),
sa.Column('exists_circumstances_article_67_71', sa.String(length=2), nullable=True),
sa.Column('customs_value_attachment', sa.String(length=2), nullable=True),
sa.Column('provisional_value_determination', sa.String(length=2), nullable=True),
sa.Column('merchandise_value_proof_attachment', sa.String(length=2), nullable=True),
sa.Column('legal_rep_rfc', sa.String(length=30), nullable=True),
sa.Column('legal_representative', sa.String(length=100), nullable=True),
sa.Column('date', sa.Integer(), nullable=True),
sa.Column('selected_invoice', sa.String(length=20), nullable=True),
sa.Column('invoice_option', sa.String(length=3), nullable=True),
sa.Column('importer_to_use', sa.String(length=8), nullable=True),
sa.Column('tenant_id', sa.Integer(), nullable=False),
sa.Column('company_id', sa.Integer(), nullable=False),
sa.Column('deleted_at', sa.DateTime(), 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.ForeignKeyConstraint(['company_id'], ['a76.company.id'], ),
sa.ForeignKeyConstraint(['tenant_id'], ['core.tenants.id'], ),
sa.PrimaryKeyConstraint('id'),
schema='a76'
)
op.create_index('idx_value_manifestations_manifestation_number', 'value_manifestations', ['manifestation_number'], unique=False, schema='a76')
op.create_index(op.f('ix_a76_value_manifestations_company_id'), 'value_manifestations', ['company_id'], unique=False, schema='a76')
op.create_index(op.f('ix_a76_value_manifestations_tenant_id'), 'value_manifestations', ['tenant_id'], unique=False, schema='a76')
op.create_table('vehicle',
sa.Column('vehicle_key', sa.String(length=14), nullable=False),
sa.Column('vehicle_id', sa.BigInteger(), nullable=False),
sa.Column('ace_vehicle_key', sa.String(length=10), nullable=True),
sa.Column('transporter_key', sa.String(length=23), nullable=True),
sa.Column('transport_identifier', sa.String(length=30), nullable=True),
sa.Column('transport_type', sa.String(length=2), nullable=True),
sa.Column('entity_code', sa.String(length=1), nullable=True),
sa.Column('transponder_number', sa.String(length=16), nullable=True),
sa.Column('dot_number', sa.String(length=8), nullable=True),
sa.Column('plate_number', sa.String(length=17), nullable=True),
sa.Column('city', sa.String(length=30), nullable=True),
sa.Column('state', sa.String(length=30), nullable=True),
sa.Column('country', sa.String(length=3), nullable=True),
sa.Column('seal', sa.String(length=49), nullable=True),
sa.Column('insurance_company_name', sa.String(length=30), nullable=True),
sa.Column('insurance_number', sa.String(length=20), nullable=True),
sa.Column('insurance_amount', sa.DECIMAL(precision=13, scale=2), nullable=True),
sa.Column('insurance_date', sa.Integer(), nullable=True),
sa.Column('box_number', sa.String(length=300), nullable=True),
sa.Column('brand', sa.String(length=20), nullable=True),
sa.Column('year', sa.String(length=4), nullable=True),
sa.Column('series', sa.String(length=30), nullable=True),
sa.Column('description', sa.String(length=100), nullable=True),
sa.Column('engine_number', sa.String(length=50), nullable=True),
sa.Column('sct_permission', sa.String(length=40), nullable=True),
sa.Column('color', sa.String(length=20), nullable=True),
sa.Column('container_key', sa.String(length=3), nullable=True),
sa.Column('tenant_id', sa.Integer(), nullable=False),
sa.Column('company_id', sa.Integer(), nullable=False),
sa.Column('deleted_at', sa.DateTime(), 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.ForeignKeyConstraint(['company_id'], ['a76.company.id'], ),
sa.ForeignKeyConstraint(['tenant_id'], ['core.tenants.id'], ),
sa.PrimaryKeyConstraint('vehicle_key'),
schema='a76'
)
op.create_index(op.f('ix_a76_vehicle_company_id'), 'vehicle', ['company_id'], unique=False, schema='a76')
op.create_index(op.f('ix_a76_vehicle_tenant_id'), 'vehicle', ['tenant_id'], unique=False, schema='a76')
op.create_index(op.f('ix_a76_vehicle_vehicle_id'), 'vehicle', ['vehicle_id'], unique=True, schema='a76')
op.create_table('company_roles',
sa.Column('id', sa.Integer(), nullable=False),
sa.Column('name', sa.String(length=100), nullable=False),
sa.Column('code', sa.String(length=100), nullable=False),
sa.Column('description', sa.String(length=255), nullable=True),
sa.Column('is_active', sa.Boolean(), server_default='true', nullable=False),
sa.Column('tenant_id', sa.Integer(), nullable=False),
sa.Column('company_id', sa.Integer(), nullable=False),
sa.Column('deleted_at', sa.DateTime(), 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.ForeignKeyConstraint(['company_id'], ['a76.company.id'], ),
sa.ForeignKeyConstraint(['tenant_id'], ['core.tenants.id'], ),
sa.PrimaryKeyConstraint('id'),
sa.UniqueConstraint('company_id', 'tenant_id', 'code', name='uq_company_role_code'),
schema='core'
)
op.create_index('ix_company_roles_company_id_is_active', 'company_roles', ['company_id', 'tenant_id', 'is_active'], unique=False, schema='core')
op.create_index(op.f('ix_core_company_roles_company_id'), 'company_roles', ['company_id'], unique=False, schema='core')
op.create_index(op.f('ix_core_company_roles_id'), 'company_roles', ['id'], unique=False, schema='core')
op.create_index(op.f('ix_core_company_roles_tenant_id'), 'company_roles', ['tenant_id'], unique=False, schema='core')
op.create_table('task_runs',
sa.Column('id', sa.Integer(), nullable=False),
sa.Column('task_id', sa.String(length=255), nullable=False),
sa.Column('tenant_id', sa.Integer(), nullable=False),
sa.Column('company_id', sa.Integer(), nullable=True),
sa.Column('requested_by_user', sa.String(length=255), nullable=True),
sa.Column('task_name', sa.String(length=255), nullable=False),
sa.Column('task_group', sa.String(length=100), nullable=False),
sa.Column('task_origin', sa.String(length=255), nullable=True),
sa.Column('status', sa.String(length=20), nullable=False),
sa.Column('celery_state_raw', sa.String(length=30), nullable=False),
sa.Column('progress_current', sa.Integer(), nullable=True),
sa.Column('progress_total', sa.Integer(), nullable=True),
sa.Column('progress_percent', sa.Float(), nullable=True),
sa.Column('progress_message', sa.String(length=500), nullable=True),
sa.Column('retries', sa.Integer(), nullable=True),
sa.Column('exception_type', sa.String(length=255), nullable=True),
sa.Column('exception_message', sa.Text(), nullable=True),
sa.Column('traceback_excerpt', sa.Text(), nullable=True),
sa.Column('result_summary', postgresql.JSONB(astext_type=sa.Text()), nullable=True),
sa.Column('meta_payload', postgresql.JSONB(astext_type=sa.Text()), nullable=True),
sa.Column('started_at', sa.DateTime(timezone=True), nullable=True),
sa.Column('finished_at', sa.DateTime(timezone=True), nullable=True),
sa.Column('created_at', sa.DateTime(timezone=True), server_default=sa.text('now()'), nullable=False),
sa.Column('updated_at', sa.DateTime(timezone=True), server_default=sa.text('now()'), nullable=False),
sa.ForeignKeyConstraint(['company_id'], ['a76.company.id'], ),
sa.ForeignKeyConstraint(['tenant_id'], ['core.tenants.id'], ),
sa.PrimaryKeyConstraint('id'),
schema='core'
)
op.create_index(op.f('ix_core_task_runs_company_id'), 'task_runs', ['company_id'], unique=False, schema='core')
op.create_index('ix_core_task_runs_task_id', 'task_runs', ['task_id'], unique=True, schema='core')
op.create_index('ix_core_task_runs_tenant_company_updated', 'task_runs', ['tenant_id', 'company_id', 'updated_at'], unique=False, schema='core')
op.create_index('ix_core_task_runs_tenant_group_updated', 'task_runs', ['tenant_id', 'task_group', 'updated_at'], unique=False, schema='core')
op.create_index(op.f('ix_core_task_runs_tenant_id'), 'task_runs', ['tenant_id'], unique=False, schema='core')
op.create_index('ix_core_task_runs_tenant_status_updated', 'task_runs', ['tenant_id', 'status', 'updated_at'], unique=False, schema='core')
op.create_index('ix_core_task_runs_tenant_updated', 'task_runs', ['tenant_id', 'updated_at'], unique=False, schema='core')
op.create_table('user_company_permissions',
sa.Column('id', sa.Integer(), nullable=False),
sa.Column('user_id', sa.String(length=100), nullable=False),
sa.Column('permission_id', sa.Integer(), nullable=False),
sa.Column('is_granted', sa.Boolean(), server_default='true', nullable=False),
sa.Column('is_active', sa.Boolean(), server_default='true', nullable=False),
sa.Column('assigned_by', sa.String(length=100), nullable=True),
sa.Column('expires_at', sa.DateTime(), nullable=True),
sa.Column('tenant_id', sa.Integer(), nullable=False),
sa.Column('company_id', sa.Integer(), nullable=False),
sa.Column('deleted_at', sa.DateTime(), 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.ForeignKeyConstraint(['company_id'], ['a76.company.id'], ),
sa.ForeignKeyConstraint(['permission_id'], ['core.permissions.id'], ondelete='CASCADE'),
sa.ForeignKeyConstraint(['tenant_id'], ['core.tenants.id'], ),
sa.PrimaryKeyConstraint('id'),
sa.UniqueConstraint('user_id', 'company_id', 'tenant_id', 'permission_id', name='uq_user_company_permission'),
schema='core'
)
op.create_index(op.f('ix_core_user_company_permissions_company_id'), 'user_company_permissions', ['company_id'], unique=False, schema='core')
op.create_index(op.f('ix_core_user_company_permissions_id'), 'user_company_permissions', ['id'], unique=False, schema='core')
op.create_index(op.f('ix_core_user_company_permissions_permission_id'), 'user_company_permissions', ['permission_id'], unique=False, schema='core')
op.create_index(op.f('ix_core_user_company_permissions_tenant_id'), 'user_company_permissions', ['tenant_id'], unique=False, schema='core')
op.create_index(op.f('ix_core_user_company_permissions_user_id'), 'user_company_permissions', ['user_id'], unique=False, schema='core')
op.create_index('ix_user_company_permissions_composite', 'user_company_permissions', ['user_id', 'company_id', 'tenant_id', 'is_active'], unique=False, schema='core')
op.create_table('user_tenants',
sa.Column('id', sa.Integer(), nullable=False),
sa.Column('keycloak_user_id', sa.String(length=255), nullable=False),
sa.Column('is_active', sa.Boolean(), server_default='true', nullable=False),
sa.Column('role', sa.String(length=50), nullable=True),
sa.Column('avatar_url', sa.String(length=500), nullable=True, comment='URL de la imagen de perfil'),
sa.Column('phone', sa.String(length=20), nullable=True, comment='Teléfono del usuario'),
sa.Column('bio', sa.Text(), nullable=True, comment='Biografía del usuario'),
sa.Column('preferences', sa.JSON(), nullable=True, comment='Preferencias del usuario (tema, idioma, etc.)'),
sa.Column('tenant_id', sa.Integer(), nullable=False),
sa.Column('company_id', sa.Integer(), nullable=False),
sa.Column('deleted_at', sa.DateTime(), 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.ForeignKeyConstraint(['company_id'], ['a76.company.id'], ),
sa.ForeignKeyConstraint(['tenant_id'], ['core.tenants.id'], ),
sa.PrimaryKeyConstraint('id'),
sa.UniqueConstraint('keycloak_user_id', 'tenant_id', 'company_id', name='uq_user_tenant'),
schema='core'
)
op.create_index(op.f('ix_core_user_tenants_company_id'), 'user_tenants', ['company_id'], unique=False, schema='core')
op.create_index(op.f('ix_core_user_tenants_id'), 'user_tenants', ['id'], unique=False, schema='core')
op.create_index(op.f('ix_core_user_tenants_keycloak_user_id'), 'user_tenants', ['keycloak_user_id'], unique=False, schema='core')
op.create_index(op.f('ix_core_user_tenants_tenant_id'), 'user_tenants', ['tenant_id'], unique=False, schema='core')
op.create_table('warning_fractions',
sa.Column('id', sa.Integer(), autoincrement=True, nullable=False),
sa.Column('fraction', sa.String(length=15), nullable=False),
sa.Column('description', sa.String(length=1000), nullable=True),
sa.Column('warning_type', sa.String(length=50), nullable=True),
sa.Column('is_active', sa.Boolean(), server_default='true', nullable=False),
sa.Column('tenant_id', sa.Integer(), nullable=False),
sa.Column('company_id', sa.Integer(), nullable=False),
sa.Column('deleted_at', sa.DateTime(), 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.ForeignKeyConstraint(['company_id'], ['a76.company.id'], ),
sa.ForeignKeyConstraint(['tenant_id'], ['core.tenants.id'], ),
sa.PrimaryKeyConstraint('id', name='warning_fractions_pkey'),
sa.UniqueConstraint('fraction', 'company_id', name='uq_warning_fractions_fraction_company'),
schema='public'
)
op.create_index(op.f('ix_public_warning_fractions_company_id'), 'warning_fractions', ['company_id'], unique=False, schema='public')
op.create_index(op.f('ix_public_warning_fractions_fraction'), 'warning_fractions', ['fraction'], unique=False, schema='public')
op.create_index(op.f('ix_public_warning_fractions_tenant_id'), 'warning_fractions', ['tenant_id'], unique=False, schema='public')
op.create_index(op.f('ix_public_warning_fractions_warning_type'), 'warning_fractions', ['warning_type'], unique=False, schema='public')
op.create_table('discharge_header',
sa.Column('id', sa.BigInteger(), autoincrement=True, nullable=False),
sa.Column('source_invoice_id', sa.BigInteger(), nullable=False, comment='Export, SM-out or CTM-send invoice that owns this discharge.'),
sa.Column('def_import_invoice_id', sa.BigInteger(), nullable=True, comment='Populated only for discharge_type=DEFINITIVE.'),
sa.Column('discharge_type', sa.String(length=15), nullable=False),
sa.Column('status', sa.String(length=15), server_default=sa.text("'applied'"), nullable=False),
sa.Column('discharge_date', sa.Date(), nullable=False),
sa.Column('reference_invoice', sa.String(length=19), nullable=True, comment='FACREFERENCIA — for rectifications'),
sa.Column('discharge_subtype', sa.String(length=10), nullable=True, comment='TIPODESC: NORMAL, PARCIAL, REPARACION, UTILERIA'),
sa.Column('partial_sequence', sa.Integer(), nullable=True, comment='CONSECPARCIAL — for partial discharges'),
sa.Column('sales_order', sa.String(length=20), nullable=True),
sa.Column('ctm_section', sa.String(length=3), nullable=True),
sa.Column('is_tooling', sa.Boolean(), server_default=sa.text('false'), nullable=False, comment='PORUTILERIA'),
sa.Column('discharge_sm', sa.String(length=4), nullable=True),
sa.Column('is_repair_update', sa.Boolean(), server_default=sa.text('false'), nullable=False, comment='ACTUALREPARACION'),
sa.Column('material_type_expo', sa.String(length=10), nullable=True, comment='TIPOMATEXPO'),
sa.Column('cancelled_by', sa.String(length=100), nullable=True),
sa.Column('cancellation_reason', sa.String(length=300), nullable=True),
sa.Column('tenant_id', sa.Integer(), nullable=False),
sa.Column('company_id', sa.Integer(), nullable=False),
sa.Column('deleted_at', sa.DateTime(), 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.ForeignKeyConstraint(['company_id'], ['a76.company.id'], ),
sa.ForeignKeyConstraint(['def_import_invoice_id'], ['a76.invoice_header.id'], ),
sa.ForeignKeyConstraint(['source_invoice_id'], ['a76.invoice_header.id'], ),
sa.ForeignKeyConstraint(['tenant_id'], ['core.tenants.id'], ),
sa.PrimaryKeyConstraint('id'),
schema='a24'
)
op.create_index(op.f('ix_a24_discharge_header_company_id'), 'discharge_header', ['company_id'], unique=False, schema='a24')
op.create_index(op.f('ix_a24_discharge_header_tenant_id'), 'discharge_header', ['tenant_id'], unique=False, schema='a24')
op.create_index('ix_dischdr_date', 'discharge_header', ['tenant_id', 'discharge_date', 'discharge_type'], unique=False, schema='a24')
op.create_index('ix_dischdr_source', 'discharge_header', ['source_invoice_id', 'status'], unique=False, schema='a24')
op.create_table('classes',
sa.Column('id', sa.Integer(), nullable=False),
sa.Column('class_code', sa.String(length=8), nullable=False),
sa.Column('description_es', sa.String(length=500), nullable=True),
sa.Column('description_en', sa.String(length=500), nullable=True),
sa.Column('material_key', sa.String(length=10), nullable=True),
sa.Column('unit_of_measure', sa.String(length=5), nullable=True),
sa.Column('fraction', sa.String(length=20), nullable=True),
sa.Column('us_fraction', sa.String(length=16), nullable=True),
sa.Column('sub_key', sa.String(length=5), nullable=True),
sa.Column('physical_review', sa.SmallInteger(), nullable=True),
sa.Column('iva_exempt_fraction', sa.String(length=4), nullable=True),
sa.Column('is_active', sa.Boolean(), server_default='true', nullable=False),
sa.Column('tenant_id', sa.Integer(), nullable=False),
sa.Column('company_id', sa.Integer(), nullable=False),
sa.Column('deleted_at', sa.DateTime(), 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.ForeignKeyConstraint(['company_id'], ['a76.company.id'], ),
sa.ForeignKeyConstraint(['material_key'], ['public.material_types.key'], name='fk_classes_material_type'),
sa.ForeignKeyConstraint(['tenant_id'], ['core.tenants.id'], ),
sa.ForeignKeyConstraint(['unit_of_measure', 'tenant_id', 'company_id'], ['a76.units_of_measure.code', 'a76.units_of_measure.tenant_id', 'a76.units_of_measure.company_id'], ),
sa.PrimaryKeyConstraint('id', name='classes_pkey'),
sa.UniqueConstraint('tenant_id', 'company_id', 'class_code', name='uq_classes_tenant_company_code'),
schema='a76'
)
op.create_index(op.f('ix_a76_classes_company_id'), 'classes', ['company_id'], unique=False, schema='a76')
op.create_index(op.f('ix_a76_classes_tenant_id'), 'classes', ['tenant_id'], unique=False, schema='a76')
op.create_table('clients_and_providers_address',
sa.Column('id', sa.Integer(), nullable=False),
sa.Column('client_id', sa.Integer(), nullable=False),
sa.Column('municipality', sa.String(length=150), nullable=True),
sa.Column('streets', sa.String(length=100), nullable=True),
sa.Column('neighborhood', sa.String(length=40), nullable=True),
sa.Column('interior_number', sa.String(length=20), nullable=True),
sa.Column('exterior_number', sa.String(length=20), nullable=True),
sa.Column('postal_code', sa.String(length=15), nullable=True),
sa.Column('city', sa.String(length=30), nullable=True),
sa.Column('state', sa.String(length=30), nullable=True),
sa.Column('country', sa.String(length=3), nullable=True),
sa.Column('phone', sa.String(length=30), nullable=True),
sa.Column('fax_number', sa.String(length=30), nullable=True),
sa.Column('email', sa.String(length=100), nullable=True),
sa.Column('contact', sa.String(length=50), nullable=True),
sa.Column('reference', sa.String(length=250), nullable=True),
sa.Column('tenant_id', sa.Integer(), nullable=False),
sa.Column('company_id', sa.Integer(), nullable=False),
sa.Column('deleted_at', sa.DateTime(), 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.ForeignKeyConstraint(['client_id'], ['a76.clients_and_providers.id'], name='fk_clients_and_providers_address_client', ondelete='CASCADE'),
sa.ForeignKeyConstraint(['client_id'], ['a76.clients_and_providers.id'], ondelete='CASCADE'),
sa.ForeignKeyConstraint(['company_id'], ['a76.company.id'], ),
sa.ForeignKeyConstraint(['tenant_id'], ['core.tenants.id'], ),
sa.PrimaryKeyConstraint('id', name='clients_and_providers_address_pkey'),
schema='a76'
)
op.create_index(op.f('ix_a76_clients_and_providers_address_company_id'), 'clients_and_providers_address', ['company_id'], unique=False, schema='a76')
op.create_index(op.f('ix_a76_clients_and_providers_address_tenant_id'), 'clients_and_providers_address', ['tenant_id'], unique=False, schema='a76')
op.create_table('clients_and_providers_programs',
sa.Column('id', sa.Integer(), nullable=False),
sa.Column('client_id', sa.Integer(), nullable=False),
sa.Column('program', sa.String(length=7), nullable=True),
sa.Column('program_number', sa.String(length=40), nullable=True),
sa.Column('prosec', sa.String(length=8), nullable=True),
sa.Column('prosec_authorization', sa.String(length=20), nullable=True),
sa.Column('secon_auth_date', sa.Integer(), nullable=True),
sa.Column('manufacturer_id', sa.String(length=25), nullable=True),
sa.Column('broker', sa.String(length=6), nullable=True),
sa.Column('import_broker', sa.String(length=6), nullable=True),
sa.Column('transfer_key', sa.String(length=8), nullable=True),
sa.Column('secon_authorization', sa.String(length=20), nullable=True),
sa.Column('applied_proportion', sa.Numeric(precision=7, scale=2), nullable=True),
sa.Column('is_certified_company', sa.String(length=1), nullable=True),
sa.Column('certified_company_registry', sa.String(length=40), nullable=True),
sa.Column('donation_auth_number', sa.String(length=50), nullable=True),
sa.Column('ctpat_svi', sa.String(length=100), nullable=True),
sa.Column('tax_registry_number', sa.String(length=40), nullable=True),
sa.Column('subassembly_service', sa.SmallInteger(), nullable=True),
sa.Column('autse_dates', sa.Integer(), nullable=True),
sa.Column('autse_number', sa.String(length=300), nullable=True),
sa.Column('tenant_id', sa.Integer(), nullable=False),
sa.Column('company_id', sa.Integer(), nullable=False),
sa.Column('deleted_at', sa.DateTime(), 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.ForeignKeyConstraint(['client_id'], ['a76.clients_and_providers.id'], name='fk_clients_and_providers_programs_client', ondelete='CASCADE'),
sa.ForeignKeyConstraint(['client_id'], ['a76.clients_and_providers.id'], ondelete='CASCADE'),
sa.ForeignKeyConstraint(['company_id'], ['a76.company.id'], ),
sa.ForeignKeyConstraint(['tenant_id'], ['core.tenants.id'], ),
sa.PrimaryKeyConstraint('id', name='clients_and_providers_programs_pkey'),
schema='a76'
)
op.create_index(op.f('ix_a76_clients_and_providers_programs_company_id'), 'clients_and_providers_programs', ['company_id'], unique=False, schema='a76')
op.create_index(op.f('ix_a76_clients_and_providers_programs_tenant_id'), 'clients_and_providers_programs', ['tenant_id'], unique=False, schema='a76')
op.create_table('concept_manifestations',
sa.Column('value_manifestation_id', sa.Integer(), nullable=False),
sa.Column('line_number', sa.Integer(), nullable=False),
sa.Column('attachment_type', sa.String(length=10), nullable=True),
sa.Column('number', sa.String(length=10), nullable=True),
sa.Column('merchandise_provider', sa.String(length=100), nullable=True),
sa.Column('invoice_document', sa.String(length=200), nullable=True),
sa.Column('amount', sa.Numeric(precision=19, scale=9), nullable=True),
sa.Column('currency', sa.String(length=3), nullable=True),
sa.Column('concept_load', sa.String(length=200), nullable=True),
sa.Column('tenant_id', sa.Integer(), nullable=False),
sa.Column('company_id', sa.Integer(), nullable=False),
sa.Column('deleted_at', sa.DateTime(), 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.ForeignKeyConstraint(['company_id'], ['a76.company.id'], ),
sa.ForeignKeyConstraint(['tenant_id'], ['core.tenants.id'], ),
sa.ForeignKeyConstraint(['value_manifestation_id'], ['a76.value_manifestations.id'], name='fk_concept_manifestation_value_manifestation'),
sa.PrimaryKeyConstraint('value_manifestation_id', 'line_number', name='concept_manifestations_pkey'),
schema='a76'
)
op.create_index('idx_concept_manifestations_value_manifestation_id', 'concept_manifestations', ['value_manifestation_id'], unique=False, schema='a76')
op.create_index(op.f('ix_a76_concept_manifestations_company_id'), 'concept_manifestations', ['company_id'], unique=False, schema='a76')
op.create_index(op.f('ix_a76_concept_manifestations_tenant_id'), 'concept_manifestations', ['tenant_id'], unique=False, schema='a76')
op.create_table('concepts',
sa.Column('id', sa.Integer(), autoincrement=True, nullable=False),
sa.Column('company_id', sa.Integer(), nullable=False),
sa.Column('code', sa.String(length=15), nullable=False),
sa.Column('description', sa.String(length=120), nullable=True),
sa.Column('description_en', sa.String(length=120), nullable=True),
sa.Column('detailed_description', sa.String(length=1000), nullable=True),
sa.Column('priority', sa.Integer(), nullable=True),
sa.Column('priority_ame', sa.Integer(), nullable=True),
sa.Column('first_total', sa.Boolean(), nullable=True),
sa.Column('type', sa.String(length=9), nullable=True),
sa.Column('is_printed', sa.Boolean(), nullable=True),
sa.Column('section', sa.Integer(), nullable=True),
sa.Column('classification', sa.String(length=30), nullable=True),
sa.Column('tenant_id', sa.Integer(), nullable=False),
sa.Column('deleted_at', sa.DateTime(), 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.ForeignKeyConstraint(['classification'], ['a76.classification_concepts.classification'], ),
sa.ForeignKeyConstraint(['tenant_id'], ['core.tenants.id'], ),
sa.PrimaryKeyConstraint('id'),
sa.UniqueConstraint('code', name='uq_concept_code'),
schema='a76'
)
op.create_index(op.f('ix_a76_concepts_tenant_id'), 'concepts', ['tenant_id'], unique=False, schema='a76')
op.create_table('country_rule_oct',
sa.Column('id', sa.Integer(), nullable=False),
sa.Column('permission', sa.String(length=20), nullable=False),
sa.Column('line', sa.Integer(), nullable=False),
sa.Column('fraction', sa.String(length=10), nullable=False),
sa.Column('country_code', sa.String(length=3), nullable=False),
sa.Column('tenant_id', sa.Integer(), nullable=False),
sa.Column('company_id', sa.Integer(), nullable=False),
sa.Column('deleted_at', sa.DateTime(), 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.ForeignKeyConstraint(['company_id'], ['a76.company.id'], ),
sa.ForeignKeyConstraint(['tenant_id', 'company_id', 'permission', 'line', 'fraction'], ['a76.fraction_rule_octave.tenant_id', 'a76.fraction_rule_octave.company_id', 'a76.fraction_rule_octave.permission', 'a76.fraction_rule_octave.line', 'a76.fraction_rule_octave.fraction'], name='fk_country_rule_oct_frac_octava', ondelete='CASCADE'),
sa.ForeignKeyConstraint(['tenant_id'], ['core.tenants.id'], ),
sa.PrimaryKeyConstraint('id', name='country_rule_oct_pkey'),
sa.UniqueConstraint('tenant_id', 'company_id', 'permission', 'line', 'fraction', 'country_code', name='uq_country_rule_oct_permission_line_fraction_country'),
schema='a76'
)
op.create_index(op.f('ix_a76_country_rule_oct_company_id'), 'country_rule_oct', ['company_id'], unique=False, schema='a76')
op.create_index(op.f('ix_a76_country_rule_oct_tenant_id'), 'country_rule_oct', ['tenant_id'], unique=False, schema='a76')
op.create_table('customs_brokers_personnel',
sa.Column('customs_broker_id', sa.Integer(), nullable=False),
sa.Column('line', sa.Integer(), nullable=False),
sa.Column('name', sa.String(length=80), nullable=True),
sa.Column('tax_id', sa.String(length=30), nullable=True),
sa.Column('personal_id', sa.String(length=20), nullable=True),
sa.Column('position', sa.String(length=30), nullable=True),
sa.Column('license', sa.String(length=4), nullable=True),
sa.Column('first_name', sa.String(length=80), nullable=True),
sa.Column('last_name', sa.String(length=80), nullable=True),
sa.Column('middle_name', sa.String(length=80), nullable=True),
sa.Column('email', sa.String(length=100), nullable=True),
sa.Column('tenant_id', sa.Integer(), nullable=False),
sa.Column('company_id', sa.Integer(), nullable=False),
sa.Column('deleted_at', sa.DateTime(), 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.ForeignKeyConstraint(['company_id'], ['a76.company.id'], ),
sa.ForeignKeyConstraint(['customs_broker_id'], ['a76.customs_brokers.id'], ondelete='CASCADE'),
sa.ForeignKeyConstraint(['tenant_id'], ['core.tenants.id'], ),
sa.PrimaryKeyConstraint('customs_broker_id', 'line'),
schema='a76'
)
op.create_index(op.f('ix_a76_customs_brokers_personnel_company_id'), 'customs_brokers_personnel', ['company_id'], unique=False, schema='a76')
op.create_index(op.f('ix_a76_customs_brokers_personnel_tenant_id'), 'customs_brokers_personnel', ['tenant_id'], unique=False, schema='a76')
op.create_table('customs_brokers_vu',
sa.Column('customs_broker_id', sa.Integer(), nullable=False),
sa.Column('certificate_path', sa.String(length=1499), nullable=True),
sa.Column('key_path', sa.String(length=1499), nullable=True),
sa.Column('access_key', sa.String(length=50), nullable=True),
sa.Column('fiel_format', sa.String(length=19), nullable=True),
sa.Column('signature_read_path', sa.String(length=1499), nullable=True),
sa.Column('archive_path', sa.String(length=1499), nullable=True),
sa.Column('fiel_access_key', sa.String(length=50), nullable=True),
sa.Column('web_service_user', sa.String(length=100), nullable=True),
sa.Column('web_service_access_key', sa.String(length=100), nullable=True),
sa.Column('vu_email', sa.String(length=800), nullable=True),
sa.Column('vu_figure_type', sa.String(length=29), nullable=True),
sa.Column('xml_files_path', sa.String(length=1499), nullable=True),
sa.Column('query_tax_id', sa.String(length=30), nullable=True),
sa.Column('doda_certificate_path', sa.String(length=1499), nullable=True),
sa.Column('doda_key_path', sa.String(length=1499), nullable=True),
sa.Column('doda_web_service_user', sa.String(length=100), nullable=True),
sa.Column('doda_web_service_access_key', sa.String(length=100), nullable=True),
sa.Column('doda_fiel_access_key', sa.String(length=50), nullable=True),
sa.Column('doda_xml_files_path', sa.String(length=1499), nullable=True),
sa.Column('tenant_id', sa.Integer(), nullable=False),
sa.Column('company_id', sa.Integer(), nullable=False),
sa.Column('deleted_at', sa.DateTime(), 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.ForeignKeyConstraint(['company_id'], ['a76.company.id'], ),
sa.ForeignKeyConstraint(['customs_broker_id'], ['a76.customs_brokers.id'], ondelete='CASCADE'),
sa.ForeignKeyConstraint(['tenant_id'], ['core.tenants.id'], ),
sa.PrimaryKeyConstraint('customs_broker_id'),
schema='a76'
)
op.create_index(op.f('ix_a76_customs_brokers_vu_company_id'), 'customs_brokers_vu', ['company_id'], unique=False, schema='a76')
op.create_index(op.f('ix_a76_customs_brokers_vu_tenant_id'), 'customs_brokers_vu', ['tenant_id'], unique=False, schema='a76')
op.create_table('doda_american_pedimentos',
sa.Column('id', sa.Integer(), autoincrement=True, nullable=False),
sa.Column('doda_id', sa.Integer(), nullable=False),
sa.Column('american_pedimento_line', sa.Integer(), nullable=False),
sa.Column('american_pedimento_type', sa.String(length=2), nullable=True),
sa.Column('american_pedimento_value', sa.String(length=20), nullable=True),
sa.Column('tenant_id', sa.Integer(), nullable=False),
sa.Column('company_id', sa.Integer(), nullable=False),
sa.Column('deleted_at', sa.DateTime(), 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.ForeignKeyConstraint(['company_id'], ['a76.company.id'], ),
sa.ForeignKeyConstraint(['doda_id'], ['a76.doda.id'], name='fk_doda_american_pedimentos_doda'),
sa.ForeignKeyConstraint(['tenant_id'], ['core.tenants.id'], ),
sa.PrimaryKeyConstraint('id', name='doda_american_pedimentos_pkey'),
schema='a76'
)
op.create_index(op.f('ix_a76_doda_american_pedimentos_company_id'), 'doda_american_pedimentos', ['company_id'], unique=False, schema='a76')
op.create_index(op.f('ix_a76_doda_american_pedimentos_tenant_id'), 'doda_american_pedimentos', ['tenant_id'], unique=False, schema='a76')
op.create_table('doda_containers',
sa.Column('id', sa.Integer(), autoincrement=True, nullable=False),
sa.Column('doda_id', sa.Integer(), nullable=False),
sa.Column('container_line', sa.Integer(), nullable=False),
sa.Column('container_value', sa.String(length=20), nullable=True),
sa.Column('seals', sa.String(length=254), nullable=True),
sa.Column('tenant_id', sa.Integer(), nullable=False),
sa.Column('company_id', sa.Integer(), nullable=False),
sa.Column('deleted_at', sa.DateTime(), 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.ForeignKeyConstraint(['company_id'], ['a76.company.id'], ),
sa.ForeignKeyConstraint(['doda_id'], ['a76.doda.id'], name='fk_doda_containers_doda'),
sa.ForeignKeyConstraint(['tenant_id'], ['core.tenants.id'], ),
sa.PrimaryKeyConstraint('id', name='doda_containers_pkey'),
schema='a76'
)
op.create_index(op.f('ix_a76_doda_containers_company_id'), 'doda_containers', ['company_id'], unique=False, schema='a76')
op.create_index(op.f('ix_a76_doda_containers_tenant_id'), 'doda_containers', ['tenant_id'], unique=False, schema='a76')
op.create_table('doda_pedimentos',
sa.Column('id', sa.Integer(), autoincrement=True, nullable=False),
sa.Column('doda_id', sa.Integer(), nullable=False),
sa.Column('pedimento_line', sa.Integer(), nullable=False),
sa.Column('authorization_patent', sa.String(length=10), nullable=True),
sa.Column('document', sa.String(length=50), nullable=True),
sa.Column('shipment', sa.String(length=11), nullable=True),
sa.Column('cove', sa.String(length=50), nullable=True),
sa.Column('umc', sa.String(length=20), nullable=True),
sa.Column('effective_amount_usd', sa.Numeric(precision=15, scale=2), nullable=True),
sa.Column('difference_amount_usd', sa.Numeric(precision=15, scale=2), nullable=True),
sa.Column('dta_niu', sa.String(length=20), nullable=True),
sa.Column('article_7', sa.Boolean(), nullable=True),
sa.Column('pedimento_id', sa.Integer(), nullable=True),
sa.Column('invoice_line', sa.Integer(), nullable=True),
sa.Column('part_ii_line', sa.Integer(), nullable=True),
sa.Column('pedimento_type', sa.String(length=20), nullable=True),
sa.Column('zero_packaging_validation', sa.Boolean(), nullable=True),
sa.Column('tenant_id', sa.Integer(), nullable=False),
sa.Column('company_id', sa.Integer(), nullable=False),
sa.Column('deleted_at', sa.DateTime(), 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.ForeignKeyConstraint(['company_id'], ['a76.company.id'], ),
sa.ForeignKeyConstraint(['doda_id'], ['a76.doda.id'], name='fk_doda_pedimentos_doda'),
sa.ForeignKeyConstraint(['tenant_id'], ['core.tenants.id'], ),
sa.PrimaryKeyConstraint('id', name='doda_pedimentos_pkey'),
schema='a76'
)
op.create_index(op.f('ix_a76_doda_pedimentos_company_id'), 'doda_pedimentos', ['company_id'], unique=False, schema='a76')
op.create_index(op.f('ix_a76_doda_pedimentos_tenant_id'), 'doda_pedimentos', ['tenant_id'], unique=False, schema='a76')
op.create_table('driver',
sa.Column('transporter_key', sa.String(length=30), nullable=False),
sa.Column('line', sa.Integer(), nullable=False),
sa.Column('driver_id', sa.BigInteger(), nullable=False),
sa.Column('driver_name', sa.String(length=80), nullable=True),
sa.Column('license_number', sa.String(length=29), nullable=True),
sa.Column('express_line_id', sa.String(length=17), nullable=True),
sa.Column('ace_id', sa.String(length=20), nullable=True),
sa.Column('birth_date', sa.Integer(), nullable=True),
sa.Column('gender', sa.String(length=1), nullable=True),
sa.Column('birth_country', sa.String(length=3), nullable=True),
sa.Column('hazardous_material_auth', sa.String(length=2), nullable=True),
sa.Column('hazardous_material_state', sa.String(length=30), nullable=True),
sa.Column('first_name', sa.String(length=20), nullable=True),
sa.Column('last_name', sa.String(length=20), nullable=True),
sa.Column('id_key1', sa.String(length=40), nullable=True),
sa.Column('id_number1', sa.String(length=20), nullable=True),
sa.Column('id_state1', sa.String(length=30), nullable=True),
sa.Column('id_country1', sa.String(length=3), nullable=True),
sa.Column('id_key2', sa.String(length=40), nullable=True),
sa.Column('id_number2', sa.String(length=20), nullable=True),
sa.Column('id_state2', sa.String(length=30), nullable=True),
sa.Column('id_country2', sa.String(length=3), nullable=True),
sa.Column('badge_number', sa.String(length=20), nullable=True),
sa.Column('class_type', sa.String(length=1), nullable=True),
sa.Column('unique_badge_number', sa.String(length=100), nullable=True),
sa.Column('tenant_id', sa.Integer(), nullable=False),
sa.Column('company_id', sa.Integer(), nullable=False),
sa.Column('deleted_at', sa.DateTime(), 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.ForeignKeyConstraint(['company_id'], ['a76.company.id'], ),
sa.ForeignKeyConstraint(['tenant_id'], ['core.tenants.id'], ),
sa.ForeignKeyConstraint(['transporter_key'], ['a76.transporter.transporter_key'], ondelete='CASCADE'),
sa.PrimaryKeyConstraint('transporter_key', 'line'),
schema='a76'
)
op.create_index(op.f('ix_a76_driver_company_id'), 'driver', ['company_id'], unique=False, schema='a76')
op.create_index(op.f('ix_a76_driver_driver_id'), 'driver', ['driver_id'], unique=True, schema='a76')
op.create_index(op.f('ix_a76_driver_tenant_id'), 'driver', ['tenant_id'], unique=False, schema='a76')
op.create_table('equivalencies',
sa.Column('id', sa.Integer(), autoincrement=True, nullable=False),
sa.Column('identifier', sa.String(length=10), nullable=False),
sa.Column('description', sa.String(length=200), nullable=True),
sa.Column('item_id', sa.Integer(), nullable=True),
sa.Column('tenant_id', sa.Integer(), nullable=False),
sa.Column('company_id', sa.Integer(), nullable=False),
sa.Column('deleted_at', sa.DateTime(), 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.ForeignKeyConstraint(['company_id'], ['a76.company.id'], ),
sa.ForeignKeyConstraint(['item_id'], ['a76.equivalency_items.id'], ondelete='SET NULL'),
sa.ForeignKeyConstraint(['tenant_id'], ['core.tenants.id'], ),
sa.PrimaryKeyConstraint('id'),
sa.UniqueConstraint('identifier', 'tenant_id', 'company_id', name='uq_equivalency_identifier'),
schema='a76'
)
op.create_index(op.f('ix_a76_equivalencies_company_id'), 'equivalencies', ['company_id'], unique=False, schema='a76')
op.create_index(op.f('ix_a76_equivalencies_tenant_id'), 'equivalencies', ['tenant_id'], unique=False, schema='a76')
op.create_table('error_catalogs',
sa.Column('id', sa.Integer(), autoincrement=True, nullable=False),
sa.Column('code', sa.String(length=15), nullable=False),
sa.Column('description', sa.String(length=255), nullable=True),
sa.Column('classification_id', sa.Integer(), nullable=True),
sa.Column('tenant_id', sa.Integer(), nullable=False),
sa.Column('company_id', sa.Integer(), nullable=False),
sa.Column('deleted_at', sa.DateTime(), 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.ForeignKeyConstraint(['classification_id'], ['a76.error_classifications.id'], name='fk_error_catalogs_classification'),
sa.ForeignKeyConstraint(['company_id'], ['a76.company.id'], ),
sa.ForeignKeyConstraint(['tenant_id'], ['core.tenants.id'], ),
sa.PrimaryKeyConstraint('id', name='error_catalogs_pkey'),
sa.UniqueConstraint('code'),
sa.UniqueConstraint('code', name='error_catalogs_code_unique'),
schema='a76'
)
op.create_index(op.f('ix_a76_error_catalogs_company_id'), 'error_catalogs', ['company_id'], unique=False, schema='a76')
op.create_index(op.f('ix_a76_error_catalogs_tenant_id'), 'error_catalogs', ['tenant_id'], unique=False, schema='a76')
op.create_table('fa_location_ext',
sa.Column('id', sa.Integer(), autoincrement=True, nullable=False),
sa.Column('location_id', sa.Integer(), nullable=False),
sa.Column('department', sa.String(length=100), nullable=True),
sa.Column('responsible', sa.String(length=200), nullable=True),
sa.Column('observations', sa.Text(), nullable=True),
sa.Column('tenant_id', sa.Integer(), nullable=False),
sa.Column('company_id', sa.Integer(), nullable=False),
sa.Column('deleted_at', sa.DateTime(), 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.ForeignKeyConstraint(['company_id'], ['a76.company.id'], ),
sa.ForeignKeyConstraint(['location_id'], ['a76.location.id'], ondelete='CASCADE'),
sa.ForeignKeyConstraint(['tenant_id'], ['core.tenants.id'], ),
sa.PrimaryKeyConstraint('id'),
sa.UniqueConstraint('location_id'),
sa.UniqueConstraint('location_id', name='uq_fa_location_ext_location_id'),
schema='a76'
)
op.create_index(op.f('ix_a76_fa_location_ext_company_id'), 'fa_location_ext', ['company_id'], unique=False, schema='a76')
op.create_index(op.f('ix_a76_fa_location_ext_tenant_id'), 'fa_location_ext', ['tenant_id'], unique=False, schema='a76')
op.create_table('fda_affirmation_codes',
sa.Column('id', sa.Integer(), nullable=False),
sa.Column('fda_catalog_id', sa.Integer(), nullable=False),
sa.Column('line', sa.Integer(), nullable=False),
sa.Column('aoc_code', sa.String(length=50), nullable=False),
sa.Column('aoc_qual', sa.String(length=100), nullable=True),
sa.Column('tenant_id', sa.Integer(), nullable=False),
sa.Column('company_id', sa.Integer(), nullable=False),
sa.Column('deleted_at', sa.DateTime(), 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.ForeignKeyConstraint(['company_id'], ['a76.company.id'], ),
sa.ForeignKeyConstraint(['fda_catalog_id'], ['a76.fda_catalog.id'], ondelete='CASCADE'),
sa.ForeignKeyConstraint(['tenant_id'], ['core.tenants.id'], ),
sa.PrimaryKeyConstraint('id', name='fda_affirmation_codes_pkey'),
schema='a76'
)
op.create_index(op.f('ix_a76_fda_affirmation_codes_company_id'), 'fda_affirmation_codes', ['company_id'], unique=False, schema='a76')
op.create_index(op.f('ix_a76_fda_affirmation_codes_fda_catalog_id'), 'fda_affirmation_codes', ['fda_catalog_id'], unique=False, schema='a76')
op.create_index(op.f('ix_a76_fda_affirmation_codes_tenant_id'), 'fda_affirmation_codes', ['tenant_id'], unique=False, schema='a76')
op.create_table('fda_constituent_elements',
sa.Column('id', sa.Integer(), nullable=False),
sa.Column('fda_catalog_id', sa.Integer(), nullable=False),
sa.Column('line', sa.Integer(), nullable=False),
sa.Column('ele_name', sa.String(length=200), nullable=False),
sa.Column('ele_qty', sa.Numeric(precision=15, scale=2), nullable=True),
sa.Column('ele_qty_uom', sa.String(length=20), nullable=True),
sa.Column('ele_pctg', sa.Numeric(precision=15, scale=2), nullable=True),
sa.Column('tenant_id', sa.Integer(), nullable=False),
sa.Column('company_id', sa.Integer(), nullable=False),
sa.Column('deleted_at', sa.DateTime(), 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.ForeignKeyConstraint(['company_id'], ['a76.company.id'], ),
sa.ForeignKeyConstraint(['fda_catalog_id'], ['a76.fda_catalog.id'], ondelete='CASCADE'),
sa.ForeignKeyConstraint(['tenant_id'], ['core.tenants.id'], ),
sa.PrimaryKeyConstraint('id', name='fda_constituent_elements_pkey'),
schema='a76'
)
op.create_index(op.f('ix_a76_fda_constituent_elements_company_id'), 'fda_constituent_elements', ['company_id'], unique=False, schema='a76')
op.create_index(op.f('ix_a76_fda_constituent_elements_fda_catalog_id'), 'fda_constituent_elements', ['fda_catalog_id'], unique=False, schema='a76')
op.create_index(op.f('ix_a76_fda_constituent_elements_tenant_id'), 'fda_constituent_elements', ['tenant_id'], unique=False, schema='a76')
op.create_table('fda_lot_production',
sa.Column('id', sa.Integer(), nullable=False),
sa.Column('fda_catalog_id', sa.Integer(), nullable=False),
sa.Column('line', sa.Integer(), nullable=False),
sa.Column('lot_number', sa.String(length=100), nullable=False),
sa.Column('production_start_date', sa.String(length=50), nullable=True),
sa.Column('production_end_date', sa.String(length=50), nullable=True),
sa.Column('tenant_id', sa.Integer(), nullable=False),
sa.Column('company_id', sa.Integer(), nullable=False),
sa.Column('deleted_at', sa.DateTime(), 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.ForeignKeyConstraint(['company_id'], ['a76.company.id'], ),
sa.ForeignKeyConstraint(['fda_catalog_id'], ['a76.fda_catalog.id'], ondelete='CASCADE'),
sa.ForeignKeyConstraint(['tenant_id'], ['core.tenants.id'], ),
sa.PrimaryKeyConstraint('id', name='fda_lot_production_pkey'),
schema='a76'
)
op.create_index(op.f('ix_a76_fda_lot_production_company_id'), 'fda_lot_production', ['company_id'], unique=False, schema='a76')
op.create_index(op.f('ix_a76_fda_lot_production_fda_catalog_id'), 'fda_lot_production', ['fda_catalog_id'], unique=False, schema='a76')
op.create_index(op.f('ix_a76_fda_lot_production_tenant_id'), 'fda_lot_production', ['tenant_id'], unique=False, schema='a76')
op.create_table('fda_specifications',
sa.Column('id', sa.Integer(), nullable=False),
sa.Column('fda_catalog_id', sa.Integer(), nullable=False),
sa.Column('prod_code', sa.String(length=50), nullable=True),
sa.Column('commodity_desc', sa.String(length=200), nullable=True),
sa.Column('brand_name', sa.String(length=100), nullable=True),
sa.Column('disclaimer', sa.String(length=100), nullable=True),
sa.Column('pgm_code', sa.String(length=50), nullable=True),
sa.Column('proc_code', sa.String(length=50), nullable=True),
sa.Column('intnd_use_code', sa.String(length=50), nullable=True),
sa.Column('intnd_use_desc', sa.String(length=200), nullable=True),
sa.Column('temp_qual', sa.String(length=50), nullable=True),
sa.Column('temp_type', sa.String(length=50), nullable=True),
sa.Column('temp_degrees', sa.Numeric(precision=10, scale=2), nullable=True),
sa.Column('temp_negative', sa.Numeric(precision=10, scale=2), nullable=True),
sa.Column('temp_location', sa.String(length=100), nullable=True),
sa.Column('quantity_1', sa.Numeric(precision=15, scale=2), nullable=True),
sa.Column('qty_uom_1', sa.String(length=20), nullable=True),
sa.Column('quantity_2', sa.Numeric(precision=15, scale=2), nullable=True),
sa.Column('qty_uom_2', sa.String(length=20), nullable=True),
sa.Column('quantity_3', sa.Numeric(precision=15, scale=2), nullable=True),
sa.Column('qty_uom_3', sa.String(length=20), nullable=True),
sa.Column('ctry_prod', sa.String(length=50), nullable=True),
sa.Column('ctry_source', sa.String(length=50), nullable=True),
sa.Column('ctry_growth', sa.String(length=50), nullable=True),
sa.Column('ctry_refusal', sa.String(length=50), nullable=True),
sa.Column('ctry_shipping', sa.String(length=50), nullable=True),
sa.Column('manuf_key', sa.String(length=50), nullable=True),
sa.Column('shipper_key', sa.String(length=50), nullable=True),
sa.Column('ult_cons_key', sa.String(length=50), nullable=True),
sa.Column('fda_imp_key', sa.String(length=50), nullable=True),
sa.Column('pn_subm_key', sa.String(length=50), nullable=True),
sa.Column('consol_key', sa.String(length=50), nullable=True),
sa.Column('producer_key', sa.String(length=50), nullable=True),
sa.Column('owner_key', sa.String(length=50), nullable=True),
sa.Column('deli_party_key', sa.String(length=50), nullable=True),
sa.Column('grower_key', sa.String(length=50), nullable=True),
sa.Column('dev_ini_imp_key', sa.String(length=50), nullable=True),
sa.Column('lacf_cont_1', sa.String(length=100), nullable=True),
sa.Column('lacf_cont_2', sa.String(length=100), nullable=True),
sa.Column('lacf_cont_3', sa.String(length=100), nullable=True),
sa.Column('pn_transmitter_key', sa.String(length=50), nullable=True),
sa.Column('tenant_id', sa.Integer(), nullable=False),
sa.Column('company_id', sa.Integer(), nullable=False),
sa.Column('deleted_at', sa.DateTime(), 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.ForeignKeyConstraint(['company_id'], ['a76.company.id'], ),
sa.ForeignKeyConstraint(['fda_catalog_id'], ['a76.fda_catalog.id'], ondelete='CASCADE'),
sa.ForeignKeyConstraint(['tenant_id'], ['core.tenants.id'], ),
sa.PrimaryKeyConstraint('id', name='fda_specifications_pkey'),
schema='a76'
)
op.create_index(op.f('ix_a76_fda_specifications_company_id'), 'fda_specifications', ['company_id'], unique=False, schema='a76')
op.create_index(op.f('ix_a76_fda_specifications_fda_catalog_id'), 'fda_specifications', ['fda_catalog_id'], unique=False, schema='a76')
op.create_index(op.f('ix_a76_fda_specifications_tenant_id'), 'fda_specifications', ['tenant_id'], unique=False, schema='a76')
op.create_table('invoice_collections',
sa.Column('id', sa.BigInteger(), autoincrement=True, nullable=False),
sa.Column('invoice_id', sa.BigInteger(), nullable=False),
sa.Column('line_number', sa.Integer(), nullable=False),
sa.Column('invoice_number', sa.String(length=15), nullable=True),
sa.Column('concept', sa.String(length=100), nullable=True),
sa.Column('tenant_id', sa.Integer(), nullable=False),
sa.Column('company_id', sa.Integer(), nullable=False),
sa.Column('deleted_at', sa.DateTime(), 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.ForeignKeyConstraint(['company_id'], ['a76.company.id'], ),
sa.ForeignKeyConstraint(['invoice_id'], ['a76.invoice_header.id'], ),
sa.ForeignKeyConstraint(['tenant_id'], ['core.tenants.id'], ),
sa.PrimaryKeyConstraint('id'),
schema='a76'
)
op.create_index(op.f('ix_a76_invoice_collections_company_id'), 'invoice_collections', ['company_id'], unique=False, schema='a76')
op.create_index(op.f('ix_a76_invoice_collections_tenant_id'), 'invoice_collections', ['tenant_id'], unique=False, schema='a76')
op.create_table('invoice_financials',
sa.Column('id', sa.BigInteger(), autoincrement=True, nullable=False),
sa.Column('invoice_id', sa.BigInteger(), nullable=False),
sa.Column('currency', sa.String(length=7), nullable=False),
sa.Column('currency_type', sa.String(length=3), nullable=True),
sa.Column('exchange_rate', sa.Numeric(precision=13, scale=6), nullable=True),
sa.Column('exchange_rate_mm', sa.Numeric(precision=13, scale=6), nullable=True),
sa.Column('value_mn', sa.Numeric(precision=23, scale=8), server_default='0', nullable=True),
sa.Column('value_me', sa.Numeric(precision=23, scale=8), server_default='0', nullable=True),
sa.Column('value_mc', sa.Numeric(precision=23, scale=8), server_default='0', nullable=True),
sa.Column('customs_value_mn', sa.Numeric(precision=23, scale=8), server_default='0', nullable=True),
sa.Column('customs_value_me', sa.Numeric(precision=23, scale=8), server_default='0', nullable=True),
sa.Column('raw_material_value_mn', sa.Numeric(precision=23, scale=8), server_default='0', nullable=True),
sa.Column('raw_material_value_me', sa.Numeric(precision=23, scale=8), server_default='0', nullable=True),
sa.Column('aggregate_value_mn', sa.Numeric(precision=23, scale=8), server_default='0', nullable=True),
sa.Column('aggregate_value_me', sa.Numeric(precision=23, scale=8), server_default='0', nullable=True),
sa.Column('aggregate_value_mc', sa.Numeric(precision=23, scale=8), server_default='0', nullable=True),
sa.Column('mexican_value_mn', sa.Numeric(precision=23, scale=8), server_default='0', nullable=True),
sa.Column('mexican_value_me', sa.Numeric(precision=23, scale=8), server_default='0', nullable=True),
sa.Column('mexican_value_mc', sa.Numeric(precision=23, scale=8), server_default='0', nullable=True),
sa.Column('national_packaging_mn', sa.Numeric(precision=23, scale=8), server_default='0', nullable=True),
sa.Column('national_packaging_me', sa.Numeric(precision=23, scale=8), server_default='0', nullable=True),
sa.Column('national_packaging_mc', sa.Numeric(precision=23, scale=8), server_default='0', nullable=True),
sa.Column('freight', sa.Numeric(precision=19, scale=8), server_default='0', nullable=True),
sa.Column('insurance', sa.Numeric(precision=19, scale=8), server_default='0', nullable=True),
sa.Column('insurance_value', sa.Numeric(precision=19, scale=8), server_default='0', nullable=True),
sa.Column('packaging', sa.Numeric(precision=19, scale=8), server_default='0', nullable=True),
sa.Column('other_increments', sa.Numeric(precision=19, scale=8), server_default='0', nullable=True),
sa.Column('other_deductibles', sa.Numeric(precision=19, scale=8), server_default='0', nullable=True),
sa.Column('total_increments_mn', sa.Numeric(precision=23, scale=8), server_default='0', nullable=True),
sa.Column('total_increments_me', sa.Numeric(precision=23, scale=8), server_default='0', nullable=True),
sa.Column('iva_mn', sa.Numeric(precision=23, scale=8), server_default='0', nullable=True),
sa.Column('iva_me', sa.Numeric(precision=23, scale=8), server_default='0', nullable=True),
sa.Column('iva_mc', sa.Numeric(precision=23, scale=8), server_default='0', nullable=True),
sa.Column('iva_factor', sa.Numeric(precision=23, scale=8), server_default='0', nullable=True),
sa.Column('tax_value_me', sa.Numeric(precision=23, scale=8), server_default='0', nullable=True),
sa.Column('seal_value_2500', sa.Boolean(), nullable=True),
sa.Column('total_quantity', sa.Numeric(precision=19, scale=8), nullable=True),
sa.Column('total_packages', sa.Integer(), nullable=True),
sa.Column('gross_weight', sa.Numeric(precision=19, scale=8), nullable=True),
sa.Column('net_weight', sa.Numeric(precision=19, scale=8), nullable=True),
sa.Column('bundle_count', sa.Integer(), nullable=True),
sa.Column('weight_factor', sa.Numeric(precision=19, scale=8), nullable=True),
sa.Column('tenant_id', sa.Integer(), nullable=False),
sa.Column('company_id', sa.Integer(), nullable=False),
sa.Column('deleted_at', sa.DateTime(), 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.ForeignKeyConstraint(['company_id'], ['a76.company.id'], ),
sa.ForeignKeyConstraint(['currency_type'], ['public.currency_types.code'], ),
sa.ForeignKeyConstraint(['invoice_id'], ['a76.invoice_header.id'], ),
sa.ForeignKeyConstraint(['tenant_id'], ['core.tenants.id'], ),
sa.PrimaryKeyConstraint('id'),
schema='a76'
)
op.create_index(op.f('ix_a76_invoice_financials_company_id'), 'invoice_financials', ['company_id'], unique=False, schema='a76')
op.create_index(op.f('ix_a76_invoice_financials_tenant_id'), 'invoice_financials', ['tenant_id'], unique=False, schema='a76')
op.create_table('invoice_logistics',
sa.Column('id', sa.BigInteger(), autoincrement=True, nullable=False),
sa.Column('invoice_id', sa.BigInteger(), nullable=False),
sa.Column('carrier_id', sa.String(length=10), nullable=True),
sa.Column('carrier_int_id', sa.BigInteger(), nullable=True),
sa.Column('transport_id', sa.String(length=10), nullable=True),
sa.Column('transport_int_id', sa.BigInteger(), nullable=True),
sa.Column('transport_us_id', sa.String(length=10), nullable=True),
sa.Column('transport_type', sa.String(length=15), server_default='none', nullable=False),
sa.Column('transport_num', sa.String(length=20), nullable=True),
sa.Column('transport_mode', sa.String(length=15), nullable=True),
sa.Column('driver_name', sa.String(length=80), nullable=True),
sa.Column('is_rail', sa.Boolean(), server_default='false', nullable=True),
sa.Column('rail_id', sa.String(length=31), nullable=True),
sa.Column('vehicle_num', sa.String(length=20), nullable=True),
sa.Column('license_plate', sa.String(length=20), nullable=True),
sa.Column('license_plate_complete', sa.String(length=40), nullable=True),
sa.Column('trailer_num', sa.String(length=20), nullable=True),
sa.Column('trailer_int_id', sa.BigInteger(), nullable=True),
sa.Column('seal_number', sa.String(length=15), nullable=True),
sa.Column('guide_number', sa.String(length=20), nullable=True),
sa.Column('bill_number', sa.String(length=15), nullable=True),
sa.Column('reference_number', sa.String(length=14), nullable=True),
sa.Column('shipment_number', sa.String(length=19), nullable=True),
sa.Column('incoterm', sa.String(length=5), nullable=True),
sa.Column('identifier_1', sa.String(length=2), nullable=True),
sa.Column('complement_1', sa.String(length=30), nullable=True),
sa.Column('identifier_2', sa.String(length=2), nullable=True),
sa.Column('complement_2', sa.String(length=30), nullable=True),
sa.Column('weight_type', sa.String(length=3), nullable=False),
sa.Column('container_types', sa.String(length=500), nullable=True),
sa.Column('vehicle_data', sa.String(length=500), nullable=True),
sa.Column('origin_location', sa.String(length=200), nullable=True),
sa.Column('destination_location', sa.String(length=200), nullable=True),
sa.Column('transport_itinerary', sa.String(length=1000), nullable=True),
sa.Column('destination_goods', sa.String(length=50), nullable=True),
sa.Column('entry_exit_date', sa.Date(), nullable=True),
sa.Column('delivery_date', sa.Date(), nullable=True),
sa.Column('delivered_status', sa.Boolean(), server_default='false', nullable=True),
sa.Column('received_by', sa.String(length=50), nullable=True),
sa.Column('payment_date', sa.Date(), nullable=True),
sa.Column('payment_receipt_num', sa.String(length=20), nullable=True),
sa.Column('is_ctm_process', sa.Boolean(), server_default='false', nullable=True),
sa.Column('equipment_reviewed', sa.Boolean(), nullable=True),
sa.Column('is_subdivision', sa.Boolean(), nullable=True),
sa.Column('acts_as_cd', sa.Boolean(), nullable=True),
sa.Column('pedimento_arrived', sa.Boolean(), nullable=True),
sa.Column('green_light_mx', sa.Boolean(), nullable=True),
sa.Column('green_light_us', sa.Boolean(), nullable=True),
sa.Column('red_light_mx', sa.Boolean(), nullable=True),
sa.Column('red_light_us', sa.Boolean(), nullable=True),
sa.Column('tenant_id', sa.Integer(), nullable=False),
sa.Column('company_id', sa.Integer(), nullable=False),
sa.Column('deleted_at', sa.DateTime(), 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.ForeignKeyConstraint(['carrier_int_id'], ['a76.transporter.transporter_id'], ),
sa.ForeignKeyConstraint(['company_id'], ['a76.company.id'], ),
sa.ForeignKeyConstraint(['invoice_id'], ['a76.invoice_header.id'], ),
sa.ForeignKeyConstraint(['tenant_id'], ['core.tenants.id'], ),
sa.ForeignKeyConstraint(['trailer_int_id'], ['a76.trailer.trailer_id'], ),
sa.ForeignKeyConstraint(['transport_int_id'], ['a76.vehicle.vehicle_id'], ),
sa.PrimaryKeyConstraint('id'),
schema='a76'
)
op.create_index(op.f('ix_a76_invoice_logistics_company_id'), 'invoice_logistics', ['company_id'], unique=False, schema='a76')
op.create_index(op.f('ix_a76_invoice_logistics_tenant_id'), 'invoice_logistics', ['tenant_id'], unique=False, schema='a76')
op.create_table('invoice_sales_details',
sa.Column('id', sa.BigInteger(), autoincrement=True, nullable=False),
sa.Column('invoice_id', sa.BigInteger(), nullable=False),
sa.Column('line_number', sa.Integer(), nullable=False),
sa.Column('sales_order', sa.String(length=20), nullable=True),
sa.Column('colors_description', sa.String(length=49), nullable=True),
sa.Column('square_color_code', sa.String(length=1), nullable=True),
sa.Column('line_bundles', sa.Integer(), nullable=True),
sa.Column('tenant_id', sa.Integer(), nullable=False),
sa.Column('company_id', sa.Integer(), nullable=False),
sa.Column('deleted_at', sa.DateTime(), 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.ForeignKeyConstraint(['company_id'], ['a76.company.id'], ),
sa.ForeignKeyConstraint(['invoice_id'], ['a76.invoice_header.id'], ),
sa.ForeignKeyConstraint(['tenant_id'], ['core.tenants.id'], ),
sa.PrimaryKeyConstraint('id'),
schema='a76'
)
op.create_index(op.f('ix_a76_invoice_sales_details_company_id'), 'invoice_sales_details', ['company_id'], unique=False, schema='a76')
op.create_index(op.f('ix_a76_invoice_sales_details_tenant_id'), 'invoice_sales_details', ['tenant_id'], unique=False, schema='a76')
op.create_table('pedimentos',
sa.Column('id', sa.Integer(), nullable=False),
sa.Column('year', sa.String(length=2), nullable=False),
sa.Column('customs_office', sa.String(length=3), nullable=False),
sa.Column('license', sa.String(length=4), nullable=False),
sa.Column('pedimento_number', sa.String(length=7), nullable=False),
sa.Column('client_id', sa.Integer(), nullable=True),
sa.Column('operation_type', sa.String(length=3), nullable=False),
sa.Column('pedimento_type', sa.String(length=20), nullable=False),
sa.Column('pedimento_code', sa.String(length=2), nullable=False),
sa.Column('regime', sa.String(length=3), nullable=False),
sa.Column('status', sa.String(length=30), nullable=True),
sa.Column('usd_value', sa.Numeric(precision=17, scale=6), nullable=True),
sa.Column('paid_price', sa.Numeric(precision=17, scale=6), nullable=True),
sa.Column('gross_weight', sa.Numeric(precision=19, scale=3), nullable=True),
sa.Column('exchange_rate', sa.Numeric(precision=9, scale=5), nullable=True),
sa.Column('observations', sa.Text(), nullable=True),
sa.Column('tenant_id', sa.Integer(), nullable=False),
sa.Column('company_id', sa.Integer(), nullable=False),
sa.Column('deleted_at', sa.DateTime(), 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.ForeignKeyConstraint(['client_id'], ['a76.clients_and_providers.id'], name='fk_pedimentos_client'),
sa.ForeignKeyConstraint(['company_id'], ['a76.company.id'], ),
sa.ForeignKeyConstraint(['pedimento_code'], ['public.pedimento_codes.code'], name='fk_pedimentos_code'),
sa.ForeignKeyConstraint(['regime'], ['public.pedimento_regimens.code'], name='fk_pedimentos_regime'),
sa.ForeignKeyConstraint(['tenant_id'], ['core.tenants.id'], ),
sa.PrimaryKeyConstraint('id', name='pedimentos_pkey'),
sa.UniqueConstraint('tenant_id', 'company_id', 'year', 'customs_office', 'license', 'pedimento_number', name='pedimentos_unique_key'),
schema='a76'
)
op.create_index('idx_pedimentos_client_id', 'pedimentos', ['client_id'], unique=False, schema='a76')
op.create_index('idx_pedimentos_created_at', 'pedimentos', ['created_at'], unique=False, schema='a76')
op.create_index('idx_pedimentos_status', 'pedimentos', ['status'], unique=False, schema='a76')
op.create_index(op.f('ix_a76_pedimentos_company_id'), 'pedimentos', ['company_id'], unique=False, schema='a76')
op.create_index(op.f('ix_a76_pedimentos_tenant_id'), 'pedimentos', ['tenant_id'], unique=False, schema='a76')
op.create_table('unit_conversions',
sa.Column('id', sa.Integer(), autoincrement=True, nullable=False),
sa.Column('from_unit_code', sa.String(length=5), nullable=False),
sa.Column('to_unit_code', sa.String(length=5), nullable=False),
sa.Column('conversion_factor', sa.Numeric(precision=13, scale=6), nullable=True),
sa.Column('tenant_id', sa.Integer(), nullable=False),
sa.Column('company_id', sa.Integer(), nullable=False),
sa.Column('deleted_at', sa.DateTime(), 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.ForeignKeyConstraint(['company_id'], ['a76.company.id'], ),
sa.ForeignKeyConstraint(['from_unit_code', 'tenant_id', 'company_id'], ['a76.units_of_measure.code', 'a76.units_of_measure.tenant_id', 'a76.units_of_measure.company_id'], ),
sa.ForeignKeyConstraint(['tenant_id'], ['core.tenants.id'], ),
sa.ForeignKeyConstraint(['to_unit_code', 'tenant_id', 'company_id'], ['a76.units_of_measure.code', 'a76.units_of_measure.tenant_id', 'a76.units_of_measure.company_id'], ),
sa.PrimaryKeyConstraint('id'),
sa.UniqueConstraint('from_unit_code', 'to_unit_code', 'tenant_id', 'company_id', name='uq_unit_conversion_pair'),
schema='a76'
)
op.create_index(op.f('ix_a76_unit_conversions_company_id'), 'unit_conversions', ['company_id'], unique=False, schema='a76')
op.create_index(op.f('ix_a76_unit_conversions_tenant_id'), 'unit_conversions', ['tenant_id'], unique=False, schema='a76')
op.create_table('role_permissions',
sa.Column('id', sa.Integer(), nullable=False),
sa.Column('company_role_id', sa.Integer(), nullable=False),
sa.Column('permission_id', sa.Integer(), nullable=False),
sa.Column('tenant_id', sa.Integer(), nullable=False),
sa.Column('company_id', sa.Integer(), nullable=False),
sa.Column('deleted_at', sa.DateTime(), 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.ForeignKeyConstraint(['company_id'], ['a76.company.id'], ),
sa.ForeignKeyConstraint(['company_role_id'], ['core.company_roles.id'], ondelete='CASCADE'),
sa.ForeignKeyConstraint(['permission_id'], ['core.permissions.id'], ondelete='CASCADE'),
sa.ForeignKeyConstraint(['tenant_id'], ['core.tenants.id'], ),
sa.PrimaryKeyConstraint('id'),
sa.UniqueConstraint('company_role_id', 'permission_id', name='uq_role_permission'),
schema='core'
)
op.create_index(op.f('ix_core_role_permissions_company_id'), 'role_permissions', ['company_id'], unique=False, schema='core')
op.create_index(op.f('ix_core_role_permissions_company_role_id'), 'role_permissions', ['company_role_id'], unique=False, schema='core')
op.create_index(op.f('ix_core_role_permissions_id'), 'role_permissions', ['id'], unique=False, schema='core')
op.create_index(op.f('ix_core_role_permissions_permission_id'), 'role_permissions', ['permission_id'], unique=False, schema='core')
op.create_index(op.f('ix_core_role_permissions_tenant_id'), 'role_permissions', ['tenant_id'], unique=False, schema='core')
op.create_index('ix_role_permissions_composite', 'role_permissions', ['company_role_id', 'permission_id'], unique=False, schema='core')
op.create_table('user_company_roles',
sa.Column('id', sa.Integer(), nullable=False),
sa.Column('user_id', sa.String(length=100), nullable=False),
sa.Column('company_role_id', sa.Integer(), nullable=False),
sa.Column('is_active', sa.Boolean(), server_default='true', nullable=False),
sa.Column('assigned_by', sa.String(length=100), nullable=True),
sa.Column('tenant_id', sa.Integer(), nullable=False),
sa.Column('company_id', sa.Integer(), nullable=False),
sa.Column('deleted_at', sa.DateTime(), 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.ForeignKeyConstraint(['company_id'], ['a76.company.id'], ),
sa.ForeignKeyConstraint(['company_role_id'], ['core.company_roles.id'], ondelete='CASCADE'),
sa.ForeignKeyConstraint(['tenant_id'], ['core.tenants.id'], ),
sa.PrimaryKeyConstraint('id'),
sa.UniqueConstraint('user_id', 'company_id', 'tenant_id', 'company_role_id', name='uq_user_company_role'),
schema='core'
)
op.create_index(op.f('ix_core_user_company_roles_company_id'), 'user_company_roles', ['company_id'], unique=False, schema='core')
op.create_index(op.f('ix_core_user_company_roles_company_role_id'), 'user_company_roles', ['company_role_id'], unique=False, schema='core')
op.create_index(op.f('ix_core_user_company_roles_id'), 'user_company_roles', ['id'], unique=False, schema='core')
op.create_index(op.f('ix_core_user_company_roles_tenant_id'), 'user_company_roles', ['tenant_id'], unique=False, schema='core')
op.create_index(op.f('ix_core_user_company_roles_user_id'), 'user_company_roles', ['user_id'], unique=False, schema='core')
op.create_index('ix_user_company_roles_user_company', 'user_company_roles', ['user_id', 'company_id', 'tenant_id', 'is_active'], unique=False, schema='core')
op.create_table('fa_classes',
sa.Column('id', sa.Integer(), nullable=False),
sa.Column('class_id', sa.Integer(), nullable=False),
sa.Column('import_tariff_code', sa.String(length=10), nullable=True),
sa.Column('import_tariff_type', sa.String(length=6), nullable=True),
sa.Column('export_tariff_code', sa.String(length=10), nullable=True),
sa.Column('export_tariff_type', sa.String(length=6), nullable=True),
sa.Column('depreciation_rate', sa.Numeric(precision=5, scale=2), nullable=True),
sa.Column('fda_code', sa.String(length=20), nullable=True),
sa.Column('eccn_code', sa.String(length=20), nullable=True),
sa.Column('class_enabled', sa.Boolean(), server_default='true', nullable=False),
sa.Column('tenant_id', sa.Integer(), nullable=False),
sa.Column('company_id', sa.Integer(), nullable=False),
sa.Column('deleted_at', sa.DateTime(), 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.ForeignKeyConstraint(['class_id'], ['a76.classes.id'], name='fk_qclasses_classes'),
sa.ForeignKeyConstraint(['company_id'], ['a76.company.id'], ),
sa.ForeignKeyConstraint(['tenant_id'], ['core.tenants.id'], ),
sa.PrimaryKeyConstraint('id', name='qclases_pk'),
schema='a24'
)
op.create_index(op.f('ix_a24_fa_classes_company_id'), 'fa_classes', ['company_id'], unique=False, schema='a24')
op.create_index(op.f('ix_a24_fa_classes_tenant_id'), 'fa_classes', ['tenant_id'], unique=False, schema='a24')
op.create_table('inv_classes',
sa.Column('id', sa.Integer(), nullable=False),
sa.Column('class_id', sa.Integer(), nullable=False),
sa.Column('stock_um', sa.String(length=5), nullable=False),
sa.Column('us_tariff_code', sa.String(length=19), nullable=False),
sa.Column('tenant_id', sa.Integer(), nullable=False),
sa.Column('company_id', sa.Integer(), nullable=False),
sa.Column('deleted_at', sa.DateTime(), 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.ForeignKeyConstraint(['class_id'], ['a76.classes.id'], name='fk_sclasses_classes'),
sa.ForeignKeyConstraint(['company_id'], ['a76.company.id'], ),
sa.ForeignKeyConstraint(['tenant_id'], ['core.tenants.id'], ),
sa.PrimaryKeyConstraint('id', name='sclases_pk'),
schema='a24'
)
op.create_index(op.f('ix_a24_inv_classes_company_id'), 'inv_classes', ['company_id'], unique=False, schema='a24')
op.create_index(op.f('ix_a24_inv_classes_tenant_id'), 'inv_classes', ['tenant_id'], unique=False, schema='a24')
op.create_table('doda_container_seals',
sa.Column('id', sa.Integer(), autoincrement=True, nullable=False),
sa.Column('container_id', sa.Integer(), nullable=False),
sa.Column('doda_id', sa.Integer(), nullable=False),
sa.Column('seal_line', sa.Integer(), nullable=False),
sa.Column('seal_value', sa.String(length=21), nullable=True),
sa.Column('tenant_id', sa.Integer(), nullable=False),
sa.Column('company_id', sa.Integer(), nullable=False),
sa.Column('deleted_at', sa.DateTime(), 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.ForeignKeyConstraint(['company_id'], ['a76.company.id'], ),
sa.ForeignKeyConstraint(['container_id'], ['a76.doda_containers.id'], name='fk_doda_container_seals_container'),
sa.ForeignKeyConstraint(['tenant_id'], ['core.tenants.id'], ),
sa.PrimaryKeyConstraint('id', name='doda_container_seals_pkey'),
schema='a76'
)
op.create_index(op.f('ix_a76_doda_container_seals_company_id'), 'doda_container_seals', ['company_id'], unique=False, schema='a76')
op.create_index(op.f('ix_a76_doda_container_seals_tenant_id'), 'doda_container_seals', ['tenant_id'], unique=False, schema='a76')
op.create_table('invoice_compliance_mx',
sa.Column('invoice_id', sa.BigInteger(), nullable=False),
sa.Column('pedimento_id', sa.Integer(), nullable=True),
sa.Column('pedimento_r1', sa.Integer(), nullable=True),
sa.Column('pedimento_k1', sa.Integer(), nullable=True),
sa.Column('remesa', sa.Integer(), nullable=True),
sa.Column('aduana', sa.String(length=3), nullable=True),
sa.Column('port_of_entry', sa.String(length=6), nullable=True),
sa.Column('destination', sa.String(length=3), nullable=True),
sa.Column('manifest_number', sa.String(length=15), nullable=True),
sa.Column('provider_header', sa.String(length=20), nullable=True),
sa.Column('provider_id', sa.Integer(), nullable=True),
sa.Column('sold_to_header', sa.String(length=20), nullable=True),
sa.Column('sold_to_id', sa.Integer(), nullable=True),
sa.Column('shipped_to_header', sa.String(length=20), nullable=True),
sa.Column('shipped_to_id', sa.Integer(), nullable=True),
sa.Column('shipped_by_header', sa.String(length=20), nullable=True),
sa.Column('shipped_by_id', sa.Integer(), nullable=True),
sa.Column('customs_broker_id', sa.Integer(), nullable=True),
sa.Column('customs_broker_us_id', sa.Integer(), nullable=True),
sa.Column('broker_invoice_num', sa.String(length=20), nullable=True),
sa.Column('broker_invoice_date', sa.Date(), nullable=True),
sa.Column('is_mixed', sa.Boolean(), nullable=True),
sa.Column('waste_type', sa.String(length=1), nullable=True),
sa.Column('scrap_type', sa.String(length=1), nullable=True),
sa.Column('appendix_17', sa.Integer(), nullable=True),
sa.Column('is_regime_change', sa.Boolean(), server_default='false', nullable=True),
sa.Column('which_exchange_rate', sa.String(length=5), nullable=True),
sa.Column('value_method', sa.String(length=2), nullable=True),
sa.Column('act_value', sa.String(length=5), nullable=True),
sa.Column('rule_3121_parties_ii', sa.Boolean(), server_default='false', nullable=True),
sa.Column('is_pedimento_pending', sa.Boolean(), server_default='false', nullable=True),
sa.Column('is_owner_of_goods', sa.Boolean(), server_default='false', nullable=True),
sa.Column('generate_balances', sa.Boolean(), server_default='false', nullable=True),
sa.Column('was_reviewed_by_company', sa.Boolean(), nullable=True),
sa.Column('edocument', sa.String(length=50), nullable=True),
sa.Column('electronic_signature', sa.String(length=999), nullable=True),
sa.Column('certificate_number', sa.String(length=99), nullable=True),
sa.Column('niu_number', sa.String(length=19), nullable=True),
sa.Column('bill_of_lading_count', sa.String(length=12), nullable=True),
sa.Column('addendum_vu', sa.String(length=204), nullable=True),
sa.Column('origin_destination_cove', sa.String(length=20), nullable=True),
sa.Column('vucem_operation_num', sa.String(length=19), nullable=True),
sa.Column('customs_person_line', sa.Integer(), nullable=True),
sa.Column('contingency_mode', sa.Boolean(), nullable=True),
sa.Column('enclosure', sa.String(length=4), nullable=True),
sa.Column('guide_type_to_identify', sa.String(length=1), nullable=True),
sa.Column('location', sa.String(length=200), nullable=True),
sa.Column('dot_code', sa.String(length=20), nullable=True),
sa.Column('subdivision', sa.String(length=20), nullable=True),
sa.Column('acts_as', sa.String(length=20), nullable=True),
sa.Column('movement_type', sa.String(length=31), nullable=True),
sa.Column('office_document', sa.String(length=30), nullable=True),
sa.Column('reason_export', sa.String(length=1), nullable=True),
sa.Column('signature_key', sa.String(length=100), nullable=True),
sa.Column('sem_id', sa.Integer(), nullable=True),
sa.Column('tenant_id', sa.Integer(), nullable=False),
sa.Column('company_id', sa.Integer(), nullable=False),
sa.Column('deleted_at', sa.DateTime(), 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.ForeignKeyConstraint(['aduana'], ['public.customs_sections.customs_code'], ),
sa.ForeignKeyConstraint(['company_id'], ['a76.company.id'], ),
sa.ForeignKeyConstraint(['customs_broker_id'], ['a76.customs_brokers.id'], ),
sa.ForeignKeyConstraint(['customs_broker_us_id'], ['a76.customs_brokers.id'], ),
sa.ForeignKeyConstraint(['invoice_id'], ['a76.invoice_header.id'], ),
sa.ForeignKeyConstraint(['pedimento_id'], ['a76.pedimentos.id'], ),
sa.ForeignKeyConstraint(['pedimento_k1'], ['a76.pedimentos.id'], ),
sa.ForeignKeyConstraint(['pedimento_r1'], ['a76.pedimentos.id'], ),
sa.ForeignKeyConstraint(['provider_id'], ['a76.clients_and_providers.id'], ),
sa.ForeignKeyConstraint(['shipped_by_id'], ['a76.clients_and_providers.id'], ),
sa.ForeignKeyConstraint(['shipped_to_id'], ['a76.clients_and_providers.id'], ),
sa.ForeignKeyConstraint(['sold_to_id'], ['a76.clients_and_providers.id'], ),
sa.ForeignKeyConstraint(['tenant_id'], ['core.tenants.id'], ),
sa.PrimaryKeyConstraint('invoice_id'),
schema='a76'
)
op.create_index(op.f('ix_a76_invoice_compliance_mx_company_id'), 'invoice_compliance_mx', ['company_id'], unique=False, schema='a76')
op.create_index(op.f('ix_a76_invoice_compliance_mx_tenant_id'), 'invoice_compliance_mx', ['tenant_id'], unique=False, schema='a76')
op.create_table('parts',
sa.Column('id', sa.Integer(), nullable=False),
sa.Column('part_number', sa.String(length=70), nullable=False),
sa.Column('commercial_part_number', sa.String(length=70), nullable=True),
sa.Column('description_spanish', sa.String(length=500), nullable=True),
sa.Column('description_english', sa.String(length=500), nullable=True),
sa.Column('part_class', sa.String(length=8), nullable=True),
sa.Column('unit_of_measure', sa.String(length=5), nullable=True),
sa.Column('unit_cost', sa.Numeric(precision=23, scale=8), nullable=True),
sa.Column('currency_type', sa.String(length=2), nullable=True),
sa.Column('currency_key', sa.String(length=3), nullable=True),
sa.Column('unit_weight', sa.Numeric(precision=19, scale=8), nullable=True),
sa.Column('weight_type', sa.String(length=6), nullable=True),
sa.Column('fraction', sa.String(length=10), nullable=True),
sa.Column('us_fraction', sa.String(length=16), nullable=True),
sa.Column('fda_key', sa.String(length=20), nullable=True),
sa.Column('fcc_key', sa.String(length=30), nullable=True),
sa.Column('license_code', sa.String(length=3), nullable=True),
sa.Column('eccn', sa.String(length=20), nullable=True),
sa.Column('export_code', sa.String(length=2), nullable=True),
sa.Column('exclusion_symbol', sa.String(length=19), nullable=True),
sa.Column('is_active', sa.Boolean(), server_default='true', nullable=True),
sa.Column('part_photo', sa.String(length=255), nullable=True),
sa.Column('creation_date', sa.Integer(), nullable=True),
sa.Column('modification_date', sa.Integer(), nullable=True),
sa.Column('modification_date_iso', sa.DateTime(), nullable=True),
sa.Column('tenant_id', sa.Integer(), nullable=False),
sa.Column('company_id', sa.Integer(), nullable=False),
sa.Column('deleted_at', sa.DateTime(), 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.ForeignKeyConstraint(['company_id'], ['a76.company.id'], ),
sa.ForeignKeyConstraint(['currency_key'], ['public.currency_types.code'], name='fk_parts_currency'),
sa.ForeignKeyConstraint(['part_class', 'tenant_id', 'company_id'], ['a76.classes.class_code', 'a76.classes.tenant_id', 'a76.classes.company_id'], name='fk_parts_class'),
sa.ForeignKeyConstraint(['tenant_id'], ['core.tenants.id'], ),
sa.ForeignKeyConstraint(['unit_of_measure', 'tenant_id', 'company_id'], ['a76.units_of_measure.code', 'a76.units_of_measure.tenant_id', 'a76.units_of_measure.company_id'], ),
sa.PrimaryKeyConstraint('id', name='parts_pkey'),
sa.UniqueConstraint('tenant_id', 'company_id', 'part_number', name='client_part_ukey'),
schema='a76'
)
op.create_index(op.f('ix_a76_parts_company_id'), 'parts', ['company_id'], unique=False, schema='a76')
op.create_index(op.f('ix_a76_parts_tenant_id'), 'parts', ['tenant_id'], unique=False, schema='a76')
op.create_table('pedimento_config_additional',
sa.Column('id', sa.Integer(), nullable=False),
sa.Column('pedimento_id', sa.Integer(), nullable=False),
sa.Column('add_po_identifier', sa.Boolean(), nullable=False),
sa.Column('do_not_exempt_norms_complement_x', sa.Boolean(), nullable=False),
sa.Column('manual_pedimento_year', sa.Integer(), nullable=True),
sa.Column('enable_import_invoice_recipient', sa.Boolean(), nullable=False),
sa.Column('send_502_validation_file_for_consolidated', sa.Boolean(), nullable=False),
sa.Column('add_remove_norms', sa.Boolean(), nullable=False),
sa.Column('tenant_id', sa.Integer(), nullable=False),
sa.Column('company_id', sa.Integer(), nullable=False),
sa.Column('deleted_at', sa.DateTime(), 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.ForeignKeyConstraint(['company_id'], ['a76.company.id'], ),
sa.ForeignKeyConstraint(['pedimento_id'], ['a76.pedimentos.id'], name='fk_pedimento_config_additional', ondelete='CASCADE'),
sa.ForeignKeyConstraint(['tenant_id'], ['core.tenants.id'], ),
sa.PrimaryKeyConstraint('id', name='pedimento_config_additional_pkey'),
sa.UniqueConstraint('tenant_id', 'company_id', 'pedimento_id', name='pedimento_config_additional_pedimento_id_key'),
schema='a76'
)
op.create_index(op.f('ix_a76_pedimento_config_additional_company_id'), 'pedimento_config_additional', ['company_id'], unique=False, schema='a76')
op.create_index(op.f('ix_a76_pedimento_config_additional_tenant_id'), 'pedimento_config_additional', ['tenant_id'], unique=False, schema='a76')
op.create_table('pedimento_config_calculations',
sa.Column('id', sa.Integer(), nullable=False),
sa.Column('pedimento_id', sa.Integer(), nullable=False),
sa.Column('dta_type', sa.String(length=1), nullable=True),
sa.Column('dta_operation', sa.Boolean(), server_default='false', nullable=False),
sa.Column('dta_vehicle_count', sa.SmallInteger(), server_default='0', nullable=False),
sa.Column('dta_mixed_rate_8permil', sa.Boolean(), server_default='false', nullable=False),
sa.Column('pays_vat', sa.Boolean(), server_default='false', nullable=False),
sa.Column('pays_prevalidation', sa.Boolean(), server_default='false', nullable=False),
sa.Column('include_sagar_certificate_fee', sa.Boolean(), server_default='false', nullable=False),
sa.Column('fixed_vehicle_dta_fee', sa.Boolean(), server_default='false', nullable=False),
sa.Column('additional_fixed_fee', sa.SmallInteger(), server_default='0', nullable=False),
sa.Column('additional_fixed_fee_payment_method', sa.SmallInteger(), nullable=True),
sa.Column('tenant_id', sa.Integer(), nullable=False),
sa.Column('company_id', sa.Integer(), nullable=False),
sa.Column('deleted_at', sa.DateTime(), 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.ForeignKeyConstraint(['company_id'], ['a76.company.id'], ),
sa.ForeignKeyConstraint(['pedimento_id'], ['a76.pedimentos.id'], name='fk_pedimento_config_calculations', ondelete='CASCADE'),
sa.ForeignKeyConstraint(['tenant_id'], ['core.tenants.id'], ),
sa.PrimaryKeyConstraint('id', name='pedimento_config_calculations_pkey'),
sa.UniqueConstraint('tenant_id', 'company_id', 'pedimento_id', name='pedimento_config_calculations_pedimento_id_key'),
schema='a76'
)
op.create_index(op.f('ix_a76_pedimento_config_calculations_company_id'), 'pedimento_config_calculations', ['company_id'], unique=False, schema='a76')
op.create_index(op.f('ix_a76_pedimento_config_calculations_tenant_id'), 'pedimento_config_calculations', ['tenant_id'], unique=False, schema='a76')
op.create_table('pedimento_config_parameters',
sa.Column('id', sa.Integer(), nullable=False),
sa.Column('pedimento_id', sa.Integer(), nullable=False),
sa.Column('is_embassy', sa.Boolean(), server_default='false', nullable=False),
sa.Column('embassy_dta', sa.Numeric(precision=11, scale=2), server_default='0.00', nullable=False),
sa.Column('rule_3121_section_ii', sa.Boolean(), server_default='false', nullable=False),
sa.Column('use_previous_tariff', sa.Boolean(), server_default='false', nullable=False),
sa.Column('use_payment_date_fi', sa.Boolean(), server_default='false', nullable=False),
sa.Column('add_state_supplier_record_505', sa.Boolean(), server_default='false', nullable=False),
sa.Column('customs_value_calculation', sa.Boolean(), server_default='false', nullable=False),
sa.Column('two_decimals_unit_value', sa.Boolean(), server_default='false', nullable=False),
sa.Column('customs_value_per_item', sa.Boolean(), server_default='false', nullable=False),
sa.Column('is_national_supplier', sa.Boolean(), server_default='false', nullable=False),
sa.Column('is_consolidated', sa.Boolean(), server_default='false', nullable=False),
sa.Column('tenant_id', sa.Integer(), nullable=False),
sa.Column('company_id', sa.Integer(), nullable=False),
sa.Column('deleted_at', sa.DateTime(), 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.ForeignKeyConstraint(['company_id'], ['a76.company.id'], ),
sa.ForeignKeyConstraint(['pedimento_id'], ['a76.pedimentos.id'], name='fk_pedimento_config_parameters', ondelete='CASCADE'),
sa.ForeignKeyConstraint(['tenant_id'], ['core.tenants.id'], ),
sa.PrimaryKeyConstraint('id', name='pedimento_config_parameters_pkey'),
sa.UniqueConstraint('tenant_id', 'company_id', 'pedimento_id', name='pedimento_config_parameters_pedimento_id_key'),
schema='a76'
)
op.create_index(op.f('ix_a76_pedimento_config_parameters_company_id'), 'pedimento_config_parameters', ['company_id'], unique=False, schema='a76')
op.create_index(op.f('ix_a76_pedimento_config_parameters_tenant_id'), 'pedimento_config_parameters', ['tenant_id'], unique=False, schema='a76')
op.create_table('pedimento_config_surcharges',
sa.Column('id', sa.Integer(), nullable=False),
sa.Column('pedimento_id', sa.Integer(), nullable=False),
sa.Column('surcharge_igi', sa.Boolean(), nullable=False),
sa.Column('surcharge_dta', sa.Boolean(), nullable=False),
sa.Column('surcharge_vat', sa.Boolean(), nullable=False),
sa.Column('surcharge_isan', sa.Boolean(), nullable=False),
sa.Column('surcharge_ieps', sa.Boolean(), nullable=False),
sa.Column('surcharge_cc', sa.Boolean(), nullable=False),
sa.Column('tenant_id', sa.Integer(), nullable=False),
sa.Column('company_id', sa.Integer(), nullable=False),
sa.Column('deleted_at', sa.DateTime(), 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.ForeignKeyConstraint(['company_id'], ['a76.company.id'], ),
sa.ForeignKeyConstraint(['pedimento_id'], ['a76.pedimentos.id'], name='fk_pedimento_config_surcharges', ondelete='CASCADE'),
sa.ForeignKeyConstraint(['tenant_id'], ['core.tenants.id'], ),
sa.PrimaryKeyConstraint('id', name='pedimento_config_surcharges_pkey'),
sa.UniqueConstraint('tenant_id', 'company_id', 'pedimento_id', name='pedimento_config_surcharges_pedimento_id_key'),
schema='a76'
)
op.create_index(op.f('ix_a76_pedimento_config_surcharges_company_id'), 'pedimento_config_surcharges', ['company_id'], unique=False, schema='a76')
op.create_index(op.f('ix_a76_pedimento_config_surcharges_tenant_id'), 'pedimento_config_surcharges', ['tenant_id'], unique=False, schema='a76')
op.create_table('pedimento_config_update_rectification',
sa.Column('id', sa.Integer(), nullable=False),
sa.Column('pedimento_id', sa.Integer(), nullable=False),
sa.Column('update_vat', sa.Boolean(), server_default='false', nullable=False),
sa.Column('update_advalorem', sa.Boolean(), server_default='false', nullable=False),
sa.Column('update_dta', sa.Boolean(), server_default='false', nullable=False),
sa.Column('update_cc', sa.Boolean(), server_default='false', nullable=False),
sa.Column('update_ieps', sa.Boolean(), server_default='false', nullable=False),
sa.Column('calculate_surcharge', sa.Boolean(), server_default='false', nullable=False),
sa.Column('tenant_id', sa.Integer(), nullable=False),
sa.Column('company_id', sa.Integer(), nullable=False),
sa.Column('deleted_at', sa.DateTime(), 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.ForeignKeyConstraint(['company_id'], ['a76.company.id'], ),
sa.ForeignKeyConstraint(['pedimento_id'], ['a76.pedimentos.id'], name='fk_pedimento_config_update_rectification', ondelete='CASCADE'),
sa.ForeignKeyConstraint(['tenant_id'], ['core.tenants.id'], ),
sa.PrimaryKeyConstraint('id', name='pedimento_config_update_rectification_pkey'),
sa.UniqueConstraint('tenant_id', 'company_id', 'pedimento_id', name='pedimento_config_update_rectification_pedimento_id_key'),
schema='a76'
)
op.create_index(op.f('ix_a76_pedimento_config_update_rectification_company_id'), 'pedimento_config_update_rectification', ['company_id'], unique=False, schema='a76')
op.create_index(op.f('ix_a76_pedimento_config_update_rectification_tenant_id'), 'pedimento_config_update_rectification', ['tenant_id'], unique=False, schema='a76')
op.create_table('pedimento_config_updates',
sa.Column('id', sa.Integer(), nullable=False),
sa.Column('pedimento_id', sa.Integer(), nullable=False),
sa.Column('update_vat', sa.Boolean(), server_default='false', nullable=False),
sa.Column('update_advalorem', sa.Boolean(), server_default='false', nullable=False),
sa.Column('update_dta', sa.Boolean(), server_default='false', nullable=False),
sa.Column('update_cc', sa.Boolean(), server_default='false', nullable=False),
sa.Column('update_ieps', sa.Boolean(), server_default='false', nullable=False),
sa.Column('tenant_id', sa.Integer(), nullable=False),
sa.Column('company_id', sa.Integer(), nullable=False),
sa.Column('deleted_at', sa.DateTime(), 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.ForeignKeyConstraint(['company_id'], ['a76.company.id'], ),
sa.ForeignKeyConstraint(['pedimento_id'], ['a76.pedimentos.id'], name='fk_pedimento_config_updates', ondelete='CASCADE'),
sa.ForeignKeyConstraint(['tenant_id'], ['core.tenants.id'], ),
sa.PrimaryKeyConstraint('id', name='pedimento_config_updates_pkey'),
sa.UniqueConstraint('tenant_id', 'company_id', 'pedimento_id', name='pedimento_config_updates_pedimento_id_key'),
schema='a76'
)
op.create_index(op.f('ix_a76_pedimento_config_updates_company_id'), 'pedimento_config_updates', ['company_id'], unique=False, schema='a76')
op.create_index(op.f('ix_a76_pedimento_config_updates_tenant_id'), 'pedimento_config_updates', ['tenant_id'], unique=False, schema='a76')
op.create_table('pedimento_containers',
sa.Column('id', sa.Integer(), nullable=False),
sa.Column('pedimento_id', sa.Integer(), nullable=False),
sa.Column('number', sa.String(length=100), nullable=True),
sa.Column('identification', sa.String(length=100), nullable=True),
sa.Column('type', sa.String(length=50), nullable=True),
sa.Column('tenant_id', sa.Integer(), nullable=False),
sa.Column('company_id', sa.Integer(), nullable=False),
sa.Column('deleted_at', sa.DateTime(), 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.ForeignKeyConstraint(['company_id'], ['a76.company.id'], ),
sa.ForeignKeyConstraint(['pedimento_id'], ['a76.pedimentos.id'], name='fk_pedimento_containers', ondelete='CASCADE'),
sa.ForeignKeyConstraint(['tenant_id'], ['core.tenants.id'], ),
sa.PrimaryKeyConstraint('id', name='pedimento_containers_pkey'),
schema='a76'
)
op.create_index(op.f('ix_a76_pedimento_containers_company_id'), 'pedimento_containers', ['company_id'], unique=False, schema='a76')
op.create_index(op.f('ix_a76_pedimento_containers_tenant_id'), 'pedimento_containers', ['tenant_id'], unique=False, schema='a76')
op.create_table('pedimento_contributions',
sa.Column('id', sa.Integer(), nullable=False),
sa.Column('pedimento_id', sa.Integer(), nullable=False),
sa.Column('contribucion', sa.String(length=50), nullable=True),
sa.Column('tipo_tasa', sa.String(length=100), nullable=True),
sa.Column('tasa', sa.Numeric(precision=15, scale=8), nullable=True),
sa.Column('forma_pago', sa.String(length=50), nullable=True),
sa.Column('importe', sa.Numeric(precision=17, scale=2), nullable=True),
sa.Column('gravamen', sa.String(length=100), nullable=True),
sa.Column('abreviacion', sa.String(length=50), nullable=True),
sa.Column('forma_pago_2', sa.String(length=50), nullable=True),
sa.Column('importe_2', sa.Numeric(precision=17, scale=2), nullable=True),
sa.Column('tenant_id', sa.Integer(), nullable=False),
sa.Column('company_id', sa.Integer(), nullable=False),
sa.Column('deleted_at', sa.DateTime(), 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.ForeignKeyConstraint(['company_id'], ['a76.company.id'], ),
sa.ForeignKeyConstraint(['pedimento_id'], ['a76.pedimentos.id'], name='fk_pedimento_contributions', ondelete='CASCADE'),
sa.ForeignKeyConstraint(['tenant_id'], ['core.tenants.id'], ),
sa.PrimaryKeyConstraint('id', name='pedimento_contributions_pkey'),
schema='a76'
)
op.create_index(op.f('ix_a76_pedimento_contributions_company_id'), 'pedimento_contributions', ['company_id'], unique=False, schema='a76')
op.create_index(op.f('ix_a76_pedimento_contributions_tenant_id'), 'pedimento_contributions', ['tenant_id'], unique=False, schema='a76')
op.create_table('pedimento_customs_offices',
sa.Column('id', sa.Integer(), nullable=False),
sa.Column('pedimento_id', sa.Integer(), nullable=False),
sa.Column('dispatch_customs', sa.String(length=3), nullable=False),
sa.Column('entry_exit_customs', sa.String(length=3), nullable=False),
sa.Column('tenant_id', sa.Integer(), nullable=False),
sa.Column('company_id', sa.Integer(), nullable=False),
sa.Column('deleted_at', sa.DateTime(), 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.ForeignKeyConstraint(['company_id'], ['a76.company.id'], ),
sa.ForeignKeyConstraint(['pedimento_id'], ['a76.pedimentos.id'], name='fk_pedimento_customs_offices', ondelete='CASCADE'),
sa.ForeignKeyConstraint(['tenant_id'], ['core.tenants.id'], ),
sa.PrimaryKeyConstraint('id', name='pedimento_customs_offices_pkey'),
sa.UniqueConstraint('tenant_id', 'company_id', 'pedimento_id', name='pedimento_customs_offices_pedimento_id_key'),
schema='a76'
)
op.create_index(op.f('ix_a76_pedimento_customs_offices_company_id'), 'pedimento_customs_offices', ['company_id'], unique=False, schema='a76')
op.create_index(op.f('ix_a76_pedimento_customs_offices_tenant_id'), 'pedimento_customs_offices', ['tenant_id'], unique=False, schema='a76')
op.create_table('pedimento_dates',
sa.Column('id', sa.Integer(), nullable=False),
sa.Column('pedimento_id', sa.Integer(), nullable=False),
sa.Column('entry_date', sa.DateTime(), nullable=False),
sa.Column('pedimento_date', sa.DateTime(), nullable=True),
sa.Column('payment_date', sa.DateTime(), nullable=True),
sa.Column('rectification_payment_date', sa.DateTime(), nullable=True),
sa.Column('extraction_date', sa.DateTime(), nullable=True),
sa.Column('submission_date', sa.DateTime(), nullable=True),
sa.Column('eucan_date', sa.DateTime(), nullable=True),
sa.Column('original_date', sa.DateTime(), nullable=True),
sa.Column('start_date', sa.DateTime(), nullable=True),
sa.Column('end_date', sa.DateTime(), nullable=False),
sa.Column('capture_time', sa.Time(), nullable=False),
sa.Column('tenant_id', sa.Integer(), nullable=False),
sa.Column('company_id', sa.Integer(), nullable=False),
sa.Column('deleted_at', sa.DateTime(), 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.ForeignKeyConstraint(['company_id'], ['a76.company.id'], ),
sa.ForeignKeyConstraint(['pedimento_id'], ['a76.pedimentos.id'], name='fk_pedimento_dates', ondelete='CASCADE'),
sa.ForeignKeyConstraint(['tenant_id'], ['core.tenants.id'], ),
sa.PrimaryKeyConstraint('id', name='pedimento_dates_pkey'),
sa.UniqueConstraint('tenant_id', 'company_id', 'pedimento_id', name='pedimento_dates_pedimento_id_key'),
schema='a76'
)
op.create_index('idx_pedimento_dates_pedimento_id', 'pedimento_dates', ['pedimento_id'], unique=False, schema='a76')
op.create_index(op.f('ix_a76_pedimento_dates_company_id'), 'pedimento_dates', ['company_id'], unique=False, schema='a76')
op.create_index(op.f('ix_a76_pedimento_dates_tenant_id'), 'pedimento_dates', ['tenant_id'], unique=False, schema='a76')
op.create_table('pedimento_decrementables',
sa.Column('id', sa.Integer(), nullable=False),
sa.Column('pedimento_id', sa.Integer(), nullable=False),
sa.Column('freight', sa.Numeric(precision=13, scale=2), nullable=True),
sa.Column('insurance', sa.Numeric(precision=13, scale=2), nullable=True),
sa.Column('loading', sa.Numeric(precision=13, scale=2), nullable=True),
sa.Column('unloading', sa.Numeric(precision=13, scale=2), nullable=True),
sa.Column('others', sa.Numeric(precision=13, scale=2), nullable=True),
sa.Column('currency', sa.String(length=3), nullable=True),
sa.Column('currency_factor', sa.Numeric(precision=15, scale=8), nullable=True),
sa.Column('not_affect_usd_value', sa.SmallInteger(), nullable=True),
sa.Column('not_affect_customs_value', sa.SmallInteger(), nullable=True),
sa.Column('tenant_id', sa.Integer(), nullable=False),
sa.Column('company_id', sa.Integer(), nullable=False),
sa.Column('deleted_at', sa.DateTime(), 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.ForeignKeyConstraint(['company_id'], ['a76.company.id'], ),
sa.ForeignKeyConstraint(['pedimento_id'], ['a76.pedimentos.id'], name='fk_pedimento_decrementables', ondelete='CASCADE'),
sa.ForeignKeyConstraint(['tenant_id'], ['core.tenants.id'], ),
sa.PrimaryKeyConstraint('id', name='pedimento_decrementables_pkey'),
sa.UniqueConstraint('tenant_id', 'company_id', 'pedimento_id', name='pedimento_decrementables_pedimento_id_key'),
schema='a76'
)
op.create_index(op.f('ix_a76_pedimento_decrementables_company_id'), 'pedimento_decrementables', ['company_id'], unique=False, schema='a76')
op.create_index(op.f('ix_a76_pedimento_decrementables_tenant_id'), 'pedimento_decrementables', ['tenant_id'], unique=False, schema='a76')
op.create_table('pedimento_guides',
sa.Column('id', sa.Integer(), nullable=False),
sa.Column('pedimento_id', sa.Integer(), nullable=False),
sa.Column('guide', sa.String(length=100), nullable=True),
sa.Column('identifier', sa.String(length=100), nullable=True),
sa.Column('tenant_id', sa.Integer(), nullable=False),
sa.Column('company_id', sa.Integer(), nullable=False),
sa.Column('deleted_at', sa.DateTime(), 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.ForeignKeyConstraint(['company_id'], ['a76.company.id'], ),
sa.ForeignKeyConstraint(['pedimento_id'], ['a76.pedimentos.id'], name='fk_pedimento_guides', ondelete='CASCADE'),
sa.ForeignKeyConstraint(['tenant_id'], ['core.tenants.id'], ),
sa.PrimaryKeyConstraint('id', name='pedimento_guides_pkey'),
schema='a76'
)
op.create_index(op.f('ix_a76_pedimento_guides_company_id'), 'pedimento_guides', ['company_id'], unique=False, schema='a76')
op.create_index(op.f('ix_a76_pedimento_guides_tenant_id'), 'pedimento_guides', ['tenant_id'], unique=False, schema='a76')
op.create_table('pedimento_incrementables',
sa.Column('id', sa.Integer(), nullable=False),
sa.Column('pedimento_id', sa.Integer(), nullable=False),
sa.Column('insured_value', sa.Numeric(precision=13, scale=2), nullable=True),
sa.Column('freight', sa.Numeric(precision=13, scale=2), nullable=True),
sa.Column('insurance', sa.Numeric(precision=13, scale=2), nullable=True),
sa.Column('packaging', sa.Numeric(precision=13, scale=2), nullable=True),
sa.Column('others', sa.Numeric(precision=13, scale=3), nullable=True),
sa.Column('deductibles', sa.Numeric(precision=13, scale=3), nullable=True),
sa.Column('currency', sa.String(length=3), nullable=True),
sa.Column('currency_factor', sa.Numeric(precision=15, scale=8), nullable=True),
sa.Column('not_affect_usd_value', sa.SmallInteger(), nullable=True),
sa.Column('not_affect_customs_value', sa.SmallInteger(), nullable=True),
sa.Column('tenant_id', sa.Integer(), nullable=False),
sa.Column('company_id', sa.Integer(), nullable=False),
sa.Column('deleted_at', sa.DateTime(), 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.ForeignKeyConstraint(['company_id'], ['a76.company.id'], ),
sa.ForeignKeyConstraint(['pedimento_id'], ['a76.pedimentos.id'], name='fk_pedimento_incrementables', ondelete='CASCADE'),
sa.ForeignKeyConstraint(['tenant_id'], ['core.tenants.id'], ),
sa.PrimaryKeyConstraint('id', name='pedimento_incrementables_pkey'),
sa.UniqueConstraint('tenant_id', 'company_id', 'pedimento_id', name='pedimento_incrementables_pedimento_id_key'),
schema='a76'
)
op.create_index(op.f('ix_a76_pedimento_incrementables_company_id'), 'pedimento_incrementables', ['company_id'], unique=False, schema='a76')
op.create_index(op.f('ix_a76_pedimento_incrementables_tenant_id'), 'pedimento_incrementables', ['tenant_id'], unique=False, schema='a76')
op.create_table('pedimento_indexes',
sa.Column('id', sa.Integer(), nullable=False),
sa.Column('pedimento_id', sa.Integer(), nullable=False),
sa.Column('update_factor_type', sa.SmallInteger(), nullable=True),
sa.Column('update_factor', sa.Numeric(precision=7, scale=4), nullable=True),
sa.Column('manual_update_factor', sa.SmallInteger(), nullable=True),
sa.Column('tenant_id', sa.Integer(), nullable=False),
sa.Column('company_id', sa.Integer(), nullable=False),
sa.Column('deleted_at', sa.DateTime(), 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.ForeignKeyConstraint(['company_id'], ['a76.company.id'], ),
sa.ForeignKeyConstraint(['pedimento_id'], ['a76.pedimentos.id'], name='fk_pedimento_indexes', ondelete='CASCADE'),
sa.ForeignKeyConstraint(['tenant_id'], ['core.tenants.id'], ),
sa.PrimaryKeyConstraint('id', name='pedimento_indexes_pkey'),
sa.UniqueConstraint('tenant_id', 'company_id', 'pedimento_id', name='pedimento_indexes_pedimento_id_key'),
schema='a76'
)
op.create_index(op.f('ix_a76_pedimento_indexes_company_id'), 'pedimento_indexes', ['company_id'], unique=False, schema='a76')
op.create_index(op.f('ix_a76_pedimento_indexes_tenant_id'), 'pedimento_indexes', ['tenant_id'], unique=False, schema='a76')
op.create_table('pedimento_packages',
sa.Column('id', sa.Integer(), nullable=False),
sa.Column('pedimento_id', sa.Integer(), nullable=False),
sa.Column('quantity', sa.Integer(), nullable=True),
sa.Column('brand', sa.String(length=100), nullable=True),
sa.Column('number', sa.String(length=100), nullable=True),
sa.Column('vehicles', sa.Integer(), nullable=True),
sa.Column('tenant_id', sa.Integer(), nullable=False),
sa.Column('company_id', sa.Integer(), nullable=False),
sa.Column('deleted_at', sa.DateTime(), 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.ForeignKeyConstraint(['company_id'], ['a76.company.id'], ),
sa.ForeignKeyConstraint(['pedimento_id'], ['a76.pedimentos.id'], name='fk_pedimento_packages', ondelete='CASCADE'),
sa.ForeignKeyConstraint(['tenant_id'], ['core.tenants.id'], ),
sa.PrimaryKeyConstraint('id', name='pedimento_packages_pkey'),
sa.UniqueConstraint('tenant_id', 'company_id', 'pedimento_id', name='pedimento_packages_pedimento_id_key'),
schema='a76'
)
op.create_index(op.f('ix_a76_pedimento_packages_company_id'), 'pedimento_packages', ['company_id'], unique=False, schema='a76')
op.create_index(op.f('ix_a76_pedimento_packages_tenant_id'), 'pedimento_packages', ['tenant_id'], unique=False, schema='a76')
op.create_table('pedimento_payments',
sa.Column('id', sa.Integer(), nullable=False),
sa.Column('pedimento_id', sa.Integer(), nullable=False),
sa.Column('acknowledgment', sa.String(length=20), nullable=False),
sa.Column('operation_number', sa.String(length=14), nullable=False),
sa.Column('bank_code', sa.Integer(), nullable=False),
sa.Column('cashier', sa.String(length=2), nullable=False),
sa.Column('date', sa.Date(), nullable=False),
sa.Column('time', sa.Time(), nullable=False),
sa.Column('shift', sa.String(length=1), nullable=False),
sa.Column('total_cash_paid', sa.Integer(), nullable=False),
sa.Column('total_contributions', sa.Integer(), nullable=False),
sa.Column('counter_payment', sa.SmallInteger(), nullable=False),
sa.Column('pece_code', sa.String(length=5), nullable=False),
sa.Column('tenant_id', sa.Integer(), nullable=False),
sa.Column('company_id', sa.Integer(), nullable=False),
sa.Column('deleted_at', sa.DateTime(), 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.ForeignKeyConstraint(['company_id'], ['a76.company.id'], ),
sa.ForeignKeyConstraint(['pedimento_id'], ['a76.pedimentos.id'], name='fk_pedimento_payments', ondelete='CASCADE'),
sa.ForeignKeyConstraint(['tenant_id'], ['core.tenants.id'], ),
sa.PrimaryKeyConstraint('id', name='pedimento_payments_pkey'),
sa.UniqueConstraint('tenant_id', 'company_id', 'pedimento_id', name='pedimento_payments_pedimento_id_key'),
schema='a76'
)
op.create_index('idx_pedimento_payments_pedimento_id', 'pedimento_payments', ['pedimento_id'], unique=False, schema='a76')
op.create_index(op.f('ix_a76_pedimento_payments_company_id'), 'pedimento_payments', ['company_id'], unique=False, schema='a76')
op.create_index(op.f('ix_a76_pedimento_payments_tenant_id'), 'pedimento_payments', ['tenant_id'], unique=False, schema='a76')
op.create_table('pedimento_rectification_destination',
sa.Column('id', sa.Integer(), nullable=False),
sa.Column('pedimento_id', sa.Integer(), nullable=False),
sa.Column('destination_pedimento_year', sa.String(length=2), nullable=False),
sa.Column('destination_customs_office', sa.String(length=3), nullable=False),
sa.Column('destination_license', sa.String(length=4), nullable=False),
sa.Column('destination_pedimento_number', sa.String(length=7), nullable=False),
sa.Column('tenant_id', sa.Integer(), nullable=False),
sa.Column('company_id', sa.Integer(), nullable=False),
sa.Column('deleted_at', sa.DateTime(), 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.ForeignKeyConstraint(['company_id'], ['a76.company.id'], ),
sa.ForeignKeyConstraint(['pedimento_id'], ['a76.pedimentos.id'], name='fk_pedimento_rectification_destination', ondelete='CASCADE'),
sa.ForeignKeyConstraint(['tenant_id'], ['core.tenants.id'], ),
sa.PrimaryKeyConstraint('id', name='pedimento_rectification_destination_pkey'),
sa.UniqueConstraint('tenant_id', 'company_id', 'pedimento_id', name='pedimento_rectification_destination_pedimento_id_key'),
schema='a76'
)
op.create_index(op.f('ix_a76_pedimento_rectification_destination_company_id'), 'pedimento_rectification_destination', ['company_id'], unique=False, schema='a76')
op.create_index(op.f('ix_a76_pedimento_rectification_destination_tenant_id'), 'pedimento_rectification_destination', ['tenant_id'], unique=False, schema='a76')
op.create_table('pedimento_rectification_origin',
sa.Column('id', sa.Integer(), nullable=False),
sa.Column('pedimento_id', sa.Integer(), nullable=False),
sa.Column('original_pedimento_year', sa.String(length=2), nullable=True),
sa.Column('original_customs_office', sa.String(length=3), nullable=True),
sa.Column('original_license', sa.String(length=4), nullable=True),
sa.Column('original_pedimento_number', sa.String(length=7), nullable=True),
sa.Column('original_pedimento_code', sa.String(length=2), nullable=True),
sa.Column('original_payment_date', sa.DateTime(), nullable=True),
sa.Column('total_cash', sa.Integer(), nullable=True),
sa.Column('total_others', sa.Integer(), nullable=True),
sa.Column('reason', sa.String(length=255), nullable=True),
sa.Column('charge_to_client', sa.SmallInteger(), nullable=True),
sa.Column('use_original_payment_date_for_interest_calc', sa.SmallInteger(), nullable=True),
sa.Column('manual_calculation', sa.SmallInteger(), nullable=True),
sa.Column('original_pedimento_norms', sa.SmallInteger(), nullable=True),
sa.Column('tenant_id', sa.Integer(), nullable=False),
sa.Column('company_id', sa.Integer(), nullable=False),
sa.Column('deleted_at', sa.DateTime(), 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.ForeignKeyConstraint(['company_id'], ['a76.company.id'], ),
sa.ForeignKeyConstraint(['pedimento_id'], ['a76.pedimentos.id'], name='fk_pedimento_rectification_origin', ondelete='CASCADE'),
sa.ForeignKeyConstraint(['tenant_id'], ['core.tenants.id'], ),
sa.PrimaryKeyConstraint('id', name='pedimento_rectification_origin_pkey'),
sa.UniqueConstraint('tenant_id', 'company_id', 'pedimento_id', name='pedimento_rectification_origin_pedimento_id_key'),
schema='a76'
)
op.create_index(op.f('ix_a76_pedimento_rectification_origin_company_id'), 'pedimento_rectification_origin', ['company_id'], unique=False, schema='a76')
op.create_index(op.f('ix_a76_pedimento_rectification_origin_tenant_id'), 'pedimento_rectification_origin', ['tenant_id'], unique=False, schema='a76')
op.create_table('pedimento_seals',
sa.Column('id', sa.Integer(), nullable=False),
sa.Column('pedimento_id', sa.Integer(), nullable=False),
sa.Column('number', sa.String(length=100), nullable=True),
sa.Column('identification', sa.String(length=100), nullable=True),
sa.Column('tenant_id', sa.Integer(), nullable=False),
sa.Column('company_id', sa.Integer(), nullable=False),
sa.Column('deleted_at', sa.DateTime(), 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.ForeignKeyConstraint(['company_id'], ['a76.company.id'], ),
sa.ForeignKeyConstraint(['pedimento_id'], ['a76.pedimentos.id'], name='fk_pedimento_seals', ondelete='CASCADE'),
sa.ForeignKeyConstraint(['tenant_id'], ['core.tenants.id'], ),
sa.PrimaryKeyConstraint('id', name='pedimento_seals_pkey'),
schema='a76'
)
op.create_index(op.f('ix_a76_pedimento_seals_company_id'), 'pedimento_seals', ['company_id'], unique=False, schema='a76')
op.create_index(op.f('ix_a76_pedimento_seals_tenant_id'), 'pedimento_seals', ['tenant_id'], unique=False, schema='a76')
op.create_table('pedimento_transport_carriers',
sa.Column('id', sa.Integer(), nullable=False),
sa.Column('pedimento_id', sa.Integer(), nullable=False),
sa.Column('carrier', sa.String(length=200), nullable=True),
sa.Column('rfc', sa.String(length=20), nullable=True),
sa.Column('curp', sa.String(length=20), nullable=True),
sa.Column('name', sa.String(length=200), nullable=True),
sa.Column('address', sa.String(length=300), nullable=True),
sa.Column('city', sa.String(length=100), nullable=True),
sa.Column('state', sa.String(length=100), nullable=True),
sa.Column('country', sa.String(length=3), nullable=True),
sa.Column('tax_id', sa.String(length=50), nullable=True),
sa.Column('total_packages', sa.Integer(), nullable=True),
sa.Column('identification', sa.String(length=100), nullable=True),
sa.Column('tenant_id', sa.Integer(), nullable=False),
sa.Column('company_id', sa.Integer(), nullable=False),
sa.Column('deleted_at', sa.DateTime(), 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.ForeignKeyConstraint(['company_id'], ['a76.company.id'], ),
sa.ForeignKeyConstraint(['pedimento_id'], ['a76.pedimentos.id'], name='fk_pedimento_transport_carriers', ondelete='CASCADE'),
sa.ForeignKeyConstraint(['tenant_id'], ['core.tenants.id'], ),
sa.PrimaryKeyConstraint('id', name='pedimento_transport_carriers_pkey'),
schema='a76'
)
op.create_index(op.f('ix_a76_pedimento_transport_carriers_company_id'), 'pedimento_transport_carriers', ['company_id'], unique=False, schema='a76')
op.create_index(op.f('ix_a76_pedimento_transport_carriers_tenant_id'), 'pedimento_transport_carriers', ['tenant_id'], unique=False, schema='a76')
op.create_table('pedimento_transport_means',
sa.Column('id', sa.Integer(), nullable=False),
sa.Column('pedimento_id', sa.Integer(), nullable=False),
sa.Column('destination', sa.SmallInteger(), nullable=False),
sa.Column('entry_exit', sa.String(length=3), nullable=False),
sa.Column('arrival', sa.String(length=3), nullable=False),
sa.Column('departure', sa.String(length=3), nullable=False),
sa.Column('tenant_id', sa.Integer(), nullable=False),
sa.Column('company_id', sa.Integer(), nullable=False),
sa.Column('deleted_at', sa.DateTime(), 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.ForeignKeyConstraint(['company_id'], ['a76.company.id'], ),
sa.ForeignKeyConstraint(['pedimento_id'], ['a76.pedimentos.id'], name='fk_pedimento_transport_means', ondelete='CASCADE'),
sa.ForeignKeyConstraint(['tenant_id'], ['core.tenants.id'], ),
sa.PrimaryKeyConstraint('id', name='pedimento_transport_means_pkey'),
sa.UniqueConstraint('tenant_id', 'company_id', 'pedimento_id', name='pedimento_transport_means_pedimento_id_key'),
schema='a76'
)
op.create_index(op.f('ix_a76_pedimento_transport_means_company_id'), 'pedimento_transport_means', ['company_id'], unique=False, schema='a76')
op.create_index(op.f('ix_a76_pedimento_transport_means_tenant_id'), 'pedimento_transport_means', ['tenant_id'], unique=False, schema='a76')
op.create_table('pedimento_validation',
sa.Column('id', sa.Integer(), nullable=False),
sa.Column('pedimento_id', sa.Integer(), nullable=False),
sa.Column('validator', sa.String(length=3), nullable=False),
sa.Column('validation_ack', sa.String(length=8), nullable=False),
sa.Column('pre_ack', sa.String(length=8), nullable=False),
sa.Column('line_signature', sa.String(length=50), nullable=False),
sa.Column('electronic_signature', sa.String(length=999), nullable=False),
sa.Column('certificate_number', sa.String(length=99), nullable=False),
sa.Column('validator_id', sa.Integer(), nullable=False),
sa.Column('responsible_id', sa.Integer(), nullable=False),
sa.Column('tenant_id', sa.Integer(), nullable=False),
sa.Column('company_id', sa.Integer(), nullable=False),
sa.Column('deleted_at', sa.DateTime(), 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.ForeignKeyConstraint(['company_id'], ['a76.company.id'], ),
sa.ForeignKeyConstraint(['pedimento_id'], ['a76.pedimentos.id'], name='fk_pedimento_validation', ondelete='CASCADE'),
sa.ForeignKeyConstraint(['tenant_id'], ['core.tenants.id'], ),
sa.PrimaryKeyConstraint('id', name='pedimento_validation_pkey'),
sa.UniqueConstraint('tenant_id', 'company_id', 'pedimento_id', name='pedimento_validation_pedimento_id_key'),
schema='a76'
)
op.create_index(op.f('ix_a76_pedimento_validation_company_id'), 'pedimento_validation', ['company_id'], unique=False, schema='a76')
op.create_index(op.f('ix_a76_pedimento_validation_tenant_id'), 'pedimento_validation', ['tenant_id'], unique=False, schema='a76')
op.create_table('fa_partes',
sa.Column('id', sa.Integer(), autoincrement=False, nullable=False),
sa.Column('origin_country', sa.String(length=3), nullable=True),
sa.Column('sector', sa.String(length=8), nullable=True),
sa.Column('fraction_type', sa.String(length=7), nullable=True),
sa.Column('tenant_id', sa.Integer(), nullable=False),
sa.Column('company_id', sa.Integer(), nullable=False),
sa.Column('deleted_at', sa.DateTime(), 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.ForeignKeyConstraint(['company_id'], ['a76.company.id'], ),
sa.ForeignKeyConstraint(['id'], ['a76.parts.id'], name='fk_fa_partes_master'),
sa.ForeignKeyConstraint(['tenant_id'], ['core.tenants.id'], ),
sa.PrimaryKeyConstraint('id', name='fa_partes_pkey'),
schema='a24'
)
op.create_index(op.f('ix_a24_fa_partes_company_id'), 'fa_partes', ['company_id'], unique=False, schema='a24')
op.create_index(op.f('ix_a24_fa_partes_tenant_id'), 'fa_partes', ['tenant_id'], unique=False, schema='a24')
op.create_table('inv_bom',
sa.Column('id', sa.Integer(), autoincrement=True, nullable=False),
sa.Column('parent_part_id', sa.Integer(), nullable=False),
sa.Column('component_part_id', sa.Integer(), nullable=False),
sa.Column('quantity', sa.Numeric(precision=19, scale=8), nullable=False),
sa.Column('uom_code', sa.String(length=5), nullable=False),
sa.Column('procedure_type', sa.String(length=10), nullable=True),
sa.Column('is_percentage', sa.Boolean(), nullable=False),
sa.Column('raw_material', sa.Numeric(precision=19, scale=8), nullable=True),
sa.Column('waste', sa.Numeric(precision=19, scale=8), nullable=True),
sa.Column('merma', sa.Numeric(precision=19, scale=8), nullable=True),
sa.Column('tenant_id', sa.Integer(), nullable=False),
sa.Column('company_id', sa.Integer(), nullable=False),
sa.Column('deleted_at', sa.DateTime(), 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.ForeignKeyConstraint(['company_id'], ['a76.company.id'], ),
sa.ForeignKeyConstraint(['component_part_id'], ['a76.parts.id'], name='fk_inv_bom_component'),
sa.ForeignKeyConstraint(['parent_part_id'], ['a76.parts.id'], name='fk_inv_bom_parent'),
sa.ForeignKeyConstraint(['tenant_id'], ['core.tenants.id'], ),
sa.PrimaryKeyConstraint('id', name='inv_bom_pkey'),
schema='a24'
)
op.create_index(op.f('ix_a24_inv_bom_company_id'), 'inv_bom', ['company_id'], unique=False, schema='a24')
op.create_index(op.f('ix_a24_inv_bom_tenant_id'), 'inv_bom', ['tenant_id'], unique=False, schema='a24')
op.create_table('inv_parte_paises',
sa.Column('id', sa.Integer(), autoincrement=True, nullable=False),
sa.Column('part_id', sa.Integer(), nullable=False),
sa.Column('country_code', sa.String(length=3), nullable=False),
sa.Column('fraction', sa.String(length=20), nullable=True),
sa.Column('is_origin', sa.Boolean(), nullable=False),
sa.Column('preference', sa.String(length=15), nullable=False),
sa.Column('has_certificate', sa.Boolean(), nullable=False),
sa.Column('certificate_number', sa.String(length=50), nullable=True),
sa.Column('end_date', sa.DateTime(), nullable=True),
sa.Column('previous_fractions_7m', sa.Boolean(), nullable=False),
sa.Column('omission_import', sa.Boolean(), nullable=False),
sa.Column('omission_export', sa.Boolean(), nullable=False),
sa.Column('import_percentage', sa.Numeric(precision=5, scale=2), nullable=True),
sa.Column('export_percentage', sa.Numeric(precision=5, scale=2), nullable=True),
sa.Column('sector', sa.String(length=10), nullable=True),
sa.Column('tenant_id', sa.Integer(), nullable=False),
sa.Column('company_id', sa.Integer(), nullable=False),
sa.Column('deleted_at', sa.DateTime(), 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.ForeignKeyConstraint(['company_id'], ['a76.company.id'], ),
sa.ForeignKeyConstraint(['part_id'], ['a76.parts.id'], name='fk_inv_parte_paises_part'),
sa.ForeignKeyConstraint(['tenant_id'], ['core.tenants.id'], ),
sa.PrimaryKeyConstraint('id', name='inv_parte_paises_pkey'),
schema='a24'
)
op.create_index(op.f('ix_a24_inv_parte_paises_company_id'), 'inv_parte_paises', ['company_id'], unique=False, schema='a24')
op.create_index(op.f('ix_a24_inv_parte_paises_tenant_id'), 'inv_parte_paises', ['tenant_id'], unique=False, schema='a24')
op.create_table('inv_partes',
sa.Column('id', sa.Integer(), autoincrement=False, nullable=False),
sa.Column('part_type', sa.String(length=10), nullable=True),
sa.Column('material_type', sa.String(length=10), nullable=True),
sa.Column('reference_number', sa.String(length=70), nullable=True),
sa.Column('flex_reference_number', sa.String(length=120), nullable=True),
sa.Column('equivalent_uom', sa.String(length=5), nullable=True),
sa.Column('conversion_factor', sa.Numeric(precision=19, scale=8), nullable=True),
sa.Column('stock_uom', sa.String(length=5), nullable=True),
sa.Column('alternate_uom', sa.String(length=5), nullable=True),
sa.Column('conversion_uom', sa.String(length=9), nullable=True),
sa.Column('added_value', sa.Numeric(precision=23, scale=8), nullable=True),
sa.Column('added_value_type', sa.String(length=2), nullable=True),
sa.Column('assigned_client', sa.String(length=50), nullable=True),
sa.Column('supplier_code', sa.String(length=8), nullable=True),
sa.Column('is_textile', sa.String(length=2), nullable=True),
sa.Column('bom_version', sa.Integer(), nullable=True),
sa.Column('is_repair', sa.String(length=3), nullable=True),
sa.Column('is_hazardous', sa.String(length=1), nullable=True),
sa.Column('emergency_number', sa.String(length=30), nullable=True),
sa.Column('danger_class', sa.String(length=4), nullable=True),
sa.Column('packaging_group', sa.String(length=3), nullable=True),
sa.Column('width', sa.String(length=50), nullable=True),
sa.Column('thickness', sa.String(length=50), nullable=True),
sa.Column('specification', sa.String(length=50), nullable=True),
sa.Column('total_value', sa.Numeric(precision=23, scale=8), nullable=True),
sa.Column('direct_labor', sa.Numeric(precision=23, scale=8), nullable=True),
sa.Column('general_expenses', sa.Numeric(precision=23, scale=8), nullable=True),
sa.Column('total_expenses', sa.Numeric(precision=23, scale=8), nullable=True),
sa.Column('depreciation', sa.Numeric(precision=23, scale=8), nullable=True),
sa.Column('tooling', sa.Numeric(precision=23, scale=8), nullable=True),
sa.Column('material_consumed', sa.Numeric(precision=23, scale=8), nullable=True),
sa.Column('profit', sa.Numeric(precision=23, scale=8), nullable=True),
sa.Column('us_fraction_alt', sa.String(length=13), nullable=True),
sa.Column('ca_fraction', sa.String(length=13), nullable=True),
sa.Column('ad_valorem_us', sa.Numeric(precision=5, scale=2), nullable=True),
sa.Column('nafta_result', sa.String(length=19), nullable=True),
sa.Column('nafta_percentage', sa.Numeric(precision=5, scale=2), nullable=True),
sa.Column('dta', sa.String(length=19), nullable=True),
sa.Column('dtb', sa.String(length=19), nullable=True),
sa.Column('dtg', sa.String(length=19), nullable=True),
sa.Column('substitute_part', sa.String(length=70), nullable=True),
sa.Column('complementary_part', sa.String(length=70), nullable=True),
sa.Column('preference_part', sa.String(length=70), nullable=True),
sa.Column('use_alternate_quantity', sa.Boolean(), nullable=True),
sa.Column('un_number', sa.String(length=30), nullable=True),
sa.Column('shipping_name', sa.String(length=200), nullable=True),
sa.Column('hazard_notes', sa.String(length=500), nullable=True),
sa.Column('repair_unit_cost', sa.Numeric(precision=23, scale=8), nullable=True),
sa.Column('repair_added_value', sa.Numeric(precision=23, scale=8), nullable=True),
sa.Column('fraction_9801', sa.String(length=10), nullable=True),
sa.Column('immex_type', sa.String(length=10), nullable=True),
sa.Column('disable_movements', sa.Boolean(), nullable=True),
sa.Column('pga_program_code', sa.String(length=10), nullable=True),
sa.Column('usmca_fraction', sa.String(length=10), nullable=True),
sa.Column('scrap_part_number', sa.String(length=70), nullable=True),
sa.Column('waste_part_number', sa.String(length=70), nullable=True),
sa.Column('scrap_description_en', sa.String(length=500), nullable=True),
sa.Column('scrap_description_es', sa.String(length=500), nullable=True),
sa.Column('scrap_export_fraction', sa.String(length=10), nullable=True),
sa.Column('scrap_us_fraction', sa.String(length=10), nullable=True),
sa.Column('equivalent_uom_2', sa.String(length=5), nullable=True),
sa.Column('conversion_factor_2', sa.Numeric(precision=19, scale=8), nullable=True),
sa.Column('has_auxiliary', sa.Boolean(), nullable=True),
sa.Column('auxiliary_uom', sa.String(length=5), nullable=True),
sa.Column('auxiliary_conversion', sa.Numeric(precision=19, scale=8), nullable=True),
sa.Column('auxiliary_unit_cost', sa.Numeric(precision=23, scale=8), nullable=True),
sa.Column('mex_packing', sa.Numeric(precision=23, scale=8), nullable=True),
sa.Column('sales_order', sa.String(length=50), nullable=True),
sa.Column('use_rule_8', sa.Boolean(), nullable=True),
sa.Column('sector', sa.String(length=150), nullable=True),
sa.Column('origin_country', sa.String(length=3), nullable=True),
sa.Column('fraction_type', sa.String(length=10), nullable=True),
sa.Column('agency_code_definition', sa.String(length=50), nullable=True),
sa.Column('carta_porte', sa.String(length=100), nullable=True),
sa.Column('client_part_names', postgresql.JSONB(astext_type=sa.Text()), nullable=True),
sa.Column('part_identifiers', postgresql.JSONB(astext_type=sa.Text()), nullable=True),
sa.Column('substitute_parts', postgresql.JSONB(astext_type=sa.Text()), nullable=True),
sa.Column('aphis_data', postgresql.JSONB(astext_type=sa.Text()), nullable=True),
sa.Column('non_discharge_clients', postgresql.JSONB(astext_type=sa.Text()), nullable=True),
sa.Column('tenant_id', sa.Integer(), nullable=False),
sa.Column('company_id', sa.Integer(), nullable=False),
sa.Column('deleted_at', sa.DateTime(), 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.ForeignKeyConstraint(['company_id'], ['a76.company.id'], ),
sa.ForeignKeyConstraint(['id'], ['a76.parts.id'], name='fk_inv_partes_master'),
sa.ForeignKeyConstraint(['tenant_id'], ['core.tenants.id'], ),
sa.PrimaryKeyConstraint('id', name='inv_partes_pkey'),
schema='a24'
)
op.create_index(op.f('ix_a24_inv_partes_company_id'), 'inv_partes', ['company_id'], unique=False, schema='a24')
op.create_index(op.f('ix_a24_inv_partes_tenant_id'), 'inv_partes', ['tenant_id'], unique=False, schema='a24')
op.create_table('item_lines',
sa.Column('id', sa.Integer(), autoincrement=True, nullable=False),
sa.Column('invoice_id', sa.BigInteger(), nullable=False),
sa.Column('line_number', sa.Integer(), nullable=False),
sa.Column('part_number_id', sa.Integer(), nullable=True),
sa.Column('component_part_number_id', sa.Integer(), nullable=True),
sa.Column('class_id', sa.Integer(), nullable=True),
sa.Column('unit_of_measure', sa.Integer(), nullable=True),
sa.Column('alternate_unit', sa.Integer(), nullable=True),
sa.Column('uma_key', sa.String(length=2), nullable=True),
sa.Column('auxiliary_unit', sa.String(length=5), nullable=True),
sa.Column('permit_number', sa.String(length=20), nullable=True),
sa.Column('page_line', sa.String(length=10), nullable=True),
sa.Column('has_certificate', sa.Boolean(), nullable=True),
sa.Column('certificate_number', sa.String(length=10), nullable=True),
sa.Column('octave_permit', sa.String(length=20), nullable=True),
sa.Column('permits_ped', sa.String(length=500), nullable=True),
sa.Column('has_fda_code', sa.Boolean(), nullable=True),
sa.Column('fda_key', sa.String(length=10), nullable=True),
sa.Column('is_military_mcia', sa.Boolean(), nullable=True),
sa.Column('iv32_type_key', sa.String(length=5), nullable=True),
sa.Column('iv32_number', sa.String(length=35), nullable=True),
sa.Column('scrap_invoice', sa.String(length=15), nullable=True),
sa.Column('consecutive_destination', sa.Integer(), nullable=True),
sa.Column('ctm_section', sa.String(length=3), nullable=True),
sa.Column('tax_payment', sa.Boolean(), nullable=True),
sa.Column('payment_method', sa.String(length=9), nullable=True),
sa.Column('igi_amount', sa.Numeric(precision=23, scale=8), nullable=True),
sa.Column('igi_payment_method', sa.String(length=9), nullable=True),
sa.Column('fcc_key', sa.String(length=30), nullable=True),
sa.Column('valuation_method', sa.String(length=2), nullable=True),
sa.Column('valuation_determined_value', sa.Numeric(precision=29, scale=8), nullable=True),
sa.Column('valuation_reason', sa.String(length=500), nullable=True),
sa.Column('container_rule', sa.String(length=50), nullable=True),
sa.Column('container_parts_ii', sa.String(length=50), nullable=True),
sa.Column('consecutive_aphis', sa.Integer(), nullable=True),
sa.Column('bom_version', sa.Integer(), nullable=True),
sa.Column('bill_version', sa.Integer(), nullable=True),
sa.Column('tlcan_value', sa.Numeric(precision=23, scale=8), nullable=True),
sa.Column('identifier', sa.String(length=2), nullable=True),
sa.Column('validation_zero', sa.Integer(), nullable=True),
sa.Column('validation_one', sa.Integer(), nullable=True),
sa.Column('material_type', sa.String(length=50), nullable=True),
sa.Column('order_type', sa.String(length=50), nullable=True),
sa.Column('line_concept', sa.String(length=50), nullable=True),
sa.Column('review_dispatch', sa.String(length=10), nullable=True),
sa.Column('take_component_pt', sa.Integer(), nullable=True),
sa.Column('pallet2', sa.SmallInteger(), nullable=True),
sa.Column('wildcard_field', sa.String(length=100), nullable=True),
sa.Column('reference_number', sa.String(length=20), nullable=True),
sa.Column('order', sa.String(length=50), nullable=True),
sa.Column('guide_number', sa.String(length=50), nullable=True),
sa.Column('depreciation_date', sa.Date(), nullable=True),
sa.Column('rectification', sa.Boolean(), nullable=True),
sa.Column('warehouse', sa.String(length=30), nullable=True),
sa.Column('location', sa.String(length=200), nullable=True),
sa.Column('tenant_id', sa.Integer(), nullable=False),
sa.Column('company_id', sa.Integer(), nullable=False),
sa.Column('deleted_at', sa.DateTime(), 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.ForeignKeyConstraint(['alternate_unit'], ['a76.units_of_measure.id'], ),
sa.ForeignKeyConstraint(['class_id'], ['a76.classes.id'], ),
sa.ForeignKeyConstraint(['company_id'], ['a76.company.id'], ),
sa.ForeignKeyConstraint(['component_part_number_id'], ['a76.parts.id'], ),
sa.ForeignKeyConstraint(['invoice_id'], ['a76.invoice_header.id'], ),
sa.ForeignKeyConstraint(['part_number_id'], ['a76.parts.id'], ),
sa.ForeignKeyConstraint(['tenant_id'], ['core.tenants.id'], ),
sa.ForeignKeyConstraint(['unit_of_measure'], ['a76.units_of_measure.id'], ),
sa.PrimaryKeyConstraint('id'),
schema='a76'
)
op.create_index(op.f('ix_a76_item_lines_company_id'), 'item_lines', ['company_id'], unique=False, schema='a76')
op.create_index(op.f('ix_a76_item_lines_tenant_id'), 'item_lines', ['tenant_id'], unique=False, schema='a76')
op.create_table('balance_movement',
sa.Column('id', sa.BigInteger(), autoincrement=True, nullable=False),
sa.Column('import_invoice_id', sa.BigInteger(), nullable=False, comment='Import invoice (cabecera de importación)'),
sa.Column('import_item_line_id', sa.Integer(), nullable=False, comment='Import line item = the PEPS lot'),
sa.Column('part_number_id', sa.Integer(), nullable=True, comment='Denormalized from item_lines.part_number_id. Enables PEPS index without joins.'),
sa.Column('movement_type', sa.String(length=20), nullable=False, comment='See MovementType enum. Determines sign and whether qty counts as used.'),
sa.Column('quantity', sa.Numeric(precision=19, scale=8), nullable=False, comment='Always positive. Sign is inferred from movement_type via NEGATIVE_MOVEMENTS.'),
sa.Column('value_me', sa.Numeric(precision=23, scale=8), nullable=True, comment='USD'),
sa.Column('value_mn', sa.Numeric(precision=23, scale=8), nullable=True, comment='MXN'),
sa.Column('net_weight', sa.Numeric(precision=19, scale=8), nullable=True),
sa.Column('source_invoice_id', sa.BigInteger(), nullable=True, comment='Export / SM / CTM invoice. NULL for entries.'),
sa.Column('source_item_line_id', sa.Integer(), nullable=True, comment='Specific line in the export / SM / CTM invoice.'),
sa.Column('order_peps', sa.BigInteger(), nullable=False, comment='PEPS order within this lot. Lower = older = consumed first.'),
sa.Column('operation_date', sa.Date(), nullable=False, comment='Date of the actual business event, not DB insert.'),
sa.Column('notes', sa.String(length=300), nullable=True),
sa.Column('tenant_id', sa.Integer(), nullable=False),
sa.Column('company_id', sa.Integer(), nullable=False),
sa.Column('deleted_at', sa.DateTime(), 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.CheckConstraint('quantity > 0', name='ck_balance_movement_qty_positive'),
sa.ForeignKeyConstraint(['company_id'], ['a76.company.id'], ),
sa.ForeignKeyConstraint(['import_invoice_id'], ['a76.invoice_header.id'], ),
sa.ForeignKeyConstraint(['import_item_line_id'], ['a76.item_lines.id'], ),
sa.ForeignKeyConstraint(['part_number_id'], ['a76.parts.id'], ),
sa.ForeignKeyConstraint(['source_invoice_id'], ['a76.invoice_header.id'], ),
sa.ForeignKeyConstraint(['source_item_line_id'], ['a76.item_lines.id'], ),
sa.ForeignKeyConstraint(['tenant_id'], ['core.tenants.id'], ),
sa.PrimaryKeyConstraint('id'),
sa.UniqueConstraint('import_item_line_id', 'order_peps', name='uq_balance_movement_lot_peps'),
schema='a24'
)
op.create_index(op.f('ix_a24_balance_movement_company_id'), 'balance_movement', ['company_id'], unique=False, schema='a24')
op.create_index(op.f('ix_a24_balance_movement_tenant_id'), 'balance_movement', ['tenant_id'], unique=False, schema='a24')
op.create_index('ix_balmov_lot', 'balance_movement', ['import_item_line_id'], unique=False, schema='a24')
op.create_index('ix_balmov_operation_date', 'balance_movement', ['tenant_id', 'operation_date', 'movement_type'], unique=False, schema='a24')
op.create_index('ix_balmov_peps_lookup', 'balance_movement', ['tenant_id', 'part_number_id', 'movement_type', 'order_peps'], unique=False, schema='a24', postgresql_include=['import_item_line_id', 'quantity', 'value_me', 'value_mn'])
op.create_index('ix_balmov_source', 'balance_movement', ['source_invoice_id', 'source_item_line_id'], unique=False, schema='a24')
op.create_table('fa_item_lines',
sa.Column('id', sa.Integer(), autoincrement=False, nullable=False),
sa.Column('asset_number', sa.String(length=25), nullable=True),
sa.Column('asset_photo', sa.String(length=255), nullable=True),
sa.Column('equipment_message', sa.String(length=40), nullable=True),
sa.Column('invoice_type_asset', sa.String(length=6), nullable=True),
sa.Column('return_import_invoice', sa.String(length=15), nullable=True),
sa.Column('return_import_date', sa.Integer(), nullable=True),
sa.Column('movement_type_import', sa.String(length=3), nullable=True),
sa.Column('search_invoice', sa.String(length=15), nullable=True),
sa.Column('search_line', sa.Integer(), nullable=True),
sa.Column('search_type', sa.String(length=10), nullable=True),
sa.Column('is_subitem', sa.Boolean(), nullable=True),
sa.Column('contains_subitems', sa.Boolean(), nullable=True),
sa.Column('subitem_number', sa.Integer(), nullable=True),
sa.Column('discharge', sa.Boolean(), nullable=True),
sa.Column('own_equipment', sa.Boolean(), nullable=True),
sa.Column('omit_annex31', sa.Boolean(), nullable=True),
sa.Column('tenant_id', sa.Integer(), nullable=False),
sa.Column('company_id', sa.Integer(), nullable=False),
sa.Column('deleted_at', sa.DateTime(), 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.ForeignKeyConstraint(['company_id'], ['a76.company.id'], ),
sa.ForeignKeyConstraint(['id'], ['a76.item_lines.id'], name='fk_fa_item_lines_master'),
sa.ForeignKeyConstraint(['tenant_id'], ['core.tenants.id'], ),
sa.PrimaryKeyConstraint('id', name='fa_item_lines_pkey'),
schema='a24'
)
op.create_index(op.f('ix_a24_fa_item_lines_company_id'), 'fa_item_lines', ['company_id'], unique=False, schema='a24')
op.create_index(op.f('ix_a24_fa_item_lines_tenant_id'), 'fa_item_lines', ['tenant_id'], unique=False, schema='a24')
op.create_table('inv_aphis_general',
sa.Column('id', sa.Integer(), autoincrement=True, nullable=False),
sa.Column('inv_part_id', sa.Integer(), nullable=False),
sa.Column('program_code', sa.String(length=10), nullable=True),
sa.Column('processing_code', sa.String(length=10), nullable=True),
sa.Column('aphis_type', sa.String(length=10), nullable=True),
sa.Column('disclaimer', sa.String(length=10), nullable=True),
sa.Column('electronic_image', sa.String(length=50), nullable=True),
sa.Column('confidential', sa.String(length=1), nullable=True),
sa.Column('global_product_id', sa.String(length=100), nullable=True),
sa.Column('intended_use_code', sa.String(length=10), nullable=True),
sa.Column('intended_use_description', sa.String(length=200), nullable=True),
sa.Column('item_type', sa.String(length=20), nullable=True),
sa.Column('product_code', sa.String(length=20), nullable=True),
sa.Column('product_code_2', sa.String(length=20), nullable=True),
sa.Column('product_code_3', sa.String(length=20), nullable=True),
sa.Column('scientific_genus_name', sa.String(length=100), nullable=True),
sa.Column('scientific_species_name', sa.String(length=100), nullable=True),
sa.Column('scientific_sub_species_name', sa.String(length=100), nullable=True),
sa.Column('common_name_specific', sa.String(length=200), nullable=True),
sa.Column('common_name_general', sa.String(length=200), nullable=True),
sa.Column('signed_doc', sa.String(length=100), nullable=True),
sa.Column('signed_doc_date', sa.Date(), nullable=True),
sa.Column('signed_doc_id', sa.String(length=50), nullable=True),
sa.Column('invoice_number', sa.String(length=50), nullable=True),
sa.Column('quantity_1', sa.String(length=50), nullable=True),
sa.Column('quantity_2', sa.String(length=50), nullable=True),
sa.Column('quantity_3', sa.String(length=50), nullable=True),
sa.Column('inspection', sa.String(length=200), nullable=True),
sa.Column('inspection_date', sa.Date(), nullable=True),
sa.Column('inspection_loc_date', sa.Date(), nullable=True),
sa.Column('inspection_location', sa.String(length=200), nullable=True),
sa.Column('country_production', sa.String(length=3), nullable=True),
sa.Column('country_source', sa.String(length=3), nullable=True),
sa.Column('tenant_id', sa.Integer(), nullable=False),
sa.Column('company_id', sa.Integer(), nullable=False),
sa.Column('deleted_at', sa.DateTime(), 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.ForeignKeyConstraint(['company_id'], ['a76.company.id'], ),
sa.ForeignKeyConstraint(['inv_part_id'], ['a24.inv_partes.id'], name='fk_aphis_general_inv_part'),
sa.ForeignKeyConstraint(['tenant_id'], ['core.tenants.id'], ),
sa.PrimaryKeyConstraint('id', name='inv_aphis_general_pkey'),
schema='a24'
)
op.create_index(op.f('ix_a24_inv_aphis_general_company_id'), 'inv_aphis_general', ['company_id'], unique=False, schema='a24')
op.create_index(op.f('ix_a24_inv_aphis_general_tenant_id'), 'inv_aphis_general', ['tenant_id'], unique=False, schema='a24')
op.create_table('ctm_receipts',
sa.Column('id', sa.Integer(), autoincrement=True, nullable=False),
sa.Column('receipt_line', sa.Integer(), nullable=False),
sa.Column('option', sa.String(length=3), nullable=True),
sa.Column('exit_invoice', sa.String(length=19), nullable=True),
sa.Column('tenant_id', sa.Integer(), nullable=False),
sa.Column('company_id', sa.Integer(), nullable=False),
sa.Column('deleted_at', sa.DateTime(), 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.ForeignKeyConstraint(['company_id'], ['a76.company.id'], ),
sa.ForeignKeyConstraint(['receipt_line'], ['a76.item_lines.id'], ),
sa.ForeignKeyConstraint(['tenant_id'], ['core.tenants.id'], ),
sa.PrimaryKeyConstraint('id'),
schema='a76'
)
op.create_index(op.f('ix_a76_ctm_receipts_company_id'), 'ctm_receipts', ['company_id'], unique=False, schema='a76')
op.create_index(op.f('ix_a76_ctm_receipts_tenant_id'), 'ctm_receipts', ['tenant_id'], unique=False, schema='a76')
op.create_table('identifier_details',
sa.Column('id', sa.Integer(), autoincrement=True, nullable=False),
sa.Column('invoice_consecutive', sa.Integer(), nullable=True),
sa.Column('part_line', sa.Integer(), nullable=True),
sa.Column('identifier_code', sa.String(length=2), nullable=True),
sa.Column('item_line_id', sa.Integer(), nullable=True),
sa.Column('module', sa.String(length=20), nullable=True),
sa.Column('complement1', sa.String(length=50), nullable=True),
sa.Column('complement2', sa.String(length=51), nullable=True),
sa.Column('complement3', sa.String(length=50), nullable=True),
sa.Column('tenant_id', sa.Integer(), nullable=False),
sa.Column('company_id', sa.Integer(), nullable=False),
sa.Column('deleted_at', sa.DateTime(), 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.ForeignKeyConstraint(['company_id'], ['a76.company.id'], ),
sa.ForeignKeyConstraint(['identifier_code'], ['a76.identifiers.code'], ),
sa.ForeignKeyConstraint(['item_line_id'], ['a76.item_lines.id'], ),
sa.ForeignKeyConstraint(['tenant_id'], ['core.tenants.id'], ),
sa.PrimaryKeyConstraint('id'),
schema='a76'
)
op.create_index(op.f('ix_a76_identifier_details_company_id'), 'identifier_details', ['company_id'], unique=False, schema='a76')
op.create_index(op.f('ix_a76_identifier_details_tenant_id'), 'identifier_details', ['tenant_id'], unique=False, schema='a76')
op.create_table('item_line_customs',
sa.Column('id', sa.Integer(), autoincrement=True, nullable=False),
sa.Column('item_line_id', sa.Integer(), nullable=False),
sa.Column('fraction', sa.String(length=10), nullable=True),
sa.Column('fraction_type', sa.String(length=7), nullable=True),
sa.Column('american_fraction', sa.String(length=16), nullable=True),
sa.Column('alternate_fraction', sa.String(length=10), nullable=True),
sa.Column('reference_fraction', sa.String(length=10), nullable=True),
sa.Column('octave_fraction', sa.String(length=10), nullable=True),
sa.Column('tlcan_fraction', sa.String(length=13), nullable=True),
sa.Column('extra_american_fraction', sa.String(length=16), nullable=True),
sa.Column('garment_fraction', sa.String(length=19), nullable=True),
sa.Column('advalorem', sa.String(length=10), nullable=True),
sa.Column('advalorem_numeric', sa.Numeric(precision=7, scale=2), nullable=True),
sa.Column('advalorem_american', sa.Numeric(precision=5, scale=2), nullable=True),
sa.Column('advalorem_tlcan', sa.Numeric(precision=5, scale=2), nullable=True),
sa.Column('rate', sa.String(length=10), nullable=True),
sa.Column('depreciation_rate', sa.Numeric(precision=5, scale=2), nullable=True),
sa.Column('origin_country', sa.String(length=3), nullable=True),
sa.Column('destination_country', sa.String(length=3), nullable=True),
sa.Column('optional_country', sa.String(length=3), nullable=True),
sa.Column('origin_procedure', sa.String(length=3), nullable=True),
sa.Column('scrap_procedure', sa.String(length=3), nullable=True),
sa.Column('sector', sa.String(length=8), nullable=True),
sa.ForeignKeyConstraint(['item_line_id'], ['a76.item_lines.id'], ),
sa.PrimaryKeyConstraint('id'),
schema='a76'
)
op.create_table('item_line_descriptions',
sa.Column('id', sa.Integer(), autoincrement=True, nullable=False),
sa.Column('item_line_id', sa.Integer(), nullable=False),
sa.Column('description_spanish', sa.String(length=4999), nullable=True),
sa.Column('description_english', sa.String(length=4999), nullable=True),
sa.Column('extra_description', sa.Text(), nullable=True),
sa.Column('part_description', sa.String(length=500), nullable=True),
sa.Column('class_description', sa.String(length=500), nullable=True),
sa.Column('package_description', sa.String(length=500), nullable=True),
sa.Column('brand', sa.String(length=50), nullable=True),
sa.Column('model', sa.String(length=50), nullable=True),
sa.Column('has_serial', sa.Boolean(), nullable=True),
sa.Column('additional_info_spanish', sa.String(length=1000), nullable=True),
sa.Column('additional_info_english', sa.String(length=1000), nullable=True),
sa.Column('lot', sa.String(length=254), nullable=True),
sa.Column('entry_number', sa.String(length=50), nullable=True),
sa.Column('eighth_rule_fraction', sa.String(length=20), nullable=True),
sa.Column('eighth_rule_line', sa.Integer(), nullable=True),
sa.Column('consider_a31', sa.Boolean(), nullable=True),
sa.Column('machinery_location', sa.String(length=200), nullable=True),
sa.ForeignKeyConstraint(['item_line_id'], ['a76.item_lines.id'], ),
sa.PrimaryKeyConstraint('id'),
schema='a76'
)
op.create_table('item_line_financials',
sa.Column('id', sa.Integer(), autoincrement=True, nullable=False),
sa.Column('item_line_id', sa.Integer(), nullable=False),
sa.Column('unit_cost_capture', sa.Numeric(precision=23, scale=8), nullable=True),
sa.Column('unit_cost_usd', sa.Numeric(precision=23, scale=8), nullable=True),
sa.Column('unit_cost_commercial_usd', sa.Numeric(precision=23, scale=8), nullable=True),
sa.Column('unit_cost_current_usd', sa.Numeric(precision=23, scale=8), nullable=True),
sa.Column('unit_cost_depreciated_usd', sa.Numeric(precision=23, scale=8), nullable=True),
sa.Column('unit_cost_subitem_usd', sa.Numeric(precision=23, scale=8), nullable=True),
sa.Column('unit_cost_auxiliary_usd', sa.Numeric(precision=23, scale=8), nullable=True),
sa.Column('sales_cost_usd', sa.Numeric(precision=23, scale=8), nullable=True),
sa.Column('commercial_unit_cost', sa.Numeric(precision=23, scale=8), nullable=True),
sa.Column('unit_cost_mxn', sa.Numeric(precision=23, scale=8), nullable=True),
sa.Column('unit_cost_commercial_mxn', sa.Numeric(precision=23, scale=8), nullable=True),
sa.Column('unit_cost_current_mxn', sa.Numeric(precision=23, scale=8), nullable=True),
sa.Column('unit_cost_depreciated_mxn', sa.Numeric(precision=23, scale=8), nullable=True),
sa.Column('unit_cost_subitem_mxn', sa.Numeric(precision=23, scale=8), nullable=True),
sa.Column('sales_cost_mxn', sa.Numeric(precision=23, scale=8), nullable=True),
sa.Column('unit_cost_mc', sa.Numeric(precision=29, scale=8), nullable=True),
sa.Column('value_mxn', sa.Numeric(precision=23, scale=8), nullable=True),
sa.Column('value_commercial_mxn', sa.Numeric(precision=23, scale=8), nullable=True),
sa.Column('value_updated_mxn', sa.Numeric(precision=23, scale=8), nullable=True),
sa.Column('value_subitem_mxn', sa.Numeric(precision=23, scale=8), nullable=True),
sa.Column('sub_import_value_mxn', sa.Numeric(precision=23, scale=8), nullable=True),
sa.Column('value_returned_mxn', sa.Numeric(precision=23, scale=8), nullable=True),
sa.Column('value_depreciated_mxn', sa.Numeric(precision=23, scale=8), nullable=True),
sa.Column('customs_value_mxn', sa.Numeric(precision=23, scale=8), nullable=True),
sa.Column('value_total_mxn', sa.Numeric(precision=23, scale=8), nullable=True),
sa.Column('value_temp_material_mxn', sa.Numeric(precision=23, scale=8), nullable=True),
sa.Column('value_def_material_mxn', sa.Numeric(precision=23, scale=8), nullable=True),
sa.Column('value_added_mxn', sa.Numeric(precision=23, scale=8), nullable=True),
sa.Column('value_national_packing_mxn', sa.Numeric(precision=23, scale=8), nullable=True),
sa.Column('vat_mxn', sa.Numeric(precision=23, scale=8), nullable=True),
sa.Column('vat_used_mxn', sa.Numeric(precision=23, scale=8), nullable=True),
sa.Column('advalorem_line_mxn', sa.Numeric(precision=23, scale=8), nullable=True),
sa.Column('value_usd', sa.Numeric(precision=29, scale=8), nullable=True),
sa.Column('value_commercial_usd', sa.Numeric(precision=23, scale=8), nullable=True),
sa.Column('value_updated_usd', sa.Numeric(precision=23, scale=8), nullable=True),
sa.Column('value_subitem_usd', sa.Numeric(precision=23, scale=8), nullable=True),
sa.Column('sub_import_value_usd', sa.Numeric(precision=23, scale=8), nullable=True),
sa.Column('value_returned_usd', sa.Numeric(precision=23, scale=8), nullable=True),
sa.Column('value_depreciated_usd', sa.Numeric(precision=23, scale=8), nullable=True),
sa.Column('customs_value_usd', sa.Numeric(precision=23, scale=8), nullable=True),
sa.Column('value_auxiliary_usd', sa.Numeric(precision=23, scale=8), nullable=True),
sa.Column('value_total_usd', sa.Numeric(precision=23, scale=8), nullable=True),
sa.Column('value_temp_material_usd', sa.Numeric(precision=23, scale=8), nullable=True),
sa.Column('value_def_material_usd', sa.Numeric(precision=23, scale=8), nullable=True),
sa.Column('value_added_usd', sa.Numeric(precision=23, scale=8), nullable=True),
sa.Column('value_national_packing_usd', sa.Numeric(precision=23, scale=8), nullable=True),
sa.Column('value_us_packing_usd', sa.Numeric(precision=23, scale=8), nullable=True),
sa.Column('vat_usd', sa.Numeric(precision=23, scale=8), nullable=True),
sa.Column('vat_used_usd', sa.Numeric(precision=23, scale=8), nullable=True),
sa.Column('value_non_originating_usd', sa.Numeric(precision=23, scale=8), nullable=True),
sa.Column('value_originating_usd', sa.Numeric(precision=23, scale=8), nullable=True),
sa.Column('igi_amount_usd', sa.Numeric(precision=23, scale=8), nullable=True),
sa.Column('exempt_amount_usd', sa.Numeric(precision=23, scale=8), nullable=True),
sa.Column('total_commercial_value', sa.Numeric(precision=23, scale=8), nullable=True),
sa.Column('advalorem_line_usd', sa.Numeric(precision=23, scale=8), nullable=True),
sa.Column('value_mc', sa.Numeric(precision=29, scale=8), nullable=True),
sa.Column('sub_import_value_mc', sa.Numeric(precision=23, scale=8), nullable=True),
sa.Column('vat_mc', sa.Numeric(precision=23, scale=8), nullable=True),
sa.Column('value_added_mc', sa.Numeric(precision=23, scale=8), nullable=True),
sa.Column('value_national_packing_mc', sa.Numeric(precision=23, scale=8), nullable=True),
sa.Column('value_total_mc', sa.Numeric(precision=23, scale=8), nullable=True),
sa.Column('value_temp_material_mc', sa.Numeric(precision=23, scale=8), nullable=True),
sa.Column('value_def_material_mc', sa.Numeric(precision=23, scale=8), nullable=True),
sa.ForeignKeyConstraint(['item_line_id'], ['a76.item_lines.id'], ),
sa.PrimaryKeyConstraint('id'),
schema='a76'
)
op.create_table('item_line_quantities',
sa.Column('id', sa.Integer(), autoincrement=True, nullable=False),
sa.Column('item_line_id', sa.Integer(), nullable=False),
sa.Column('quantity', sa.Numeric(precision=19, scale=8), nullable=True),
sa.Column('alternate_quantity', sa.Numeric(precision=19, scale=8), nullable=True),
sa.Column('quantity_uma', sa.Numeric(precision=19, scale=8), nullable=True),
sa.Column('auxiliary_quantity', sa.Numeric(precision=19, scale=8), nullable=True),
sa.Column('quantity_temp_export', sa.Numeric(precision=19, scale=8), nullable=True),
sa.Column('serial_count', sa.Integer(), nullable=True),
sa.Column('net_weight', sa.Numeric(precision=19, scale=8), nullable=True),
sa.Column('gross_weight', sa.Numeric(precision=19, scale=8), nullable=True),
sa.Column('package_id', sa.Integer(), nullable=True),
sa.Column('package_quantity', sa.Integer(), nullable=True),
sa.Column('container_quantity', sa.SmallInteger(), nullable=True),
sa.Column('container_description', sa.String(length=40), nullable=True),
sa.Column('box_count', sa.String(length=30), nullable=True),
sa.ForeignKeyConstraint(['item_line_id'], ['a76.item_lines.id'], ),
sa.ForeignKeyConstraint(['package_id'], ['a76.packages.id'], ),
sa.PrimaryKeyConstraint('id'),
schema='a76'
)
op.create_table('item_line_series',
sa.Column('id', sa.Integer(), autoincrement=True, nullable=False),
sa.Column('line_item_id', sa.Integer(), nullable=False),
sa.Column('row', sa.Integer(), nullable=False),
sa.Column('serial_numbers', sa.String(length=50), nullable=True),
sa.Column('model', sa.String(length=50), nullable=True),
sa.Column('sub_model', sa.String(length=50), nullable=True),
sa.Column('brand', sa.String(length=50), nullable=True),
sa.Column('number_id', sa.String(length=25), nullable=True),
sa.Column('discharge', sa.Boolean(), nullable=True),
sa.Column('serie_row', sa.Integer(), nullable=True),
sa.Column('image_path', sa.String(length=255), nullable=True),
sa.Column('tenant_id', sa.Integer(), nullable=False),
sa.Column('company_id', sa.Integer(), nullable=False),
sa.Column('deleted_at', sa.DateTime(), 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.ForeignKeyConstraint(['company_id'], ['a76.company.id'], ),
sa.ForeignKeyConstraint(['line_item_id'], ['a76.item_lines.id'], ),
sa.ForeignKeyConstraint(['tenant_id'], ['core.tenants.id'], ),
sa.PrimaryKeyConstraint('id'),
schema='a76'
)
op.create_index(op.f('ix_a76_item_line_series_company_id'), 'item_line_series', ['company_id'], unique=False, schema='a76')
op.create_index(op.f('ix_a76_item_line_series_tenant_id'), 'item_line_series', ['tenant_id'], unique=False, schema='a76')
op.create_table('discharge_detail',
sa.Column('id', sa.BigInteger(), autoincrement=True, nullable=False),
sa.Column('discharge_header_id', sa.BigInteger(), nullable=False),
sa.Column('export_item_line_id', sa.Integer(), nullable=True, comment='NULL for waste-only discharges.'),
sa.Column('part_number', sa.String(length=70), nullable=True, comment='NUMPARTE of the export line (denormalized)'),
sa.Column('export_part_number', sa.String(length=70), nullable=True, comment='NUMPARTEEXPO — as it appears in the pedimento'),
sa.Column('export_line_ref', sa.Integer(), nullable=True, comment='LINEAEXPOREF — for rectification references'),
sa.Column('import_item_line_id', sa.Integer(), nullable=False),
sa.Column('movement_id', sa.BigInteger(), nullable=False, comment='The BalanceMovement that records this consumption. Required.'),
sa.Column('quantity_discharged', sa.Numeric(precision=19, scale=8), nullable=False),
sa.Column('unit_of_measure', sa.String(length=5), nullable=True),
sa.Column('value_mn', sa.Numeric(precision=23, scale=8), nullable=True),
sa.Column('value_me', sa.Numeric(precision=23, scale=8), nullable=True),
sa.Column('net_weight', sa.Numeric(precision=19, scale=8), nullable=True),
sa.Column('gross_weight', sa.Numeric(precision=19, scale=8), nullable=True),
sa.Column('tariff_fraction', sa.String(length=10), nullable=True),
sa.Column('fraction_type', sa.String(length=7), nullable=True),
sa.Column('ad_valorem', sa.String(length=10), nullable=True),
sa.Column('country_of_origin', sa.String(length=3), nullable=True),
sa.Column('sector', sa.String(length=8), nullable=True),
sa.Column('original_part', sa.String(length=70), nullable=True, comment='PARTEORIGINAL'),
sa.Column('equivalent_quantity', sa.Numeric(precision=19, scale=8), nullable=True, comment='CANTEQUIVALENTE'),
sa.Column('equivalent_unit', sa.String(length=5), nullable=True),
sa.Column('returned_quantity_sm', sa.Numeric(precision=19, scale=8), nullable=True, comment='CANTRETORNADASAM'),
sa.Column('waste_type', sa.String(length=1), nullable=True, comment='M=merma, D=desperdicio, S=scrap'),
sa.Column('take_balance_base_pt', sa.String(length=2), nullable=True, comment='TOMARSALDOBASEALPT'),
sa.Column('igi_amount', sa.Numeric(precision=23, scale=8), nullable=True),
sa.Column('tax_payment', sa.String(length=1), nullable=True),
sa.Column('has_certificate', sa.String(length=1), nullable=True),
sa.Column('iva_mn', sa.Numeric(precision=23, scale=8), nullable=True),
sa.Column('iva_me', sa.Numeric(precision=23, scale=8), nullable=True),
sa.Column('origin_import_invoice', sa.String(length=15), nullable=True, comment='FACTURAIMPO original (denorm for SM)'),
sa.Column('procedence', sa.String(length=3), nullable=True),
sa.Column('tenant_id', sa.Integer(), nullable=False),
sa.Column('company_id', sa.Integer(), nullable=False),
sa.Column('deleted_at', sa.DateTime(), 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.CheckConstraint('movement_id IS NOT NULL', name='ck_dischdet_movement_required'),
sa.ForeignKeyConstraint(['company_id'], ['a76.company.id'], ),
sa.ForeignKeyConstraint(['discharge_header_id'], ['a24.discharge_header.id'], ),
sa.ForeignKeyConstraint(['export_item_line_id'], ['a76.item_lines.id'], ),
sa.ForeignKeyConstraint(['import_item_line_id'], ['a76.item_lines.id'], ),
sa.ForeignKeyConstraint(['movement_id'], ['a24.balance_movement.id'], ),
sa.ForeignKeyConstraint(['tenant_id'], ['core.tenants.id'], ),
sa.PrimaryKeyConstraint('id'),
schema='a24'
)
op.create_index(op.f('ix_a24_discharge_detail_company_id'), 'discharge_detail', ['company_id'], unique=False, schema='a24')
op.create_index(op.f('ix_a24_discharge_detail_tenant_id'), 'discharge_detail', ['tenant_id'], unique=False, schema='a24')
op.create_index('ix_dischdet_export_line', 'discharge_detail', ['export_item_line_id'], unique=False, schema='a24')
op.create_index('ix_dischdet_header', 'discharge_detail', ['discharge_header_id'], unique=False, schema='a24')
op.create_index('ix_dischdet_import_lot', 'discharge_detail', ['import_item_line_id'], unique=False, schema='a24')
op.create_index('ix_dischdet_part', 'discharge_detail', ['tenant_id', 'part_number'], unique=False, schema='a24')
op.create_table('discharge_scrap',
sa.Column('id', sa.BigInteger(), autoincrement=True, nullable=False),
sa.Column('discharge_header_id', sa.BigInteger(), nullable=True, comment='NULL when scrap is registered independently (not tied to an export).'),
sa.Column('import_item_line_id', sa.Integer(), nullable=False),
sa.Column('movement_id', sa.BigInteger(), nullable=True),
sa.Column('scrap_type', sa.String(length=1), nullable=False, comment='M=merma, D=desperdicio, S=scrap, X=destrucción'),
sa.Column('finished_good_line_id', sa.Integer(), nullable=True, comment='Export line of the product whose manufacture created this scrap.'),
sa.Column('finished_good_part', sa.String(length=70), nullable=True),
sa.Column('scrap_export_invoice_id', sa.BigInteger(), nullable=True, comment='If desperdicio has its own export pedimento.'),
sa.Column('part_number', sa.String(length=70), nullable=False),
sa.Column('item_class', sa.String(length=8), nullable=True),
sa.Column('quantity', sa.Numeric(precision=19, scale=8), nullable=False),
sa.Column('unit_of_measure', sa.String(length=5), nullable=False),
sa.Column('value_mn', sa.Numeric(precision=23, scale=8), nullable=True),
sa.Column('value_me', sa.Numeric(precision=23, scale=8), nullable=True),
sa.Column('net_weight', sa.Numeric(precision=19, scale=8), nullable=True),
sa.Column('procedence', sa.String(length=3), nullable=True),
sa.Column('scrap_date', sa.Date(), nullable=False),
sa.Column('tenant_id', sa.Integer(), nullable=False),
sa.Column('company_id', sa.Integer(), nullable=False),
sa.Column('deleted_at', sa.DateTime(), 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.ForeignKeyConstraint(['company_id'], ['a76.company.id'], ),
sa.ForeignKeyConstraint(['discharge_header_id'], ['a24.discharge_header.id'], ),
sa.ForeignKeyConstraint(['finished_good_line_id'], ['a76.item_lines.id'], ),
sa.ForeignKeyConstraint(['import_item_line_id'], ['a76.item_lines.id'], ),
sa.ForeignKeyConstraint(['movement_id'], ['a24.balance_movement.id'], ),
sa.ForeignKeyConstraint(['scrap_export_invoice_id'], ['a76.invoice_header.id'], ),
sa.ForeignKeyConstraint(['tenant_id'], ['core.tenants.id'], ),
sa.PrimaryKeyConstraint('id'),
schema='a24'
)
op.create_index(op.f('ix_a24_discharge_scrap_company_id'), 'discharge_scrap', ['company_id'], unique=False, schema='a24')
op.create_index(op.f('ix_a24_discharge_scrap_tenant_id'), 'discharge_scrap', ['tenant_id'], unique=False, schema='a24')
op.create_index('ix_dischscrap_date', 'discharge_scrap', ['tenant_id', 'scrap_date'], unique=False, schema='a24')
op.create_index('ix_dischscrap_header', 'discharge_scrap', ['discharge_header_id'], unique=False, schema='a24')
op.create_index('ix_dischscrap_import_lot', 'discharge_scrap', ['import_item_line_id'], unique=False, schema='a24')
op.create_table('inv_aphis_characteristic',
sa.Column('id', sa.Integer(), autoincrement=True, nullable=False),
sa.Column('aphis_general_id', sa.Integer(), nullable=False),
sa.Column('item_id', sa.String(length=50), nullable=True),
sa.Column('number_from', sa.String(length=50), nullable=True),
sa.Column('number_to', sa.String(length=50), nullable=True),
sa.Column('category_type', sa.String(length=50), nullable=True),
sa.Column('commodity_qua', sa.String(length=50), nullable=True),
sa.Column('commodity_char_qua', sa.String(length=50), nullable=True),
sa.Column('description', sa.String(length=200), nullable=True),
sa.Column('category_code', sa.String(length=50), nullable=True),
sa.Column('tenant_id', sa.Integer(), nullable=False),
sa.Column('company_id', sa.Integer(), nullable=False),
sa.Column('deleted_at', sa.DateTime(), 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.ForeignKeyConstraint(['aphis_general_id'], ['a24.inv_aphis_general.id'], ),
sa.ForeignKeyConstraint(['company_id'], ['a76.company.id'], ),
sa.ForeignKeyConstraint(['tenant_id'], ['core.tenants.id'], ),
sa.PrimaryKeyConstraint('id', name='inv_aphis_characteristic_pkey'),
schema='a24'
)
op.create_index(op.f('ix_a24_inv_aphis_characteristic_company_id'), 'inv_aphis_characteristic', ['company_id'], unique=False, schema='a24')
op.create_index(op.f('ix_a24_inv_aphis_characteristic_tenant_id'), 'inv_aphis_characteristic', ['tenant_id'], unique=False, schema='a24')
op.create_table('inv_aphis_containers',
sa.Column('id', sa.Integer(), autoincrement=True, nullable=False),
sa.Column('aphis_general_id', sa.Integer(), nullable=False),
sa.Column('container_number', sa.String(length=50), nullable=True),
sa.Column('length', sa.String(length=20), nullable=True),
sa.Column('type', sa.String(length=50), nullable=True),
sa.Column('tenant_id', sa.Integer(), nullable=False),
sa.Column('company_id', sa.Integer(), nullable=False),
sa.Column('deleted_at', sa.DateTime(), 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.ForeignKeyConstraint(['aphis_general_id'], ['a24.inv_aphis_general.id'], ),
sa.ForeignKeyConstraint(['company_id'], ['a76.company.id'], ),
sa.ForeignKeyConstraint(['tenant_id'], ['core.tenants.id'], ),
sa.PrimaryKeyConstraint('id', name='inv_aphis_containers_pkey'),
schema='a24'
)
op.create_index(op.f('ix_a24_inv_aphis_containers_company_id'), 'inv_aphis_containers', ['company_id'], unique=False, schema='a24')
op.create_index(op.f('ix_a24_inv_aphis_containers_tenant_id'), 'inv_aphis_containers', ['tenant_id'], unique=False, schema='a24')
op.create_table('inv_aphis_entities',
sa.Column('id', sa.Integer(), autoincrement=True, nullable=False),
sa.Column('aphis_general_id', sa.Integer(), nullable=False),
sa.Column('consignee_key', sa.String(length=50), nullable=True),
sa.Column('broker_key', sa.String(length=50), nullable=True),
sa.Column('lpco_auth_party_key', sa.String(length=50), nullable=True),
sa.Column('grower_key', sa.String(length=50), nullable=True),
sa.Column('tenant_id', sa.Integer(), nullable=False),
sa.Column('company_id', sa.Integer(), nullable=False),
sa.Column('deleted_at', sa.DateTime(), 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.ForeignKeyConstraint(['aphis_general_id'], ['a24.inv_aphis_general.id'], ),
sa.ForeignKeyConstraint(['company_id'], ['a76.company.id'], ),
sa.ForeignKeyConstraint(['tenant_id'], ['core.tenants.id'], ),
sa.PrimaryKeyConstraint('id', name='inv_aphis_entities_pkey'),
schema='a24'
)
op.create_index(op.f('ix_a24_inv_aphis_entities_company_id'), 'inv_aphis_entities', ['company_id'], unique=False, schema='a24')
op.create_index(op.f('ix_a24_inv_aphis_entities_tenant_id'), 'inv_aphis_entities', ['tenant_id'], unique=False, schema='a24')
op.create_table('inv_aphis_lpcos',
sa.Column('id', sa.Integer(), autoincrement=True, nullable=False),
sa.Column('aphis_general_id', sa.Integer(), nullable=False),
sa.Column('issuer', sa.String(length=100), nullable=True),
sa.Column('issuer_loc_qua', sa.String(length=50), nullable=True),
sa.Column('issuer_loc', sa.String(length=50), nullable=True),
sa.Column('issuer_loc_desc', sa.String(length=200), nullable=True),
sa.Column('uom', sa.String(length=20), nullable=True),
sa.Column('txn_type', sa.String(length=50), nullable=True),
sa.Column('type', sa.String(length=50), nullable=True),
sa.Column('number', sa.String(length=50), nullable=True),
sa.Column('date_qual', sa.String(length=50), nullable=True),
sa.Column('date', sa.Date(), nullable=True),
sa.Column('qty', sa.String(length=50), nullable=True),
sa.Column('tenant_id', sa.Integer(), nullable=False),
sa.Column('company_id', sa.Integer(), nullable=False),
sa.Column('deleted_at', sa.DateTime(), 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.ForeignKeyConstraint(['aphis_general_id'], ['a24.inv_aphis_general.id'], ),
sa.ForeignKeyConstraint(['company_id'], ['a76.company.id'], ),
sa.ForeignKeyConstraint(['tenant_id'], ['core.tenants.id'], ),
sa.PrimaryKeyConstraint('id', name='inv_aphis_lpcos_pkey'),
schema='a24'
)
op.create_index(op.f('ix_a24_inv_aphis_lpcos_company_id'), 'inv_aphis_lpcos', ['company_id'], unique=False, schema='a24')
op.create_index(op.f('ix_a24_inv_aphis_lpcos_tenant_id'), 'inv_aphis_lpcos', ['tenant_id'], unique=False, schema='a24')
op.create_table('inv_aphis_routing',
sa.Column('id', sa.Integer(), autoincrement=True, nullable=False),
sa.Column('aphis_general_id', sa.Integer(), nullable=False),
sa.Column('type', sa.String(length=50), nullable=True),
sa.Column('country', sa.String(length=50), nullable=True),
sa.Column('name', sa.String(length=100), nullable=True),
sa.Column('tenant_id', sa.Integer(), nullable=False),
sa.Column('company_id', sa.Integer(), nullable=False),
sa.Column('deleted_at', sa.DateTime(), 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.ForeignKeyConstraint(['aphis_general_id'], ['a24.inv_aphis_general.id'], ),
sa.ForeignKeyConstraint(['company_id'], ['a76.company.id'], ),
sa.ForeignKeyConstraint(['tenant_id'], ['core.tenants.id'], ),
sa.PrimaryKeyConstraint('id', name='inv_aphis_routing_pkey'),
schema='a24'
)
op.create_index(op.f('ix_a24_inv_aphis_routing_company_id'), 'inv_aphis_routing', ['company_id'], unique=False, schema='a24')
op.create_index(op.f('ix_a24_inv_aphis_routing_tenant_id'), 'inv_aphis_routing', ['tenant_id'], unique=False, schema='a24')
op.create_table('inv_aphis_stype_pitems',
sa.Column('id', sa.Integer(), autoincrement=True, nullable=False),
sa.Column('aphis_general_id', sa.Integer(), nullable=False),
sa.Column('source_type_code', sa.String(length=50), nullable=True),
sa.Column('country_code', sa.String(length=3), nullable=True),
sa.Column('geo_location', sa.String(length=100), nullable=True),
sa.Column('processing_start', sa.Date(), nullable=True),
sa.Column('processing_end', sa.Date(), nullable=True),
sa.Column('processing_type', sa.String(length=50), nullable=True),
sa.Column('processing_desc', sa.String(length=200), nullable=True),
sa.Column('tenant_id', sa.Integer(), nullable=False),
sa.Column('company_id', sa.Integer(), nullable=False),
sa.Column('deleted_at', sa.DateTime(), 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.ForeignKeyConstraint(['aphis_general_id'], ['a24.inv_aphis_general.id'], ),
sa.ForeignKeyConstraint(['company_id'], ['a76.company.id'], ),
sa.ForeignKeyConstraint(['tenant_id'], ['core.tenants.id'], ),
sa.PrimaryKeyConstraint('id', name='inv_aphis_stype_pitems_pkey'),
schema='a24'
)
op.create_index(op.f('ix_a24_inv_aphis_stype_pitems_company_id'), 'inv_aphis_stype_pitems', ['company_id'], unique=False, schema='a24')
op.create_index(op.f('ix_a24_inv_aphis_stype_pitems_tenant_id'), 'inv_aphis_stype_pitems', ['tenant_id'], unique=False, schema='a24')
op.create_table('item_line_references',
sa.Column('id', sa.Integer(), autoincrement=True, nullable=False),
sa.Column('item_line_id', sa.Integer(), nullable=False),
sa.Column('serie_id', sa.Integer(), nullable=True),
sa.Column('customer_invoice', sa.Integer(), nullable=True),
sa.Column('assigned_client', sa.Integer(), nullable=True),
sa.Column('supplier', sa.Integer(), nullable=True),
sa.Column('requisitioner', sa.Integer(), nullable=True),
sa.Column('sent_to', sa.Integer(), nullable=True),
sa.Column('ped_line', sa.Integer(), nullable=True),
sa.Column('ro_line', sa.Integer(), nullable=True),
sa.ForeignKeyConstraint(['assigned_client'], ['a76.clients_and_providers.id'], ),
sa.ForeignKeyConstraint(['customer_invoice'], ['a76.clients_and_providers.id'], ),
sa.ForeignKeyConstraint(['item_line_id'], ['a76.item_lines.id'], ),
sa.ForeignKeyConstraint(['requisitioner'], ['a76.clients_and_providers.id'], ),
sa.ForeignKeyConstraint(['sent_to'], ['a76.clients_and_providers.id'], ),
sa.ForeignKeyConstraint(['serie_id'], ['a76.item_line_series.id'], ),
sa.ForeignKeyConstraint(['supplier'], ['a76.clients_and_providers.id'], ),
sa.PrimaryKeyConstraint('id'),
schema='a76'
)
# Row-Level Security (multi-tenant). Ver estándar Aduanasoft — políticas usan GUCs app.tenant_id / app.company_id.
_enable_rls_tenant_company()
# ### end Alembic commands ###
def downgrade() -> None:
"""Downgrade schema."""
_disable_rls_tenant_company()
# ### commands auto generated by Alembic - please adjust! ###
op.drop_table('item_line_references', schema='a76')
op.drop_index(op.f('ix_a24_inv_aphis_stype_pitems_tenant_id'), table_name='inv_aphis_stype_pitems', schema='a24')
op.drop_index(op.f('ix_a24_inv_aphis_stype_pitems_company_id'), table_name='inv_aphis_stype_pitems', schema='a24')
op.drop_table('inv_aphis_stype_pitems', schema='a24')
op.drop_index(op.f('ix_a24_inv_aphis_routing_tenant_id'), table_name='inv_aphis_routing', schema='a24')
op.drop_index(op.f('ix_a24_inv_aphis_routing_company_id'), table_name='inv_aphis_routing', schema='a24')
op.drop_table('inv_aphis_routing', schema='a24')
op.drop_index(op.f('ix_a24_inv_aphis_lpcos_tenant_id'), table_name='inv_aphis_lpcos', schema='a24')
op.drop_index(op.f('ix_a24_inv_aphis_lpcos_company_id'), table_name='inv_aphis_lpcos', schema='a24')
op.drop_table('inv_aphis_lpcos', schema='a24')
op.drop_index(op.f('ix_a24_inv_aphis_entities_tenant_id'), table_name='inv_aphis_entities', schema='a24')
op.drop_index(op.f('ix_a24_inv_aphis_entities_company_id'), table_name='inv_aphis_entities', schema='a24')
op.drop_table('inv_aphis_entities', schema='a24')
op.drop_index(op.f('ix_a24_inv_aphis_containers_tenant_id'), table_name='inv_aphis_containers', schema='a24')
op.drop_index(op.f('ix_a24_inv_aphis_containers_company_id'), table_name='inv_aphis_containers', schema='a24')
op.drop_table('inv_aphis_containers', schema='a24')
op.drop_index(op.f('ix_a24_inv_aphis_characteristic_tenant_id'), table_name='inv_aphis_characteristic', schema='a24')
op.drop_index(op.f('ix_a24_inv_aphis_characteristic_company_id'), table_name='inv_aphis_characteristic', schema='a24')
op.drop_table('inv_aphis_characteristic', schema='a24')
op.drop_index('ix_dischscrap_import_lot', table_name='discharge_scrap', schema='a24')
op.drop_index('ix_dischscrap_header', table_name='discharge_scrap', schema='a24')
op.drop_index('ix_dischscrap_date', table_name='discharge_scrap', schema='a24')
op.drop_index(op.f('ix_a24_discharge_scrap_tenant_id'), table_name='discharge_scrap', schema='a24')
op.drop_index(op.f('ix_a24_discharge_scrap_company_id'), table_name='discharge_scrap', schema='a24')
op.drop_table('discharge_scrap', schema='a24')
op.drop_index('ix_dischdet_part', table_name='discharge_detail', schema='a24')
op.drop_index('ix_dischdet_import_lot', table_name='discharge_detail', schema='a24')
op.drop_index('ix_dischdet_header', table_name='discharge_detail', schema='a24')
op.drop_index('ix_dischdet_export_line', table_name='discharge_detail', schema='a24')
op.drop_index(op.f('ix_a24_discharge_detail_tenant_id'), table_name='discharge_detail', schema='a24')
op.drop_index(op.f('ix_a24_discharge_detail_company_id'), table_name='discharge_detail', schema='a24')
op.drop_table('discharge_detail', schema='a24')
op.drop_index(op.f('ix_a76_item_line_series_tenant_id'), table_name='item_line_series', schema='a76')
op.drop_index(op.f('ix_a76_item_line_series_company_id'), table_name='item_line_series', schema='a76')
op.drop_table('item_line_series', schema='a76')
op.drop_table('item_line_quantities', schema='a76')
op.drop_table('item_line_financials', schema='a76')
op.drop_table('item_line_descriptions', schema='a76')
op.drop_table('item_line_customs', schema='a76')
op.drop_index(op.f('ix_a76_identifier_details_tenant_id'), table_name='identifier_details', schema='a76')
op.drop_index(op.f('ix_a76_identifier_details_company_id'), table_name='identifier_details', schema='a76')
op.drop_table('identifier_details', schema='a76')
op.drop_index(op.f('ix_a76_ctm_receipts_tenant_id'), table_name='ctm_receipts', schema='a76')
op.drop_index(op.f('ix_a76_ctm_receipts_company_id'), table_name='ctm_receipts', schema='a76')
op.drop_table('ctm_receipts', schema='a76')
op.drop_index(op.f('ix_a24_inv_aphis_general_tenant_id'), table_name='inv_aphis_general', schema='a24')
op.drop_index(op.f('ix_a24_inv_aphis_general_company_id'), table_name='inv_aphis_general', schema='a24')
op.drop_table('inv_aphis_general', schema='a24')
op.drop_index(op.f('ix_a24_fa_item_lines_tenant_id'), table_name='fa_item_lines', schema='a24')
op.drop_index(op.f('ix_a24_fa_item_lines_company_id'), table_name='fa_item_lines', schema='a24')
op.drop_table('fa_item_lines', schema='a24')
op.drop_index('ix_balmov_source', table_name='balance_movement', schema='a24')
op.drop_index('ix_balmov_peps_lookup', table_name='balance_movement', schema='a24', postgresql_include=['import_item_line_id', 'quantity', 'value_me', 'value_mn'])
op.drop_index('ix_balmov_operation_date', table_name='balance_movement', schema='a24')
op.drop_index('ix_balmov_lot', table_name='balance_movement', schema='a24')
op.drop_index(op.f('ix_a24_balance_movement_tenant_id'), table_name='balance_movement', schema='a24')
op.drop_index(op.f('ix_a24_balance_movement_company_id'), table_name='balance_movement', schema='a24')
op.drop_table('balance_movement', schema='a24')
op.drop_index(op.f('ix_a76_item_lines_tenant_id'), table_name='item_lines', schema='a76')
op.drop_index(op.f('ix_a76_item_lines_company_id'), table_name='item_lines', schema='a76')
op.drop_table('item_lines', schema='a76')
op.drop_index(op.f('ix_a24_inv_partes_tenant_id'), table_name='inv_partes', schema='a24')
op.drop_index(op.f('ix_a24_inv_partes_company_id'), table_name='inv_partes', schema='a24')
op.drop_table('inv_partes', schema='a24')
op.drop_index(op.f('ix_a24_inv_parte_paises_tenant_id'), table_name='inv_parte_paises', schema='a24')
op.drop_index(op.f('ix_a24_inv_parte_paises_company_id'), table_name='inv_parte_paises', schema='a24')
op.drop_table('inv_parte_paises', schema='a24')
op.drop_index(op.f('ix_a24_inv_bom_tenant_id'), table_name='inv_bom', schema='a24')
op.drop_index(op.f('ix_a24_inv_bom_company_id'), table_name='inv_bom', schema='a24')
op.drop_table('inv_bom', schema='a24')
op.drop_index(op.f('ix_a24_fa_partes_tenant_id'), table_name='fa_partes', schema='a24')
op.drop_index(op.f('ix_a24_fa_partes_company_id'), table_name='fa_partes', schema='a24')
op.drop_table('fa_partes', schema='a24')
op.drop_index(op.f('ix_a76_pedimento_validation_tenant_id'), table_name='pedimento_validation', schema='a76')
op.drop_index(op.f('ix_a76_pedimento_validation_company_id'), table_name='pedimento_validation', schema='a76')
op.drop_table('pedimento_validation', schema='a76')
op.drop_index(op.f('ix_a76_pedimento_transport_means_tenant_id'), table_name='pedimento_transport_means', schema='a76')
op.drop_index(op.f('ix_a76_pedimento_transport_means_company_id'), table_name='pedimento_transport_means', schema='a76')
op.drop_table('pedimento_transport_means', schema='a76')
op.drop_index(op.f('ix_a76_pedimento_transport_carriers_tenant_id'), table_name='pedimento_transport_carriers', schema='a76')
op.drop_index(op.f('ix_a76_pedimento_transport_carriers_company_id'), table_name='pedimento_transport_carriers', schema='a76')
op.drop_table('pedimento_transport_carriers', schema='a76')
op.drop_index(op.f('ix_a76_pedimento_seals_tenant_id'), table_name='pedimento_seals', schema='a76')
op.drop_index(op.f('ix_a76_pedimento_seals_company_id'), table_name='pedimento_seals', schema='a76')
op.drop_table('pedimento_seals', schema='a76')
op.drop_index(op.f('ix_a76_pedimento_rectification_origin_tenant_id'), table_name='pedimento_rectification_origin', schema='a76')
op.drop_index(op.f('ix_a76_pedimento_rectification_origin_company_id'), table_name='pedimento_rectification_origin', schema='a76')
op.drop_table('pedimento_rectification_origin', schema='a76')
op.drop_index(op.f('ix_a76_pedimento_rectification_destination_tenant_id'), table_name='pedimento_rectification_destination', schema='a76')
op.drop_index(op.f('ix_a76_pedimento_rectification_destination_company_id'), table_name='pedimento_rectification_destination', schema='a76')
op.drop_table('pedimento_rectification_destination', schema='a76')
op.drop_index(op.f('ix_a76_pedimento_payments_tenant_id'), table_name='pedimento_payments', schema='a76')
op.drop_index(op.f('ix_a76_pedimento_payments_company_id'), table_name='pedimento_payments', schema='a76')
op.drop_index('idx_pedimento_payments_pedimento_id', table_name='pedimento_payments', schema='a76')
op.drop_table('pedimento_payments', schema='a76')
op.drop_index(op.f('ix_a76_pedimento_packages_tenant_id'), table_name='pedimento_packages', schema='a76')
op.drop_index(op.f('ix_a76_pedimento_packages_company_id'), table_name='pedimento_packages', schema='a76')
op.drop_table('pedimento_packages', schema='a76')
op.drop_index(op.f('ix_a76_pedimento_indexes_tenant_id'), table_name='pedimento_indexes', schema='a76')
op.drop_index(op.f('ix_a76_pedimento_indexes_company_id'), table_name='pedimento_indexes', schema='a76')
op.drop_table('pedimento_indexes', schema='a76')
op.drop_index(op.f('ix_a76_pedimento_incrementables_tenant_id'), table_name='pedimento_incrementables', schema='a76')
op.drop_index(op.f('ix_a76_pedimento_incrementables_company_id'), table_name='pedimento_incrementables', schema='a76')
op.drop_table('pedimento_incrementables', schema='a76')
op.drop_index(op.f('ix_a76_pedimento_guides_tenant_id'), table_name='pedimento_guides', schema='a76')
op.drop_index(op.f('ix_a76_pedimento_guides_company_id'), table_name='pedimento_guides', schema='a76')
op.drop_table('pedimento_guides', schema='a76')
op.drop_index(op.f('ix_a76_pedimento_decrementables_tenant_id'), table_name='pedimento_decrementables', schema='a76')
op.drop_index(op.f('ix_a76_pedimento_decrementables_company_id'), table_name='pedimento_decrementables', schema='a76')
op.drop_table('pedimento_decrementables', schema='a76')
op.drop_index(op.f('ix_a76_pedimento_dates_tenant_id'), table_name='pedimento_dates', schema='a76')
op.drop_index(op.f('ix_a76_pedimento_dates_company_id'), table_name='pedimento_dates', schema='a76')
op.drop_index('idx_pedimento_dates_pedimento_id', table_name='pedimento_dates', schema='a76')
op.drop_table('pedimento_dates', schema='a76')
op.drop_index(op.f('ix_a76_pedimento_customs_offices_tenant_id'), table_name='pedimento_customs_offices', schema='a76')
op.drop_index(op.f('ix_a76_pedimento_customs_offices_company_id'), table_name='pedimento_customs_offices', schema='a76')
op.drop_table('pedimento_customs_offices', schema='a76')
op.drop_index(op.f('ix_a76_pedimento_contributions_tenant_id'), table_name='pedimento_contributions', schema='a76')
op.drop_index(op.f('ix_a76_pedimento_contributions_company_id'), table_name='pedimento_contributions', schema='a76')
op.drop_table('pedimento_contributions', schema='a76')
op.drop_index(op.f('ix_a76_pedimento_containers_tenant_id'), table_name='pedimento_containers', schema='a76')
op.drop_index(op.f('ix_a76_pedimento_containers_company_id'), table_name='pedimento_containers', schema='a76')
op.drop_table('pedimento_containers', schema='a76')
op.drop_index(op.f('ix_a76_pedimento_config_updates_tenant_id'), table_name='pedimento_config_updates', schema='a76')
op.drop_index(op.f('ix_a76_pedimento_config_updates_company_id'), table_name='pedimento_config_updates', schema='a76')
op.drop_table('pedimento_config_updates', schema='a76')
op.drop_index(op.f('ix_a76_pedimento_config_update_rectification_tenant_id'), table_name='pedimento_config_update_rectification', schema='a76')
op.drop_index(op.f('ix_a76_pedimento_config_update_rectification_company_id'), table_name='pedimento_config_update_rectification', schema='a76')
op.drop_table('pedimento_config_update_rectification', schema='a76')
op.drop_index(op.f('ix_a76_pedimento_config_surcharges_tenant_id'), table_name='pedimento_config_surcharges', schema='a76')
op.drop_index(op.f('ix_a76_pedimento_config_surcharges_company_id'), table_name='pedimento_config_surcharges', schema='a76')
op.drop_table('pedimento_config_surcharges', schema='a76')
op.drop_index(op.f('ix_a76_pedimento_config_parameters_tenant_id'), table_name='pedimento_config_parameters', schema='a76')
op.drop_index(op.f('ix_a76_pedimento_config_parameters_company_id'), table_name='pedimento_config_parameters', schema='a76')
op.drop_table('pedimento_config_parameters', schema='a76')
op.drop_index(op.f('ix_a76_pedimento_config_calculations_tenant_id'), table_name='pedimento_config_calculations', schema='a76')
op.drop_index(op.f('ix_a76_pedimento_config_calculations_company_id'), table_name='pedimento_config_calculations', schema='a76')
op.drop_table('pedimento_config_calculations', schema='a76')
op.drop_index(op.f('ix_a76_pedimento_config_additional_tenant_id'), table_name='pedimento_config_additional', schema='a76')
op.drop_index(op.f('ix_a76_pedimento_config_additional_company_id'), table_name='pedimento_config_additional', schema='a76')
op.drop_table('pedimento_config_additional', schema='a76')
op.drop_index(op.f('ix_a76_parts_tenant_id'), table_name='parts', schema='a76')
op.drop_index(op.f('ix_a76_parts_company_id'), table_name='parts', schema='a76')
op.drop_table('parts', schema='a76')
op.drop_index(op.f('ix_a76_invoice_compliance_mx_tenant_id'), table_name='invoice_compliance_mx', schema='a76')
op.drop_index(op.f('ix_a76_invoice_compliance_mx_company_id'), table_name='invoice_compliance_mx', schema='a76')
op.drop_table('invoice_compliance_mx', schema='a76')
op.drop_index(op.f('ix_a76_doda_container_seals_tenant_id'), table_name='doda_container_seals', schema='a76')
op.drop_index(op.f('ix_a76_doda_container_seals_company_id'), table_name='doda_container_seals', schema='a76')
op.drop_table('doda_container_seals', schema='a76')
op.drop_index(op.f('ix_a24_inv_classes_tenant_id'), table_name='inv_classes', schema='a24')
op.drop_index(op.f('ix_a24_inv_classes_company_id'), table_name='inv_classes', schema='a24')
op.drop_table('inv_classes', schema='a24')
op.drop_index(op.f('ix_a24_fa_classes_tenant_id'), table_name='fa_classes', schema='a24')
op.drop_index(op.f('ix_a24_fa_classes_company_id'), table_name='fa_classes', schema='a24')
op.drop_table('fa_classes', schema='a24')
op.drop_index('ix_user_company_roles_user_company', table_name='user_company_roles', schema='core')
op.drop_index(op.f('ix_core_user_company_roles_user_id'), table_name='user_company_roles', schema='core')
op.drop_index(op.f('ix_core_user_company_roles_tenant_id'), table_name='user_company_roles', schema='core')
op.drop_index(op.f('ix_core_user_company_roles_id'), table_name='user_company_roles', schema='core')
op.drop_index(op.f('ix_core_user_company_roles_company_role_id'), table_name='user_company_roles', schema='core')
op.drop_index(op.f('ix_core_user_company_roles_company_id'), table_name='user_company_roles', schema='core')
op.drop_table('user_company_roles', schema='core')
op.drop_index('ix_role_permissions_composite', table_name='role_permissions', schema='core')
op.drop_index(op.f('ix_core_role_permissions_tenant_id'), table_name='role_permissions', schema='core')
op.drop_index(op.f('ix_core_role_permissions_permission_id'), table_name='role_permissions', schema='core')
op.drop_index(op.f('ix_core_role_permissions_id'), table_name='role_permissions', schema='core')
op.drop_index(op.f('ix_core_role_permissions_company_role_id'), table_name='role_permissions', schema='core')
op.drop_index(op.f('ix_core_role_permissions_company_id'), table_name='role_permissions', schema='core')
op.drop_table('role_permissions', schema='core')
op.drop_index(op.f('ix_a76_unit_conversions_tenant_id'), table_name='unit_conversions', schema='a76')
op.drop_index(op.f('ix_a76_unit_conversions_company_id'), table_name='unit_conversions', schema='a76')
op.drop_table('unit_conversions', schema='a76')
op.drop_index(op.f('ix_a76_pedimentos_tenant_id'), table_name='pedimentos', schema='a76')
op.drop_index(op.f('ix_a76_pedimentos_company_id'), table_name='pedimentos', schema='a76')
op.drop_index('idx_pedimentos_status', table_name='pedimentos', schema='a76')
op.drop_index('idx_pedimentos_created_at', table_name='pedimentos', schema='a76')
op.drop_index('idx_pedimentos_client_id', table_name='pedimentos', schema='a76')
op.drop_table('pedimentos', schema='a76')
op.drop_index(op.f('ix_a76_invoice_sales_details_tenant_id'), table_name='invoice_sales_details', schema='a76')
op.drop_index(op.f('ix_a76_invoice_sales_details_company_id'), table_name='invoice_sales_details', schema='a76')
op.drop_table('invoice_sales_details', schema='a76')
op.drop_index(op.f('ix_a76_invoice_logistics_tenant_id'), table_name='invoice_logistics', schema='a76')
op.drop_index(op.f('ix_a76_invoice_logistics_company_id'), table_name='invoice_logistics', schema='a76')
op.drop_table('invoice_logistics', schema='a76')
op.drop_index(op.f('ix_a76_invoice_financials_tenant_id'), table_name='invoice_financials', schema='a76')
op.drop_index(op.f('ix_a76_invoice_financials_company_id'), table_name='invoice_financials', schema='a76')
op.drop_table('invoice_financials', schema='a76')
op.drop_index(op.f('ix_a76_invoice_collections_tenant_id'), table_name='invoice_collections', schema='a76')
op.drop_index(op.f('ix_a76_invoice_collections_company_id'), table_name='invoice_collections', schema='a76')
op.drop_table('invoice_collections', schema='a76')
op.drop_index(op.f('ix_a76_fda_specifications_tenant_id'), table_name='fda_specifications', schema='a76')
op.drop_index(op.f('ix_a76_fda_specifications_fda_catalog_id'), table_name='fda_specifications', schema='a76')
op.drop_index(op.f('ix_a76_fda_specifications_company_id'), table_name='fda_specifications', schema='a76')
op.drop_table('fda_specifications', schema='a76')
op.drop_index(op.f('ix_a76_fda_lot_production_tenant_id'), table_name='fda_lot_production', schema='a76')
op.drop_index(op.f('ix_a76_fda_lot_production_fda_catalog_id'), table_name='fda_lot_production', schema='a76')
op.drop_index(op.f('ix_a76_fda_lot_production_company_id'), table_name='fda_lot_production', schema='a76')
op.drop_table('fda_lot_production', schema='a76')
op.drop_index(op.f('ix_a76_fda_constituent_elements_tenant_id'), table_name='fda_constituent_elements', schema='a76')
op.drop_index(op.f('ix_a76_fda_constituent_elements_fda_catalog_id'), table_name='fda_constituent_elements', schema='a76')
op.drop_index(op.f('ix_a76_fda_constituent_elements_company_id'), table_name='fda_constituent_elements', schema='a76')
op.drop_table('fda_constituent_elements', schema='a76')
op.drop_index(op.f('ix_a76_fda_affirmation_codes_tenant_id'), table_name='fda_affirmation_codes', schema='a76')
op.drop_index(op.f('ix_a76_fda_affirmation_codes_fda_catalog_id'), table_name='fda_affirmation_codes', schema='a76')
op.drop_index(op.f('ix_a76_fda_affirmation_codes_company_id'), table_name='fda_affirmation_codes', schema='a76')
op.drop_table('fda_affirmation_codes', schema='a76')
op.drop_index(op.f('ix_a76_fa_location_ext_tenant_id'), table_name='fa_location_ext', schema='a76')
op.drop_index(op.f('ix_a76_fa_location_ext_company_id'), table_name='fa_location_ext', schema='a76')
op.drop_table('fa_location_ext', schema='a76')
op.drop_index(op.f('ix_a76_error_catalogs_tenant_id'), table_name='error_catalogs', schema='a76')
op.drop_index(op.f('ix_a76_error_catalogs_company_id'), table_name='error_catalogs', schema='a76')
op.drop_table('error_catalogs', schema='a76')
op.drop_index(op.f('ix_a76_equivalencies_tenant_id'), table_name='equivalencies', schema='a76')
op.drop_index(op.f('ix_a76_equivalencies_company_id'), table_name='equivalencies', schema='a76')
op.drop_table('equivalencies', schema='a76')
op.drop_index(op.f('ix_a76_driver_tenant_id'), table_name='driver', schema='a76')
op.drop_index(op.f('ix_a76_driver_driver_id'), table_name='driver', schema='a76')
op.drop_index(op.f('ix_a76_driver_company_id'), table_name='driver', schema='a76')
op.drop_table('driver', schema='a76')
op.drop_index(op.f('ix_a76_doda_pedimentos_tenant_id'), table_name='doda_pedimentos', schema='a76')
op.drop_index(op.f('ix_a76_doda_pedimentos_company_id'), table_name='doda_pedimentos', schema='a76')
op.drop_table('doda_pedimentos', schema='a76')
op.drop_index(op.f('ix_a76_doda_containers_tenant_id'), table_name='doda_containers', schema='a76')
op.drop_index(op.f('ix_a76_doda_containers_company_id'), table_name='doda_containers', schema='a76')
op.drop_table('doda_containers', schema='a76')
op.drop_index(op.f('ix_a76_doda_american_pedimentos_tenant_id'), table_name='doda_american_pedimentos', schema='a76')
op.drop_index(op.f('ix_a76_doda_american_pedimentos_company_id'), table_name='doda_american_pedimentos', schema='a76')
op.drop_table('doda_american_pedimentos', schema='a76')
op.drop_index(op.f('ix_a76_customs_brokers_vu_tenant_id'), table_name='customs_brokers_vu', schema='a76')
op.drop_index(op.f('ix_a76_customs_brokers_vu_company_id'), table_name='customs_brokers_vu', schema='a76')
op.drop_table('customs_brokers_vu', schema='a76')
op.drop_index(op.f('ix_a76_customs_brokers_personnel_tenant_id'), table_name='customs_brokers_personnel', schema='a76')
op.drop_index(op.f('ix_a76_customs_brokers_personnel_company_id'), table_name='customs_brokers_personnel', schema='a76')
op.drop_table('customs_brokers_personnel', schema='a76')
op.drop_index(op.f('ix_a76_country_rule_oct_tenant_id'), table_name='country_rule_oct', schema='a76')
op.drop_index(op.f('ix_a76_country_rule_oct_company_id'), table_name='country_rule_oct', schema='a76')
op.drop_table('country_rule_oct', schema='a76')
op.drop_index(op.f('ix_a76_concepts_tenant_id'), table_name='concepts', schema='a76')
op.drop_table('concepts', schema='a76')
op.drop_index(op.f('ix_a76_concept_manifestations_tenant_id'), table_name='concept_manifestations', schema='a76')
op.drop_index(op.f('ix_a76_concept_manifestations_company_id'), table_name='concept_manifestations', schema='a76')
op.drop_index('idx_concept_manifestations_value_manifestation_id', table_name='concept_manifestations', schema='a76')
op.drop_table('concept_manifestations', schema='a76')
op.drop_index(op.f('ix_a76_clients_and_providers_programs_tenant_id'), table_name='clients_and_providers_programs', schema='a76')
op.drop_index(op.f('ix_a76_clients_and_providers_programs_company_id'), table_name='clients_and_providers_programs', schema='a76')
op.drop_table('clients_and_providers_programs', schema='a76')
op.drop_index(op.f('ix_a76_clients_and_providers_address_tenant_id'), table_name='clients_and_providers_address', schema='a76')
op.drop_index(op.f('ix_a76_clients_and_providers_address_company_id'), table_name='clients_and_providers_address', schema='a76')
op.drop_table('clients_and_providers_address', schema='a76')
op.drop_index(op.f('ix_a76_classes_tenant_id'), table_name='classes', schema='a76')
op.drop_index(op.f('ix_a76_classes_company_id'), table_name='classes', schema='a76')
op.drop_table('classes', schema='a76')
op.drop_index('ix_dischdr_source', table_name='discharge_header', schema='a24')
op.drop_index('ix_dischdr_date', table_name='discharge_header', schema='a24')
op.drop_index(op.f('ix_a24_discharge_header_tenant_id'), table_name='discharge_header', schema='a24')
op.drop_index(op.f('ix_a24_discharge_header_company_id'), table_name='discharge_header', schema='a24')
op.drop_table('discharge_header', schema='a24')
op.drop_index(op.f('ix_public_warning_fractions_warning_type'), table_name='warning_fractions', schema='public')
op.drop_index(op.f('ix_public_warning_fractions_tenant_id'), table_name='warning_fractions', schema='public')
op.drop_index(op.f('ix_public_warning_fractions_fraction'), table_name='warning_fractions', schema='public')
op.drop_index(op.f('ix_public_warning_fractions_company_id'), table_name='warning_fractions', schema='public')
op.drop_table('warning_fractions', schema='public')
op.drop_index(op.f('ix_core_user_tenants_tenant_id'), table_name='user_tenants', schema='core')
op.drop_index(op.f('ix_core_user_tenants_keycloak_user_id'), table_name='user_tenants', schema='core')
op.drop_index(op.f('ix_core_user_tenants_id'), table_name='user_tenants', schema='core')
op.drop_index(op.f('ix_core_user_tenants_company_id'), table_name='user_tenants', schema='core')
op.drop_table('user_tenants', schema='core')
op.drop_index('ix_user_company_permissions_composite', table_name='user_company_permissions', schema='core')
op.drop_index(op.f('ix_core_user_company_permissions_user_id'), table_name='user_company_permissions', schema='core')
op.drop_index(op.f('ix_core_user_company_permissions_tenant_id'), table_name='user_company_permissions', schema='core')
op.drop_index(op.f('ix_core_user_company_permissions_permission_id'), table_name='user_company_permissions', schema='core')
op.drop_index(op.f('ix_core_user_company_permissions_id'), table_name='user_company_permissions', schema='core')
op.drop_index(op.f('ix_core_user_company_permissions_company_id'), table_name='user_company_permissions', schema='core')
op.drop_table('user_company_permissions', schema='core')
op.drop_index('ix_core_task_runs_tenant_updated', table_name='task_runs', schema='core')
op.drop_index('ix_core_task_runs_tenant_status_updated', table_name='task_runs', schema='core')
op.drop_index(op.f('ix_core_task_runs_tenant_id'), table_name='task_runs', schema='core')
op.drop_index('ix_core_task_runs_tenant_group_updated', table_name='task_runs', schema='core')
op.drop_index('ix_core_task_runs_tenant_company_updated', table_name='task_runs', schema='core')
op.drop_index('ix_core_task_runs_task_id', table_name='task_runs', schema='core')
op.drop_index(op.f('ix_core_task_runs_company_id'), table_name='task_runs', schema='core')
op.drop_table('task_runs', schema='core')
op.drop_index(op.f('ix_core_company_roles_tenant_id'), table_name='company_roles', schema='core')
op.drop_index(op.f('ix_core_company_roles_id'), table_name='company_roles', schema='core')
op.drop_index(op.f('ix_core_company_roles_company_id'), table_name='company_roles', schema='core')
op.drop_index('ix_company_roles_company_id_is_active', table_name='company_roles', schema='core')
op.drop_table('company_roles', schema='core')
op.drop_index(op.f('ix_a76_vehicle_vehicle_id'), table_name='vehicle', schema='a76')
op.drop_index(op.f('ix_a76_vehicle_tenant_id'), table_name='vehicle', schema='a76')
op.drop_index(op.f('ix_a76_vehicle_company_id'), table_name='vehicle', schema='a76')
op.drop_table('vehicle', schema='a76')
op.drop_index(op.f('ix_a76_value_manifestations_tenant_id'), table_name='value_manifestations', schema='a76')
op.drop_index(op.f('ix_a76_value_manifestations_company_id'), table_name='value_manifestations', schema='a76')
op.drop_index('idx_value_manifestations_manifestation_number', table_name='value_manifestations', schema='a76')
op.drop_table('value_manifestations', schema='a76')
op.drop_index(op.f('ix_a76_us_tariff_fractions_tenant_id'), table_name='us_tariff_fractions', schema='a76')
op.drop_index(op.f('ix_a76_us_tariff_fractions_id'), table_name='us_tariff_fractions', schema='a76')
op.drop_index(op.f('ix_a76_us_tariff_fractions_company_id'), table_name='us_tariff_fractions', schema='a76')
op.drop_table('us_tariff_fractions', schema='a76')
op.drop_index(op.f('ix_a76_units_of_measure_general_tenant_id'), table_name='units_of_measure_general', schema='a76')
op.drop_index(op.f('ix_a76_units_of_measure_general_company_id'), table_name='units_of_measure_general', schema='a76')
op.drop_table('units_of_measure_general', schema='a76')
op.drop_index(op.f('ix_a76_units_of_measure_tenant_id'), table_name='units_of_measure', schema='a76')
op.drop_index(op.f('ix_a76_units_of_measure_company_id'), table_name='units_of_measure', schema='a76')
op.drop_table('units_of_measure', schema='a76')
op.drop_index(op.f('ix_a76_transporter_transporter_id'), table_name='transporter', schema='a76')
op.drop_index(op.f('ix_a76_transporter_tenant_id'), table_name='transporter', schema='a76')
op.drop_index(op.f('ix_a76_transporter_company_id'), table_name='transporter', schema='a76')
op.drop_table('transporter', schema='a76')
op.drop_index(op.f('ix_a76_trailer_trailer_id'), table_name='trailer', schema='a76')
op.drop_index(op.f('ix_a76_trailer_tenant_id'), table_name='trailer', schema='a76')
op.drop_index(op.f('ix_a76_trailer_company_id'), table_name='trailer', schema='a76')
op.drop_table('trailer', schema='a76')
op.drop_index(op.f('ix_a76_subassembly_entries_tenant_id'), table_name='subassembly_entries', schema='a76')
op.drop_index(op.f('ix_a76_subassembly_entries_company_id'), table_name='subassembly_entries', schema='a76')
op.drop_table('subassembly_entries', schema='a76')
op.drop_index(op.f('ix_a76_signatures_tenant_id'), table_name='signatures', schema='a76')
op.drop_index(op.f('ix_a76_signatures_company_id'), table_name='signatures', schema='a76')
op.drop_table('signatures', schema='a76')
op.drop_index(op.f('ix_a76_sectors_tenant_id'), table_name='sectors', schema='a76')
op.drop_index(op.f('ix_a76_sectors_company_id'), table_name='sectors', schema='a76')
op.drop_table('sectors', schema='a76')
op.drop_index(op.f('ix_a76_seal_tenant_id'), table_name='seal', schema='a76')
op.drop_index(op.f('ix_a76_seal_company_id'), table_name='seal', schema='a76')
op.drop_table('seal', schema='a76')
op.drop_index(op.f('ix_a76_previous_fractions_tenant_id'), table_name='previous_fractions', schema='a76')
op.drop_index(op.f('ix_a76_previous_fractions_company_id'), table_name='previous_fractions', schema='a76')
op.drop_table('previous_fractions', schema='a76')
op.drop_index(op.f('ix_a76_prevalidators_tenant_id'), table_name='prevalidators', schema='a76')
op.drop_index(op.f('ix_a76_prevalidators_company_id'), table_name='prevalidators', schema='a76')
op.drop_table('prevalidators', schema='a76')
op.drop_index(op.f('ix_a76_ports_tenant_id'), table_name='ports', schema='a76')
op.drop_index(op.f('ix_a76_ports_company_id'), table_name='ports', schema='a76')
op.drop_table('ports', schema='a76')
op.drop_index(op.f('ix_a76_permission_rule_octave_tenant_id'), table_name='permission_rule_octave', schema='a76')
op.drop_index(op.f('ix_a76_permission_rule_octave_company_id'), table_name='permission_rule_octave', schema='a76')
op.drop_table('permission_rule_octave', schema='a76')
op.drop_index(op.f('ix_a76_permission_rule_oct_tenant_id'), table_name='permission_rule_oct', schema='a76')
op.drop_index(op.f('ix_a76_permission_rule_oct_company_id'), table_name='permission_rule_oct', schema='a76')
op.drop_table('permission_rule_oct', schema='a76')
op.drop_index(op.f('ix_a76_packing_lists_tenant_id'), table_name='packing_lists', schema='a76')
op.drop_index(op.f('ix_a76_packing_lists_company_id'), table_name='packing_lists', schema='a76')
op.drop_table('packing_lists', schema='a76')
op.drop_index(op.f('ix_a76_packages_tenant_id'), table_name='packages', schema='a76')
op.drop_index(op.f('ix_a76_packages_company_id'), table_name='packages', schema='a76')
op.drop_table('packages', schema='a76')
op.drop_index(op.f('ix_a76_octave_balance_tenant_id'), table_name='octave_balance', schema='a76')
op.drop_index(op.f('ix_a76_octave_balance_company_id'), table_name='octave_balance', schema='a76')
op.drop_table('octave_balance', schema='a76')
op.drop_index(op.f('ix_a76_multi_currency_types_tenant_id'), table_name='multi_currency_types', schema='a76')
op.drop_index(op.f('ix_a76_multi_currency_types_company_id'), table_name='multi_currency_types', schema='a76')
op.drop_table('multi_currency_types', schema='a76')
op.drop_index(op.f('ix_a76_manifests_tenant_id'), table_name='manifests', schema='a76')
op.drop_index(op.f('ix_a76_manifests_company_id'), table_name='manifests', schema='a76')
op.drop_index('idx_manifests_manifest_number', table_name='manifests', schema='a76')
op.drop_table('manifests', schema='a76')
op.drop_index(op.f('ix_a76_manifest_drivers_tenant_id'), table_name='manifest_drivers', schema='a76')
op.drop_index(op.f('ix_a76_manifest_drivers_company_id'), table_name='manifest_drivers', schema='a76')
op.drop_index('idx_manifest_drivers_manifest_number', table_name='manifest_drivers', schema='a76')
op.drop_table('manifest_drivers', schema='a76')
op.drop_index(op.f('ix_a76_manifest_anexos_tenant_id'), table_name='manifest_anexos', schema='a76')
op.drop_index(op.f('ix_a76_manifest_anexos_company_id'), table_name='manifest_anexos', schema='a76')
op.drop_index('idx_manifest_anexos_consecutive', table_name='manifest_anexos', schema='a76')
op.drop_table('manifest_anexos', schema='a76')
op.drop_index(op.f('ix_a76_location_tenant_id'), table_name='location', schema='a76')
op.drop_index(op.f('ix_a76_location_company_id'), table_name='location', schema='a76')
op.drop_table('location', schema='a76')
op.drop_index(op.f('ix_a76_legends_tenant_id'), table_name='legends', schema='a76')
op.drop_index(op.f('ix_a76_legends_company_id'), table_name='legends', schema='a76')
op.drop_table('legends', schema='a76')
op.drop_index(op.f('ix_a76_item_presets_tenant_id'), table_name='item_presets', schema='a76')
op.drop_index(op.f('ix_a76_item_presets_company_id'), table_name='item_presets', schema='a76')
op.drop_table('item_presets', schema='a76')
op.drop_index(op.f('ix_a76_invoice_settings_tenant_id'), table_name='invoice_settings', schema='a76')
op.drop_index(op.f('ix_a76_invoice_settings_company_id'), table_name='invoice_settings', schema='a76')
op.drop_table('invoice_settings', schema='a76')
op.drop_index(op.f('ix_a76_invoice_header_tenant_id'), table_name='invoice_header', schema='a76')
op.drop_index(op.f('ix_a76_invoice_header_company_id'), table_name='invoice_header', schema='a76')
op.drop_table('invoice_header', schema='a76')
op.drop_index(op.f('ix_a76_inpc_tenant_id'), table_name='inpc', schema='a76')
op.drop_index(op.f('ix_a76_inpc_company_id'), table_name='inpc', schema='a76')
op.drop_table('inpc', schema='a76')
op.drop_index(op.f('ix_a76_identifiers_tenant_id'), table_name='identifiers', schema='a76')
op.drop_index(op.f('ix_a76_identifiers_company_id'), table_name='identifiers', schema='a76')
op.drop_table('identifiers', schema='a76')
op.drop_index(op.f('ix_a76_historical_tariff_fractions_tenant_id'), table_name='historical_tariff_fractions', schema='a76')
op.drop_index(op.f('ix_a76_historical_tariff_fractions_company_id'), table_name='historical_tariff_fractions', schema='a76')
op.drop_table('historical_tariff_fractions', schema='a76')
op.drop_index(op.f('ix_a76_fraction_rule_octave_tenant_id'), table_name='fraction_rule_octave', schema='a76')
op.drop_index(op.f('ix_a76_fraction_rule_octave_company_id'), table_name='fraction_rule_octave', schema='a76')
op.drop_table('fraction_rule_octave', schema='a76')
op.drop_index(op.f('ix_a76_fda_catalog_tenant_id'), table_name='fda_catalog', schema='a76')
op.drop_index(op.f('ix_a76_fda_catalog_fda_key'), table_name='fda_catalog', schema='a76')
op.drop_index(op.f('ix_a76_fda_catalog_description'), table_name='fda_catalog', schema='a76')
op.drop_index(op.f('ix_a76_fda_catalog_company_id'), table_name='fda_catalog', schema='a76')
op.drop_table('fda_catalog', schema='a76')
op.drop_index(op.f('ix_a76_expediente_archivo_tenant_id'), table_name='expediente_archivo', schema='a76')
op.drop_index(op.f('ix_a76_expediente_archivo_task_id'), table_name='expediente_archivo', schema='a76')
op.drop_index(op.f('ix_a76_expediente_archivo_external_task_id'), table_name='expediente_archivo', schema='a76')
op.drop_index(op.f('ix_a76_expediente_archivo_company_id'), table_name='expediente_archivo', schema='a76')
op.drop_table('expediente_archivo', schema='a76')
op.drop_index(op.f('ix_a76_exchange_rate_tenant_id'), table_name='exchange_rate', schema='a76')
op.drop_index(op.f('ix_a76_exchange_rate_company_id'), table_name='exchange_rate', schema='a76')
op.drop_table('exchange_rate', schema='a76')
op.drop_index(op.f('ix_a76_error_classifications_tenant_id'), table_name='error_classifications', schema='a76')
op.drop_index(op.f('ix_a76_error_classifications_company_id'), table_name='error_classifications', schema='a76')
op.drop_table('error_classifications', schema='a76')
op.drop_index(op.f('ix_a76_equivalency_items_tenant_id'), table_name='equivalency_items', schema='a76')
op.drop_index(op.f('ix_a76_equivalency_items_company_id'), table_name='equivalency_items', schema='a76')
op.drop_table('equivalency_items', schema='a76')
op.drop_index(op.f('ix_a76_electronic_notices_tenant_id'), table_name='electronic_notices', schema='a76')
op.drop_index(op.f('ix_a76_electronic_notices_company_id'), table_name='electronic_notices', schema='a76')
op.drop_table('electronic_notices', schema='a76')
op.drop_index(op.f("ix_a76_doda_alta_log_task_id"), table_name="doda_alta_log", schema="a76")
op.drop_index(op.f("ix_a76_doda_alta_log_doda_id"), table_name="doda_alta_log", schema="a76")
op.drop_index(op.f("ix_a76_doda_alta_log_tenant_id"), table_name="doda_alta_log", schema="a76")
op.drop_index(op.f("ix_a76_doda_alta_log_company_id"), table_name="doda_alta_log", schema="a76")
op.drop_table("doda_alta_log", schema="a76")
op.drop_index(op.f('ix_a76_doda_tenant_id'), table_name='doda', schema='a76')
op.drop_index(op.f('ix_a76_doda_company_id'), table_name='doda', schema='a76')
op.drop_table('doda', schema='a76')
op.drop_index(op.f('ix_a76_document_types_digitization_tenant_id'), table_name='document_types_digitization', schema='a76')
op.drop_index(op.f('ix_a76_document_types_digitization_company_id'), table_name='document_types_digitization', schema='a76')
op.drop_index(op.f('ix_a76_document_types_digitization_code'), table_name='document_types_digitization', schema='a76')
op.drop_table('document_types_digitization', schema='a76')
op.drop_index(op.f('ix_a76_depreciation_catalog_tenant_id'), table_name='depreciation_catalog', schema='a76')
op.drop_index(op.f('ix_a76_depreciation_catalog_fraction'), table_name='depreciation_catalog', schema='a76')
op.drop_index(op.f('ix_a76_depreciation_catalog_description'), table_name='depreciation_catalog', schema='a76')
op.drop_index(op.f('ix_a76_depreciation_catalog_company_id'), table_name='depreciation_catalog', schema='a76')
op.drop_table('depreciation_catalog', schema='a76')
op.drop_index(op.f('ix_a76_customs_brokers_tenant_id'), table_name='customs_brokers', schema='a76')
op.drop_index(op.f('ix_a76_customs_brokers_company_id'), table_name='customs_brokers', schema='a76')
op.drop_table('customs_brokers', schema='a76')
op.drop_index(op.f('ix_a76_company_prevalidator_company_id'), table_name='company_prevalidator', schema='a76')
op.drop_table('company_prevalidator', schema='a76')
op.drop_index(op.f('ix_a76_company_electronic_agent_company_id'), table_name='company_electronic_agent', schema='a76')
op.drop_table('company_electronic_agent', schema='a76')
op.drop_index(op.f('ix_a76_company_digital_certificate_company_id'), table_name='company_digital_certificate', schema='a76')
op.drop_table('company_digital_certificate', schema='a76')
op.drop_index(op.f('ix_a76_company_cfdi_company_id'), table_name='company_cfdi', schema='a76')
op.drop_table('company_cfdi', schema='a76')
op.drop_index(op.f('ix_a76_company_certification_company_id'), table_name='company_certification', schema='a76')
op.drop_table('company_certification', schema='a76')
op.drop_index(op.f('ix_a76_company_address_company_id'), table_name='company_address', schema='a76')
op.drop_table('company_address', schema='a76')
op.drop_index(op.f('ix_a76_clients_and_providers_tenant_id'), table_name='clients_and_providers', schema='a76')
op.drop_index(op.f('ix_a76_clients_and_providers_company_id'), table_name='clients_and_providers', schema='a76')
op.drop_table('clients_and_providers', schema='a76')
op.drop_index(op.f('ix_a76_classification_concepts_tenant_id'), table_name='classification_concepts', schema='a76')
op.drop_index(op.f('ix_a76_classification_concepts_company_id'), table_name='classification_concepts', schema='a76')
op.drop_table('classification_concepts', schema='a76')
op.drop_index(op.f('ix_a76_canadian_tariff_fractions_tenant_id'), table_name='canadian_tariff_fractions', schema='a76')
op.drop_index(op.f('ix_a76_canadian_tariff_fractions_id'), table_name='canadian_tariff_fractions', schema='a76')
op.drop_index(op.f('ix_a76_canadian_tariff_fractions_fraction'), table_name='canadian_tariff_fractions', schema='a76')
op.drop_index(op.f('ix_a76_canadian_tariff_fractions_country_code'), table_name='canadian_tariff_fractions', schema='a76')
op.drop_index(op.f('ix_a76_canadian_tariff_fractions_company_id'), table_name='canadian_tariff_fractions', schema='a76')
op.drop_table('canadian_tariff_fractions', schema='a76')
op.drop_index(op.f('ix_a76_audit_logs_username'), table_name='audit_logs', schema='a76')
op.drop_index(op.f('ix_a76_audit_logs_timestamp'), table_name='audit_logs', schema='a76')
op.drop_index(op.f('ix_a76_audit_logs_tenant_id'), table_name='audit_logs', schema='a76')
op.drop_index(op.f('ix_a76_audit_logs_table_name'), table_name='audit_logs', schema='a76')
op.drop_index(op.f('ix_a76_audit_logs_system'), table_name='audit_logs', schema='a76')
op.drop_index(op.f('ix_a76_audit_logs_session_id'), table_name='audit_logs', schema='a76')
op.drop_index(op.f('ix_a76_audit_logs_reference'), table_name='audit_logs', schema='a76')
op.drop_index(op.f('ix_a76_audit_logs_record_id'), table_name='audit_logs', schema='a76')
op.drop_index(op.f('ix_a76_audit_logs_procedure'), table_name='audit_logs', schema='a76')
op.drop_index(op.f('ix_a76_audit_logs_operation_type'), table_name='audit_logs', schema='a76')
op.drop_index(op.f('ix_a76_audit_logs_date'), table_name='audit_logs', schema='a76')
op.drop_index(op.f('ix_a76_audit_logs_company_id'), table_name='audit_logs', schema='a76')
op.drop_index('idx_audit_username_date', table_name='audit_logs', schema='a76')
op.drop_index('idx_audit_table_record', table_name='audit_logs', schema='a76')
op.drop_index('idx_audit_system_timestamp', table_name='audit_logs', schema='a76')
op.drop_index('idx_audit_procedure_date', table_name='audit_logs', schema='a76')
op.drop_table('audit_logs', schema='a76')
op.drop_index(op.f('ix_a76_app_settings_tenant_id'), table_name='app_settings', schema='a76')
op.drop_index(op.f('ix_a76_app_settings_company_id'), table_name='app_settings', schema='a76')
op.drop_table('app_settings', schema='a76')
op.drop_index(op.f('ix_a76_CompanyVU_company_id'), table_name='CompanyVU', schema='a76')
op.drop_table('CompanyVU', schema='a76')
op.drop_table('states', schema='public')
op.drop_table('code_pedimento_regimens', schema='public')
op.drop_index(op.f('ix_core_licenses_tenant_id'), table_name='licenses', schema='core')
op.drop_index(op.f('ix_core_licenses_id'), table_name='licenses', schema='core')
op.drop_table('licenses', schema='core')
op.drop_index(op.f('ix_core_license_usage_tenant_id'), table_name='license_usage', schema='core')
op.drop_index(op.f('ix_core_license_usage_id'), table_name='license_usage', schema='core')
op.drop_table('license_usage', schema='core')
op.drop_index(op.f('ix_a76_customs_broker_concepts_tenant_id'), table_name='customs_broker_concepts', schema='a76')
op.drop_table('customs_broker_concepts', schema='a76')
op.drop_index(op.f('ix_a76_company_tenant_id'), table_name='company', schema='a76')
op.drop_table('company', schema='a76')
op.drop_table('valuation_methods', schema='public')
op.drop_table('transport_types', schema='public')
op.drop_table('transport_modes', schema='public')
op.drop_table('trailer_type', schema='public')
op.drop_table('pedimento_transport_catalog', schema='public')
op.drop_table('pedimento_regimens', schema='public')
op.drop_table('pedimento_codes', schema='public')
op.drop_table('payment_methods', schema='public')
op.drop_table('material_types', schema='public')
op.drop_table('license_exceptions', schema='public')
op.drop_table('invoice_types', schema='public')
op.drop_table('incoterms', schema='public')
op.drop_table('identifiers', schema='public')
op.drop_table('customs_warehouses', schema='public')
op.drop_table('customs_sections', schema='public')
op.drop_table('currency_types', schema='public')
op.drop_index('ak_country_ame', table_name='countries', schema='public')
op.drop_table('countries', schema='public')
op.drop_index(op.f('ix_public_carta_porte_codes_code'), table_name='carta_porte_codes', schema='public')
op.drop_table('carta_porte_codes', schema='public')
op.drop_index(op.f('ix_public_agency_tariff_codes_tariff_flag_code'), table_name='agency_tariff_codes', schema='public')
op.drop_index(op.f('ix_public_agency_tariff_codes_program_code'), table_name='agency_tariff_codes', schema='public')
op.drop_index(op.f('ix_public_agency_tariff_codes_agency_code'), table_name='agency_tariff_codes', schema='public')
op.drop_table('agency_tariff_codes', schema='public')
op.drop_index(op.f('ix_help_articles_uuid'), table_name='help_articles')
op.drop_index(op.f('ix_help_articles_slug'), table_name='help_articles')
op.drop_table('help_articles')
op.drop_index(op.f('ix_core_tenants_slug'), table_name='tenants', schema='core')
op.drop_index(op.f('ix_core_tenants_name'), table_name='tenants', schema='core')
op.drop_index(op.f('ix_core_tenants_id'), table_name='tenants', schema='core')
op.drop_table('tenants', schema='core')
op.drop_index(op.f('ix_core_permissions_module'), table_name='permissions', schema='core')
op.drop_index(op.f('ix_core_permissions_id'), table_name='permissions', schema='core')
op.drop_index(op.f('ix_core_permissions_code'), table_name='permissions', schema='core')
op.drop_table('permissions', schema='core')
op.drop_table('containers')
op.drop_table('unit_of_measure_oma', schema='a76')
op.drop_table('unit_of_measure_customs', schema='a76')
op.drop_table('unit_of_measure_american', schema='a76')
op.drop_table('unit_of_measure_ace', schema='a76')
op.drop_index(op.f('ix_a76_tariff_fractions_fraction'), table_name='tariff_fractions', schema='a76')
op.drop_index(op.f('ix_a76_tariff_fractions_code'), table_name='tariff_fractions', schema='a76')
op.drop_table('tariff_fractions', schema='a76')
op.drop_index(op.f('ix_a24_inv_aphis_catalog_company_id'), table_name='inv_aphis_catalog', schema='a24')
op.drop_table('inv_aphis_catalog', schema='a24')
# ### end Alembic commands ###
# Eliminar ENUM types de PostgreSQL — no se borran automáticamente con las tablas
op.execute("DROP TYPE IF EXISTS tenanttype")
op.execute("DROP TYPE IF EXISTS licenseplan")
op.execute("DROP TYPE IF EXISTS licensestatus")
op.execute("DROP TYPE IF EXISTS entity_client_or_provider")