remove hypertable from potential_arrivals
This commit is contained in:
parent
7ae3614f17
commit
273a0cd6d6
|
@ -9,13 +9,15 @@ const supabase = new SupabaseManagement({
|
|||
const db = supabase.db<Database>(process.env.NEXT_PUBLIC_SUPABASE_URL || "");
|
||||
|
||||
client.defineJob({
|
||||
id: "on-new-todos",
|
||||
name: "On New Todos",
|
||||
id: "bus-stop-sanity-check",
|
||||
name: "Sanity Check Potential Job Arrivals",
|
||||
version: "0.1.1",
|
||||
trigger: db.onInserted({
|
||||
table: 'potential_arrivals',
|
||||
}),
|
||||
run: async (payload, io, ctx) => {
|
||||
console.log(payload);
|
||||
await io.runTask("log-payload", async function() {
|
||||
console.log(payload);
|
||||
});
|
||||
},
|
||||
});
|
||||
|
|
|
@ -0,0 +1,18 @@
|
|||
-- Trigger.dev doesn't play nice with timescaledb due to timescaledb's
|
||||
-- magic internal tables. So we remove the hypertable for now.
|
||||
delete from raw_bus_positions where id in (select raw_pos_id from potential_arrivals);
|
||||
|
||||
drop table potential_arrivals cascade;
|
||||
|
||||
CREATE TABLE potential_arrivals(
|
||||
id BIGINT GENERATED ALWAYS AS IDENTITY,
|
||||
raw_pos_id BIGINT NOT NULL,
|
||||
bus_id text NOT NULL,
|
||||
bus_coords GEOGRAPHY(Point, 4326) NOT NULL,
|
||||
measured_at TIMESTAMP WITH TIME ZONE NOT NULL,
|
||||
stop_id bigint NOT NULL,
|
||||
distance decimal NOT NULL
|
||||
);
|
||||
|
||||
CREATE INDEX potential_arrives_raw_pos_id ON potential_arrivals (raw_pos_id);
|
||||
CREATE INDEX potential_arrivals_spatial ON potential_arrivals USING GIST (bus_coords);
|
Loading…
Reference in New Issue