54 lines
1.6 KiB
Plaintext
54 lines
1.6 KiB
Plaintext
/*
|
|
This test is excluded from the Postgres 17 suite because it does not ship
|
|
with the Supabase PG17 image
|
|
*/
|
|
create extension if not exists timescaledb;
|
|
NOTICE: extension "timescaledb" already exists, skipping
|
|
-- Confirm we're running the apache version
|
|
show timescaledb.license;
|
|
timescaledb.license
|
|
---------------------
|
|
apache
|
|
(1 row)
|
|
|
|
-- Create schema v
|
|
create schema v;
|
|
-- Create a table in the v schema
|
|
create table v.sensor_data (
|
|
time timestamptz not null,
|
|
sensor_id int not null,
|
|
temperature double precision not null,
|
|
humidity double precision not null
|
|
);
|
|
-- Convert the table to a hypertable
|
|
select create_hypertable('v.sensor_data', 'time');
|
|
create_hypertable
|
|
---------------------
|
|
(1,v,sensor_data,t)
|
|
(1 row)
|
|
|
|
-- Insert some data into the hypertable
|
|
insert into v.sensor_data (time, sensor_id, temperature, humidity)
|
|
values
|
|
('2024-08-09', 1, 22.5, 60.2),
|
|
('2024-08-08', 1, 23.0, 59.1),
|
|
('2024-08-07', 2, 21.7, 63.3);
|
|
-- Select data from the hypertable
|
|
select
|
|
*
|
|
from
|
|
v.sensor_data;
|
|
time | sensor_id | temperature | humidity
|
|
------------------------------+-----------+-------------+----------
|
|
Fri Aug 09 00:00:00 2024 PDT | 1 | 22.5 | 60.2
|
|
Thu Aug 08 00:00:00 2024 PDT | 1 | 23 | 59.1
|
|
Wed Aug 07 00:00:00 2024 PDT | 2 | 21.7 | 63.3
|
|
(3 rows)
|
|
|
|
-- Drop schema v and all its entities
|
|
drop schema v cascade;
|
|
NOTICE: drop cascades to 3 other objects
|
|
DETAIL: drop cascades to table v.sensor_data
|
|
drop cascades to table _timescaledb_internal._hyper_1_1_chunk
|
|
drop cascades to table _timescaledb_internal._hyper_1_2_chunk
|