2019-09-10 15:42:34 +03:00
|
|
|
--
|
2020-01-06 16:52:41 +02:00
|
|
|
-- Copyright © 2016-2020 The Thingsboard Authors
|
2019-09-10 15:42:34 +03:00
|
|
|
--
|
|
|
|
|
-- Licensed under the Apache License, Version 2.0 (the "License");
|
|
|
|
|
-- you may not use this file except in compliance with the License.
|
|
|
|
|
-- You may obtain a copy of the License at
|
|
|
|
|
--
|
|
|
|
|
-- http://www.apache.org/licenses/LICENSE-2.0
|
|
|
|
|
--
|
|
|
|
|
-- Unless required by applicable law or agreed to in writing, software
|
|
|
|
|
-- distributed under the License is distributed on an "AS IS" BASIS,
|
|
|
|
|
-- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
|
|
|
-- See the License for the specific language governing permissions and
|
|
|
|
|
-- limitations under the License.
|
|
|
|
|
--
|
|
|
|
|
|
|
|
|
|
CREATE EXTENSION IF NOT EXISTS timescaledb CASCADE;
|
|
|
|
|
|
2020-03-10 17:49:00 +02:00
|
|
|
CREATE TABLE IF NOT EXISTS ts_kv (
|
2020-01-29 12:53:46 +02:00
|
|
|
entity_id uuid NOT NULL,
|
|
|
|
|
key int NOT NULL,
|
|
|
|
|
ts bigint NOT NULL,
|
|
|
|
|
bool_v boolean,
|
|
|
|
|
str_v varchar(10000000),
|
|
|
|
|
long_v bigint,
|
|
|
|
|
dbl_v double precision,
|
2020-02-14 19:18:18 +02:00
|
|
|
json_v json,
|
2020-03-10 17:49:00 +02:00
|
|
|
CONSTRAINT ts_kv_pkey PRIMARY KEY (entity_id, key, ts)
|
2020-01-29 12:53:46 +02:00
|
|
|
);
|
|
|
|
|
|
|
|
|
|
CREATE TABLE IF NOT EXISTS ts_kv_dictionary (
|
|
|
|
|
key varchar(255) NOT NULL,
|
|
|
|
|
key_id serial UNIQUE,
|
|
|
|
|
CONSTRAINT ts_key_id_pkey PRIMARY KEY (key)
|
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
CREATE TABLE IF NOT EXISTS ts_kv_latest (
|
2020-02-06 09:08:47 +02:00
|
|
|
entity_id uuid NOT NULL,
|
|
|
|
|
key int NOT NULL,
|
2019-09-10 15:42:34 +03:00
|
|
|
ts bigint NOT NULL,
|
|
|
|
|
bool_v boolean,
|
|
|
|
|
str_v varchar(10000000),
|
|
|
|
|
long_v bigint,
|
|
|
|
|
dbl_v double precision,
|
2020-02-14 19:18:18 +02:00
|
|
|
json_v json,
|
2020-02-06 09:08:47 +02:00
|
|
|
CONSTRAINT ts_kv_latest_pkey PRIMARY KEY (entity_id, key)
|
2020-02-07 15:38:04 +02:00
|
|
|
);
|