"""Initial baseline

Revision ID: ad5a6de3a358
Revises: 
Create Date: 2026-05-17 18:31:34.000767

"""
from typing import Sequence, Union

from alembic import op
import sqlalchemy as sa


# revision identifiers, used by Alembic.
revision: str = 'ad5a6de3a358'
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:
    """Upgrade schema."""
    # ### commands auto generated by Alembic - please adjust! ###
    op.create_table('alimentos_preparados',
    sa.Column('descripcion', sa.String(length=255), nullable=False),
    sa.Column('cantidad', sa.Float(), nullable=False),
    sa.Column('unidad', sa.String(length=50), nullable=False),
    sa.Column('equipo', sa.String(length=100), nullable=False),
    sa.Column('fecha', sa.Date(), nullable=False),
    sa.Column('id', sa.Integer(), autoincrement=True, nullable=False),
    sa.Column('sync_id', sa.String(length=36), nullable=False),
    sa.Column('is_deleted', sa.Boolean(), nullable=True),
    sa.Column('created_at', sa.DateTime(), nullable=True),
    sa.Column('updated_at', sa.DateTime(), nullable=True),
    sa.Column('last_sync', sa.DateTime(), nullable=True),
    sa.PrimaryKeyConstraint('id', name=op.f('pk_alimentos_preparados'))
    )
    with op.batch_alter_table('alimentos_preparados', schema=None) as batch_op:
        batch_op.create_index(batch_op.f('ix_alimentos_preparados_id'), ['id'], unique=False)
        batch_op.create_index(batch_op.f('ix_alimentos_preparados_sync_id'), ['sync_id'], unique=True)

    op.create_table('areas',
    sa.Column('area', sa.String(length=100), nullable=False),
    sa.Column('id', sa.Integer(), autoincrement=True, nullable=False),
    sa.Column('sync_id', sa.String(length=36), nullable=False),
    sa.Column('is_deleted', sa.Boolean(), nullable=True),
    sa.Column('created_at', sa.DateTime(), nullable=True),
    sa.Column('updated_at', sa.DateTime(), nullable=True),
    sa.Column('last_sync', sa.DateTime(), nullable=True),
    sa.PrimaryKeyConstraint('id', name=op.f('pk_areas')),
    sa.UniqueConstraint('area', name=op.f('uq_areas_area'))
    )
    with op.batch_alter_table('areas', schema=None) as batch_op:
        batch_op.create_index(batch_op.f('ix_areas_id'), ['id'], unique=False)
        batch_op.create_index(batch_op.f('ix_areas_sync_id'), ['sync_id'], unique=True)

    op.create_table('donaciones',
    sa.Column('descripcion', sa.String(length=255), nullable=False),
    sa.Column('cantidad', sa.Float(), nullable=False),
    sa.Column('unidad', sa.String(length=50), nullable=False),
    sa.Column('equipo', sa.String(length=100), nullable=True),
    sa.Column('fecha', sa.Date(), nullable=False),
    sa.Column('id', sa.Integer(), autoincrement=True, nullable=False),
    sa.Column('sync_id', sa.String(length=36), nullable=False),
    sa.Column('is_deleted', sa.Boolean(), nullable=True),
    sa.Column('created_at', sa.DateTime(), nullable=True),
    sa.Column('updated_at', sa.DateTime(), nullable=True),
    sa.Column('last_sync', sa.DateTime(), nullable=True),
    sa.PrimaryKeyConstraint('id', name=op.f('pk_donaciones'))
    )
    with op.batch_alter_table('donaciones', schema=None) as batch_op:
        batch_op.create_index(batch_op.f('ix_donaciones_id'), ['id'], unique=False)
        batch_op.create_index(batch_op.f('ix_donaciones_sync_id'), ['sync_id'], unique=True)

    op.create_table('ensenanzas',
    sa.Column('capitan', sa.String(), nullable=True),
    sa.Column('subcapitan', sa.Integer(), nullable=True),
    sa.Column('fecha', sa.Date(), nullable=True),
    sa.Column('id', sa.Integer(), autoincrement=True, nullable=False),
    sa.Column('sync_id', sa.String(length=36), nullable=False),
    sa.Column('is_deleted', sa.Boolean(), nullable=True),
    sa.Column('created_at', sa.DateTime(), nullable=True),
    sa.Column('updated_at', sa.DateTime(), nullable=True),
    sa.Column('last_sync', sa.DateTime(), nullable=True),
    sa.PrimaryKeyConstraint('id', name=op.f('pk_ensenanzas'))
    )
    with op.batch_alter_table('ensenanzas', schema=None) as batch_op:
        batch_op.create_index(batch_op.f('ix_ensenanzas_id'), ['id'], unique=False)
        batch_op.create_index(batch_op.f('ix_ensenanzas_sync_id'), ['sync_id'], unique=True)

    op.create_table('otrasareas',
    sa.Column('alabanza', sa.Integer(), nullable=True),
    sa.Column('protocolo', sa.Integer(), nullable=True),
    sa.Column('semillitas', sa.Integer(), nullable=True),
    sa.Column('sonido', sa.Integer(), nullable=True),
    sa.Column('teatro', sa.Integer(), nullable=True),
    sa.Column('tv', sa.Integer(), nullable=True),
    sa.Column('ujier', sa.Integer(), nullable=True),
    sa.Column('seguridad', sa.Integer(), nullable=True),
    sa.Column('fecha', sa.Date(), nullable=True),
    sa.Column('id', sa.Integer(), autoincrement=True, nullable=False),
    sa.Column('sync_id', sa.String(length=36), nullable=False),
    sa.Column('is_deleted', sa.Boolean(), nullable=True),
    sa.Column('created_at', sa.DateTime(), nullable=True),
    sa.Column('updated_at', sa.DateTime(), nullable=True),
    sa.Column('last_sync', sa.DateTime(), nullable=True),
    sa.PrimaryKeyConstraint('id', name=op.f('pk_otrasareas'))
    )
    with op.batch_alter_table('otrasareas', schema=None) as batch_op:
        batch_op.create_index(batch_op.f('ix_otrasareas_id'), ['id'], unique=False)
        batch_op.create_index(batch_op.f('ix_otrasareas_sync_id'), ['sync_id'], unique=True)

    op.create_table('pastores',
    sa.Column('nombre', sa.String(length=100), nullable=False),
    sa.Column('iglesia', sa.String(length=100), nullable=False),
    sa.Column('id', sa.Integer(), autoincrement=True, nullable=False),
    sa.Column('sync_id', sa.String(length=36), nullable=False),
    sa.Column('is_deleted', sa.Boolean(), nullable=True),
    sa.Column('created_at', sa.DateTime(), nullable=True),
    sa.Column('updated_at', sa.DateTime(), nullable=True),
    sa.Column('last_sync', sa.DateTime(), nullable=True),
    sa.PrimaryKeyConstraint('id', name=op.f('pk_pastores'))
    )
    with op.batch_alter_table('pastores', schema=None) as batch_op:
        batch_op.create_index(batch_op.f('ix_pastores_id'), ['id'], unique=False)
        batch_op.create_index(batch_op.f('ix_pastores_sync_id'), ['sync_id'], unique=True)

    op.create_table('permissions',
    sa.Column('codigo', sa.String(length=100), nullable=False),
    sa.Column('descripcion', sa.String(length=255), nullable=True),
    sa.Column('id', sa.Integer(), autoincrement=True, nullable=False),
    sa.Column('sync_id', sa.String(length=36), nullable=False),
    sa.Column('is_deleted', sa.Boolean(), nullable=True),
    sa.Column('created_at', sa.DateTime(), nullable=True),
    sa.Column('updated_at', sa.DateTime(), nullable=True),
    sa.Column('last_sync', sa.DateTime(), nullable=True),
    sa.PrimaryKeyConstraint('id', name=op.f('pk_permissions'))
    )
    with op.batch_alter_table('permissions', schema=None) as batch_op:
        batch_op.create_index(batch_op.f('ix_permissions_codigo'), ['codigo'], unique=True)
        batch_op.create_index(batch_op.f('ix_permissions_id'), ['id'], unique=False)
        batch_op.create_index(batch_op.f('ix_permissions_sync_id'), ['sync_id'], unique=True)

    op.create_table('recepciones',
    sa.Column('nombre', sa.String(), nullable=True),
    sa.Column('fecha', sa.Date(), nullable=True),
    sa.Column('id', sa.Integer(), autoincrement=True, nullable=False),
    sa.Column('sync_id', sa.String(length=36), nullable=False),
    sa.Column('is_deleted', sa.Boolean(), nullable=True),
    sa.Column('created_at', sa.DateTime(), nullable=True),
    sa.Column('updated_at', sa.DateTime(), nullable=True),
    sa.Column('last_sync', sa.DateTime(), nullable=True),
    sa.PrimaryKeyConstraint('id', name=op.f('pk_recepciones'))
    )
    with op.batch_alter_table('recepciones', schema=None) as batch_op:
        batch_op.create_index(batch_op.f('ix_recepciones_id'), ['id'], unique=False)
        batch_op.create_index(batch_op.f('ix_recepciones_sync_id'), ['sync_id'], unique=True)

    op.create_table('roles',
    sa.Column('nombre', sa.String(length=50), nullable=False),
    sa.Column('descripcion', sa.String(length=255), nullable=True),
    sa.Column('id', sa.Integer(), autoincrement=True, nullable=False),
    sa.Column('sync_id', sa.String(length=36), nullable=False),
    sa.Column('is_deleted', sa.Boolean(), nullable=True),
    sa.Column('created_at', sa.DateTime(), nullable=True),
    sa.Column('updated_at', sa.DateTime(), nullable=True),
    sa.Column('last_sync', sa.DateTime(), nullable=True),
    sa.PrimaryKeyConstraint('id', name=op.f('pk_roles'))
    )
    with op.batch_alter_table('roles', schema=None) as batch_op:
        batch_op.create_index(batch_op.f('ix_roles_id'), ['id'], unique=False)
        batch_op.create_index(batch_op.f('ix_roles_nombre'), ['nombre'], unique=True)
        batch_op.create_index(batch_op.f('ix_roles_sync_id'), ['sync_id'], unique=True)

    op.create_table('sync_queue',
    sa.Column('entity_name', sa.String(length=80), nullable=False),
    sa.Column('entity_sync_id', sa.String(length=36), nullable=False),
    sa.Column('operation', sa.String(length=20), nullable=False),
    sa.Column('payload_json', sa.Text(), nullable=False),
    sa.Column('status', sa.String(length=20), nullable=False),
    sa.Column('attempts', sa.Integer(), nullable=False),
    sa.Column('last_error', sa.Text(), nullable=True),
    sa.Column('processed_at', sa.DateTime(), nullable=True),
    sa.Column('id', sa.Integer(), autoincrement=True, nullable=False),
    sa.Column('sync_id', sa.String(length=36), nullable=False),
    sa.Column('is_deleted', sa.Boolean(), nullable=True),
    sa.Column('created_at', sa.DateTime(), nullable=True),
    sa.Column('updated_at', sa.DateTime(), nullable=True),
    sa.Column('last_sync', sa.DateTime(), nullable=True),
    sa.PrimaryKeyConstraint('id', name=op.f('pk_sync_queue'))
    )
    with op.batch_alter_table('sync_queue', schema=None) as batch_op:
        batch_op.create_index(batch_op.f('ix_sync_queue_entity_name'), ['entity_name'], unique=False)
        batch_op.create_index(batch_op.f('ix_sync_queue_entity_sync_id'), ['entity_sync_id'], unique=False)
        batch_op.create_index(batch_op.f('ix_sync_queue_id'), ['id'], unique=False)
        batch_op.create_index(batch_op.f('ix_sync_queue_sync_id'), ['sync_id'], unique=True)

    op.create_table('alimentos_preparados_componentes',
    sa.Column('alimento_preparado_id', sa.Integer(), nullable=False),
    sa.Column('donacion_materia_id', sa.Integer(), nullable=False),
    sa.Column('cantidad_usada', sa.Float(), nullable=False),
    sa.Column('id', sa.Integer(), autoincrement=True, nullable=False),
    sa.Column('sync_id', sa.String(length=36), nullable=False),
    sa.Column('is_deleted', sa.Boolean(), nullable=True),
    sa.Column('created_at', sa.DateTime(), nullable=True),
    sa.Column('updated_at', sa.DateTime(), nullable=True),
    sa.Column('last_sync', sa.DateTime(), nullable=True),
    sa.ForeignKeyConstraint(['alimento_preparado_id'], ['alimentos_preparados.id'], name=op.f('fk_alimentos_preparados_componentes_alimento_preparado_id_alimentos_preparados')),
    sa.ForeignKeyConstraint(['donacion_materia_id'], ['donaciones.id'], name=op.f('fk_alimentos_preparados_componentes_donacion_materia_id_donaciones')),
    sa.PrimaryKeyConstraint('id', name=op.f('pk_alimentos_preparados_componentes'))
    )
    with op.batch_alter_table('alimentos_preparados_componentes', schema=None) as batch_op:
        batch_op.create_index(batch_op.f('ix_alimentos_preparados_componentes_id'), ['id'], unique=False)
        batch_op.create_index(batch_op.f('ix_alimentos_preparados_componentes_sync_id'), ['sync_id'], unique=True)

    op.create_table('lideres',
    sa.Column('nombre', sa.String(length=100), nullable=False),
    sa.Column('edad', sa.Integer(), nullable=False),
    sa.Column('fecha_nacimiento', sa.Date(), nullable=True),
    sa.Column('cedula', sa.Integer(), nullable=False),
    sa.Column('celular', sa.String(length=20), nullable=True),
    sa.Column('correo', sa.String(length=100), nullable=True),
    sa.Column('id_pastor', sa.Integer(), nullable=True),
    sa.Column('id', sa.Integer(), autoincrement=True, nullable=False),
    sa.Column('sync_id', sa.String(length=36), nullable=False),
    sa.Column('is_deleted', sa.Boolean(), nullable=True),
    sa.Column('created_at', sa.DateTime(), nullable=True),
    sa.Column('updated_at', sa.DateTime(), nullable=True),
    sa.Column('last_sync', sa.DateTime(), nullable=True),
    sa.ForeignKeyConstraint(['id_pastor'], ['pastores.id'], name=op.f('fk_lideres_id_pastor_pastores')),
    sa.PrimaryKeyConstraint('id', name=op.f('pk_lideres')),
    sa.UniqueConstraint('cedula', name=op.f('uq_lideres_cedula')),
    sa.UniqueConstraint('correo', name=op.f('uq_lideres_correo'))
    )
    with op.batch_alter_table('lideres', schema=None) as batch_op:
        batch_op.create_index(batch_op.f('ix_lideres_id'), ['id'], unique=False)
        batch_op.create_index(batch_op.f('ix_lideres_sync_id'), ['sync_id'], unique=True)

    op.create_table('role_permissions',
    sa.Column('role_id', sa.Integer(), nullable=False),
    sa.Column('permission_id', sa.Integer(), nullable=False),
    sa.ForeignKeyConstraint(['permission_id'], ['permissions.id'], name=op.f('fk_role_permissions_permission_id_permissions'), ondelete='CASCADE'),
    sa.ForeignKeyConstraint(['role_id'], ['roles.id'], name=op.f('fk_role_permissions_role_id_roles'), ondelete='CASCADE'),
    sa.PrimaryKeyConstraint('role_id', 'permission_id', name=op.f('pk_role_permissions'))
    )
    op.create_table('salones',
    sa.Column('salon', sa.String(), nullable=False),
    sa.Column('edad', sa.String(), nullable=False),
    sa.Column('id_area', sa.Integer(), nullable=True),
    sa.Column('id', sa.Integer(), autoincrement=True, nullable=False),
    sa.Column('sync_id', sa.String(length=36), nullable=False),
    sa.Column('is_deleted', sa.Boolean(), nullable=True),
    sa.Column('created_at', sa.DateTime(), nullable=True),
    sa.Column('updated_at', sa.DateTime(), nullable=True),
    sa.Column('last_sync', sa.DateTime(), nullable=True),
    sa.ForeignKeyConstraint(['id_area'], ['areas.id'], name=op.f('fk_salones_id_area_areas')),
    sa.PrimaryKeyConstraint('id', name=op.f('pk_salones')),
    sa.UniqueConstraint('salon', name=op.f('uq_salones_salon'))
    )
    with op.batch_alter_table('salones', schema=None) as batch_op:
        batch_op.create_index(batch_op.f('ix_salones_id'), ['id'], unique=False)
        batch_op.create_index(batch_op.f('ix_salones_sync_id'), ['sync_id'], unique=True)

    op.create_table('usuarios',
    sa.Column('username', sa.String(length=60), nullable=False),
    sa.Column('password', sa.String(length=255), nullable=False),
    sa.Column('activo', sa.Boolean(), nullable=False),
    sa.Column('reset_token', sa.String(length=100), nullable=True),
    sa.Column('reset_token_expiry', sa.DateTime(), nullable=True),
    sa.Column('rol_id', sa.Integer(), nullable=False),
    sa.Column('id', sa.Integer(), autoincrement=True, nullable=False),
    sa.Column('sync_id', sa.String(length=36), nullable=False),
    sa.Column('is_deleted', sa.Boolean(), nullable=True),
    sa.Column('created_at', sa.DateTime(), nullable=True),
    sa.Column('updated_at', sa.DateTime(), nullable=True),
    sa.Column('last_sync', sa.DateTime(), nullable=True),
    sa.ForeignKeyConstraint(['rol_id'], ['roles.id'], name=op.f('fk_usuarios_rol_id_roles')),
    sa.PrimaryKeyConstraint('id', name=op.f('pk_usuarios'))
    )
    with op.batch_alter_table('usuarios', schema=None) as batch_op:
        batch_op.create_index(batch_op.f('ix_usuarios_id'), ['id'], unique=False)
        batch_op.create_index(batch_op.f('ix_usuarios_reset_token'), ['reset_token'], unique=False)
        batch_op.create_index(batch_op.f('ix_usuarios_rol_id'), ['rol_id'], unique=False)
        batch_op.create_index(batch_op.f('ix_usuarios_sync_id'), ['sync_id'], unique=True)
        batch_op.create_index(batch_op.f('ix_usuarios_username'), ['username'], unique=True)

    op.create_table('coordinadores',
    sa.Column('nombre', sa.String(length=100), nullable=False),
    sa.Column('edad', sa.Integer(), nullable=False),
    sa.Column('fecha_nacimiento', sa.Date(), nullable=True),
    sa.Column('cedula', sa.Integer(), nullable=False),
    sa.Column('celular', sa.String(length=20), nullable=True),
    sa.Column('correo', sa.String(length=100), nullable=True),
    sa.Column('id_lider', sa.Integer(), nullable=True),
    sa.Column('id_area', sa.Integer(), nullable=True),
    sa.Column('id', sa.Integer(), autoincrement=True, nullable=False),
    sa.Column('sync_id', sa.String(length=36), nullable=False),
    sa.Column('is_deleted', sa.Boolean(), nullable=True),
    sa.Column('created_at', sa.DateTime(), nullable=True),
    sa.Column('updated_at', sa.DateTime(), nullable=True),
    sa.Column('last_sync', sa.DateTime(), nullable=True),
    sa.ForeignKeyConstraint(['id_area'], ['areas.id'], name=op.f('fk_coordinadores_id_area_areas')),
    sa.ForeignKeyConstraint(['id_lider'], ['lideres.id'], name=op.f('fk_coordinadores_id_lider_lideres')),
    sa.PrimaryKeyConstraint('id', name=op.f('pk_coordinadores')),
    sa.UniqueConstraint('cedula', name=op.f('uq_coordinadores_cedula')),
    sa.UniqueConstraint('correo', name=op.f('uq_coordinadores_correo'))
    )
    with op.batch_alter_table('coordinadores', schema=None) as batch_op:
        batch_op.create_index(batch_op.f('ix_coordinadores_id'), ['id'], unique=False)
        batch_op.create_index(batch_op.f('ix_coordinadores_sync_id'), ['sync_id'], unique=True)

    op.create_table('distribuciones',
    sa.Column('donacion_id', sa.Integer(), nullable=True),
    sa.Column('alimento_preparado_id', sa.Integer(), nullable=True),
    sa.Column('salon_id', sa.Integer(), nullable=True),
    sa.Column('area_id', sa.Integer(), nullable=True),
    sa.Column('recepcion_id', sa.Integer(), nullable=True),
    sa.Column('cantidad', sa.Float(), nullable=False),
    sa.Column('unidad', sa.String(length=50), nullable=False),
    sa.Column('fecha', sa.Date(), nullable=False),
    sa.Column('id', sa.Integer(), autoincrement=True, nullable=False),
    sa.Column('sync_id', sa.String(length=36), nullable=False),
    sa.Column('is_deleted', sa.Boolean(), nullable=True),
    sa.Column('created_at', sa.DateTime(), nullable=True),
    sa.Column('updated_at', sa.DateTime(), nullable=True),
    sa.Column('last_sync', sa.DateTime(), nullable=True),
    sa.ForeignKeyConstraint(['alimento_preparado_id'], ['alimentos_preparados.id'], name=op.f('fk_distribuciones_alimento_preparado_id_alimentos_preparados')),
    sa.ForeignKeyConstraint(['area_id'], ['areas.id'], name=op.f('fk_distribuciones_area_id_areas')),
    sa.ForeignKeyConstraint(['donacion_id'], ['donaciones.id'], name=op.f('fk_distribuciones_donacion_id_donaciones')),
    sa.ForeignKeyConstraint(['recepcion_id'], ['recepciones.id'], name=op.f('fk_distribuciones_recepcion_id_recepciones')),
    sa.ForeignKeyConstraint(['salon_id'], ['salones.id'], name=op.f('fk_distribuciones_salon_id_salones')),
    sa.PrimaryKeyConstraint('id', name=op.f('pk_distribuciones'))
    )
    with op.batch_alter_table('distribuciones', schema=None) as batch_op:
        batch_op.create_index(batch_op.f('ix_distribuciones_id'), ['id'], unique=False)
        batch_op.create_index(batch_op.f('ix_distribuciones_sync_id'), ['sync_id'], unique=True)

    op.create_table('capitanes',
    sa.Column('nombre', sa.String(length=100), nullable=False),
    sa.Column('edad', sa.Integer(), nullable=False),
    sa.Column('fecha_nacimiento', sa.Date(), nullable=True),
    sa.Column('cedula', sa.Integer(), nullable=False),
    sa.Column('celular', sa.String(length=20), nullable=True),
    sa.Column('correo', sa.String(length=100), nullable=True),
    sa.Column('id_coordinador', sa.Integer(), nullable=True),
    sa.Column('id', sa.Integer(), autoincrement=True, nullable=False),
    sa.Column('sync_id', sa.String(length=36), nullable=False),
    sa.Column('is_deleted', sa.Boolean(), nullable=True),
    sa.Column('created_at', sa.DateTime(), nullable=True),
    sa.Column('updated_at', sa.DateTime(), nullable=True),
    sa.Column('last_sync', sa.DateTime(), nullable=True),
    sa.ForeignKeyConstraint(['id_coordinador'], ['coordinadores.id'], name=op.f('fk_capitanes_id_coordinador_coordinadores')),
    sa.PrimaryKeyConstraint('id', name=op.f('pk_capitanes')),
    sa.UniqueConstraint('cedula', name=op.f('uq_capitanes_cedula')),
    sa.UniqueConstraint('correo', name=op.f('uq_capitanes_correo'))
    )
    with op.batch_alter_table('capitanes', schema=None) as batch_op:
        batch_op.create_index(batch_op.f('ix_capitanes_id'), ['id'], unique=False)
        batch_op.create_index(batch_op.f('ix_capitanes_sync_id'), ['sync_id'], unique=True)

    op.create_table('auxiliares',
    sa.Column('nombre', sa.String(length=100), nullable=False),
    sa.Column('edad', sa.Integer(), nullable=False),
    sa.Column('fecha_nacimiento', sa.Date(), nullable=True),
    sa.Column('cedula', sa.Integer(), nullable=False),
    sa.Column('celular', sa.String(length=20), nullable=True),
    sa.Column('correo', sa.String(length=100), nullable=True),
    sa.Column('numero_equipo', sa.Integer(), nullable=True),
    sa.Column('id_area', sa.Integer(), nullable=True),
    sa.Column('id_capitan', sa.Integer(), nullable=True),
    sa.Column('id', sa.Integer(), autoincrement=True, nullable=False),
    sa.Column('sync_id', sa.String(length=36), nullable=False),
    sa.Column('is_deleted', sa.Boolean(), nullable=True),
    sa.Column('created_at', sa.DateTime(), nullable=True),
    sa.Column('updated_at', sa.DateTime(), nullable=True),
    sa.Column('last_sync', sa.DateTime(), nullable=True),
    sa.ForeignKeyConstraint(['id_area'], ['areas.id'], name=op.f('fk_auxiliares_id_area_areas')),
    sa.ForeignKeyConstraint(['id_capitan'], ['capitanes.id'], name=op.f('fk_auxiliares_id_capitan_capitanes')),
    sa.PrimaryKeyConstraint('id', name=op.f('pk_auxiliares')),
    sa.UniqueConstraint('cedula', name=op.f('uq_auxiliares_cedula')),
    sa.UniqueConstraint('correo', name=op.f('uq_auxiliares_correo'))
    )
    with op.batch_alter_table('auxiliares', schema=None) as batch_op:
        batch_op.create_index(batch_op.f('ix_auxiliares_id'), ['id'], unique=False)
        batch_op.create_index(batch_op.f('ix_auxiliares_sync_id'), ['sync_id'], unique=True)

    op.create_table('colaboradores',
    sa.Column('nombre', sa.String(length=100), nullable=False),
    sa.Column('edad', sa.Integer(), nullable=False),
    sa.Column('fecha_nacimiento', sa.Date(), nullable=True),
    sa.Column('cedula', sa.Integer(), nullable=False),
    sa.Column('celular', sa.String(length=20), nullable=True),
    sa.Column('correo', sa.String(length=100), nullable=True),
    sa.Column('numero_equipo', sa.Integer(), nullable=True),
    sa.Column('id_area', sa.Integer(), nullable=True),
    sa.Column('id_capitan', sa.Integer(), nullable=True),
    sa.Column('id', sa.Integer(), autoincrement=True, nullable=False),
    sa.Column('sync_id', sa.String(length=36), nullable=False),
    sa.Column('is_deleted', sa.Boolean(), nullable=True),
    sa.Column('created_at', sa.DateTime(), nullable=True),
    sa.Column('updated_at', sa.DateTime(), nullable=True),
    sa.Column('last_sync', sa.DateTime(), nullable=True),
    sa.ForeignKeyConstraint(['id_area'], ['areas.id'], name=op.f('fk_colaboradores_id_area_areas')),
    sa.ForeignKeyConstraint(['id_capitan'], ['capitanes.id'], name=op.f('fk_colaboradores_id_capitan_capitanes')),
    sa.PrimaryKeyConstraint('id', name=op.f('pk_colaboradores')),
    sa.UniqueConstraint('cedula', name=op.f('uq_colaboradores_cedula')),
    sa.UniqueConstraint('correo', name=op.f('uq_colaboradores_correo'))
    )
    with op.batch_alter_table('colaboradores', schema=None) as batch_op:
        batch_op.create_index(batch_op.f('ix_colaboradores_id'), ['id'], unique=False)
        batch_op.create_index(batch_op.f('ix_colaboradores_sync_id'), ['sync_id'], unique=True)

    op.create_table('docentes',
    sa.Column('nombre', sa.String(length=100), nullable=False),
    sa.Column('edad', sa.Integer(), nullable=False),
    sa.Column('fecha_nacimiento', sa.Date(), nullable=True),
    sa.Column('cedula', sa.Integer(), nullable=False),
    sa.Column('celular', sa.String(length=20), nullable=True),
    sa.Column('correo', sa.String(length=100), nullable=True),
    sa.Column('numero_equipo', sa.Integer(), nullable=True),
    sa.Column('id_area', sa.Integer(), nullable=True),
    sa.Column('id_capitan', sa.Integer(), nullable=True),
    sa.Column('id', sa.Integer(), autoincrement=True, nullable=False),
    sa.Column('sync_id', sa.String(length=36), nullable=False),
    sa.Column('is_deleted', sa.Boolean(), nullable=True),
    sa.Column('created_at', sa.DateTime(), nullable=True),
    sa.Column('updated_at', sa.DateTime(), nullable=True),
    sa.Column('last_sync', sa.DateTime(), nullable=True),
    sa.ForeignKeyConstraint(['id_area'], ['areas.id'], name=op.f('fk_docentes_id_area_areas')),
    sa.ForeignKeyConstraint(['id_capitan'], ['capitanes.id'], name=op.f('fk_docentes_id_capitan_capitanes')),
    sa.PrimaryKeyConstraint('id', name=op.f('pk_docentes')),
    sa.UniqueConstraint('cedula', name=op.f('uq_docentes_cedula')),
    sa.UniqueConstraint('correo', name=op.f('uq_docentes_correo'))
    )
    with op.batch_alter_table('docentes', schema=None) as batch_op:
        batch_op.create_index(batch_op.f('ix_docentes_id'), ['id'], unique=False)
        batch_op.create_index(batch_op.f('ix_docentes_sync_id'), ['sync_id'], unique=True)

    op.create_table('servidores',
    sa.Column('nombre', sa.String(length=100), nullable=False),
    sa.Column('edad', sa.Integer(), nullable=False),
    sa.Column('fecha_nacimiento', sa.Date(), nullable=True),
    sa.Column('cedula', sa.Integer(), nullable=False),
    sa.Column('celular', sa.String(length=20), nullable=True),
    sa.Column('correo', sa.String(length=100), nullable=True),
    sa.Column('numero_equipo', sa.Integer(), nullable=True),
    sa.Column('id_area', sa.Integer(), nullable=True),
    sa.Column('id_capitan', sa.Integer(), nullable=True),
    sa.Column('id', sa.Integer(), autoincrement=True, nullable=False),
    sa.Column('sync_id', sa.String(length=36), nullable=False),
    sa.Column('is_deleted', sa.Boolean(), nullable=True),
    sa.Column('created_at', sa.DateTime(), nullable=True),
    sa.Column('updated_at', sa.DateTime(), nullable=True),
    sa.Column('last_sync', sa.DateTime(), nullable=True),
    sa.ForeignKeyConstraint(['id_area'], ['areas.id'], name=op.f('fk_servidores_id_area_areas')),
    sa.ForeignKeyConstraint(['id_capitan'], ['capitanes.id'], name=op.f('fk_servidores_id_capitan_capitanes')),
    sa.PrimaryKeyConstraint('id', name=op.f('pk_servidores')),
    sa.UniqueConstraint('cedula', name=op.f('uq_servidores_cedula')),
    sa.UniqueConstraint('correo', name=op.f('uq_servidores_correo'))
    )
    with op.batch_alter_table('servidores', schema=None) as batch_op:
        batch_op.create_index(batch_op.f('ix_servidores_id'), ['id'], unique=False)
        batch_op.create_index(batch_op.f('ix_servidores_sync_id'), ['sync_id'], unique=True)

    op.create_table('asistencia_servidores',
    sa.Column('id_servidor', sa.Integer(), nullable=False),
    sa.Column('fecha', sa.Date(), nullable=False),
    sa.Column('rol', sa.String(length=50), nullable=False),
    sa.Column('categoria_contexto', sa.String(length=50), nullable=False),
    sa.Column('referencia_id', sa.Integer(), nullable=True),
    sa.Column('id', sa.Integer(), autoincrement=True, nullable=False),
    sa.Column('sync_id', sa.String(length=36), nullable=False),
    sa.Column('is_deleted', sa.Boolean(), nullable=True),
    sa.Column('created_at', sa.DateTime(), nullable=True),
    sa.Column('updated_at', sa.DateTime(), nullable=True),
    sa.Column('last_sync', sa.DateTime(), nullable=True),
    sa.ForeignKeyConstraint(['id_servidor'], ['servidores.id'], name=op.f('fk_asistencia_servidores_id_servidor_servidores')),
    sa.PrimaryKeyConstraint('id', name=op.f('pk_asistencia_servidores'))
    )
    with op.batch_alter_table('asistencia_servidores', schema=None) as batch_op:
        batch_op.create_index(batch_op.f('ix_asistencia_servidores_categoria_contexto'), ['categoria_contexto'], unique=False)
        batch_op.create_index(batch_op.f('ix_asistencia_servidores_fecha'), ['fecha'], unique=False)
        batch_op.create_index(batch_op.f('ix_asistencia_servidores_id'), ['id'], unique=False)
        batch_op.create_index(batch_op.f('ix_asistencia_servidores_sync_id'), ['sync_id'], unique=True)

    op.create_table('aulas',
    sa.Column('condicion', sa.String(), nullable=False),
    sa.Column('ninos', sa.Integer(), nullable=False),
    sa.Column('ninas', sa.Integer(), nullable=False),
    sa.Column('fecha', sa.Date(), nullable=False),
    sa.Column('id_salon', sa.Integer(), nullable=True),
    sa.Column('id_maestra', sa.Integer(), nullable=True),
    sa.Column('id_auxiliar', sa.Integer(), nullable=True),
    sa.Column('id', sa.Integer(), autoincrement=True, nullable=False),
    sa.Column('sync_id', sa.String(length=36), nullable=False),
    sa.Column('is_deleted', sa.Boolean(), nullable=True),
    sa.Column('created_at', sa.DateTime(), nullable=True),
    sa.Column('updated_at', sa.DateTime(), nullable=True),
    sa.Column('last_sync', sa.DateTime(), nullable=True),
    sa.ForeignKeyConstraint(['id_auxiliar'], ['auxiliares.id'], name=op.f('fk_aulas_id_auxiliar_auxiliares')),
    sa.ForeignKeyConstraint(['id_maestra'], ['docentes.id'], name=op.f('fk_aulas_id_maestra_docentes')),
    sa.ForeignKeyConstraint(['id_salon'], ['salones.id'], name=op.f('fk_aulas_id_salon_salones')),
    sa.PrimaryKeyConstraint('id', name=op.f('pk_aulas'))
    )
    with op.batch_alter_table('aulas', schema=None) as batch_op:
        batch_op.create_index(batch_op.f('ix_aulas_id'), ['id'], unique=False)
        batch_op.create_index(batch_op.f('ix_aulas_sync_id'), ['sync_id'], unique=True)

    op.create_table('logisticas',
    sa.Column('fecha', sa.Date(), nullable=False),
    sa.Column('id_capitan', sa.Integer(), nullable=True),
    sa.Column('observaciones', sa.Text(), nullable=True),
    sa.Column('almacen', sa.Integer(), nullable=True),
    sa.Column('distribucion', sa.Integer(), nullable=True),
    sa.Column('hidratacion', sa.Integer(), nullable=True),
    sa.Column('pasillo', sa.Integer(), nullable=True),
    sa.Column('secretaria', sa.Integer(), nullable=True),
    sa.Column('capitan', sa.Integer(), nullable=True),
    sa.Column('id', sa.Integer(), autoincrement=True, nullable=False),
    sa.Column('sync_id', sa.String(length=36), nullable=False),
    sa.Column('is_deleted', sa.Boolean(), nullable=True),
    sa.Column('created_at', sa.DateTime(), nullable=True),
    sa.Column('updated_at', sa.DateTime(), nullable=True),
    sa.Column('last_sync', sa.DateTime(), nullable=True),
    sa.ForeignKeyConstraint(['id_capitan'], ['servidores.id'], name=op.f('fk_logisticas_id_capitan_servidores')),
    sa.PrimaryKeyConstraint('id', name=op.f('pk_logisticas'))
    )
    with op.batch_alter_table('logisticas', schema=None) as batch_op:
        batch_op.create_index(batch_op.f('ix_logisticas_fecha'), ['fecha'], unique=False)
        batch_op.create_index(batch_op.f('ix_logisticas_id'), ['id'], unique=False)
        batch_op.create_index(batch_op.f('ix_logisticas_sync_id'), ['sync_id'], unique=True)

    # ### end Alembic commands ###


def downgrade() -> None:
    """Downgrade schema."""
    # ### commands auto generated by Alembic - please adjust! ###
    with op.batch_alter_table('logisticas', schema=None) as batch_op:
        batch_op.drop_index(batch_op.f('ix_logisticas_sync_id'))
        batch_op.drop_index(batch_op.f('ix_logisticas_id'))
        batch_op.drop_index(batch_op.f('ix_logisticas_fecha'))

    op.drop_table('logisticas')
    with op.batch_alter_table('aulas', schema=None) as batch_op:
        batch_op.drop_index(batch_op.f('ix_aulas_sync_id'))
        batch_op.drop_index(batch_op.f('ix_aulas_id'))

    op.drop_table('aulas')
    with op.batch_alter_table('asistencia_servidores', schema=None) as batch_op:
        batch_op.drop_index(batch_op.f('ix_asistencia_servidores_sync_id'))
        batch_op.drop_index(batch_op.f('ix_asistencia_servidores_id'))
        batch_op.drop_index(batch_op.f('ix_asistencia_servidores_fecha'))
        batch_op.drop_index(batch_op.f('ix_asistencia_servidores_categoria_contexto'))

    op.drop_table('asistencia_servidores')
    with op.batch_alter_table('servidores', schema=None) as batch_op:
        batch_op.drop_index(batch_op.f('ix_servidores_sync_id'))
        batch_op.drop_index(batch_op.f('ix_servidores_id'))

    op.drop_table('servidores')
    with op.batch_alter_table('docentes', schema=None) as batch_op:
        batch_op.drop_index(batch_op.f('ix_docentes_sync_id'))
        batch_op.drop_index(batch_op.f('ix_docentes_id'))

    op.drop_table('docentes')
    with op.batch_alter_table('colaboradores', schema=None) as batch_op:
        batch_op.drop_index(batch_op.f('ix_colaboradores_sync_id'))
        batch_op.drop_index(batch_op.f('ix_colaboradores_id'))

    op.drop_table('colaboradores')
    with op.batch_alter_table('auxiliares', schema=None) as batch_op:
        batch_op.drop_index(batch_op.f('ix_auxiliares_sync_id'))
        batch_op.drop_index(batch_op.f('ix_auxiliares_id'))

    op.drop_table('auxiliares')
    with op.batch_alter_table('capitanes', schema=None) as batch_op:
        batch_op.drop_index(batch_op.f('ix_capitanes_sync_id'))
        batch_op.drop_index(batch_op.f('ix_capitanes_id'))

    op.drop_table('capitanes')
    with op.batch_alter_table('distribuciones', schema=None) as batch_op:
        batch_op.drop_index(batch_op.f('ix_distribuciones_sync_id'))
        batch_op.drop_index(batch_op.f('ix_distribuciones_id'))

    op.drop_table('distribuciones')
    with op.batch_alter_table('coordinadores', schema=None) as batch_op:
        batch_op.drop_index(batch_op.f('ix_coordinadores_sync_id'))
        batch_op.drop_index(batch_op.f('ix_coordinadores_id'))

    op.drop_table('coordinadores')
    with op.batch_alter_table('usuarios', schema=None) as batch_op:
        batch_op.drop_index(batch_op.f('ix_usuarios_username'))
        batch_op.drop_index(batch_op.f('ix_usuarios_sync_id'))
        batch_op.drop_index(batch_op.f('ix_usuarios_rol_id'))
        batch_op.drop_index(batch_op.f('ix_usuarios_reset_token'))
        batch_op.drop_index(batch_op.f('ix_usuarios_id'))

    op.drop_table('usuarios')
    with op.batch_alter_table('salones', schema=None) as batch_op:
        batch_op.drop_index(batch_op.f('ix_salones_sync_id'))
        batch_op.drop_index(batch_op.f('ix_salones_id'))

    op.drop_table('salones')
    op.drop_table('role_permissions')
    with op.batch_alter_table('lideres', schema=None) as batch_op:
        batch_op.drop_index(batch_op.f('ix_lideres_sync_id'))
        batch_op.drop_index(batch_op.f('ix_lideres_id'))

    op.drop_table('lideres')
    with op.batch_alter_table('alimentos_preparados_componentes', schema=None) as batch_op:
        batch_op.drop_index(batch_op.f('ix_alimentos_preparados_componentes_sync_id'))
        batch_op.drop_index(batch_op.f('ix_alimentos_preparados_componentes_id'))

    op.drop_table('alimentos_preparados_componentes')
    with op.batch_alter_table('sync_queue', schema=None) as batch_op:
        batch_op.drop_index(batch_op.f('ix_sync_queue_sync_id'))
        batch_op.drop_index(batch_op.f('ix_sync_queue_id'))
        batch_op.drop_index(batch_op.f('ix_sync_queue_entity_sync_id'))
        batch_op.drop_index(batch_op.f('ix_sync_queue_entity_name'))

    op.drop_table('sync_queue')
    with op.batch_alter_table('roles', schema=None) as batch_op:
        batch_op.drop_index(batch_op.f('ix_roles_sync_id'))
        batch_op.drop_index(batch_op.f('ix_roles_nombre'))
        batch_op.drop_index(batch_op.f('ix_roles_id'))

    op.drop_table('roles')
    with op.batch_alter_table('recepciones', schema=None) as batch_op:
        batch_op.drop_index(batch_op.f('ix_recepciones_sync_id'))
        batch_op.drop_index(batch_op.f('ix_recepciones_id'))

    op.drop_table('recepciones')
    with op.batch_alter_table('permissions', schema=None) as batch_op:
        batch_op.drop_index(batch_op.f('ix_permissions_sync_id'))
        batch_op.drop_index(batch_op.f('ix_permissions_id'))
        batch_op.drop_index(batch_op.f('ix_permissions_codigo'))

    op.drop_table('permissions')
    with op.batch_alter_table('pastores', schema=None) as batch_op:
        batch_op.drop_index(batch_op.f('ix_pastores_sync_id'))
        batch_op.drop_index(batch_op.f('ix_pastores_id'))

    op.drop_table('pastores')
    with op.batch_alter_table('otrasareas', schema=None) as batch_op:
        batch_op.drop_index(batch_op.f('ix_otrasareas_sync_id'))
        batch_op.drop_index(batch_op.f('ix_otrasareas_id'))

    op.drop_table('otrasareas')
    with op.batch_alter_table('ensenanzas', schema=None) as batch_op:
        batch_op.drop_index(batch_op.f('ix_ensenanzas_sync_id'))
        batch_op.drop_index(batch_op.f('ix_ensenanzas_id'))

    op.drop_table('ensenanzas')
    with op.batch_alter_table('donaciones', schema=None) as batch_op:
        batch_op.drop_index(batch_op.f('ix_donaciones_sync_id'))
        batch_op.drop_index(batch_op.f('ix_donaciones_id'))

    op.drop_table('donaciones')
    with op.batch_alter_table('areas', schema=None) as batch_op:
        batch_op.drop_index(batch_op.f('ix_areas_sync_id'))
        batch_op.drop_index(batch_op.f('ix_areas_id'))

    op.drop_table('areas')
    with op.batch_alter_table('alimentos_preparados', schema=None) as batch_op:
        batch_op.drop_index(batch_op.f('ix_alimentos_preparados_sync_id'))
        batch_op.drop_index(batch_op.f('ix_alimentos_preparados_id'))

    op.drop_table('alimentos_preparados')
    # ### end Alembic commands ###
