Refactor database models to use server defaults for boolean and timestamp fields
- Updated `TimestampMixin` to use `server_default` for `created_at` and `updated_at` fields. - Modified various models in the `fa_classes`, `doc_types_dig`, `ports`, `units_of_measure`, `invoices`, `parts`, `trailers`, `licenses`, `tenants`, and `user_tenant` modules to set `server_default` for boolean fields and other relevant fields. - Adjusted the `trailer_types` model to change the schema from `a76` to `public`. - Implemented database migration execution during application startup in `main.py`. - Removed old Alembic migration execution logic from the entrypoint script. - Updated seed data for units of measure and removed unused seed files.
This commit is contained in:
@@ -41,18 +41,18 @@ wait_for_tcp "${CORE_DB_HOST:-postgres-a76}" "${CORE_DB_PORT:-5432}" "PostgreSQL
|
||||
wait_for_tcp "keycloak" "8080" "Keycloak"
|
||||
|
||||
# Ejecutar migraciones de Alembic
|
||||
if [ -d "/app/alembic" ]; then
|
||||
echo "Ejecutando migraciones de Alembic..."
|
||||
alembic upgrade head || {
|
||||
echo "⚠ WARNING: Error al ejecutar migraciones"
|
||||
echo " Verificando estado de la base de datos..."
|
||||
alembic current || echo " No se pudo determinar la versión actual"
|
||||
}
|
||||
echo "✓ Migraciones completadas"
|
||||
else
|
||||
echo "⚠ WARNING: Directorio /app/alembic no encontrado"
|
||||
echo " Las migraciones de base de datos no se ejecutaron"
|
||||
fi
|
||||
#if [ -d "/app/alembic" ]; then
|
||||
# echo "Ejecutando migraciones de Alembic..."
|
||||
# alembic upgrade head || {
|
||||
# echo "⚠ WARNING: Error al ejecutar migraciones"
|
||||
# echo " Verificando estado de la base de datos..."
|
||||
# alembic current || echo " No se pudo determinar la versión actual"
|
||||
# }
|
||||
# echo "✓ Migraciones completadas"
|
||||
#else
|
||||
# echo "⚠ WARNING: Directorio /app/alembic no encontrado"
|
||||
# echo " Las migraciones de base de datos no se ejecutaron"
|
||||
#fi
|
||||
|
||||
echo "=========================================="
|
||||
echo "Iniciando aplicación FastAPI..."
|
||||
|
||||
@@ -530,7 +530,7 @@ if [ $TENANT_QUERY_STATUS -ne 0 ]; then
|
||||
echo -e "${RED}✗ Error al consultar el tenant:${NC}"
|
||||
echo "$TENANT_ID_RESULT"
|
||||
echo -e "${YELLOW}Verificando si la tabla existe...${NC}"
|
||||
docker exec -e PGPASSWORD="${POSTGRES_PASSWORD}" anexo76-postgres-a76 psql -h localhost -p 5432 -U "${POSTGRES_USER}" -d "${POSTGRES_DB}" -c "\dt core.tenants;"
|
||||
exec_pg_sql "\dt core.tenants;"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
@@ -540,7 +540,7 @@ if [ -z "$TENANT_ID" ]; then
|
||||
echo -e "${RED}✗ Error: No se pudo obtener el ID del tenant${NC}"
|
||||
echo "Resultado de la consulta: '$TENANT_ID_RESULT'"
|
||||
echo -e "${YELLOW}Intentando ver todos los tenants...${NC}"
|
||||
docker exec -e PGPASSWORD="${POSTGRES_PASSWORD}" anexo76-postgres-a76 psql -h localhost -p 5432 -U "${POSTGRES_USER}" -d "${POSTGRES_DB}" -c "SELECT id, slug FROM core.tenants LIMIT 10;"
|
||||
exec_pg_sql "SELECT id, slug FROM core.tenants LIMIT 10;"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
|
||||
Reference in New Issue
Block a user