sip_huellas/api/migrations/versions/a946075b6c2c_migracion_sistema_papiloscopico.py

100 lines
4.2 KiB
Python

"""migracion_sistema_papiloscopico
Revision ID: a946075b6c2c
Revises: 04e47df0b26f
Create Date: 2026-05-21 19:06:40.586192
"""
from alembic import op
import sqlalchemy as sa
# revision identifiers, used by Alembic.
revision = 'a946075b6c2c'
down_revision = '04e47df0b26f'
branch_labels = None
depends_on = None
def upgrade():
# ### commands auto generated by Alembic - please adjust! ###
op.create_table('origen_huellas',
sa.Column('id', sa.Integer(), nullable=False),
sa.Column('descripcion', sa.String(length=255), nullable=False),
sa.Column('lado', sa.String(length=50), nullable=True),
sa.PrimaryKeyConstraint('id')
)
op.create_table('personas',
sa.Column('cod_id', sa.Integer(), nullable=False),
sa.Column('cod_nombre', sa.String(length=255), nullable=False),
sa.Column('fecha_nacimiento', sa.Date(), nullable=True),
sa.Column('sexo', sa.String(length=1), nullable=True),
sa.PrimaryKeyConstraint('cod_id')
)
op.create_table('puntos_caracteristicos',
sa.Column('id', sa.Integer(), autoincrement=True, nullable=False),
sa.Column('nombre', sa.String(length=255), nullable=False),
sa.Column('foto', sa.LargeBinary(), nullable=True),
sa.PrimaryKeyConstraint('id')
)
op.create_table('tipos_f',
sa.Column('id', sa.Integer(), autoincrement=True, nullable=False),
sa.Column('nombre', sa.String(length=255), nullable=False),
sa.Column('foto', sa.LargeBinary(), nullable=True),
sa.Column('descripcion', sa.Text(), nullable=True),
sa.PrimaryKeyConstraint('id')
)
op.create_table('huellas',
sa.Column('id', sa.Integer(), autoincrement=True, nullable=False),
sa.Column('descripcion', sa.String(length=255), nullable=True),
sa.Column('origen_hd', sa.String(length=255), nullable=True),
sa.Column('foto', sa.LargeBinary(), nullable=True),
sa.Column('persona_cod_id', sa.Integer(), nullable=False),
sa.Column('origen_huella_id', sa.Integer(), nullable=False),
sa.ForeignKeyConstraint(['origen_huella_id'], ['origen_huellas.id'], ondelete='RESTRICT'),
sa.ForeignKeyConstraint(['persona_cod_id'], ['personas.cod_id'], ondelete='CASCADE'),
sa.PrimaryKeyConstraint('id')
)
op.create_table('subclasificaciones',
sa.Column('id', sa.Integer(), autoincrement=True, nullable=False),
sa.Column('nombre', sa.String(length=255), nullable=False),
sa.Column('tipo_f_id', sa.Integer(), nullable=False),
sa.ForeignKeyConstraint(['tipo_f_id'], ['tipos_f.id'], ondelete='RESTRICT'),
sa.PrimaryKeyConstraint('id')
)
op.create_table('fichas_clasificacion',
sa.Column('id', sa.Integer(), autoincrement=True, nullable=False),
sa.Column('huella_id', sa.Integer(), nullable=False),
sa.Column('subclasificacion_id', sa.Integer(), nullable=False),
sa.Column('tipos_f_id', sa.Integer(), nullable=False),
sa.Column('fecha', sa.Date(), nullable=False),
sa.ForeignKeyConstraint(['huella_id'], ['huellas.id'], ondelete='CASCADE'),
sa.ForeignKeyConstraint(['subclasificacion_id'], ['subclasificaciones.id'], ondelete='RESTRICT'),
sa.ForeignKeyConstraint(['tipos_f_id'], ['tipos_f.id'], ondelete='RESTRICT'),
sa.PrimaryKeyConstraint('id')
)
op.create_table('huella_punto_caracteristico',
sa.Column('huella_id', sa.Integer(), nullable=False),
sa.Column('punto_id', sa.Integer(), nullable=False),
sa.Column('x', sa.Numeric(precision=10, scale=6), nullable=False),
sa.Column('y', sa.Numeric(precision=10, scale=6), nullable=False),
sa.Column('angulo', sa.Numeric(precision=5, scale=2), nullable=False),
sa.ForeignKeyConstraint(['huella_id'], ['huellas.id'], ondelete='CASCADE'),
sa.ForeignKeyConstraint(['punto_id'], ['puntos_caracteristicos.id'], ondelete='CASCADE'),
sa.PrimaryKeyConstraint('huella_id', 'punto_id')
)
# ### end Alembic commands ###
def downgrade():
# ### commands auto generated by Alembic - please adjust! ###
op.drop_table('huella_punto_caracteristico')
op.drop_table('fichas_clasificacion')
op.drop_table('subclasificaciones')
op.drop_table('huellas')
op.drop_table('tipos_f')
op.drop_table('puntos_caracteristicos')
op.drop_table('personas')
op.drop_table('origen_huellas')
# ### end Alembic commands ###