1
+ -- Table for Mk12 or Boost deals
1
2
CREATE TABLE market_mk12_deals (
2
3
uuid TEXT NOT NULL ,
4
+ <<<<<<< HEAD
3
5
created_at TIMESTAMPTZ NOT NULL DEFAULT CURRENT_TIMESTAMP AT TIME ZONE ' UTC' ,
6
+ =======
7
+ sp_id BIGINT NOT NULL ,
8
+
9
+ created_at TIMESTAMPTZ NOT NULL DEFAULT TIMEZONE(' UTC' , NOW()),
10
+
11
+ >>>>>>> 48e953d (poller redesign)
4
12
signed_proposal_cid TEXT NOT NULL ,
5
13
proposal_signature BYTEA NOT NULL ,
6
14
proposal jsonb NOT NULL ,
7
- piece_cid TEXT NOT NULL ,
8
- piece_size BIGINT NOT NULL ,
15
+
9
16
offline BOOLEAN NOT NULL ,
10
17
verified BOOLEAN NOT NULL ,
11
- sp_id BIGINT NOT NULL ,
18
+
12
19
start_epoch BIGINT NOT NULL ,
13
20
end_epoch BIGINT NOT NULL ,
21
+
14
22
client_peer_id TEXT NOT NULL ,
23
+
15
24
chain_deal_id BIGINT DEFAULT NULL ,
16
25
publish_cid TEXT DEFAULT NULL ,
26
+
27
+ piece_cid TEXT NOT NULL ,
28
+ piece_size BIGINT NOT NULL ,
17
29
length BIGINT DEFAULT NULL ,
30
+
18
31
fast_retrieval BOOLEAN NOT NULL ,
19
32
announce_to_ipni BOOLEAN NOT NULL ,
33
+
20
34
url TEXT DEFAULT NULL ,
21
35
url_headers jsonb NOT NULL DEFAULT ' {}' ,
36
+
22
37
error TEXT DEFAULT NULL ,
23
38
24
39
primary key (uuid, sp_id, piece_cid, signed_proposal_cid),
25
40
unique (uuid),
26
41
unique (signed_proposal_cid)
27
42
);
28
43
44
+ -- Table for old lotus market deals. This is just for deal
45
+ -- which are still alive. It should not be used for any processing
29
46
CREATE TABLE market_legacy_deals (
30
47
signed_proposal_cid TEXT ,
31
48
proposal_signature BYTEA ,
@@ -46,6 +63,7 @@ CREATE TABLE market_legacy_deals (
46
63
primary key (sp_id, piece_cid, signed_proposal_cid)
47
64
);
48
65
66
+ -- This table is used for storing piece metadata (piece indexing)
49
67
CREATE TABLE market_piece_metadata (
50
68
piece_cid TEXT NOT NULL PRIMARY KEY ,
51
69
version INT NOT NULL DEFAULT 2 ,
@@ -57,14 +75,19 @@ CREATE TABLE market_piece_metadata (
57
75
unique (piece_cid)
58
76
);
59
77
78
+ -- This table binds the piece metadata to specific deals (piece indexing)
60
79
CREATE TABLE market_piece_deal (
61
- id TEXT NOT NULL ,
80
+ id TEXT NOT NULL , -- (UUID for new deals, PropCID for old)
62
81
piece_cid TEXT NOT NULL ,
82
+
63
83
boost_deal BOOLEAN NOT NULL ,
64
84
legacy_deal BOOLEAN NOT NULL DEFAULT FALSE,
85
+
65
86
chain_deal_id BIGINT NOT NULL DEFAULT 0 ,
87
+
66
88
sp_id BIGINT NOT NULL ,
67
89
sector_num BIGINT NOT NULL ,
90
+
68
91
piece_offset BIGINT NOT NULL ,
69
92
piece_length BIGINT NOT NULL ,
70
93
raw_size BIGINT NOT NULL ,
@@ -74,6 +97,7 @@ CREATE TABLE market_piece_deal (
74
97
unique (sp_id, id)
75
98
);
76
99
100
+ -- This function is used to insert piece metadata and piece deal (piece indexing)
77
101
CREATE OR REPLACE FUNCTION process_piece_deal (
78
102
_id TEXT ,
79
103
_piece_cid TEXT ,
@@ -108,64 +132,95 @@ VALUES (
108
132
END;
109
133
$$ LANGUAGE plpgsql;
110
134
135
+ -- Storage Ask for ask protocol
111
136
CREATE TABLE market_mk12_storage_ask (
137
+ sp_id BIGINT NOT NULL ,
138
+
112
139
price BIGINT NOT NULL ,
113
140
verified_price BIGINT NOT NULL ,
141
+
114
142
min_size BIGINT NOT NULL ,
115
143
max_size BIGINT NOT NULL ,
116
- sp_id BIGINT NOT NULL ,
144
+
117
145
created_at BIGINT NOT NULL ,
118
146
expiry BIGINT NOT NULL ,
147
+
119
148
sequence BIGINT NOT NULL ,
120
149
unique (sp_id)
121
150
);
122
151
152
+ -- Used for processing Mk12 deals
123
153
CREATE TABLE market_mk12_deal_pipeline (
124
154
uuid TEXT NOT NULL ,
125
155
sp_id BIGINT NOT NULL ,
156
+
126
157
started BOOLEAN DEFAULT FALSE,
158
+
127
159
piece_cid TEXT NOT NULL ,
160
+ <<<<<<< HEAD
128
161
piece_size BOOLEAN NOT NULL ,
162
+ =======
163
+ piece_size BIGINT NOT NULL ,
164
+ file_size BIGINT DEFAULT NULL , -- raw piece size
165
+
166
+ >>>>>>> 48e953d (poller redesign)
129
167
offline BOOLEAN NOT NULL ,
130
- downloaded BOOLEAN DEFAULT FALSE,
168
+
131
169
url TEXT DEFAULT NULL ,
132
170
headers jsonb NOT NULL DEFAULT ' {}' ,
133
- file_size BIGINT DEFAULT NULL ,
171
+
134
172
commp_task_id BIGINT DEFAULT NULL ,
135
173
after_commp BOOLEAN DEFAULT FALSE,
136
- find_task_id BIGINT DEFAULT NULL ,
137
- after_find BOOLEAN DEFAULT FALSE,
174
+
138
175
psd_task_id BIGINT DEFAULT NULL ,
139
176
after_psd BOOLEAN DEFAULT FALSE,
177
+
140
178
psd_wait_time TIMESTAMPTZ ,
179
+
141
180
find_deal_task_id BIGINT DEFAULT NULL ,
142
181
after_find_deal BOOLEAN DEFAULT FALSE,
182
+
143
183
sector BIGINT ,
144
184
sector_offset BIGINT ,
185
+
145
186
sealed BOOLEAN DEFAULT FALSE,
146
187
indexed BOOLEAN DEFAULT FALSE,
147
188
148
189
constraint market_mk12_deal_pipeline_identity_key unique (uuid)
149
190
);
150
191
192
+ -- This table can be used to track remote piece for offline deals
193
+ -- The entries must be created by users
151
194
CREATE TABLE market_offline_urls (
152
195
piece_cid TEXT NOT NULL ,
196
+
153
197
url TEXT NOT NULL ,
154
198
headers jsonb NOT NULL DEFAULT ' {}' ,
199
+
155
200
raw_size BIGINT NOT NULL ,
201
+
156
202
unique (piece_cid)
157
203
);
158
204
205
+ -- indexing tracker is separate from
159
206
CREATE TABLE market_indexing_tasks (
160
- id TEXT NOT NULL ,
207
+ uuid TEXT NOT NULL ,
208
+
161
209
sp_id BIGINT NOT NULL ,
162
210
sector_number BIGINT NOT NULL ,
163
211
reg_seal_proof INT NOT NULL ,
212
+
164
213
piece_offset BIGINT NOT NULL ,
165
214
piece_size BIGINT NOT NULL ,
166
215
raw_size BIGINT NOT NULL ,
167
216
piece_cid TEXT NOT NULL ,
217
+ <<<<<<< HEAD
168
218
created_at TIMESTAMPTZ NOT NULL DEFAULT CURRENT_TIMESTAMP AT TIME ZONE ' UTC' ,
219
+ =======
220
+
221
+ created_at TIMESTAMPTZ NOT NULL DEFAULT TIMEZONE(' UTC' , NOW()),
222
+
223
+ >>>>>>> 48e953d (poller redesign)
169
224
task_id BIGINT DEFAULT NULL ,
170
225
171
226
constraint market_indexing_tasks_identity_key
@@ -200,6 +255,35 @@ CREATE TABLE direct_deals (
200
255
keep_unsealed_copy BOOLEAN
201
256
);
202
257
258
+ ALTER TABLE parked_piece_refs
259
+ ADD COLUMN host text ;
260
+
261
+ create table file_parked_pieces (
262
+ id bigserial primary key ,
263
+ created_at timestamp default current_timestamp ,
264
+ piece_cid text not null ,
265
+ piece_padded_size bigint not null ,
266
+ piece_raw_size bigint not null ,
267
+ complete boolean not null default false,
268
+ task_id bigint default null ,
269
+ cleanup_task_id bigint default null ,
270
+ unique (piece_cid)
271
+ );
272
+
273
+ /*
274
+ * This table is used to keep track of the references to the file parked pieces
275
+ * so that we can delete them when they are no longer needed.
276
+ *
277
+ * All references into the file_parked_pieces table should be done through this table.
278
+ */
279
+ create table file_parked_piece_refs (
280
+ ref_id bigserial primary key ,
281
+ piece_id bigint not null ,
282
+ data_url text not null ,
283
+ node text not null ,
284
+ foreign key (piece_id) references file_parked_pieces(id) on delete cascade
285
+ );
286
+
203
287
204
288
205
289
0 commit comments