-
-
Notifications
You must be signed in to change notification settings - Fork 140
Expand file tree
/
Copy patholdsqlite.sql
More file actions
596 lines (554 loc) · 17.6 KB
/
oldsqlite.sql
File metadata and controls
596 lines (554 loc) · 17.6 KB
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
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
/*
Navicat Premium Dump SQL
Source Server : peerbanhelper
Source Server Type : SQLite
Source Server Version : 3045000 (3.45.0)
Source Schema : main
Target Server Type : SQLite
Target Server Version : 3045000 (3.45.0)
File Encoding : 65001
Date: 25/01/2026 22:09:11
*/
PRAGMA
foreign_keys = false;
-- ----------------------------
-- Table structure for alert
-- ----------------------------
DROP TABLE IF EXISTS "alert";
CREATE TABLE "alert"
(
"id" INTEGER PRIMARY KEY AUTOINCREMENT,
"createAt" TIMESTAMP NOT NULL,
"readAt" TIMESTAMP,
"level" VARCHAR NOT NULL,
"identifier" VARCHAR NOT NULL,
"title" VARCHAR NOT NULL,
"content" VARCHAR NOT NULL
);
-- ----------------------------
-- Table structure for banlist
-- ----------------------------
DROP TABLE IF EXISTS "banlist";
CREATE TABLE "banlist"
(
"address" VARCHAR,
"metadata" VARCHAR NOT NULL,
PRIMARY KEY ("address")
);
-- ----------------------------
-- Table structure for history
-- ----------------------------
DROP TABLE IF EXISTS "history";
CREATE TABLE "history"
(
"id" INTEGER PRIMARY KEY AUTOINCREMENT,
"banAt" TIMESTAMP NOT NULL,
"unbanAt" TIMESTAMP NOT NULL,
"ip" VARCHAR NOT NULL,
"port" INTEGER NOT NULL,
"peerId" VARCHAR,
"peerClientName" VARCHAR,
"peerUploaded" BIGINT,
"peerDownloaded" BIGINT,
"peerProgress" DOUBLE PRECISION NOT NULL,
"downloaderProgress" DOUBLE PRECISION NOT NULL,
"torrent_id" BIGINT NOT NULL,
"rule_id" BIGINT NOT NULL,
"description" VARCHAR NOT NULL,
"flags" VARCHAR,
"downloader" VARCHAR NOT NULL,
"structuredData" VARCHAR NOT NULL DEFAULT '{}'
);
-- ----------------------------
-- Table structure for metadata
-- ----------------------------
DROP TABLE IF EXISTS "metadata";
CREATE TABLE "metadata"
(
"key" VARCHAR,
"value" VARCHAR,
PRIMARY KEY ("key")
);
-- ----------------------------
-- Table structure for modules
-- ----------------------------
DROP TABLE IF EXISTS "modules";
CREATE TABLE "modules"
(
"id" INTEGER PRIMARY KEY AUTOINCREMENT,
"name" VARCHAR,
UNIQUE ("name" ASC)
);
-- ----------------------------
-- Table structure for pcb_address
-- ----------------------------
DROP TABLE IF EXISTS "pcb_address";
CREATE TABLE "pcb_address"
(
"id" INTEGER PRIMARY KEY AUTOINCREMENT,
"ip" VARCHAR NOT NULL,
"port" INTEGER NOT NULL,
"torrentId" VARCHAR NOT NULL,
"lastReportProgress" DOUBLE PRECISION NOT NULL,
"lastReportUploaded" BIGINT,
"trackingUploadedIncreaseTotal" BIGINT,
"rewindCounter" INTEGER NOT NULL,
"progressDifferenceCounter" INTEGER NOT NULL,
"firstTimeSeen" TIMESTAMP NOT NULL,
"lastTimeSeen" TIMESTAMP NOT NULL,
"downloader" VARCHAR NOT NULL,
"banDelayWindowEndAt" TIMESTAMP NOT NULL,
"fastPcbTestExecuteAt" BIGINT NOT NULL,
"lastTorrentCompletedSize" BIGINT NOT NULL,
UNIQUE ("ip" ASC, "port" ASC, "torrentId" ASC, "downloader" ASC)
);
-- ----------------------------
-- Table structure for pcb_range
-- ----------------------------
DROP TABLE IF EXISTS "pcb_range";
CREATE TABLE "pcb_range"
(
"id" INTEGER PRIMARY KEY AUTOINCREMENT,
"range" VARCHAR NOT NULL,
"torrentId" VARCHAR NOT NULL,
"lastReportProgress" DOUBLE PRECISION NOT NULL,
"lastReportUploaded" BIGINT,
"trackingUploadedIncreaseTotal" BIGINT,
"rewindCounter" INTEGER NOT NULL,
"progressDifferenceCounter" INTEGER NOT NULL,
"firstTimeSeen" TIMESTAMP NOT NULL,
"lastTimeSeen" TIMESTAMP NOT NULL,
"downloader" VARCHAR NOT NULL,
"banDelayWindowEndAt" TIMESTAMP NOT NULL,
"fastPcbTestExecuteAt" BIGINT NOT NULL,
"lastTorrentCompletedSize" BIGINT NOT NULL,
UNIQUE ("range" ASC, "torrentId" ASC, "downloader" ASC)
);
-- ----------------------------
-- Table structure for peer_connection_metrics
-- ----------------------------
DROP TABLE IF EXISTS "peer_connection_metrics";
CREATE TABLE "peer_connection_metrics"
(
"id" INTEGER PRIMARY KEY AUTOINCREMENT,
"timeframeAt" TIMESTAMP NOT NULL,
"downloader" VARCHAR NOT NULL,
"totalConnections" BIGINT NOT NULL DEFAULT 0,
"incomingConnections" BIGINT NOT NULL DEFAULT 0,
"remoteRefuseTransferToClient" BIGINT NOT NULL DEFAULT 0,
"remoteAcceptTransferToClient" BIGINT NOT NULL DEFAULT 0,
"localRefuseTransferToPeer" BIGINT NOT NULL DEFAULT 0,
"localAcceptTransferToPeer" BIGINT NOT NULL DEFAULT 0,
"localNotInterested" BIGINT NOT NULL DEFAULT 0,
"questionStatus" BIGINT NOT NULL DEFAULT 0,
"optimisticUnchoke" BIGINT NOT NULL DEFAULT 0,
"fromDHT" BIGINT NOT NULL DEFAULT 0,
"fromPEX" BIGINT NOT NULL DEFAULT 0,
"fromLSD" BIGINT NOT NULL DEFAULT 0,
"fromTrackerOrOther" BIGINT NOT NULL DEFAULT 0,
"rc4Encrypted" BIGINT NOT NULL DEFAULT 0,
"plainTextEncrypted" BIGINT NOT NULL DEFAULT 0,
"utpSocket" BIGINT NOT NULL DEFAULT 0,
"tcpSocket" BIGINT NOT NULL DEFAULT 0,
UNIQUE ("timeframeAt" ASC, "downloader" ASC)
);
-- ----------------------------
-- Table structure for peer_connection_metrics_track
-- ----------------------------
DROP TABLE IF EXISTS "peer_connection_metrics_track";
CREATE TABLE "peer_connection_metrics_track"
(
"id" INTEGER PRIMARY KEY AUTOINCREMENT,
"timeframeAt" TIMESTAMP NOT NULL,
"downloader" VARCHAR NOT NULL,
"torrent_id" BIGINT NOT NULL,
"address" VARCHAR NOT NULL,
"port" INTEGER NOT NULL,
"peerId" VARCHAR,
"clientName" VARCHAR,
"lastFlags" VARCHAR,
UNIQUE ("timeframeAt" ASC, "downloader" ASC, "torrent_id" ASC, "address" ASC, "port" ASC)
);
-- ----------------------------
-- Table structure for peer_records
-- ----------------------------
DROP TABLE IF EXISTS "peer_records";
CREATE TABLE "peer_records"
(
"id" INTEGER PRIMARY KEY AUTOINCREMENT,
"address" VARCHAR NOT NULL,
"port" INTEGER NOT NULL DEFAULT 0,
"torrent_id" BIGINT NOT NULL,
"downloader" VARCHAR NOT NULL,
"peerId" VARCHAR,
"clientName" VARCHAR,
"uploaded" BIGINT NOT NULL,
"uploadedOffset" BIGINT NOT NULL,
"uploadSpeed" BIGINT NOT NULL DEFAULT 0,
"downloaded" BIGINT NOT NULL,
"downloadedOffset" BIGINT NOT NULL,
"downloadSpeed" BIGINT NOT NULL DEFAULT 0,
"lastFlags" VARCHAR,
"firstTimeSeen" TIMESTAMP NOT NULL,
"lastTimeSeen" TIMESTAMP NOT NULL,
UNIQUE ("address" ASC, "port" ASC, "torrent_id" ASC, "downloader" ASC)
);
-- ----------------------------
-- Table structure for rule_sub_info
-- ----------------------------
DROP TABLE IF EXISTS "rule_sub_info";
CREATE TABLE "rule_sub_info"
(
"ruleId" VARCHAR,
"enabled" BOOLEAN,
"ruleName" VARCHAR,
"subUrl" VARCHAR,
"lastUpdate" BIGINT,
"entCount" INTEGER,
PRIMARY KEY ("ruleId")
);
-- ----------------------------
-- Table structure for rule_sub_log
-- ----------------------------
DROP TABLE IF EXISTS "rule_sub_log";
CREATE TABLE "rule_sub_log"
(
"id" INTEGER PRIMARY KEY AUTOINCREMENT,
"ruleId" VARCHAR,
"updateTime" BIGINT,
"count" INTEGER,
"updateType" VARCHAR
);
-- ----------------------------
-- Table structure for rules
-- ----------------------------
DROP TABLE IF EXISTS "rules";
CREATE TABLE "rules"
(
"id" INTEGER PRIMARY KEY AUTOINCREMENT,
"module_id" BIGINT NOT NULL,
"rule" VARCHAR NOT NULL,
UNIQUE ("module_id" ASC, "rule" ASC)
);
-- ----------------------------
-- Table structure for sqlite_sequence
-- ----------------------------
DROP TABLE IF EXISTS "sqlite_sequence";
CREATE TABLE "sqlite_sequence"
(
"name",
"seq"
);
-- ----------------------------
-- Table structure for sqlite_stat1
-- ----------------------------
DROP TABLE IF EXISTS "sqlite_stat1";
CREATE TABLE "sqlite_stat1"
(
"tbl",
"idx",
"stat"
);
-- ----------------------------
-- Table structure for sqlite_stat4
-- ----------------------------
DROP TABLE IF EXISTS "sqlite_stat4";
CREATE TABLE "sqlite_stat4"
(
"tbl",
"idx",
"neq",
"nlt",
"ndlt",
"sample"
);
-- ----------------------------
-- Table structure for torrents
-- ----------------------------
DROP TABLE IF EXISTS "torrents";
CREATE TABLE "torrents"
(
"id" INTEGER PRIMARY KEY AUTOINCREMENT,
"infoHash" VARCHAR NOT NULL,
"name" VARCHAR NOT NULL,
"size" BIGINT NOT NULL,
"privateTorrent" BOOLEAN
);
-- ----------------------------
-- Table structure for traffic_journal_v3
-- ----------------------------
DROP TABLE IF EXISTS "traffic_journal_v3";
CREATE TABLE "traffic_journal_v3"
(
"id" INTEGER PRIMARY KEY AUTOINCREMENT,
"timestamp" BIGINT,
"downloader" VARCHAR,
"dataOverallUploadedAtStart" BIGINT,
"dataOverallUploaded" BIGINT,
"dataOverallDownloadedAtStart" BIGINT,
"dataOverallDownloaded" BIGINT,
"protocolOverallUploadedAtStart" BIGINT,
"protocolOverallUploaded" BIGINT,
"protocolOverallDownloadedAtStart" BIGINT,
"protocolOverallDownloaded" BIGINT,
UNIQUE ("timestamp" ASC, "downloader" ASC)
);
-- ----------------------------
-- Auto increment value for alert
-- ----------------------------
UPDATE "sqlite_sequence"
SET seq = 2
WHERE name = 'alert';
-- ----------------------------
-- Indexes structure for table alert
-- ----------------------------
CREATE INDEX "alert_createAt_idx"
ON "alert" (
"createAt" ASC
);
CREATE INDEX "alert_identifier_idx"
ON "alert" (
"identifier" ASC
);
CREATE INDEX "alert_level_idx"
ON "alert" (
"level" ASC
);
CREATE INDEX "alert_readAt_idx"
ON "alert" (
"readAt" ASC
);
-- ----------------------------
-- Indexes structure for table banlist
-- ----------------------------
CREATE INDEX "banlist_address_idx"
ON "banlist" (
"address" ASC
);
-- ----------------------------
-- Indexes structure for table history
-- ----------------------------
CREATE INDEX "history_banAt_idx"
ON "history" (
"banAt" ASC
);
CREATE INDEX "history_downloader_idx"
ON "history" (
"downloader" ASC
);
CREATE INDEX "history_id_idx"
ON "history" (
"id" ASC
);
CREATE INDEX "history_ip_idx"
ON "history" (
"ip" ASC
);
CREATE INDEX "history_peerClientName_idx"
ON "history" (
"peerClientName" ASC
);
CREATE INDEX "history_peerId_idx"
ON "history" (
"peerId" ASC
);
CREATE INDEX "history_port_idx"
ON "history" (
"port" ASC
);
CREATE INDEX "history_rule_idx"
ON "history" (
"rule_id" ASC
);
CREATE INDEX "history_torrent_idx"
ON "history" (
"torrent_id" ASC
);
-- ----------------------------
-- Indexes structure for table metadata
-- ----------------------------
CREATE INDEX "metadata_key_idx"
ON "metadata" (
"key" ASC
);
-- ----------------------------
-- Indexes structure for table modules
-- ----------------------------
CREATE INDEX "modules_name_idx"
ON "modules" (
"name" ASC
);
-- ----------------------------
-- Indexes structure for table pcb_address
-- ----------------------------
CREATE INDEX "pcb_address_downloader_idx"
ON "pcb_address" (
"downloader" ASC
);
CREATE INDEX "pcb_address_firstTimeSeen_idx"
ON "pcb_address" (
"firstTimeSeen" ASC
);
CREATE INDEX "pcb_address_ip_idx"
ON "pcb_address" (
"ip" ASC
);
CREATE INDEX "pcb_address_lastTimeSeen_idx"
ON "pcb_address" (
"lastTimeSeen" ASC
);
CREATE INDEX "pcb_address_torrentId_idx"
ON "pcb_address" (
"torrentId" ASC
);
-- ----------------------------
-- Indexes structure for table pcb_range
-- ----------------------------
CREATE INDEX "pcb_range_downloader_idx"
ON "pcb_range" (
"downloader" ASC
);
CREATE INDEX "pcb_range_firstTimeSeen_idx"
ON "pcb_range" (
"firstTimeSeen" ASC
);
CREATE INDEX "pcb_range_lastTimeSeen_idx"
ON "pcb_range" (
"lastTimeSeen" ASC
);
CREATE INDEX "pcb_range_range_idx"
ON "pcb_range" (
"range" ASC
);
CREATE INDEX "pcb_range_torrentId_idx"
ON "pcb_range" (
"torrentId" ASC
);
-- ----------------------------
-- Indexes structure for table peer_connection_metrics
-- ----------------------------
CREATE INDEX "peer_connection_metrics_downloader_idx"
ON "peer_connection_metrics" (
"downloader" ASC
);
CREATE INDEX "peer_connection_metrics_timeframeAt_idx"
ON "peer_connection_metrics" (
"timeframeAt" ASC
);
-- ----------------------------
-- Indexes structure for table peer_connection_metrics_track
-- ----------------------------
CREATE INDEX "peer_connection_metrics_track_timeframeAt_idx"
ON "peer_connection_metrics_track" (
"timeframeAt" ASC
);
CREATE INDEX "peer_connection_metrics_track_torrent_idx"
ON "peer_connection_metrics_track" (
"torrent_id" ASC
);
-- ----------------------------
-- Indexes structure for table peer_records
-- ----------------------------
CREATE INDEX "peer_records_address_idx"
ON "peer_records" (
"address" ASC
);
CREATE INDEX "peer_records_clientName_idx"
ON "peer_records" (
"clientName" ASC
);
CREATE INDEX "peer_records_downloader_idx"
ON "peer_records" (
"downloader" ASC
);
CREATE INDEX "peer_records_firstTimeSeen_idx"
ON "peer_records" (
"firstTimeSeen" ASC
);
CREATE INDEX "peer_records_lastTimeSeen_idx"
ON "peer_records" (
"lastTimeSeen" ASC
);
CREATE INDEX "peer_records_peerId_idx"
ON "peer_records" (
"peerId" ASC
);
CREATE INDEX "peer_records_torrent_idx"
ON "peer_records" (
"torrent_id" ASC
);
-- ----------------------------
-- Indexes structure for table rule_sub_info
-- ----------------------------
CREATE INDEX "rule_sub_info_ruleId_idx"
ON "rule_sub_info" (
"ruleId" ASC
);
-- ----------------------------
-- Auto increment value for rule_sub_log
-- ----------------------------
UPDATE "sqlite_sequence"
SET seq = 2
WHERE name = 'rule_sub_log';
-- ----------------------------
-- Indexes structure for table rule_sub_log
-- ----------------------------
CREATE INDEX "rule_sub_log_id_idx"
ON "rule_sub_log" (
"id" ASC
);
CREATE INDEX "rule_sub_log_ruleId_idx"
ON "rule_sub_log" (
"ruleId" ASC
);
-- ----------------------------
-- Indexes structure for table rules
-- ----------------------------
CREATE INDEX "rules_id_idx"
ON "rules" (
"id" ASC
);
-- ----------------------------
-- Auto increment value for torrents
-- ----------------------------
UPDATE "sqlite_sequence"
SET seq = 1
WHERE name = 'torrents';
-- ----------------------------
-- Indexes structure for table torrents
-- ----------------------------
CREATE INDEX "torrents_id_idx"
ON "torrents" (
"id" ASC
);
CREATE UNIQUE INDEX "torrents_infoHash_idx"
ON "torrents" (
"infoHash" ASC
);
CREATE INDEX "torrents_name_idx"
ON "torrents" (
"name" ASC
);
-- ----------------------------
-- Auto increment value for traffic_journal_v3
-- ----------------------------
UPDATE "sqlite_sequence"
SET seq = 1
WHERE name = 'traffic_journal_v3';
-- ----------------------------
-- Indexes structure for table traffic_journal_v3
-- ----------------------------
CREATE INDEX "traffic_journal_v3_downloader_idx"
ON "traffic_journal_v3" (
"downloader" ASC
);
CREATE INDEX "traffic_journal_v3_id_idx"
ON "traffic_journal_v3" (
"id" ASC
);
CREATE INDEX "traffic_journal_v3_timestamp_idx"
ON "traffic_journal_v3" (
"timestamp" ASC
);
PRAGMA
foreign_keys = true;