Skip to content

Commit

Permalink
fix migrations
Browse files Browse the repository at this point in the history
  • Loading branch information
nicokant committed Jan 24, 2024
1 parent 6e2c31f commit 0097972
Show file tree
Hide file tree
Showing 6 changed files with 5 additions and 233 deletions.
18 changes: 0 additions & 18 deletions db/migrations/20231122005008_logger_data.sql

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
-- migrate:up

alter table logger_instrumentation add constraint logger_instrumentation_filename_key unique (filename);

-- migrate:down
68 changes: 0 additions & 68 deletions db/migrations/20231122005845_import_logger_data_gps.sql

This file was deleted.

72 changes: 0 additions & 72 deletions db/migrations/20231122021711_import_logger_data_gps_pathtrack.sql

This file was deleted.

73 changes: 0 additions & 73 deletions db/migrations/20240117072241_row_to_json_errors_detail.sql
Original file line number Diff line number Diff line change
Expand Up @@ -32,78 +32,5 @@ exception
end;
$$;

create or replace function import_logger_data_gps() returns trigger language plpgsql
as $$
begin
insert into logger_data values(
new.filename,
null,
(new."UTC_datetime" || ' UTC')::timestamp,
case when new.hdop = '0.0'
then null
else ST_SetSRID(ST_MakePoint(
new."Latitude"::float,
new."Longitude"::float,
new."Altitude_m"::float
), 4326)
end,
new.satcount::integer,
case when new.hdop = '0.0'
then null
else new.hdop::decimal
end
) on conflict do nothing;
return null;
exception
when others then
raise exception using
errcode = sqlstate,
message = sqlerrm,
detail = row_to_json(new);
end;
$$;

create or replace function import_logger_data_gps_pathtrack() returns trigger language plpgsql
as $$
begin
insert into logger_data values(
new.filename,
null,
make_timestamptz(
(new.year)::int,
(new.month)::int,
(new.day)::int,
(new.hour)::int,
(new.minute)::int,
(new.second)::float,
'UTC'
),
case when new.accuracy = '9999.999'
then null
else ST_SetSRID(ST_MakePoint(
new.lat::float,
new.lon::float,
case when new.altitude = '9999.999'
then null
else (new.altitude)::float
end
), 4326)
end,
new.satellites::integer,
case when new.accuracy = '9999.999'
then null
else new.accuracy::decimal
end
) on conflict do nothing;
return null;
exception
when others then
raise exception using
errcode = sqlstate,
message = sqlerrm,
detail = row_to_json(new);
end;
$$;

-- migrate:down

Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
-- migrate:up
alter table logger_instrumentation alter column filename drop not null;

create function safe_cast_bool(p_in text)
returns bool
as
Expand Down

0 comments on commit 0097972

Please sign in to comment.