-
Notifications
You must be signed in to change notification settings - Fork 0
/
init.sql
161 lines (159 loc) · 4.03 KB
/
init.sql
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
CREATE TABLE hourly_orders
(
hour bigint,
block_id bigint,
name text,
price double precision,
volume double precision,
type text
);
ALTER TABLE "hourly_orders"
ADD PRIMARY KEY ("block_id", "hour", "name");
CREATE TABLE linked_orders
(
block_id bigint,
hour bigint,
name text,
price double precision,
volume double precision,
link bigint,
type text
);
ALTER TABLE "linked_orders"
ADD PRIMARY KEY ("block_id", "hour", "name");
CREATE TABLE exclusive_orders
(
block_id bigint,
hour bigint,
name text,
price double precision,
volume double precision
);
ALTER TABLE "exclusive_orders"
ADD PRIMARY KEY ("block_id", "hour", "name");
CREATE TABLE capacities
(
"time" timestamp without time zone,
bio double precision,
coal double precision,
gas double precision,
lignite double precision,
nuclear double precision,
solar double precision,
water double precision,
wind double precision,
storage double precision,
agent text,
area text
);
ALTER TABLE "capacities"
ADD PRIMARY KEY ("time", "agent");
CREATE TABLE demand
(
"time" timestamp without time zone,
power double precision,
heat double precision,
step text,
agent text,
area text
);
ALTER TABLE "demand"
ADD PRIMARY KEY ("time", "step", "agent");
CREATE TABLE generation
(
"time" timestamp without time zone,
total double precision,
solar double precision,
wind double precision,
water double precision,
bio double precision,
lignite double precision,
coal double precision,
gas double precision,
nuclear double precision,
storage double precision,
allocation double precision,
step text,
agent text,
area text
);
ALTER TABLE "generation"
ADD PRIMARY KEY ("time", "step", "agent");
CREATE TABLE auction_results
(
"time" timestamp without time zone,
price double precision,
volume double precision,
magic_source double precision
);
ALTER TABLE "auction_results"
ADD PRIMARY KEY ("time");
CREATE TABLE hourly_results
(
hour bigint,
block_id bigint,
name text,
price double precision,
volume double precision,
type text
);
ALTER TABLE "hourly_results"
ADD PRIMARY KEY ("block_id", "hour", "name");
CREATE TABLE linked_results
(
block_id bigint,
hour bigint,
name text,
price double precision,
volume double precision,
link bigint,
type text
);
ALTER TABLE "linked_results"
ADD PRIMARY KEY ("block_id", "hour", "name");
CREATE TABLE exclusive_results
(
block_id bigint,
hour bigint,
name text,
price double precision,
volume double precision
);
ALTER TABLE "exclusive_results"
ADD PRIMARY KEY ("block_id", "hour", "name");
CREATE TABLE orders
(
"time" timestamp without time zone,
volume double precision,
price double precision,
agent text,
area text
);
ALTER TABLE "orders"
ADD PRIMARY KEY ("time","agent");
CREATE TABLE cash_flows
(
"time" timestamp without time zone,
profit double precision,
emission double precision,
fuel double precision,
start_ups double precision,
forecast double precision,
agent text,
area text
);
ALTER TABLE "cash_flows"
ADD PRIMARY KEY ("time","agent");
CREATE TABLE merit_order
(
"time" timestamp without time zone,
price double precision,
volume double precision,
type text,
hour integer
);
SELECT create_hypertable('orders', 'time', if_not_exists => TRUE, migrate_data => TRUE);
SELECT create_hypertable('auction_results', 'time', if_not_exists => TRUE, migrate_data => TRUE);
SELECT create_hypertable('capacities', 'time', if_not_exists => TRUE, migrate_data => TRUE);
SELECT create_hypertable('generation', 'time', if_not_exists => TRUE, migrate_data => TRUE);
SELECT create_hypertable('demand', 'time', if_not_exists => TRUE, migrate_data => TRUE);