From 0265477f463dd9ba5f488f8e47640e4110e80970 Mon Sep 17 00:00:00 2001 From: kianiadee Date: Wed, 27 May 2026 14:36:45 +0300 Subject: [PATCH] fix: fn_vehicle_trips takes bigint (domain.vehicles.vehicle_id is bigserial) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit PG function overloading is type-strict: integer→bigint isn't implicit. The prior signature (integer, date) didn't match callers passing vehicle_id directly. Also prepends a DROP for the integer-signature in case the previous migration ran and left a now-orphan function around. --- db/migrations/20260601000019_fn_vehicle_trips.sql | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/db/migrations/20260601000019_fn_vehicle_trips.sql b/db/migrations/20260601000019_fn_vehicle_trips.sql index 34b1c25..2a7eac9 100644 --- a/db/migrations/20260601000019_fn_vehicle_trips.sql +++ b/db/migrations/20260601000019_fn_vehicle_trips.sql @@ -33,8 +33,13 @@ -- Falls back to movement-only segmentation (has_acc_data=false in the -- response) when every position for the day has acc_state IS NULL. +-- Drop any prior signature; the function identity is (name + arg types), +-- so a CREATE OR REPLACE with a different arg type would create a sibling. +DROP FUNCTION IF EXISTS serve.fn_vehicle_trips(integer, date); +DROP FUNCTION IF EXISTS serve.fn_vehicle_trips(bigint, date); + CREATE OR REPLACE FUNCTION serve.fn_vehicle_trips( - p_vehicle_id integer, + p_vehicle_id bigint, p_date_eat date ) RETURNS jsonb LANGUAGE plpgsql STABLE @@ -385,4 +390,5 @@ $fn$; -- migrate:down +DROP FUNCTION IF EXISTS serve.fn_vehicle_trips(bigint, date); DROP FUNCTION IF EXISTS serve.fn_vehicle_trips(integer, date);