first commit
This commit is contained in:
1
migrations/README
Normal file
1
migrations/README
Normal file
@@ -0,0 +1 @@
|
||||
Generic single-database configuration.
|
||||
BIN
migrations/__pycache__/env.cpython-311.pyc
Normal file
BIN
migrations/__pycache__/env.cpython-311.pyc
Normal file
Binary file not shown.
55
migrations/env.py
Normal file
55
migrations/env.py
Normal file
@@ -0,0 +1,55 @@
|
||||
|
||||
|
||||
import sys
|
||||
from pathlib import Path
|
||||
from logging.config import fileConfig
|
||||
|
||||
from sqlalchemy import engine_from_config
|
||||
from sqlalchemy import pool
|
||||
|
||||
from alembic import context
|
||||
|
||||
# Agregar el directorio raíz al path
|
||||
sys.path.append(str(Path(__file__).parent.parent))
|
||||
|
||||
# Importar target_metadata desde modules
|
||||
from app.modules import target_metadata
|
||||
|
||||
config = context.config
|
||||
|
||||
if config.config_file_name is not None:
|
||||
fileConfig(config.config_file_name)
|
||||
|
||||
def run_migrations_offline() -> None:
|
||||
url = config.get_main_option("sqlalchemy.url")
|
||||
context.configure(
|
||||
url=url,
|
||||
target_metadata=target_metadata,
|
||||
literal_binds=True,
|
||||
dialect_opts={"paramstyle": "named"},
|
||||
)
|
||||
|
||||
with context.begin_transaction():
|
||||
context.run_migrations()
|
||||
|
||||
def run_migrations_online() -> None:
|
||||
connectable = engine_from_config(
|
||||
config.get_section(config.config_ini_section, {}),
|
||||
prefix="sqlalchemy.",
|
||||
poolclass=pool.NullPool,
|
||||
)
|
||||
|
||||
with connectable.connect() as connection:
|
||||
context.configure(
|
||||
connection=connection, target_metadata=target_metadata
|
||||
)
|
||||
|
||||
with context.begin_transaction():
|
||||
context.run_migrations()
|
||||
|
||||
if context.is_offline_mode():
|
||||
run_migrations_offline()
|
||||
else:
|
||||
run_migrations_online()
|
||||
|
||||
|
||||
26
migrations/script.py.mako
Normal file
26
migrations/script.py.mako
Normal file
@@ -0,0 +1,26 @@
|
||||
"""${message}
|
||||
|
||||
Revision ID: ${up_revision}
|
||||
Revises: ${down_revision | comma,n}
|
||||
Create Date: ${create_date}
|
||||
|
||||
"""
|
||||
from typing import Sequence, Union
|
||||
|
||||
from alembic import op
|
||||
import sqlalchemy as sa
|
||||
${imports if imports else ""}
|
||||
|
||||
# revision identifiers, used by Alembic.
|
||||
revision: str = ${repr(up_revision)}
|
||||
down_revision: Union[str, None] = ${repr(down_revision)}
|
||||
branch_labels: Union[str, Sequence[str], None] = ${repr(branch_labels)}
|
||||
depends_on: Union[str, Sequence[str], None] = ${repr(depends_on)}
|
||||
|
||||
|
||||
def upgrade() -> None:
|
||||
${upgrades if upgrades else "pass"}
|
||||
|
||||
|
||||
def downgrade() -> None:
|
||||
${downgrades if downgrades else "pass"}
|
||||
407
migrations/versions/03baecbcb5d9_adjustmen_modules.py
Normal file
407
migrations/versions/03baecbcb5d9_adjustmen_modules.py
Normal file
@@ -0,0 +1,407 @@
|
||||
"""adjustmen_modules
|
||||
|
||||
Revision ID: 03baecbcb5d9
|
||||
Revises: d41d0457f936
|
||||
Create Date: 2026-04-01 18:46:35.084090
|
||||
|
||||
"""
|
||||
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 = '03baecbcb5d9'
|
||||
down_revision: Union[str, None] = 'd41d0457f936'
|
||||
branch_labels: Union[str, Sequence[str], None] = None
|
||||
depends_on: Union[str, Sequence[str], None] = None
|
||||
|
||||
|
||||
def upgrade() -> None:
|
||||
# ### commands auto generated by Alembic - please adjust! ###
|
||||
op.create_table('configuration',
|
||||
sa.Column('id', sa.Integer(), autoincrement=True, nullable=False),
|
||||
sa.Column('smtp_host', sa.String(length=100), nullable=True),
|
||||
sa.Column('smtp_port', sa.Integer(), nullable=True),
|
||||
sa.Column('smtp_user', sa.String(length=100), nullable=True),
|
||||
sa.Column('smtp_password', sa.String(length=100), nullable=True),
|
||||
sa.Column('is_active', sa.Boolean(), nullable=False),
|
||||
sa.Column('created_at', sa.DateTime(timezone=True), server_default=sa.text('now()'), nullable=False),
|
||||
sa.Column('updated_at', sa.DateTime(timezone=True), nullable=True),
|
||||
sa.Column('deleted_at', sa.DateTime(timezone=True), nullable=True),
|
||||
sa.Column('last_send', sa.DateTime(timezone=True), server_default=sa.text('now()'), nullable=False),
|
||||
sa.Column('created_by', sa.Integer(), nullable=False),
|
||||
sa.Column('updtated_by', sa.Integer(), nullable=True),
|
||||
sa.Column('deleted_by', sa.Integer(), nullable=True),
|
||||
sa.PrimaryKeyConstraint('id')
|
||||
)
|
||||
op.create_index('idx_cofig_active', 'configuration', ['is_active'], unique=False)
|
||||
op.create_table('credits',
|
||||
sa.Column('id', sa.Integer(), autoincrement=True, nullable=False),
|
||||
sa.Column('title', sa.String(length=30), nullable=False),
|
||||
sa.Column('rfc', sa.String(length=25), nullable=False),
|
||||
sa.Column('razon_social', sa.String(length=100), nullable=False),
|
||||
sa.Column('tipo_persona', sa.String(length=100), nullable=False),
|
||||
sa.Column('supuesto', sa.Enum('CANCELADOS', 'CONDONADOS', 'FIRMES', 'SENTENCIAS', 'EXIGIBLES', 'RETORNO_INVERSIONES', 'FRACCION_X', 'FRACCION_VII', 'NO_LOCALIZADOS', name='supuestos'), nullable=False),
|
||||
sa.Column('fecha_primera_publicacion', sa.Date(), nullable=False),
|
||||
sa.Column('fecha_publicacion_ley_transparencia', sa.Date(), nullable=True),
|
||||
sa.Column('fecha_cancelacion', sa.Date(), nullable=True),
|
||||
sa.Column('fecha_cancelacion_csd', sa.Date(), nullable=True),
|
||||
sa.Column('entidad_federativa', sa.String(), nullable=False),
|
||||
sa.Column('monto', sa.Integer(), nullable=True),
|
||||
sa.Column('motivo', sa.Text(), nullable=True),
|
||||
sa.Column('location_id', sa.Integer(), nullable=False),
|
||||
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=True),
|
||||
sa.Column('uploaded_by', sa.Integer(), nullable=True),
|
||||
sa.PrimaryKeyConstraint('id')
|
||||
)
|
||||
op.create_table('edos',
|
||||
sa.Column('id', sa.Integer(), nullable=False),
|
||||
sa.Column('numero', sa.Integer(), nullable=False),
|
||||
sa.Column('razon_social', sa.String(length=100), nullable=False),
|
||||
sa.Column('situacion', sa.Enum('SENTENCIA_FAVORABLE', 'DEFINITIVO', name='situcion'), nullable=False),
|
||||
sa.Column('numero_definitivo', sa.String(length=60), nullable=False),
|
||||
sa.Column('fecha_definitivo', sa.Date(), nullable=False),
|
||||
sa.Column('publicaccion_sat', sa.Date(), nullable=True),
|
||||
sa.Column('numero_def_dof', sa.String(length=100), nullable=True),
|
||||
sa.Column('fecha_def_dof', sa.Date(), nullable=True),
|
||||
sa.Column('publicacion_dof', sa.Date(), nullable=True),
|
||||
sa.Column('numero_fav_sat', sa.String(length=100), nullable=True),
|
||||
sa.PrimaryKeyConstraint('id')
|
||||
)
|
||||
op.create_table('efos',
|
||||
sa.Column('id', sa.Integer(), nullable=False),
|
||||
sa.Column('numero', sa.Integer(), nullable=False),
|
||||
sa.Column('rfc', sa.String(length=30), nullable=False),
|
||||
sa.Column('nombre_contribuyente', sa.String(length=100), nullable=False),
|
||||
sa.Column('situacion', sa.String(length=60), nullable=False),
|
||||
sa.Column('publi_presuntos_sat', sa.Date(), nullable=True),
|
||||
sa.Column('publi_desvirtuados_sat', sa.Date(), nullable=True),
|
||||
sa.Column('publi_definitivos_sat', sa.Date(), nullable=True),
|
||||
sa.Column('publi_favorables_sat', sa.Date(), 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), nullable=False),
|
||||
sa.Column('loaded_by', sa.Integer(), nullable=False),
|
||||
sa.PrimaryKeyConstraint('id')
|
||||
)
|
||||
op.create_table('files',
|
||||
sa.Column('id', sa.Integer(), nullable=False),
|
||||
sa.Column('title', sa.String(length=50), nullable=True),
|
||||
sa.Column('summary', sa.Text(), nullable=False),
|
||||
sa.Column('document_url', sa.String(length=100), nullable=False),
|
||||
sa.Column('file_type', sa.String(length=50), nullable=False),
|
||||
sa.Column('file_size', sa.Integer(), nullable=False),
|
||||
sa.Column('feed_id', sa.Integer(), nullable=False),
|
||||
sa.Column('created_at', sa.DateTime(timezone=True), server_default=sa.text('now()'), nullable=False),
|
||||
sa.Column('updated_at', sa.DateTime(timezone=True), nullable=False),
|
||||
sa.Column('uploaded_by', sa.Integer(), nullable=False),
|
||||
sa.Column('updated_by', sa.Integer(), nullable=True),
|
||||
sa.PrimaryKeyConstraint('id')
|
||||
)
|
||||
op.create_table('invoices',
|
||||
sa.Column('id', sa.Integer(), nullable=True),
|
||||
sa.Column('emisor', sa.String(length=100), nullable=False),
|
||||
sa.Column('receptor', sa.String(length=110), nullable=False),
|
||||
sa.Column('uuid', sa.String(length=255), nullable=False),
|
||||
sa.Column('total', sa.Integer(), nullable=False),
|
||||
sa.Column('tipo', sa.String(length=50), nullable=True),
|
||||
sa.Column('date', sa.DateTime(), nullable=True),
|
||||
sa.Column('verified_at', sa.DateTime(timezone=True), server_default=sa.text('now()'), nullable=False),
|
||||
sa.Column('verified_by', sa.Integer(), nullable=True),
|
||||
sa.PrimaryKeyConstraint('id')
|
||||
)
|
||||
op.create_table('location',
|
||||
sa.Column('id', sa.Integer(), nullable=False),
|
||||
sa.Column('country', sa.String(length=120), nullable=False),
|
||||
sa.Column('country_id', sa.Integer(), nullable=False),
|
||||
sa.Column('state', sa.String(length=100), nullable=False),
|
||||
sa.Column('state_id', sa.Integer(), nullable=False),
|
||||
sa.Column('city', sa.String(length=100), nullable=False),
|
||||
sa.Column('city_id', sa.Integer(), nullable=False),
|
||||
sa.Column('cp_zp', sa.Integer(), nullable=True),
|
||||
sa.Column('street', sa.String(length=120), nullable=True),
|
||||
sa.Column('is_department', sa.Boolean(), nullable=False),
|
||||
sa.Column('number_ext', sa.Integer(), nullable=True),
|
||||
sa.Column('number_int', sa.Integer(), nullable=True),
|
||||
sa.Column('is_active', sa.Boolean(), nullable=False),
|
||||
sa.Column('created_at', sa.DateTime(timezone=True), server_default=sa.text('now()'), nullable=False),
|
||||
sa.Column('updated_at', sa.DateTime(timezone=True), nullable=True),
|
||||
sa.Column('deleted_at', sa.DateTime(), nullable=True),
|
||||
sa.Column('created_by', sa.Integer(), nullable=True),
|
||||
sa.Column('updated_by', sa.Integer(), nullable=True),
|
||||
sa.Column('deleted_by', sa.Integer(), nullable=True),
|
||||
sa.PrimaryKeyConstraint('id')
|
||||
)
|
||||
op.create_index('idx_location_active', 'location', ['is_active'], unique=False)
|
||||
op.create_index('idx_location_city', 'location', ['city'], unique=False)
|
||||
op.create_index('idx_location_country', 'location', ['country'], unique=False)
|
||||
op.create_index('idx_location_cp', 'location', ['cp_zp'], unique=False)
|
||||
op.create_index('idx_location_state', 'location', ['state'], unique=False)
|
||||
op.create_table('users',
|
||||
sa.Column('id', sa.Integer(), autoincrement=True, nullable=False),
|
||||
sa.Column('name', sa.String(length=100), nullable=False),
|
||||
sa.Column('middle_Name', sa.String(length=100), nullable=True),
|
||||
sa.Column('last_Name', sa.String(length=120), nullable=False),
|
||||
sa.Column('rfc', sa.String(length=60), nullable=False),
|
||||
sa.Column('email', sa.String(length=120), nullable=False),
|
||||
sa.Column('password', sa.String(length=255), nullable=False),
|
||||
sa.Column('client_id', sa.Integer(), nullable=False),
|
||||
sa.Column('rol_operativo', sa.Enum('COMPRAS', 'VENTAS', 'LOGISTICA', 'ADUANA_SOFT', 'CLIENTE', 'OPERATIVO', name='rol'), nullable=False),
|
||||
sa.Column('tipo_usuario', sa.Enum('ROOT', 'ADMIN', 'PRIVILEGED', 'ADMIN_LICENCIAS', 'UPDATER', 'USER', name='tipousuario'), nullable=False),
|
||||
sa.Column('permite_diot', sa.Boolean(), nullable=False),
|
||||
sa.Column('enterprise_id', sa.Integer(), nullable=True),
|
||||
sa.Column('firma', sa.String(length=110), nullable=True),
|
||||
sa.Column('branches_id', sa.Integer(), nullable=True),
|
||||
sa.Column('license_id', sa.Integer(), nullable=True),
|
||||
sa.Column('is_active', sa.Boolean(), nullable=False),
|
||||
sa.Column('created_at', sa.DateTime(timezone=True), server_default=sa.text('now()'), nullable=False),
|
||||
sa.Column('updated_at', sa.DateTime(timezone=True), nullable=True),
|
||||
sa.Column('deleted_at', sa.DateTime(timezone=True), nullable=True),
|
||||
sa.Column('last_login', sa.DateTime(timezone=True), server_default=sa.text('now()'), nullable=False),
|
||||
sa.Column('created_by', sa.Integer(), nullable=True),
|
||||
sa.Column('updated_by', sa.Integer(), nullable=True),
|
||||
sa.Column('deleted_by', sa.Integer(), nullable=True),
|
||||
sa.Column('password_reset_token', sa.String(), nullable=True),
|
||||
sa.Column('password_reset_expires', sa.String(), nullable=True),
|
||||
sa.PrimaryKeyConstraint('id'),
|
||||
sa.UniqueConstraint('email'),
|
||||
sa.UniqueConstraint('firma'),
|
||||
sa.UniqueConstraint('rfc')
|
||||
)
|
||||
op.create_index(op.f('ix_users_id'), 'users', ['id'], unique=False)
|
||||
op.create_table('clients',
|
||||
sa.Column('id', sa.Integer(), nullable=False),
|
||||
sa.Column('rfc', sa.String(length=60), nullable=False),
|
||||
sa.Column('email', sa.String(length=150), nullable=False),
|
||||
sa.Column('short_name', sa.String(length=255), nullable=True),
|
||||
sa.Column('razon_social', sa.String(length=255), nullable=False),
|
||||
sa.Column('fiscal_number', sa.String(length=15), nullable=False),
|
||||
sa.Column('cellphone', sa.String(length=20), nullable=False),
|
||||
sa.Column('medio', sa.Enum('MANUAL', 'DIOT', 'EXCEL', 'FACTURA', name='medio_enum'), nullable=False),
|
||||
sa.Column('third_type', sa.Enum('NACIONAL', 'EXTRANJERO', 'GLOBAL', name='tercero_enum'), nullable=False),
|
||||
sa.Column('operation_type', sa.Enum('PRESTACIONSERVICIOSPROFECIONALES', 'ARRENDAMIENTOSINMUENBLES', 'OTROS', name='operacion_enum'), nullable=False),
|
||||
sa.Column('is_foreign', sa.Boolean(), nullable=True),
|
||||
sa.Column('user_id', sa.Integer(), nullable=False),
|
||||
sa.Column('location_id', sa.Integer(), 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), nullable=True),
|
||||
sa.Column('deleted_at', sa.DateTime(timezone=True), nullable=True),
|
||||
sa.Column('created_by', sa.Integer(), nullable=True),
|
||||
sa.Column('updated_by', sa.Integer(), nullable=True),
|
||||
sa.Column('deleted_by', sa.Integer(), nullable=True),
|
||||
sa.ForeignKeyConstraint(['location_id'], ['location.id'], ),
|
||||
sa.ForeignKeyConstraint(['user_id'], ['users.id'], ),
|
||||
sa.PrimaryKeyConstraint('id'),
|
||||
sa.UniqueConstraint('email'),
|
||||
sa.UniqueConstraint('fiscal_number'),
|
||||
sa.UniqueConstraint('rfc')
|
||||
)
|
||||
op.create_index(op.f('ix_clients_id'), 'clients', ['id'], unique=False)
|
||||
op.create_index(op.f('ix_clients_razon_social'), 'clients', ['razon_social'], unique=False)
|
||||
op.create_table('feed',
|
||||
sa.Column('id', sa.Integer(), nullable=False),
|
||||
sa.Column('title', sa.String(length=50), nullable=False),
|
||||
sa.Column('body', sa.Text(), nullable=True),
|
||||
sa.Column('document_url', sa.String(), nullable=True),
|
||||
sa.Column('publication_date', sa.Date(), nullable=True),
|
||||
sa.Column('is_important', sa.Boolean(), nullable=False),
|
||||
sa.Column('created_at', sa.DateTime(timezone=True), server_default=sa.text('now()'), nullable=False),
|
||||
sa.Column('updated_at', sa.DateTime(timezone=True), nullable=True),
|
||||
sa.Column('user_id', sa.Integer(), nullable=True),
|
||||
sa.Column('created_by', sa.Integer(), nullable=False),
|
||||
sa.Column('updated_by', sa.Integer(), nullable=True),
|
||||
sa.Column('file_id', sa.Integer(), nullable=True),
|
||||
sa.ForeignKeyConstraint(['user_id'], ['users.id'], ),
|
||||
sa.PrimaryKeyConstraint('id')
|
||||
)
|
||||
op.create_table('interacctions',
|
||||
sa.Column('id', sa.Integer(), nullable=False),
|
||||
sa.Column('feed_id', sa.Integer(), nullable=False),
|
||||
sa.Column('user_id', sa.Integer(), nullable=False),
|
||||
sa.Column('type_iteractions', sa.Enum('LIKE', 'DONT_LIKE', 'APPROVED', 'DISAPRROVE', 'NONE', name='type_interactios'), nullable=False),
|
||||
sa.Column('created_at', sa.DateTime(timezone=True), server_default=sa.text('now()'), nullable=False),
|
||||
sa.Column('updated_at', sa.DateTime(timezone=True), nullable=True),
|
||||
sa.ForeignKeyConstraint(['user_id'], ['users.id'], ),
|
||||
sa.PrimaryKeyConstraint('id')
|
||||
)
|
||||
op.create_table('affidavit_logs',
|
||||
sa.Column('id', sa.Integer(), autoincrement=True, nullable=False),
|
||||
sa.Column('operation', sa.Enum('DELETED', 'CREATED', 'UPDATED', 'TRIED', 'MOST', 'LESS', 'MINUS', 'CANCELED', name='operation'), nullable=True),
|
||||
sa.Column('user_id', sa.Integer(), nullable=True),
|
||||
sa.Column('client_id', sa.Integer(), nullable=True),
|
||||
sa.Column('description', sa.Text(), nullable=False),
|
||||
sa.Column('adjustment', sa.String(length=100), nullable=True),
|
||||
sa.Column('status', sa.Enum('COMPLETED', 'PARTIAL', 'INITIAL', 'NO_PROCECED', 'INVALID', name='status'), nullable=True),
|
||||
sa.Column('sign', sa.String(), nullable=False),
|
||||
sa.Column('created_at', sa.DateTime(timezone=True), server_default=sa.text('now()'), nullable=False),
|
||||
sa.Column('updated_at', sa.DateTime(timezone=True), nullable=True),
|
||||
sa.Column('deleted_at', sa.DateTime(timezone=True), nullable=True),
|
||||
sa.Column('created_by', sa.Integer(), nullable=True),
|
||||
sa.Column('updated_by', sa.Integer(), nullable=True),
|
||||
sa.Column('deleted_by', sa.Integer(), nullable=True),
|
||||
sa.ForeignKeyConstraint(['client_id'], ['clients.id'], ),
|
||||
sa.ForeignKeyConstraint(['user_id'], ['users.id'], ),
|
||||
sa.PrimaryKeyConstraint('id')
|
||||
)
|
||||
op.create_index('idx_affidavit_client', 'affidavit_logs', ['client_id'], unique=False)
|
||||
op.create_index('idx_affidavit_created', 'affidavit_logs', ['created_at'], unique=False)
|
||||
op.create_index('idx_affidavit_operation', 'affidavit_logs', ['operation'], unique=False)
|
||||
op.create_index('idx_affidavit_status', 'affidavit_logs', ['status'], unique=False)
|
||||
op.create_index('idx_affidavit_user', 'affidavit_logs', ['user_id'], unique=False)
|
||||
op.create_table('branches',
|
||||
sa.Column('id', sa.Integer(), autoincrement=True, nullable=False),
|
||||
sa.Column('direccion', sa.String(length=255), nullable=False),
|
||||
sa.Column('cp', sa.Integer(), nullable=False),
|
||||
sa.Column('is_physical', sa.Boolean(), nullable=False),
|
||||
sa.Column('location_id', sa.Integer(), nullable=False),
|
||||
sa.Column('is_active', sa.Boolean(), nullable=False),
|
||||
sa.Column('client_id', sa.Integer(), 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), nullable=True),
|
||||
sa.Column('deleted_at', sa.DateTime(timezone=True), nullable=True),
|
||||
sa.Column('created_by', sa.Integer(), nullable=True),
|
||||
sa.Column('updated_by', sa.Integer(), nullable=True),
|
||||
sa.Column('deleted_by', sa.Integer(), nullable=True),
|
||||
sa.ForeignKeyConstraint(['client_id'], ['clients.id'], ),
|
||||
sa.ForeignKeyConstraint(['location_id'], ['location.id'], ),
|
||||
sa.PrimaryKeyConstraint('id')
|
||||
)
|
||||
op.create_index('idx_branches_active', 'branches', ['is_active'], unique=False)
|
||||
op.create_index('idx_branches_client', 'branches', ['client_id'], unique=False)
|
||||
op.create_index('idx_branches_location', 'branches', ['location_id'], unique=False)
|
||||
op.create_table('coments',
|
||||
sa.Column('id', sa.Integer(), nullable=False),
|
||||
sa.Column('texto', sa.Text(), nullable=False),
|
||||
sa.Column('user_id', sa.Integer(), nullable=True),
|
||||
sa.Column('feed_id', sa.Integer(), nullable=True),
|
||||
sa.Column('is_active', sa.Boolean(), nullable=False),
|
||||
sa.Column('created_at', sa.DateTime(timezone=True), server_default=sa.text('now()'), nullable=False),
|
||||
sa.Column('deactivate_at', sa.DateTime(timezone=True), nullable=True),
|
||||
sa.Column('created_by', sa.Integer(), nullable=False),
|
||||
sa.Column('deactivated_by', sa.Integer(), nullable=True),
|
||||
sa.ForeignKeyConstraint(['feed_id'], ['feed.id'], ),
|
||||
sa.ForeignKeyConstraint(['user_id'], ['users.id'], ),
|
||||
sa.PrimaryKeyConstraint('id')
|
||||
)
|
||||
op.create_index('idx_coments_active', 'coments', ['is_active'], unique=False)
|
||||
op.create_index('idx_coments_created', 'coments', ['created_at'], unique=False)
|
||||
op.create_index('idx_coments_feed', 'coments', ['feed_id'], unique=False)
|
||||
op.create_index('idx_coments_user', 'coments', ['user_id'], unique=False)
|
||||
op.create_table('license',
|
||||
sa.Column('id', sa.Integer(), nullable=False),
|
||||
sa.Column('titular', sa.Integer(), nullable=False),
|
||||
sa.Column('begins_at', sa.DateTime(timezone=True), server_default=sa.text('now()'), nullable=False),
|
||||
sa.Column('ends_at', sa.DateTime(timezone=True), server_default=sa.text('now()'), nullable=False),
|
||||
sa.Column('token_license', sa.String(length=30), nullable=True),
|
||||
sa.Column('location_id', sa.Integer(), nullable=False),
|
||||
sa.Column('client_id', sa.Integer(), nullable=False),
|
||||
sa.Column('created_at', sa.DateTime(timezone=True), server_default=sa.text('now()'), nullable=False),
|
||||
sa.Column('updated_at', sa.DateTime(timezone=True), nullable=True),
|
||||
sa.Column('deleted_at', sa.DateTime(timezone=True), nullable=False),
|
||||
sa.Column('created_by', sa.Integer(), nullable=True),
|
||||
sa.Column('updated_by', sa.Integer(), nullable=True),
|
||||
sa.Column('deleted_by', sa.Integer(), nullable=True),
|
||||
sa.ForeignKeyConstraint(['client_id'], ['clients.id'], ),
|
||||
sa.ForeignKeyConstraint(['titular'], ['users.id'], ),
|
||||
sa.PrimaryKeyConstraint('id')
|
||||
)
|
||||
op.create_table('moves',
|
||||
sa.Column('id', sa.Integer(), nullable=False),
|
||||
sa.Column('action_type', sa.Enum('UPLOAD', 'MATCH', 'QUERY', 'CONSUMPTION', 'CREATE', 'DELETE', 'SOLD', 'INTERACTION', 'COMMENT', 'CONFIG', 'EMAIL', name='action_type'), nullable=False),
|
||||
sa.Column('target_type', sa.Enum('CLIENT', 'INVOICES', 'FEED', 'EFOS', 'CREDITS', 'USERS', 'EMAIL', name='target_type'), nullable=False),
|
||||
sa.Column('description', sa.Text(), nullable=True),
|
||||
sa.Column('move_metadata', postgresql.JSONB(astext_type=sa.Text()), nullable=True),
|
||||
sa.Column('ip_address', sa.String(length=45), nullable=True),
|
||||
sa.Column('user_agent', sa.String(length=255), nullable=True),
|
||||
sa.Column('client_id', sa.Integer(), nullable=True),
|
||||
sa.Column('user_id', sa.Integer(), nullable=True),
|
||||
sa.Column('is_active', sa.Boolean(), nullable=False),
|
||||
sa.Column('created_at', sa.DateTime(timezone=True), server_default=sa.text('now()'), nullable=False),
|
||||
sa.Column('created_by', sa.Integer(), nullable=True),
|
||||
sa.Column('updated_at', sa.DateTime(timezone=True), nullable=True),
|
||||
sa.Column('deleted_by', sa.Integer(), nullable=True),
|
||||
sa.ForeignKeyConstraint(['client_id'], ['clients.id'], ),
|
||||
sa.ForeignKeyConstraint(['user_id'], ['users.id'], ),
|
||||
sa.PrimaryKeyConstraint('id')
|
||||
)
|
||||
op.create_table('suppliers',
|
||||
sa.Column('id', sa.Integer(), nullable=False),
|
||||
sa.Column('rfc', sa.String(length=60), nullable=False),
|
||||
sa.Column('email', sa.String(length=150), nullable=False),
|
||||
sa.Column('short_name', sa.String(length=255), nullable=True),
|
||||
sa.Column('razon_social', sa.String(length=255), nullable=False),
|
||||
sa.Column('fiscal_number', sa.String(length=15), nullable=False),
|
||||
sa.Column('cellphone', sa.String(length=20), nullable=False),
|
||||
sa.Column('supplier_type', sa.Enum('NACIONAL', 'EXTRANJERO', 'GLOBAL', name='suppliertype'), nullable=False),
|
||||
sa.Column('location_id', sa.Integer(), nullable=True),
|
||||
sa.Column('is_active', sa.Boolean(), nullable=False),
|
||||
sa.Column('client_id', sa.Integer(), nullable=False),
|
||||
sa.Column('created_at', sa.DateTime(timezone=True), server_default=sa.text('now()'), nullable=False),
|
||||
sa.Column('updated_at', sa.DateTime(timezone=True), nullable=True),
|
||||
sa.Column('deleted_at', sa.DateTime(timezone=True), nullable=True),
|
||||
sa.Column('created_by', sa.Integer(), nullable=True),
|
||||
sa.Column('updated_by', sa.Integer(), nullable=True),
|
||||
sa.Column('deleted_by', sa.Integer(), nullable=True),
|
||||
sa.ForeignKeyConstraint(['client_id'], ['clients.id'], ),
|
||||
sa.ForeignKeyConstraint(['location_id'], ['location.id'], ),
|
||||
sa.PrimaryKeyConstraint('id'),
|
||||
sa.UniqueConstraint('email'),
|
||||
sa.UniqueConstraint('fiscal_number'),
|
||||
sa.UniqueConstraint('rfc')
|
||||
)
|
||||
op.create_index('idx_suppliers_active', 'suppliers', ['is_active'], unique=False)
|
||||
op.create_index('idx_suppliers_client', 'suppliers', ['client_id'], unique=False)
|
||||
op.create_index('idx_suppliers_location', 'suppliers', ['location_id'], unique=False)
|
||||
op.create_index('idx_suppliers_type', 'suppliers', ['supplier_type'], unique=False)
|
||||
op.create_index(op.f('ix_suppliers_razon_social'), 'suppliers', ['razon_social'], unique=False)
|
||||
# ### end Alembic commands ###
|
||||
|
||||
|
||||
def downgrade() -> None:
|
||||
# ### commands auto generated by Alembic - please adjust! ###
|
||||
op.drop_index(op.f('ix_suppliers_razon_social'), table_name='suppliers')
|
||||
op.drop_index('idx_suppliers_type', table_name='suppliers')
|
||||
op.drop_index('idx_suppliers_location', table_name='suppliers')
|
||||
op.drop_index('idx_suppliers_client', table_name='suppliers')
|
||||
op.drop_index('idx_suppliers_active', table_name='suppliers')
|
||||
op.drop_table('suppliers')
|
||||
op.drop_table('moves')
|
||||
op.drop_table('license')
|
||||
op.drop_index('idx_coments_user', table_name='coments')
|
||||
op.drop_index('idx_coments_feed', table_name='coments')
|
||||
op.drop_index('idx_coments_created', table_name='coments')
|
||||
op.drop_index('idx_coments_active', table_name='coments')
|
||||
op.drop_table('coments')
|
||||
op.drop_index('idx_branches_location', table_name='branches')
|
||||
op.drop_index('idx_branches_client', table_name='branches')
|
||||
op.drop_index('idx_branches_active', table_name='branches')
|
||||
op.drop_table('branches')
|
||||
op.drop_index('idx_affidavit_user', table_name='affidavit_logs')
|
||||
op.drop_index('idx_affidavit_status', table_name='affidavit_logs')
|
||||
op.drop_index('idx_affidavit_operation', table_name='affidavit_logs')
|
||||
op.drop_index('idx_affidavit_created', table_name='affidavit_logs')
|
||||
op.drop_index('idx_affidavit_client', table_name='affidavit_logs')
|
||||
op.drop_table('affidavit_logs')
|
||||
op.drop_table('interacctions')
|
||||
op.drop_table('feed')
|
||||
op.drop_index(op.f('ix_clients_razon_social'), table_name='clients')
|
||||
op.drop_index(op.f('ix_clients_id'), table_name='clients')
|
||||
op.drop_table('clients')
|
||||
op.drop_index(op.f('ix_users_id'), table_name='users')
|
||||
op.drop_table('users')
|
||||
op.drop_index('idx_location_state', table_name='location')
|
||||
op.drop_index('idx_location_cp', table_name='location')
|
||||
op.drop_index('idx_location_country', table_name='location')
|
||||
op.drop_index('idx_location_city', table_name='location')
|
||||
op.drop_index('idx_location_active', table_name='location')
|
||||
op.drop_table('location')
|
||||
op.drop_table('invoices')
|
||||
op.drop_table('files')
|
||||
op.drop_table('efos')
|
||||
op.drop_table('edos')
|
||||
op.drop_table('credits')
|
||||
op.drop_index('idx_cofig_active', table_name='configuration')
|
||||
op.drop_table('configuration')
|
||||
# ### end Alembic commands ###
|
||||
@@ -0,0 +1,36 @@
|
||||
"""XMA architecture - all modules with bidirectional relationships
|
||||
|
||||
Revision ID: 37e3df20754e
|
||||
Revises: 8e2919155783
|
||||
Create Date: 2026-04-01 19:35:18.366513
|
||||
|
||||
"""
|
||||
from typing import Sequence, Union
|
||||
|
||||
from alembic import op
|
||||
import sqlalchemy as sa
|
||||
|
||||
|
||||
# revision identifiers, used by Alembic.
|
||||
revision: str = '37e3df20754e'
|
||||
down_revision: Union[str, None] = '8e2919155783'
|
||||
branch_labels: Union[str, Sequence[str], None] = None
|
||||
depends_on: Union[str, Sequence[str], None] = None
|
||||
|
||||
|
||||
def upgrade() -> None:
|
||||
# ### commands auto generated by Alembic - please adjust! ###
|
||||
op.create_foreign_key(None, 'credits', 'location', ['location_id'], ['id'])
|
||||
op.drop_column('users', 'license_id')
|
||||
op.drop_column('users', 'branches_id')
|
||||
op.drop_column('users', 'client_id')
|
||||
# ### end Alembic commands ###
|
||||
|
||||
|
||||
def downgrade() -> None:
|
||||
# ### commands auto generated by Alembic - please adjust! ###
|
||||
op.add_column('users', sa.Column('client_id', sa.INTEGER(), autoincrement=False, nullable=False))
|
||||
op.add_column('users', sa.Column('branches_id', sa.INTEGER(), autoincrement=False, nullable=True))
|
||||
op.add_column('users', sa.Column('license_id', sa.INTEGER(), autoincrement=False, nullable=True))
|
||||
op.drop_constraint(None, 'credits', type_='foreignkey')
|
||||
# ### end Alembic commands ###
|
||||
42
migrations/versions/84e064c18a0f_adjustmen_modules.py
Normal file
42
migrations/versions/84e064c18a0f_adjustmen_modules.py
Normal file
@@ -0,0 +1,42 @@
|
||||
"""adjustmen_modules
|
||||
|
||||
Revision ID: 84e064c18a0f
|
||||
Revises: 03baecbcb5d9
|
||||
Create Date: 2026-04-01 19:09:19.420667
|
||||
|
||||
"""
|
||||
from typing import Sequence, Union
|
||||
|
||||
from alembic import op
|
||||
import sqlalchemy as sa
|
||||
|
||||
|
||||
# revision identifiers, used by Alembic.
|
||||
revision: str = '84e064c18a0f'
|
||||
down_revision: Union[str, None] = '03baecbcb5d9'
|
||||
branch_labels: Union[str, Sequence[str], None] = None
|
||||
depends_on: Union[str, Sequence[str], None] = None
|
||||
|
||||
|
||||
def upgrade() -> None:
|
||||
# ### commands auto generated by Alembic - please adjust! ###
|
||||
op.add_column('branches', sa.Column('user_id', sa.Integer(), nullable=True))
|
||||
op.create_index('idx_branches_user', 'branches', ['user_id'], unique=False)
|
||||
op.create_foreign_key(None, 'branches', 'users', ['user_id'], ['id'])
|
||||
op.alter_column('invoices', 'id',
|
||||
existing_type=sa.INTEGER(),
|
||||
nullable=True,
|
||||
autoincrement=True)
|
||||
# ### end Alembic commands ###
|
||||
|
||||
|
||||
def downgrade() -> None:
|
||||
# ### commands auto generated by Alembic - please adjust! ###
|
||||
op.alter_column('invoices', 'id',
|
||||
existing_type=sa.INTEGER(),
|
||||
nullable=False,
|
||||
autoincrement=True)
|
||||
op.drop_constraint(None, 'branches', type_='foreignkey')
|
||||
op.drop_index('idx_branches_user', table_name='branches')
|
||||
op.drop_column('branches', 'user_id')
|
||||
# ### end Alembic commands ###
|
||||
30
migrations/versions/8e2919155783_base_adjustment_1_5.py
Normal file
30
migrations/versions/8e2919155783_base_adjustment_1_5.py
Normal file
@@ -0,0 +1,30 @@
|
||||
"""base_adjustment_1.5
|
||||
|
||||
Revision ID: 8e2919155783
|
||||
Revises: b7441b91f586
|
||||
Create Date: 2026-04-01 19:14:53.327618
|
||||
|
||||
"""
|
||||
from typing import Sequence, Union
|
||||
|
||||
from alembic import op
|
||||
import sqlalchemy as sa
|
||||
|
||||
|
||||
# revision identifiers, used by Alembic.
|
||||
revision: str = '8e2919155783'
|
||||
down_revision: Union[str, None] = 'b7441b91f586'
|
||||
branch_labels: Union[str, Sequence[str], None] = None
|
||||
depends_on: Union[str, Sequence[str], None] = None
|
||||
|
||||
|
||||
def upgrade() -> None:
|
||||
# ### commands auto generated by Alembic - please adjust! ###
|
||||
pass
|
||||
# ### end Alembic commands ###
|
||||
|
||||
|
||||
def downgrade() -> None:
|
||||
# ### commands auto generated by Alembic - please adjust! ###
|
||||
pass
|
||||
# ### end Alembic commands ###
|
||||
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
34
migrations/versions/b7441b91f586_base_adjustment.py
Normal file
34
migrations/versions/b7441b91f586_base_adjustment.py
Normal file
@@ -0,0 +1,34 @@
|
||||
"""base_adjustment
|
||||
|
||||
Revision ID: b7441b91f586
|
||||
Revises: 84e064c18a0f
|
||||
Create Date: 2026-04-01 19:12:39.530941
|
||||
|
||||
"""
|
||||
from typing import Sequence, Union
|
||||
|
||||
from alembic import op
|
||||
import sqlalchemy as sa
|
||||
|
||||
|
||||
# revision identifiers, used by Alembic.
|
||||
revision: str = 'b7441b91f586'
|
||||
down_revision: Union[str, None] = '84e064c18a0f'
|
||||
branch_labels: Union[str, Sequence[str], None] = None
|
||||
depends_on: Union[str, Sequence[str], None] = None
|
||||
|
||||
|
||||
def upgrade() -> None:
|
||||
# ### commands auto generated by Alembic - please adjust! ###
|
||||
op.add_column('branches', sa.Column('user_id', sa.Integer(), nullable=True))
|
||||
op.create_index('idx_branches_user', 'branches', ['user_id'], unique=False)
|
||||
op.create_foreign_key(None, 'branches', 'users', ['user_id'], ['id'])
|
||||
# ### end Alembic commands ###
|
||||
|
||||
|
||||
def downgrade() -> None:
|
||||
# ### commands auto generated by Alembic - please adjust! ###
|
||||
op.drop_constraint(None, 'branches', type_='foreignkey')
|
||||
op.drop_index('idx_branches_user', table_name='branches')
|
||||
op.drop_column('branches', 'user_id')
|
||||
# ### end Alembic commands ###
|
||||
30
migrations/versions/b7bce6fc0d7e_fix_moves_relations.py
Normal file
30
migrations/versions/b7bce6fc0d7e_fix_moves_relations.py
Normal file
@@ -0,0 +1,30 @@
|
||||
"""fix-moves-relations
|
||||
|
||||
Revision ID: b7bce6fc0d7e
|
||||
Revises: fbbb979fa356
|
||||
Create Date: 2026-04-01 20:05:19.603068
|
||||
|
||||
"""
|
||||
from typing import Sequence, Union
|
||||
|
||||
from alembic import op
|
||||
import sqlalchemy as sa
|
||||
|
||||
|
||||
# revision identifiers, used by Alembic.
|
||||
revision: str = 'b7bce6fc0d7e'
|
||||
down_revision: Union[str, None] = 'fbbb979fa356'
|
||||
branch_labels: Union[str, Sequence[str], None] = None
|
||||
depends_on: Union[str, Sequence[str], None] = None
|
||||
|
||||
|
||||
def upgrade() -> None:
|
||||
# ### commands auto generated by Alembic - please adjust! ###
|
||||
pass
|
||||
# ### end Alembic commands ###
|
||||
|
||||
|
||||
def downgrade() -> None:
|
||||
# ### commands auto generated by Alembic - please adjust! ###
|
||||
pass
|
||||
# ### end Alembic commands ###
|
||||
@@ -0,0 +1,30 @@
|
||||
"""fix relationships foreign_keys
|
||||
|
||||
Revision ID: c01f58ebc7d4
|
||||
Revises: b7bce6fc0d7e
|
||||
Create Date: 2026-04-01 20:14:07.773329
|
||||
|
||||
"""
|
||||
from typing import Sequence, Union
|
||||
|
||||
from alembic import op
|
||||
import sqlalchemy as sa
|
||||
|
||||
|
||||
# revision identifiers, used by Alembic.
|
||||
revision: str = 'c01f58ebc7d4'
|
||||
down_revision: Union[str, None] = 'b7bce6fc0d7e'
|
||||
branch_labels: Union[str, Sequence[str], None] = None
|
||||
depends_on: Union[str, Sequence[str], None] = None
|
||||
|
||||
|
||||
def upgrade() -> None:
|
||||
# ### commands auto generated by Alembic - please adjust! ###
|
||||
pass
|
||||
# ### end Alembic commands ###
|
||||
|
||||
|
||||
def downgrade() -> None:
|
||||
# ### commands auto generated by Alembic - please adjust! ###
|
||||
pass
|
||||
# ### end Alembic commands ###
|
||||
30
migrations/versions/d41d0457f936_initial_schema.py
Normal file
30
migrations/versions/d41d0457f936_initial_schema.py
Normal file
@@ -0,0 +1,30 @@
|
||||
"""initial_schema
|
||||
|
||||
Revision ID: d41d0457f936
|
||||
Revises:
|
||||
Create Date: 2026-04-01 17:39:33.561392
|
||||
|
||||
"""
|
||||
from typing import Sequence, Union
|
||||
|
||||
from alembic import op
|
||||
import sqlalchemy as sa
|
||||
|
||||
|
||||
# revision identifiers, used by Alembic.
|
||||
revision: str = 'd41d0457f936'
|
||||
down_revision: Union[str, None] = None
|
||||
branch_labels: Union[str, Sequence[str], None] = None
|
||||
depends_on: Union[str, Sequence[str], None] = None
|
||||
|
||||
|
||||
def upgrade() -> None:
|
||||
# ### commands auto generated by Alembic - please adjust! ###
|
||||
pass
|
||||
# ### end Alembic commands ###
|
||||
|
||||
|
||||
def downgrade() -> None:
|
||||
# ### commands auto generated by Alembic - please adjust! ###
|
||||
pass
|
||||
# ### end Alembic commands ###
|
||||
56
migrations/versions/fbbb979fa356_fixed_relations_ships.py
Normal file
56
migrations/versions/fbbb979fa356_fixed_relations_ships.py
Normal file
@@ -0,0 +1,56 @@
|
||||
"""fixed_Relations_ships
|
||||
|
||||
Revision ID: fbbb979fa356
|
||||
Revises: 37e3df20754e
|
||||
Create Date: 2026-04-01 19:51:19.291930
|
||||
|
||||
"""
|
||||
from typing import Sequence, Union
|
||||
|
||||
from alembic import op
|
||||
import sqlalchemy as sa
|
||||
|
||||
|
||||
# revision identifiers, used by Alembic.
|
||||
revision: str = 'fbbb979fa356'
|
||||
down_revision: Union[str, None] = '37e3df20754e'
|
||||
branch_labels: Union[str, Sequence[str], None] = None
|
||||
depends_on: Union[str, Sequence[str], None] = None
|
||||
|
||||
|
||||
def upgrade() -> None:
|
||||
# ### commands auto generated by Alembic - please adjust! ###
|
||||
op.create_foreign_key(None, 'affidavit_logs', 'users', ['deleted_by'], ['id'])
|
||||
op.create_foreign_key(None, 'affidavit_logs', 'users', ['updated_by'], ['id'])
|
||||
op.create_foreign_key(None, 'affidavit_logs', 'users', ['created_by'], ['id'])
|
||||
op.create_foreign_key(None, 'coments', 'users', ['deactivated_by'], ['id'])
|
||||
op.create_foreign_key(None, 'coments', 'users', ['created_by'], ['id'])
|
||||
op.alter_column('feed', 'created_by',
|
||||
existing_type=sa.INTEGER(),
|
||||
nullable=True)
|
||||
op.create_foreign_key(None, 'feed', 'users', ['created_by'], ['id'])
|
||||
op.create_foreign_key(None, 'feed', 'users', ['updated_by'], ['id'])
|
||||
op.create_foreign_key(None, 'interacctions', 'feed', ['feed_id'], ['id'])
|
||||
op.create_foreign_key(None, 'license', 'location', ['location_id'], ['id'])
|
||||
op.create_foreign_key(None, 'moves', 'users', ['created_by'], ['id'])
|
||||
op.create_foreign_key(None, 'moves', 'users', ['deleted_by'], ['id'])
|
||||
# ### end Alembic commands ###
|
||||
|
||||
|
||||
def downgrade() -> None:
|
||||
# ### commands auto generated by Alembic - please adjust! ###
|
||||
op.drop_constraint(None, 'moves', type_='foreignkey')
|
||||
op.drop_constraint(None, 'moves', type_='foreignkey')
|
||||
op.drop_constraint(None, 'license', type_='foreignkey')
|
||||
op.drop_constraint(None, 'interacctions', type_='foreignkey')
|
||||
op.drop_constraint(None, 'feed', type_='foreignkey')
|
||||
op.drop_constraint(None, 'feed', type_='foreignkey')
|
||||
op.alter_column('feed', 'created_by',
|
||||
existing_type=sa.INTEGER(),
|
||||
nullable=False)
|
||||
op.drop_constraint(None, 'coments', type_='foreignkey')
|
||||
op.drop_constraint(None, 'coments', type_='foreignkey')
|
||||
op.drop_constraint(None, 'affidavit_logs', type_='foreignkey')
|
||||
op.drop_constraint(None, 'affidavit_logs', type_='foreignkey')
|
||||
op.drop_constraint(None, 'affidavit_logs', type_='foreignkey')
|
||||
# ### end Alembic commands ###
|
||||
Reference in New Issue
Block a user