@@ -74,7 +74,7 @@ CREATE TABLE statistics_meta (
74
74
unit_of_measurement VARCHAR(255),
75
75
has_mean BOOLEAN,
76
76
has_sum BOOLEAN,
77
- name VARCHAR(255),
77
+ name VARCHAR(255), mean_type INTEGER NOT NULL DEFAULT 0,
78
78
PRIMARY KEY (id)
79
79
)
80
80
@@ -87,14 +87,6 @@ CREATE TABLE recorder_runs (
87
87
PRIMARY KEY (run_id)
88
88
)
89
89
90
- CREATE TABLE migration_changes (
91
- migration_id VARCHAR(255) NOT NULL,
92
- version SMALLINT NOT NULL,
93
- PRIMARY KEY (migration_id)
94
- )
95
-
96
-
97
-
98
90
CREATE TABLE schema_changes (
99
91
change_id INTEGER NOT NULL,
100
92
schema_version INTEGER,
@@ -137,7 +129,6 @@ CREATE TABLE states (
137
129
event_id SMALLINT,
138
130
last_changed CHAR(0),
139
131
last_changed_ts FLOAT,
140
- last_reported_ts FLOAT,
141
132
last_updated CHAR(0),
142
133
last_updated_ts FLOAT,
143
134
old_state_id INTEGER,
@@ -149,7 +140,7 @@ CREATE TABLE states (
149
140
context_id_bin BLOB,
150
141
context_user_id_bin BLOB,
151
142
context_parent_id_bin BLOB,
152
- metadata_id INTEGER,
143
+ metadata_id INTEGER, last_reported_ts FLOAT,
153
144
PRIMARY KEY (state_id),
154
145
FOREIGN KEY(old_state_id) REFERENCES states (state_id),
155
146
FOREIGN KEY(attributes_id) REFERENCES state_attributes (attributes_id),
@@ -169,7 +160,7 @@ CREATE TABLE statistics (
169
160
last_reset CHAR(0),
170
161
last_reset_ts FLOAT,
171
162
state FLOAT,
172
- sum FLOAT,
163
+ sum FLOAT, mean_weight FLOAT,
173
164
PRIMARY KEY (id),
174
165
FOREIGN KEY(metadata_id) REFERENCES statistics_meta (id) ON DELETE CASCADE
175
166
)
@@ -187,7 +178,7 @@ CREATE TABLE statistics_short_term (
187
178
last_reset CHAR(0),
188
179
last_reset_ts FLOAT,
189
180
state FLOAT,
190
- sum FLOAT,
181
+ sum FLOAT, mean_weight FLOAT,
191
182
PRIMARY KEY (id),
192
183
FOREIGN KEY(metadata_id) REFERENCES statistics_meta (id) ON DELETE CASCADE
193
184
)
@@ -212,27 +203,33 @@ CREATE INDEX ix_events_data_id ON events (data_id)
212
203
213
204
CREATE INDEX ix_events_event_type_id_time_fired_ts ON events (event_type_id, time_fired_ts)
214
205
206
+ CREATE INDEX ix_events_time_fired_ts ON events (time_fired_ts)
207
+
215
208
CREATE INDEX ix_events_context_id_bin ON events (context_id_bin)
216
209
217
- CREATE INDEX ix_events_time_fired_ts ON events (time_fired_ts )
210
+ CREATE INDEX ix_states_context_id_bin ON states (context_id_bin )
218
211
219
212
CREATE INDEX ix_states_attributes_id ON states (attributes_id)
220
213
214
+ CREATE INDEX ix_states_last_updated_ts ON states (last_updated_ts)
215
+
221
216
CREATE INDEX ix_states_metadata_id_last_updated_ts ON states (metadata_id, last_updated_ts)
222
217
223
218
CREATE INDEX ix_states_old_state_id ON states (old_state_id)
224
219
225
- CREATE INDEX ix_states_context_id_bin ON states (context_id_bin)
226
-
227
- CREATE INDEX ix_states_last_updated_ts ON states (last_updated_ts)
220
+ CREATE INDEX ix_statistics_start_ts ON statistics (start_ts)
228
221
229
222
CREATE UNIQUE INDEX ix_statistics_statistic_id_start_ts ON statistics (metadata_id, start_ts)
230
223
231
- CREATE INDEX ix_statistics_start_ts ON statistics ( start_ts)
224
+ CREATE UNIQUE INDEX ix_statistics_short_term_statistic_id_start_ts ON statistics_short_term (metadata_id, start_ts)
232
225
233
226
CREATE INDEX ix_statistics_short_term_start_ts ON statistics_short_term (start_ts)
234
227
235
- CREATE UNIQUE INDEX ix_statistics_short_term_statistic_id_start_ts ON statistics_short_term (metadata_id, start_ts)
228
+ CREATE TABLE migration_changes (
229
+ migration_id VARCHAR(255) NOT NULL,
230
+ version SMALLINT NOT NULL,
231
+ PRIMARY KEY (migration_id)
232
+ )
236
233
```
237
234
238
235
To only show the details about the ` states ` table (since we are using that one in the next examples):
0 commit comments